[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Misra R17.1 in Xen


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • Date: Tue, 30 Dec 2025 19:28:35 +0100
  • Arc-authentication-results: i=1; bugseng.com; arc=none smtp.remote-ip=162.55.131.47
  • Arc-message-signature: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; c=relaxed/relaxed; t=1767119316; h=DKIM-Signature:MIME-Version:Date:From:To:Cc:Subject:In-Reply-To: References:Message-ID:X-Sender:Organization:Content-Type: Content-Transfer-Encoding; bh=qMAYbliFMkDTGZvSMeybrph5kn01G3GXrtbFc+mgyVA=; b=TFkjFcM/utBAK6V7jQzOhEZdbsQ/8xe8u4rq4xuknF4W7GiMUJLd2KDq46VUyDv+jI7f IZPhHW2XMKsiFQzSATwcEsN5l6myOBDFu8+Fi3+6XKKDfSFJ+CPJQd/0xYmZE4PJJR98D o2Q/GyDrdRoYxlI+i4RIdniIvcCPqfHy0GVGehp+Y6wcfshkXMjw5M2Vp93JKojHsb3BJ d4KJLPmNCKbUCOQKngyTBpNZGTMCEyNZXkDEUb7WPNAIVGHACiW1msA45tVs3fnX7Zcuk h6+bb8Ls1yhA8wX356o/Wd+wTT/rri+V7/ph8hxQeSIAe5jHX8WvDdepFNUBayjJuXcI6 xvyN9Nh16Iei5w0PmohbDQmj2UgJFsLvIuQsqC8n2wC/O4JWfHF+chSXiPhWg9ofVEdoR Ngf/4rWdfvKCwthvUkhskjBUmo9IFjyBSu+v3bdAc3qALaMybNBr/gKE9fnWnRgfk2JBP 1jkqe+5vTQ325WgCn+U1zrfewCBr90CsrUGVKytTI+h/8FCPlaZH2CrpTqEt7MzYRvB73 GJp+VIIe4t4Z4Exs0vHzyAbOCU5OElVEW1GKqe5uyDl7jMHjPyAsVXbSIiWWmwuq+FMAs kLbGgYeqis79R/ts8BfY2mMPNAPslu66Hx2cciz9UwYueskmXsoL0eqPO3qL7o8=
  • Arc-seal: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; cv=none; t=1767119316; b=GxnHOKuasmqw6k/s2o3tXGGo1Y0JjEDaZskhwGHZBYdzpXKSGRNmbVbGHFeTA7JGx8zf A/i4LqJEeA0TXFJSiNFWdqJqtLK40C5chHrScv09Ioxvc8Rbkx+oykW8sSYz1g3EkKUa0 o6Qo3ewjIhcp+9Ap9PXJO8fZDnb+GJJabc/aam7+DRjQ6YQs4e7BiPlMCJIi07ezlHnzC kMuTUM6YLYUQyFpVd0QXu4oPhd92JiQ07RkEP7v1jLGILNJo9S/flrtOWIi3VojDJ8Fvb xbFDEn9kDEJx44uRIX9TIGUtsMzZGK18PVvFy5xbrfy5YOKX0O8aC0tDqGxfIPH+svM47 xvPdua8326DOC4qCA+qp9q5FbWlp2gpAiMvcCihDqiAKqefsLDKbASSBGRGoaGGwhhuqo RnKjUtURHALVWSg9Z8NhZvDLnwdNq9KLk3D9cpKxR9zcxMAL9z847TZ4YihNpVdoqZ/vJ kdufloj+umLtgATC2K/W3LsGcQF+dQiEa9L4gBIfpBsIHvTmYHK8QmTnj2qKD3en4VWJ9 W0K9DTt7mPhm5542D6efj93MW2pAgJiFow1q6PgwOqScT9pOT2nd6nBGVMoM7hRZN5/Ym e/Yd0sHkUqZh4E0wuvXuLzsbe51RbMCczGmop9O9v28Vpbgl0bTdFaeCVbzJAUQ=
  • Authentication-results: bugseng.com; arc=none smtp.remote-ip=162.55.131.47
  • Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, consulting@xxxxxxxxxxx, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
  • Delivery-date: Tue, 30 Dec 2025 18:29:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2025-12-30 18:34, Nicola Vetrini wrote:
On 2025-12-30 18:05, Andrew Cooper wrote:
Hello,

The x86_64-allcode run highlights one new violation of R17.1,
vmcoreinfo_append_str().  In writing this email, I've found another in
debugtrace_printk() meaning that we're missing some options in the
-allcode configuration.

In deviations.ecl we have:

-doc_begin="printf()-like functions are allowed to use the variadic features provided by stdarg.h."
-config=MC3A2.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(^.*printk\\(.*\\)$)))"}
-config=MC3A2.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(^.*printf\\(.*\\)$)))"}
-config=MC3A2.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(name(panic)&&kind(function))))"}
-config=MC3A2.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(name(elf_call_log_callback)&&kind(function))))"}
-config=MC3A2.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(name(vprintk_common)&&kind(function))))"}
-config=MC3A2.R17.1,macros+={hide , "^va_(arg|start|copy|end)$"}
-doc_end


First, we have no printf() so that row should be removed.


I think it was for other variants of printf that are present in Xen (e.g. vsnprintf). Perhaps it could be restricted a bit to be more explicit.

But, more importantly this is safe if and only if the function
declaration uses __attribute__((__format__(printf, ...))) to cause the
compiler to perform format typechecking.

Is it possible to encode this attribute requirement in the Eclair
expression, so that e.g. accidentally dropping the attribute causes a
violation to be reported?  This would also be rather safer than assuming
that any prefix on printk() is safe.


Well, the UBs associated to that rule (to varargs in general) go beyond the formatting issues, but checking that the function decl has the attribute is a good suggestion to harden these deviations. I'll make some experiments and report back on this thread.

Currently it is possible to match on the presence of the attribute "format", not on its arguments. Since "printf" is the only archetype used with "format" I don't think this is a big issue currently, but I'll let you be the judge on that.


Thanks,

~Andrew

--
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.