lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202512061640.9hKTnB8p-lkp@intel.com>
Date: Sat, 6 Dec 2025 16:12:01 +0800
From: kernel test robot <lkp@...el.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: llvm@...ts.linux.dev, oe-kbuild-all@...ts.linux.dev,
	linux-kernel@...r.kernel.org, Petr Mladek <pmladek@...e.com>,
	Kees Cook <kees@...nel.org>
Subject: kernel/trace/bpf_trace.c:378:65: warning: diagnostic behavior may be
 improved by adding the 'format(printf, 1, 0)' attribute to the declaration
 of '____bpf_trace_printk'

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   416f99c3b16f582a3fc6d64a1f77f39d94b76de5
commit: 7bf819aa992faee980610e9021aec0c38aac53be vsnprintf: Mark binary printing functions with __printf() attribute
date:   8 months ago
config: riscv-defconfig (https://download.01.org/0day-ci/archive/20251206/202512061640.9hKTnB8p-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 14bf95b06a18b9b59c89601cbc0e5a6f2176b118)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251206/202512061640.9hKTnB8p-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512061640.9hKTnB8p-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> kernel/trace/bpf_trace.c:378:65: warning: diagnostic behavior may be improved by adding the 'format(printf, 1, 0)' attribute to the declaration of '____bpf_trace_printk' [-Wmissing-format-attribute]
     363 | BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1,
         | __attribute__((format(printf, 1, 0))) 
     364 |            u64, arg2, u64, arg3)
     365 | {
     366 |         u64 args[MAX_TRACE_PRINTK_VARARGS] = { arg1, arg2, arg3 };
     367 |         struct bpf_bprintf_data data = {
     368 |                 .get_bin_args   = true,
     369 |                 .get_buf        = true,
     370 |         };
     371 |         int ret;
     372 | 
     373 |         ret = bpf_bprintf_prepare(fmt, fmt_size, args,
     374 |                                   MAX_TRACE_PRINTK_VARARGS, &data);
     375 |         if (ret < 0)
     376 |                 return ret;
     377 | 
     378 |         ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args);
         |                                                                        ^
   kernel/trace/bpf_trace.c:363:1: note: '____bpf_trace_printk' declared here
     363 | BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1,
         | ^
   include/linux/filter.h:613:31: note: expanded from macro 'BPF_CALL_5'
     613 | #define BPF_CALL_5(name, ...)   BPF_CALL_x(5, __NOATTR, name, __VA_ARGS__)
         |                                 ^
   include/linux/filter.h:597:6: note: expanded from macro 'BPF_CALL_x'
     597 |         u64 ____##name(__BPF_MAP(x, __BPF_DECL_ARGS, __BPF_V, __VA_ARGS__));   \
         |             ^
   <scratch space>:141:1: note: expanded from here
     141 | ____bpf_trace_printk
         | ^
>> kernel/trace/bpf_trace.c:433:65: warning: diagnostic behavior may be improved by adding the 'format(printf, 1, 0)' attribute to the declaration of '____bpf_trace_vprintk' [-Wmissing-format-attribute]
     415 |         ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args);
         |                                                                        ^
   kernel/trace/bpf_trace.c:415:1: note: '____bpf_trace_vprintk' declared here
     415 | BPF_CALL_4(bpf_trace_vprintk, char *, fmt, u32, fmt_size, const void *, args,
         | ^
   include/linux/filter.h:612:31: note: expanded from macro 'BPF_CALL_4'
     612 | #define BPF_CALL_4(name, ...)   BPF_CALL_x(4, __NOATTR, name, __VA_ARGS__)
         |                                 ^
   include/linux/filter.h:597:6: note: expanded from macro 'BPF_CALL_x'
     597 |         u64 ____##name(__BPF_MAP(x, __BPF_DECL_ARGS, __BPF_V, __VA_ARGS__));   \
         |             ^
   <scratch space>:154:1: note: expanded from here
     154 | ____bpf_trace_vprintk
         | ^
   kernel/trace/bpf_trace.c:475:35: warning: diagnostic behavior may be improved by adding the 'format(printf, 2, 0)' attribute to the declaration of '____bpf_seq_printf' [-Wmissing-format-attribute]
     458 |         seq_bprintf(m, fmt, data.bin_args);
         |                                          ^
   kernel/trace/bpf_trace.c:458:1: note: '____bpf_seq_printf' declared here
     458 | BPF_CALL_5(bpf_seq_printf, struct seq_file *, m, char *, fmt, u32, fmt_size,
         | ^
   include/linux/filter.h:613:31: note: expanded from macro 'BPF_CALL_5'
     613 | #define BPF_CALL_5(name, ...)   BPF_CALL_x(5, __NOATTR, name, __VA_ARGS__)
         |                                 ^
   include/linux/filter.h:597:6: note: expanded from macro 'BPF_CALL_x'
     597 |         u64 ____##name(__BPF_MAP(x, __BPF_DECL_ARGS, __BPF_V, __VA_ARGS__));   \
         |             ^
   <scratch space>:169:1: note: expanded from here
     169 | ____bpf_seq_printf
         | ^
   kernel/trace/bpf_trace.c:3382:10: warning: default initialization of an object of type 'typeof ((attr->link_create.uprobe_multi.path))' (aka 'const unsigned long long') leaves the object uninitialized [-Wdefault-const-init-var-unsafe]
    3382 |         upath = u64_to_user_ptr(attr->link_create.uprobe_multi.path);
         |                 ^
   include/linux/kernel.h:52:2: note: expanded from macro 'u64_to_user_ptr'
      52 |         typecheck(u64, (x));            \
         |         ^
   include/linux/typecheck.h:11:12: note: expanded from macro 'typecheck'
      11 |         typeof(x) __dummy2; \
         |                   ^
   kernel/trace/bpf_trace.c:3383:13: warning: default initialization of an object of type 'typeof ((attr->link_create.uprobe_multi.offsets))' (aka 'const unsigned long long') leaves the object uninitialized [-Wdefault-const-init-var-unsafe]
    3383 |         uoffsets = u64_to_user_ptr(attr->link_create.uprobe_multi.offsets);
         |                    ^
   include/linux/kernel.h:52:2: note: expanded from macro 'u64_to_user_ptr'
      52 |         typecheck(u64, (x));            \
         |         ^
   include/linux/typecheck.h:11:12: note: expanded from macro 'typecheck'
      11 |         typeof(x) __dummy2; \
         |                   ^
   kernel/trace/bpf_trace.c:3392:21: warning: default initialization of an object of type 'typeof ((attr->link_create.uprobe_multi.ref_ctr_offsets))' (aka 'const unsigned long long') leaves the object uninitialized [-Wdefault-const-init-var-unsafe]
    3392 |         uref_ctr_offsets = u64_to_user_ptr(attr->link_create.uprobe_multi.ref_ctr_offsets);
         |                            ^
   include/linux/kernel.h:52:2: note: expanded from macro 'u64_to_user_ptr'
      52 |         typecheck(u64, (x));            \
         |         ^
   include/linux/typecheck.h:11:12: note: expanded from macro 'typecheck'
      11 |         typeof(x) __dummy2; \
         |                   ^
   kernel/trace/bpf_trace.c:3393:13: warning: default initialization of an object of type 'typeof ((attr->link_create.uprobe_multi.cookies))' (aka 'const unsigned long long') leaves the object uninitialized [-Wdefault-const-init-var-unsafe]
    3393 |         ucookies = u64_to_user_ptr(attr->link_create.uprobe_multi.cookies);
         |                    ^
   include/linux/kernel.h:52:2: note: expanded from macro 'u64_to_user_ptr'
      52 |         typecheck(u64, (x));            \
         |         ^
   include/linux/typecheck.h:11:12: note: expanded from macro 'typecheck'
      11 |         typeof(x) __dummy2; \
         |                   ^
   7 warnings generated.


vim +378 kernel/trace/bpf_trace.c

ac5a72ea5c8989 Alan Maguire       2020-07-13  362  
d9c9e4db186ab4 Florent Revest     2021-04-19  363  BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1,
d9c9e4db186ab4 Florent Revest     2021-04-19  364  	   u64, arg2, u64, arg3)
ac5a72ea5c8989 Alan Maguire       2020-07-13  365  {
d9c9e4db186ab4 Florent Revest     2021-04-19  366  	u64 args[MAX_TRACE_PRINTK_VARARGS] = { arg1, arg2, arg3 };
78aa1cc9404399 Jiri Olsa          2022-12-15  367  	struct bpf_bprintf_data data = {
78aa1cc9404399 Jiri Olsa          2022-12-15  368  		.get_bin_args	= true,
e2bb9e01d589f7 Jiri Olsa          2022-12-15  369  		.get_buf	= true,
78aa1cc9404399 Jiri Olsa          2022-12-15  370  	};
ac5a72ea5c8989 Alan Maguire       2020-07-13  371  	int ret;
ac5a72ea5c8989 Alan Maguire       2020-07-13  372  
78aa1cc9404399 Jiri Olsa          2022-12-15  373  	ret = bpf_bprintf_prepare(fmt, fmt_size, args,
78aa1cc9404399 Jiri Olsa          2022-12-15  374  				  MAX_TRACE_PRINTK_VARARGS, &data);
d9c9e4db186ab4 Florent Revest     2021-04-19  375  	if (ret < 0)
d9c9e4db186ab4 Florent Revest     2021-04-19  376  		return ret;
d9c9e4db186ab4 Florent Revest     2021-04-19  377  
e2bb9e01d589f7 Jiri Olsa          2022-12-15 @378  	ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args);
d9c9e4db186ab4 Florent Revest     2021-04-19  379  
e2bb9e01d589f7 Jiri Olsa          2022-12-15  380  	trace_bpf_trace_printk(data.buf);
ac5a72ea5c8989 Alan Maguire       2020-07-13  381  
f19a4050455aad Jiri Olsa          2022-12-15  382  	bpf_bprintf_cleanup(&data);
ac5a72ea5c8989 Alan Maguire       2020-07-13  383  
d9c9e4db186ab4 Florent Revest     2021-04-19  384  	return ret;
9c959c863f8217 Alexei Starovoitov 2015-03-25  385  }
9c959c863f8217 Alexei Starovoitov 2015-03-25  386  
9c959c863f8217 Alexei Starovoitov 2015-03-25  387  static const struct bpf_func_proto bpf_trace_printk_proto = {
9c959c863f8217 Alexei Starovoitov 2015-03-25  388  	.func		= bpf_trace_printk,
9c959c863f8217 Alexei Starovoitov 2015-03-25  389  	.gpl_only	= true,
9c959c863f8217 Alexei Starovoitov 2015-03-25  390  	.ret_type	= RET_INTEGER,
216e3cd2f28dbb Hao Luo            2021-12-16  391  	.arg1_type	= ARG_PTR_TO_MEM | MEM_RDONLY,
39f19ebbf57b40 Alexei Starovoitov 2017-01-09  392  	.arg2_type	= ARG_CONST_SIZE,
9c959c863f8217 Alexei Starovoitov 2015-03-25  393  };
9c959c863f8217 Alexei Starovoitov 2015-03-25  394  
10aceb629e1984 Dave Marchevsky    2021-09-17  395  static void __set_printk_clr_event(void)
0756ea3e85139d Alexei Starovoitov 2015-06-12  396  {
0756ea3e85139d Alexei Starovoitov 2015-06-12  397  	/*
ac5a72ea5c8989 Alan Maguire       2020-07-13  398  	 * This program might be calling bpf_trace_printk,
ac5a72ea5c8989 Alan Maguire       2020-07-13  399  	 * so enable the associated bpf_trace/bpf_trace_printk event.
ac5a72ea5c8989 Alan Maguire       2020-07-13  400  	 * Repeat this each time as it is possible a user has
ac5a72ea5c8989 Alan Maguire       2020-07-13  401  	 * disabled bpf_trace_printk events.  By loading a program
ac5a72ea5c8989 Alan Maguire       2020-07-13  402  	 * calling bpf_trace_printk() however the user has expressed
ac5a72ea5c8989 Alan Maguire       2020-07-13  403  	 * the intent to see such events.
0756ea3e85139d Alexei Starovoitov 2015-06-12  404  	 */
ac5a72ea5c8989 Alan Maguire       2020-07-13  405  	if (trace_set_clr_event("bpf_trace", "bpf_trace_printk", 1))
ac5a72ea5c8989 Alan Maguire       2020-07-13  406  		pr_warn_ratelimited("could not enable bpf_trace_printk events");
10aceb629e1984 Dave Marchevsky    2021-09-17  407  }
0756ea3e85139d Alexei Starovoitov 2015-06-12  408  
10aceb629e1984 Dave Marchevsky    2021-09-17  409  const struct bpf_func_proto *bpf_get_trace_printk_proto(void)
10aceb629e1984 Dave Marchevsky    2021-09-17  410  {
10aceb629e1984 Dave Marchevsky    2021-09-17  411  	__set_printk_clr_event();
0756ea3e85139d Alexei Starovoitov 2015-06-12  412  	return &bpf_trace_printk_proto;
0756ea3e85139d Alexei Starovoitov 2015-06-12  413  }
0756ea3e85139d Alexei Starovoitov 2015-06-12  414  
78aa1cc9404399 Jiri Olsa          2022-12-15  415  BPF_CALL_4(bpf_trace_vprintk, char *, fmt, u32, fmt_size, const void *, args,
10aceb629e1984 Dave Marchevsky    2021-09-17  416  	   u32, data_len)
10aceb629e1984 Dave Marchevsky    2021-09-17  417  {
78aa1cc9404399 Jiri Olsa          2022-12-15  418  	struct bpf_bprintf_data data = {
78aa1cc9404399 Jiri Olsa          2022-12-15  419  		.get_bin_args	= true,
e2bb9e01d589f7 Jiri Olsa          2022-12-15  420  		.get_buf	= true,
78aa1cc9404399 Jiri Olsa          2022-12-15  421  	};
10aceb629e1984 Dave Marchevsky    2021-09-17  422  	int ret, num_args;
10aceb629e1984 Dave Marchevsky    2021-09-17  423  
10aceb629e1984 Dave Marchevsky    2021-09-17  424  	if (data_len & 7 || data_len > MAX_BPRINTF_VARARGS * 8 ||
78aa1cc9404399 Jiri Olsa          2022-12-15  425  	    (data_len && !args))
10aceb629e1984 Dave Marchevsky    2021-09-17  426  		return -EINVAL;
10aceb629e1984 Dave Marchevsky    2021-09-17  427  	num_args = data_len / 8;
10aceb629e1984 Dave Marchevsky    2021-09-17  428  
78aa1cc9404399 Jiri Olsa          2022-12-15  429  	ret = bpf_bprintf_prepare(fmt, fmt_size, args, num_args, &data);
10aceb629e1984 Dave Marchevsky    2021-09-17  430  	if (ret < 0)
10aceb629e1984 Dave Marchevsky    2021-09-17  431  		return ret;
10aceb629e1984 Dave Marchevsky    2021-09-17  432  
e2bb9e01d589f7 Jiri Olsa          2022-12-15 @433  	ret = bstr_printf(data.buf, MAX_BPRINTF_BUF, fmt, data.bin_args);
10aceb629e1984 Dave Marchevsky    2021-09-17  434  
e2bb9e01d589f7 Jiri Olsa          2022-12-15  435  	trace_bpf_trace_printk(data.buf);
10aceb629e1984 Dave Marchevsky    2021-09-17  436  
f19a4050455aad Jiri Olsa          2022-12-15  437  	bpf_bprintf_cleanup(&data);
10aceb629e1984 Dave Marchevsky    2021-09-17  438  
10aceb629e1984 Dave Marchevsky    2021-09-17  439  	return ret;
10aceb629e1984 Dave Marchevsky    2021-09-17  440  }
10aceb629e1984 Dave Marchevsky    2021-09-17  441  

:::::: The code at line 378 was first introduced by commit
:::::: e2bb9e01d589f7fa82573aedd2765ff9b277816a bpf: Remove trace_printk_lock

:::::: TO: Jiri Olsa <jolsa@...nel.org>
:::::: CC: Daniel Borkmann <daniel@...earbox.net>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ