On Mon, 2026-02-02 at 10:58 +0100, Arnd Bergmann wrote: > From: Arnd Bergmann <[email protected]> > > The sunrpc change to use trace_printk() for debugging caused > a new warning for every instance of dprintk() in some configurations, > when -Wformat-security is enabled: > > fs/nfs/getroot.c: In function 'nfs_get_root': > fs/nfs/getroot.c:90:17: error: format not a string literal and no format > arguments [-Werror=format-security] > 90 | nfs_errorf(fc, "NFS: Couldn't getattr on root"); > > I've been slowly chipping away at those warnings over time with the > intention of enabling them by default in the future. While I could not > figure out why this only happens for this one instance, I see that the > __trace_bprintk() function is always called with a local variable as > the format string, rather than a literal. > > Remove the __printf(2,3) annotation on this function, as this is can > only be validated for literals. The format strings still get checked > because the underlying literal keeps getting passed into __trace_printk() > in the "else" branch, which is not taken but still evaluated for > compile-time warnings. > > Fixes: ec7d8e68ef0e ("sunrpc: add a Kconfig option to redirect dfprintk() > output to trace buffer") > Signed-off-by: Arnd Bergmann <[email protected]> > --- > include/linux/trace_printk.h | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/include/linux/trace_printk.h b/include/linux/trace_printk.h > index bb5874097f24..2670ec7f4262 100644 > --- a/include/linux/trace_printk.h > +++ b/include/linux/trace_printk.h > @@ -107,7 +107,6 @@ do { > \ > __trace_printk(_THIS_IP_, fmt, ##args); \ > } while (0) > > -extern __printf(2, 3) > int __trace_bprintk(unsigned long ip, const char *fmt, ...); > > extern __printf(2, 3)
Acked-by: Jeff Layton <[email protected]>
