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: <202512081321.2h9ThWTg-lkp@intel.com>
Date: Mon, 8 Dec 2025 13:30:51 +0100
From: kernel test robot <lkp@...el.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
	Petr Mladek <pmladek@...e.com>, Kees Cook <kees@...nel.org>
Subject: kernel/bpf/helpers.c:1065:53: warning: diagnostic behavior may be
 improved by adding the 'format(printf, 3, 0)' attribute to the declaration
 of '____bpf_snprintf'

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   f09079bd04a924c72d555cd97942d5f8d7eca98c
commit: 7bf819aa992faee980610e9021aec0c38aac53be vsnprintf: Mark binary printing functions with __printf() attribute
date:   9 months ago
config: arm64-allnoconfig-bpf (https://download.01.org/0day-ci/archive/20251208/202512081321.2h9ThWTg-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 2222cfe7e11ff3e0434bc696856629199ef0da7c)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251208/202512081321.2h9ThWTg-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/202512081321.2h9ThWTg-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> kernel/bpf/helpers.c:1065:53: warning: diagnostic behavior may be improved by adding the 'format(printf, 3, 0)' attribute to the declaration of '____bpf_snprintf' [-Wmissing-format-attribute]
    1045 |         err = bstr_printf(str, str_size, fmt, data.bin_args);
         |                                                            ^
   kernel/bpf/helpers.c:1045:1: note: '____bpf_snprintf' declared here
    1045 | BPF_CALL_5(bpf_snprintf, char *, str, u32, str_size, char *, fmt,
         | ^
   ./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>:194:1: note: expanded from here
     194 | ____bpf_snprintf
         | ^
   1 warning generated.


vim +1065 kernel/bpf/helpers.c

d9c9e4db186ab4 Florent Revest  2021-04-19  1044  
7b15523a989b63 Florent Revest  2021-04-19  1045  BPF_CALL_5(bpf_snprintf, char *, str, u32, str_size, char *, fmt,
78aa1cc9404399 Jiri Olsa       2022-12-15  1046  	   const void *, args, u32, data_len)
7b15523a989b63 Florent Revest  2021-04-19  1047  {
78aa1cc9404399 Jiri Olsa       2022-12-15  1048  	struct bpf_bprintf_data data = {
78aa1cc9404399 Jiri Olsa       2022-12-15  1049  		.get_bin_args	= true,
78aa1cc9404399 Jiri Olsa       2022-12-15  1050  	};
7b15523a989b63 Florent Revest  2021-04-19  1051  	int err, num_args;
7b15523a989b63 Florent Revest  2021-04-19  1052  
335ff4990cf3bf Dave Marchevsky 2021-09-17  1053  	if (data_len % 8 || data_len > MAX_BPRINTF_VARARGS * 8 ||
78aa1cc9404399 Jiri Olsa       2022-12-15  1054  	    (data_len && !args))
7b15523a989b63 Florent Revest  2021-04-19  1055  		return -EINVAL;
7b15523a989b63 Florent Revest  2021-04-19  1056  	num_args = data_len / 8;
7b15523a989b63 Florent Revest  2021-04-19  1057  
7b15523a989b63 Florent Revest  2021-04-19  1058  	/* ARG_PTR_TO_CONST_STR guarantees that fmt is zero-terminated so we
7b15523a989b63 Florent Revest  2021-04-19  1059  	 * can safely give an unbounded size.
7b15523a989b63 Florent Revest  2021-04-19  1060  	 */
78aa1cc9404399 Jiri Olsa       2022-12-15  1061  	err = bpf_bprintf_prepare(fmt, UINT_MAX, args, num_args, &data);
7b15523a989b63 Florent Revest  2021-04-19  1062  	if (err < 0)
7b15523a989b63 Florent Revest  2021-04-19  1063  		return err;
7b15523a989b63 Florent Revest  2021-04-19  1064  
78aa1cc9404399 Jiri Olsa       2022-12-15 @1065  	err = bstr_printf(str, str_size, fmt, data.bin_args);
48cac3f4a96ddf Florent Revest  2021-04-27  1066  
f19a4050455aad Jiri Olsa       2022-12-15  1067  	bpf_bprintf_cleanup(&data);
7b15523a989b63 Florent Revest  2021-04-19  1068  
7b15523a989b63 Florent Revest  2021-04-19  1069  	return err + 1;
7b15523a989b63 Florent Revest  2021-04-19  1070  }
7b15523a989b63 Florent Revest  2021-04-19  1071  

:::::: The code at line 1065 was first introduced by commit
:::::: 78aa1cc9404399a15d2a1205329c6a06236f5378 bpf: Add struct for bin_args arg in bpf_bprintf_prepare

:::::: 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