[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aYRapf5K8wFGEO8v@pathway.suse.cz>
Date: Thu, 5 Feb 2026 09:53:57 +0100
From: Petr Mladek <pmladek@...e.com>
To: Arnd Bergmann <arnd@...nel.org>
Cc: Kees Cook <kees@...nel.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Arnd Bergmann <arnd@...db.de>, kernel test robot <lkp@...el.com>,
Alexei Starovoitov <alexei.starovoitov@...il.com>,
Andy Shevchenko <andy@...nel.org>,
Alexei Starovoitov <ast@...nel.org>,
Bartosz Golaszewski <brgl@...nel.org>, linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org, bpf@...r.kernel.org
Subject: Re: [PATCH] vsnprintf: drop __printf() attributes on binary printing
functions
On Wed 2026-02-04 14:26:23, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@...db.de>
>
> 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")
>From the commit message, it is not obvious why reverting these commits
won't bring back the warnings in the modified functions.
My understanding is that the warnings won't get back thanks to
the commit bd67c1c3c353b6560 ("vsnprintf: Silence false positive
GCC warning for va_format()") as explained by the original cover
letter, see
https://lore.kernel.org/all/20250321144822.324050-1-andriy.shevchenko@linux.intel.com/#t
It would be worth to mentionin this in the commit message.
> Link: https://lore.kernel.org/all/CAADnVQK3eZp3yp35OUx8j1UBsQFhgsn5-4VReqAJ=68PaaKYmg@mail.gmail.com/
> Closes: https://lore.kernel.org/oe-kbuild-all/202512061640.9hKTnB8p-lkp@intel.com/
> Reported-by: kernel test robot <lkp@...el.com>
> Suggested-by: Alexei Starovoitov <alexei.starovoitov@...il.com>
> Acked-by: Alexei Starovoitov <alexei.starovoitov@...il.com>
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> ---
> For reference, three additional patches are required before we can drop
> the Makefile.warn line that currently hides these warnings:
>
> https://lore.kernel.org/lkml/20260203162546.2254900-1-arnd@kernel.org/
> https://lore.kernel.org/lkml/20260203163440.2674340-1-arnd@kernel.org/
> https://lore.kernel.org/lkml/20260203164545.3174910-1-arnd@kernel.org/
>
> Tested using randconfig builds on arm/arm64/x86
> ---
> include/linux/seq_file.h | 1 -
> include/linux/string.h | 4 ++--
> 2 files changed, 2 insertions(+), 3 deletions(-)
Otherwise, the change looks good to me. Feel free to use,
ideally with the updated commit message:
Acked-by: Petr Mladek <pmladek@...e.com>
I wonder who should take this patch. Should it go via
printk/bpf/tracing or another tree?
Does anyone has any preference, please?
Best Regards,
Petr
Powered by blists - more mailing lists