Skip to contentSkip to conversation

audit: Mark audit_log_vformat() with __printf() attribute

PATCH Applied Andy Shevchenko 2 participants 4 messages Mar 13, 2025 – Apr 11, 2025 Audit

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 audit: Mark audit_log_vformat() with __printf() attribute

audit_log_vformat() is using printf() type of format, and GCC compiler (Debian 14.2.0-17) is not happy about this:

kernel/audit.c:1978:9: error: function ‘audit_log_vformat’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format] kernel/audit.c:1987:17: error: function ‘audit_log_vformat’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]

Fix the compilation errors (make W=1 when CONFIG_WERROR=y, which is default) by adding __printf() attribute.

---

v2: added necessary technical information to the commit message (Paul)

 kernel/audit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/audit.c +2 -2
index 5f5bf85bcc90..f365e1bbeac6 100644
@@ -1956,8 +1956,8 @@ static inline int audit_expand(struct audit_buffer *ab, int extra)
  * will be called a second time.  Currently, we assume that a printk
  * can't format message larger than 1024 bytes, so we don't either.
  */
-static void audit_log_vformat(struct audit_buffer *ab, const char *fmt,
-			      va_list args)
+static __printf(2, 0)
+void audit_log_vformat(struct audit_buffer *ab, const char *fmt, va_list args)
 {
 	int len, avail;
 	struct sk_buff *skb;
Signature · 1 line
2.47.2
#1 lore raw
Quoted 8 lines · Andy Shevchenko

audit_log_vformat() is using printf() type of format, and GCC compiler (Debian 14.2.0-17) is not happy about this:

kernel/audit.c:1978:9: error: function ‘audit_log_vformat’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format] kernel/audit.c:1987:17: error: function ‘audit_log_vformat’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]

Fix the compilation errors (make W=1 when CONFIG_WERROR=y, which is default) by adding __printf() attribute.

Any comments on this? Can it be applied?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Applied
#2 lore raw
In reply to Andy Shevchenko
Quoted 10 lines · On Mar 13, 2025 Andy Shevchenko <[email protected]> wrote:

audit_log_vformat() is using printf() type of format, and GCC compiler (Debian 14.2.0-17) is not happy about this:

kernel/audit.c:1978:9: error: function ‘audit_log_vformat’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format] kernel/audit.c:1987:17: error: function ‘audit_log_vformat’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]

Fix the compilation errors (make W=1 when CONFIG_WERROR=y, which is default) by adding __printf() attribute.

Quoted 6 lines

---
v2: added necessary technical information to the commit message (Paul)

 kernel/audit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Merged into audit/dev-staging, this will move to audit/dev after the upcoming merge window.

--
paul-moore.com

maintainer
#3 lore raw
Quoted 15 lines · Paul Moore
Quoted 14 lines · On Mar 13, 2025 Andy Shevchenko <[email protected]> wrote:

audit_log_vformat() is using printf() type of format, and GCC compiler (Debian 14.2.0-17) is not happy about this:

kernel/audit.c:1978:9: error: function ‘audit_log_vformat’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format] kernel/audit.c:1987:17: error: function ‘audit_log_vformat’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]

Fix the compilation errors (make W=1 when CONFIG_WERROR=y, which is default) by adding __printf() attribute.

---
v2: added necessary technical information to the commit message (Paul)

Quoted 5 lines
Quoted 2 lines
 kernel/audit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Merged into audit/dev-staging, this will move to audit/dev after the upcoming merge window.

... and now it is in audit/dev, thanks.

Signature · 1 line
paul-moore.com