Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vsnprintf: drop __printf() attributes on binary printing functions

The printf() format attributes are applied inconsistently for the binary
printf helpers, which causes warnings for the bpf_trace code using
them from functions that pass down format strings:

kernel/trace/bpf_trace.c: In function '____bpf_trace_printk':
kernel/trace/bpf_trace.c:377:9: error: function '____bpf_trace_printk' might be a candidate for 'gnu_printf' format attribute [-Werror=suggest-attribute=format]
377 | ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args);
| ^~~

This can be addressed either by annotating all five callers in bpf code,
or by removing the annotations on the callees that were added by Andy
Shevchenko last year.

As Alexei Starovoitov points out, there are no callers in C code that
would benefit from the __printf attributes, the only users are in BPF
code or in the do_trace_printk() helper that already checks the arguments.

Drop all three of these annotations, reverting the earlierl commits that
added these, in order to get a clean build with -Wsuggest-attribute=format.

Fixes: 6b2c1e30ad68 ("seq_file: Mark binary printing functions with __printf() attribute")
Fixes: 7bf819aa992f ("vsnprintf: Mark binary printing functions with __printf() attribute")
Link: https://lore.kernel.org/all/CAADnVQK3eZp3yp35OUx8j1UBsQFhgsn5-4VReqAJ=68PaaKYmg@mail.gmail.com/
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202512061640.9hKTnB8p-lkp@intel.com/
Suggested-by: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Acked-by: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Petr Mladek <pmladek@suse.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20260204132643.1302967-1-arnd@kernel.org
Signed-off-by: Petr Mladek <pmladek@suse.com>

authored by

Arnd Bergmann and committed by
Petr Mladek
b07829d5 9bfa52da

+2 -3
-1
include/linux/seq_file.h
··· 181 181 int seq_release_private(struct inode *, struct file *); 182 182 183 183 #ifdef CONFIG_BINARY_PRINTF 184 - __printf(2, 0) 185 184 void seq_bprintf(struct seq_file *m, const char *f, const u32 *binary); 186 185 #endif 187 186
+2 -2
include/linux/string.h
··· 336 336 #define sysfs_match_string(_a, _s) __sysfs_match_string(_a, ARRAY_SIZE(_a), _s) 337 337 338 338 #ifdef CONFIG_BINARY_PRINTF 339 - __printf(3, 0) int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args); 340 - __printf(3, 0) int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf); 339 + int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args); 340 + int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf); 341 341 #endif 342 342 343 343 extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,