tree:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: ca0e494af5edb59002665bf12871e94b4163a257
commit: ac5a72ea5c8989871e61f6bb0852e0f91de51ebe [7274/8137] bpf: Use dedicated
bpf_trace_printk event instead of trace_printk()
config: mips-randconfig-r022-20200715 (attached as .config)
compiler: mips64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O
~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout ac5a72ea5c8989871e61f6bb0852e0f91de51ebe
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
kernel/trace/bpf_trace.c: In function '____bpf_trace_printk':
> kernel/trace/bpf_trace.c:538:2: warning: function
'____bpf_trace_printk' might be a candidate for 'gnu_printf' format
attribute [-Wsuggest-attribute=format]
538 | return __BPF_TP_EMIT();
| ^~~~~~
> kernel/trace/bpf_trace.c:538:2: warning: function
'____bpf_trace_printk' might be a candidate for 'gnu_printf' format
attribute [-Wsuggest-attribute=format]
>
kernel/trace/bpf_trace.c:538:2: warning: function '____bpf_trace_printk' might be
a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> kernel/trace/bpf_trace.c:538:2: warning: function
'____bpf_trace_printk' might be a candidate for 'gnu_printf' format
attribute [-Wsuggest-attribute=format]
>
kernel/trace/bpf_trace.c:538:2: warning: function '____bpf_trace_printk' might be
a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> kernel/trace/bpf_trace.c:538:2: warning: function
'____bpf_trace_printk' might be a candidate for 'gnu_printf' format
attribute [-Wsuggest-attribute=format]
>
kernel/trace/bpf_trace.c:538:2: warning: function '____bpf_trace_printk' might be
a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> kernel/trace/bpf_trace.c:538:2: warning: function
'____bpf_trace_printk' might be a candidate for 'gnu_printf' format
attribute [-Wsuggest-attribute=format]
>
kernel/trace/bpf_trace.c:538:2: warning: function '____bpf_trace_printk' might be
a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> kernel/trace/bpf_trace.c:538:2: warning: function
'____bpf_trace_printk' might be a candidate for 'gnu_printf' format
attribute [-Wsuggest-attribute=format]
>
kernel/trace/bpf_trace.c:538:2: warning: function '____bpf_trace_printk' might be
a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> kernel/trace/bpf_trace.c:538:2: warning: function
'____bpf_trace_printk' might be a candidate for 'gnu_printf' format
attribute [-Wsuggest-attribute=format]
>
kernel/trace/bpf_trace.c:538:2: warning: function '____bpf_trace_printk' might be
a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> kernel/trace/bpf_trace.c:538:2: warning: function
'____bpf_trace_printk' might be a candidate for 'gnu_printf' format
attribute [-Wsuggest-attribute=format]
>
kernel/trace/bpf_trace.c:538:2: warning: function '____bpf_trace_printk' might be
a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> kernel/trace/bpf_trace.c:538:2: warning: function
'____bpf_trace_printk' might be a candidate for 'gnu_printf' format
attribute [-Wsuggest-attribute=format]
>
kernel/trace/bpf_trace.c:538:2: warning: function '____bpf_trace_printk' might be
a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> kernel/trace/bpf_trace.c:538:2: warning: function
'____bpf_trace_printk' might be a candidate for 'gnu_printf' format
attribute [-Wsuggest-attribute=format]
>
kernel/trace/bpf_trace.c:538:2: warning: function '____bpf_trace_printk' might be
a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> kernel/trace/bpf_trace.c:538:2: warning: function
'____bpf_trace_printk' might be a candidate for 'gnu_printf' format
attribute [-Wsuggest-attribute=format]
kernel/trace/bpf_trace.c:538:2: warning:
function '____bpf_trace_printk' might be a candidate for 'gnu_printf'
format attribute [-Wsuggest-attribute=format]
kernel/trace/bpf_trace.c:538:2: warning: function '____bpf_trace_printk' might
be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
kernel/trace/bpf_trace.c:538:2: warning: function '____bpf_trace_printk' might
be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
kernel/trace/bpf_trace.c:538:2: warning: function '____bpf_trace_printk' might
be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
kernel/trace/bpf_trace.c:538:2: warning: function '____bpf_trace_printk' might
be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
kernel/trace/bpf_trace.c:538:2: warning: function '____bpf_trace_printk' might
be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
kernel/trace/bpf_trace.c:538:2: warning: function '____bpf_trace_printk' might
be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
vim +538 kernel/trace/bpf_trace.c
ac5a72ea5c8989 Alan Maguire 2020-07-13 405
9c959c863f8217 Alexei Starovoitov 2015-03-25 406 /*
7bda4b40c5624c John Fastabend 2017-07-02 407 * Only limited trace_printk()
conversion specifiers allowed:
2df6bb5493f83c Song Liu 2020-06-29 408 * %d %i %u %x %ld %li %lu %lx %lld
%lli %llu %llx %p %pB %pks %pus %s
9c959c863f8217 Alexei Starovoitov 2015-03-25 409 */
f3694e00123802 Daniel Borkmann 2016-09-09 410 BPF_CALL_5(bpf_trace_printk, char *,
fmt, u32, fmt_size, u64, arg1,
f3694e00123802 Daniel Borkmann 2016-09-09 411 u64, arg2, u64, arg3)
9c959c863f8217 Alexei Starovoitov 2015-03-25 412 {
b2a5212fb63456 Daniel Borkmann 2020-05-15 413 int i, mod[3] = {}, fmt_cnt = 0;
b2a5212fb63456 Daniel Borkmann 2020-05-15 414 char buf[64], fmt_ptype;
b2a5212fb63456 Daniel Borkmann 2020-05-15 415 void *unsafe_ptr = NULL;
8d3b7dce862291 Alexei Starovoitov 2015-08-28 416 bool str_seen = false;
9c959c863f8217 Alexei Starovoitov 2015-03-25 417
9c959c863f8217 Alexei Starovoitov 2015-03-25 418 /*
9c959c863f8217 Alexei Starovoitov 2015-03-25 419 *
bpf_check()->check_func_arg()->check_stack_boundary()
9c959c863f8217 Alexei Starovoitov 2015-03-25 420 * guarantees that fmt points to bpf
program stack,
9c959c863f8217 Alexei Starovoitov 2015-03-25 421 * fmt_size bytes of it were
initialized and fmt_size > 0
9c959c863f8217 Alexei Starovoitov 2015-03-25 422 */
9c959c863f8217 Alexei Starovoitov 2015-03-25 423 if (fmt[--fmt_size] != 0)
9c959c863f8217 Alexei Starovoitov 2015-03-25 424 return -EINVAL;
9c959c863f8217 Alexei Starovoitov 2015-03-25 425
9c959c863f8217 Alexei Starovoitov 2015-03-25 426 /* check format string for allowed
specifiers */
9c959c863f8217 Alexei Starovoitov 2015-03-25 427 for (i = 0; i < fmt_size; i++) {
9c959c863f8217 Alexei Starovoitov 2015-03-25 428 if ((!isprint(fmt[i]) &&
!isspace(fmt[i])) || !isascii(fmt[i]))
9c959c863f8217 Alexei Starovoitov 2015-03-25 429 return -EINVAL;
9c959c863f8217 Alexei Starovoitov 2015-03-25 430
9c959c863f8217 Alexei Starovoitov 2015-03-25 431 if (fmt[i] != '%')
9c959c863f8217 Alexei Starovoitov 2015-03-25 432 continue;
9c959c863f8217 Alexei Starovoitov 2015-03-25 433
9c959c863f8217 Alexei Starovoitov 2015-03-25 434 if (fmt_cnt >= 3)
9c959c863f8217 Alexei Starovoitov 2015-03-25 435 return -EINVAL;
9c959c863f8217 Alexei Starovoitov 2015-03-25 436
9c959c863f8217 Alexei Starovoitov 2015-03-25 437 /* fmt[i] != 0 && fmt[last]
== 0, so we can access fmt[i + 1] */
9c959c863f8217 Alexei Starovoitov 2015-03-25 438 i++;
9c959c863f8217 Alexei Starovoitov 2015-03-25 439 if (fmt[i] == 'l') {
9c959c863f8217 Alexei Starovoitov 2015-03-25 440 mod[fmt_cnt]++;
9c959c863f8217 Alexei Starovoitov 2015-03-25 441 i++;
b2a5212fb63456 Daniel Borkmann 2020-05-15 442 } else if (fmt[i] == 'p') {
9c959c863f8217 Alexei Starovoitov 2015-03-25 443 mod[fmt_cnt]++;
b2a5212fb63456 Daniel Borkmann 2020-05-15 444 if ((fmt[i + 1] == 'k' ||
b2a5212fb63456 Daniel Borkmann 2020-05-15 445 fmt[i + 1] == 'u')
&&
b2a5212fb63456 Daniel Borkmann 2020-05-15 446 fmt[i + 2] == 's') {
b2a5212fb63456 Daniel Borkmann 2020-05-15 447 fmt_ptype = fmt[i + 1];
b2a5212fb63456 Daniel Borkmann 2020-05-15 448 i += 2;
b2a5212fb63456 Daniel Borkmann 2020-05-15 449 goto fmt_str;
b2a5212fb63456 Daniel Borkmann 2020-05-15 450 }
b2a5212fb63456 Daniel Borkmann 2020-05-15 451
2df6bb5493f83c Song Liu 2020-06-29 452 if (fmt[i + 1] == 'B') {
2df6bb5493f83c Song Liu 2020-06-29 453 i++;
2df6bb5493f83c Song Liu 2020-06-29 454 goto fmt_next;
2df6bb5493f83c Song Liu 2020-06-29 455 }
2df6bb5493f83c Song Liu 2020-06-29 456
1efb6ee3edea57 Martynas Pumputis 2018-11-23 457 /* disallow any further format
extensions */
1efb6ee3edea57 Martynas Pumputis 2018-11-23 458 if (fmt[i + 1] != 0 &&
1efb6ee3edea57 Martynas Pumputis 2018-11-23 459 !isspace(fmt[i + 1]) &&
1efb6ee3edea57 Martynas Pumputis 2018-11-23 460 !ispunct(fmt[i + 1]))
9c959c863f8217 Alexei Starovoitov 2015-03-25 461 return -EINVAL;
b2a5212fb63456 Daniel Borkmann 2020-05-15 462
b2a5212fb63456 Daniel Borkmann 2020-05-15 463 goto fmt_next;
b2a5212fb63456 Daniel Borkmann 2020-05-15 464 } else if (fmt[i] == 's') {
b2a5212fb63456 Daniel Borkmann 2020-05-15 465 mod[fmt_cnt]++;
b2a5212fb63456 Daniel Borkmann 2020-05-15 466 fmt_ptype = fmt[i];
b2a5212fb63456 Daniel Borkmann 2020-05-15 467 fmt_str:
8d3b7dce862291 Alexei Starovoitov 2015-08-28 468 if (str_seen)
8d3b7dce862291 Alexei Starovoitov 2015-08-28 469 /* allow only one '%s' per
fmt string */
8d3b7dce862291 Alexei Starovoitov 2015-08-28 470 return -EINVAL;
8d3b7dce862291 Alexei Starovoitov 2015-08-28 471 str_seen = true;
8d3b7dce862291 Alexei Starovoitov 2015-08-28 472
b2a5212fb63456 Daniel Borkmann 2020-05-15 473 if (fmt[i + 1] != 0 &&
b2a5212fb63456 Daniel Borkmann 2020-05-15 474 !isspace(fmt[i + 1]) &&
b2a5212fb63456 Daniel Borkmann 2020-05-15 475 !ispunct(fmt[i + 1]))
b2a5212fb63456 Daniel Borkmann 2020-05-15 476 return -EINVAL;
b2a5212fb63456 Daniel Borkmann 2020-05-15 477
8d3b7dce862291 Alexei Starovoitov 2015-08-28 478 switch (fmt_cnt) {
b2a5212fb63456 Daniel Borkmann 2020-05-15 479 case 0:
b2a5212fb63456 Daniel Borkmann 2020-05-15 480 unsafe_ptr = (void *)(long)arg1;
f3694e00123802 Daniel Borkmann 2016-09-09 481 arg1 = (long)buf;
8d3b7dce862291 Alexei Starovoitov 2015-08-28 482 break;
b2a5212fb63456 Daniel Borkmann 2020-05-15 483 case 1:
b2a5212fb63456 Daniel Borkmann 2020-05-15 484 unsafe_ptr = (void *)(long)arg2;
f3694e00123802 Daniel Borkmann 2016-09-09 485 arg2 = (long)buf;
8d3b7dce862291 Alexei Starovoitov 2015-08-28 486 break;
b2a5212fb63456 Daniel Borkmann 2020-05-15 487 case 2:
b2a5212fb63456 Daniel Borkmann 2020-05-15 488 unsafe_ptr = (void *)(long)arg3;
f3694e00123802 Daniel Borkmann 2016-09-09 489 arg3 = (long)buf;
8d3b7dce862291 Alexei Starovoitov 2015-08-28 490 break;
8d3b7dce862291 Alexei Starovoitov 2015-08-28 491 }
b2a5212fb63456 Daniel Borkmann 2020-05-15 492
d7b2977b816223 Christoph Hellwig 2020-06-08 493 bpf_trace_copy_string(buf,
unsafe_ptr, fmt_ptype,
8d3b7dce862291 Alexei Starovoitov 2015-08-28 494 sizeof(buf));
b2a5212fb63456 Daniel Borkmann 2020-05-15 495 goto fmt_next;
9c959c863f8217 Alexei Starovoitov 2015-03-25 496 }
9c959c863f8217 Alexei Starovoitov 2015-03-25 497
9c959c863f8217 Alexei Starovoitov 2015-03-25 498 if (fmt[i] == 'l') {
9c959c863f8217 Alexei Starovoitov 2015-03-25 499 mod[fmt_cnt]++;
9c959c863f8217 Alexei Starovoitov 2015-03-25 500 i++;
9c959c863f8217 Alexei Starovoitov 2015-03-25 501 }
9c959c863f8217 Alexei Starovoitov 2015-03-25 502
7bda4b40c5624c John Fastabend 2017-07-02 503 if (fmt[i] != 'i' &&
fmt[i] != 'd' &&
7bda4b40c5624c John Fastabend 2017-07-02 504 fmt[i] != 'u' &&
fmt[i] != 'x')
9c959c863f8217 Alexei Starovoitov 2015-03-25 505 return -EINVAL;
b2a5212fb63456 Daniel Borkmann 2020-05-15 506 fmt_next:
9c959c863f8217 Alexei Starovoitov 2015-03-25 507 fmt_cnt++;
9c959c863f8217 Alexei Starovoitov 2015-03-25 508 }
9c959c863f8217 Alexei Starovoitov 2015-03-25 509
88a5c690b66110 Daniel Borkmann 2017-08-16 510 /* Horrid workaround for getting
va_list handling working with different
88a5c690b66110 Daniel Borkmann 2017-08-16 511 * argument type combinations
generically for 32 and 64 bit archs.
88a5c690b66110 Daniel Borkmann 2017-08-16 512 */
88a5c690b66110 Daniel Borkmann 2017-08-16 513 #define
__BPF_TP_EMIT() __BPF_ARG3_TP()
88a5c690b66110 Daniel Borkmann 2017-08-16 514 #define __BPF_TP(...) \
ac5a72ea5c8989 Alan Maguire 2020-07-13 515 bpf_do_trace_printk(fmt,
##__VA_ARGS__)
88a5c690b66110 Daniel Borkmann 2017-08-16 516
88a5c690b66110 Daniel Borkmann 2017-08-16 517 #define __BPF_ARG1_TP(...) \
88a5c690b66110 Daniel Borkmann 2017-08-16 518 ((mod[0] == 2 || (mod[0] == 1
&& __BITS_PER_LONG == 64)) \
88a5c690b66110 Daniel Borkmann 2017-08-16 519 ? __BPF_TP(arg1,
##__VA_ARGS__) \
88a5c690b66110 Daniel Borkmann 2017-08-16 520 : ((mod[0] == 1 || (mod[0] == 0
&& __BITS_PER_LONG == 32)) \
88a5c690b66110 Daniel Borkmann 2017-08-16 521 ? __BPF_TP((long)arg1,
##__VA_ARGS__) \
88a5c690b66110 Daniel Borkmann 2017-08-16 522 : __BPF_TP((u32)arg1,
##__VA_ARGS__)))
88a5c690b66110 Daniel Borkmann 2017-08-16 523
88a5c690b66110 Daniel Borkmann 2017-08-16 524 #define __BPF_ARG2_TP(...) \
88a5c690b66110 Daniel Borkmann 2017-08-16 525 ((mod[1] == 2 || (mod[1] == 1
&& __BITS_PER_LONG == 64)) \
88a5c690b66110 Daniel Borkmann 2017-08-16 526 ? __BPF_ARG1_TP(arg2,
##__VA_ARGS__) \
88a5c690b66110 Daniel Borkmann 2017-08-16 527 : ((mod[1] == 1 || (mod[1] == 0
&& __BITS_PER_LONG == 32)) \
88a5c690b66110 Daniel Borkmann 2017-08-16 528 ? __BPF_ARG1_TP((long)arg2,
##__VA_ARGS__) \
88a5c690b66110 Daniel Borkmann 2017-08-16 529 : __BPF_ARG1_TP((u32)arg2,
##__VA_ARGS__)))
88a5c690b66110 Daniel Borkmann 2017-08-16 530
88a5c690b66110 Daniel Borkmann 2017-08-16 531 #define __BPF_ARG3_TP(...) \
88a5c690b66110 Daniel Borkmann 2017-08-16 532 ((mod[2] == 2 || (mod[2] == 1
&& __BITS_PER_LONG == 64)) \
88a5c690b66110 Daniel Borkmann 2017-08-16 533 ? __BPF_ARG2_TP(arg3,
##__VA_ARGS__) \
88a5c690b66110 Daniel Borkmann 2017-08-16 534 : ((mod[2] == 1 || (mod[2] == 0
&& __BITS_PER_LONG == 32)) \
88a5c690b66110 Daniel Borkmann 2017-08-16 535 ? __BPF_ARG2_TP((long)arg3,
##__VA_ARGS__) \
88a5c690b66110 Daniel Borkmann 2017-08-16 536 : __BPF_ARG2_TP((u32)arg3,
##__VA_ARGS__)))
88a5c690b66110 Daniel Borkmann 2017-08-16 537
88a5c690b66110 Daniel Borkmann 2017-08-16 @538 return __BPF_TP_EMIT();
9c959c863f8217 Alexei Starovoitov 2015-03-25 539 }
9c959c863f8217 Alexei Starovoitov 2015-03-25 540
:::::: The code at line 538 was first introduced by commit
:::::: 88a5c690b66110ad255380d8f629c629cf6ca559 bpf: fix bpf_trace_printk on 32 bit archs
:::::: TO: Daniel Borkmann <daniel(a)iogearbox.net>
:::::: CC: David S. Miller <davem(a)davemloft.net>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org