From bda8bb8011d865cebf066350c8625e8be1625656 Mon Sep 17 00:00:00 2001
From: Shung-Hsi Yu <[email protected]>
Date: Fri, 18 Apr 2025 15:22:00 +0800
Subject: [PATCH bpf-next 1/1] bpf: use proper type to calculate
bpf_raw_tp_null_args.mask index
The calculation of the index used to access the mask field in 'struct bpf_raw_tp_null_args' is done with 'int' type, which could overflow when the tracepoint being attached has more than 8 arguments.
While none of the tracepoints mentioned in raw_tp_null_args[] currently have more than 8 arguments, there do exist tracepoints that had more than 8 arguments (e.g. iocost_iocg_forgive_debt), so use the correct type for calculation and avoid Smatch static checker warning.
--- kernel/bpf/btf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/btf.c +2 -2
@@ -6829,10 +6829,10 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type,/* Is this a func with potential NULL args? */ if (strcmp (tname, raw_tp_null_args[i].func))continue ; -if (raw_tp_null_args[i].mask & (0x1 << (arg *4 ))) +if (raw_tp_null_args[i].mask & (0x1ULL << (arg *4 ))) info->reg_type |=PTR_MAYBE_NULL ;/* Is the current arg IS_ERR? */ -if (raw_tp_null_args[i].mask & (0x2 << (arg *4 ))) +if (raw_tp_null_args[i].mask & (0x2ULL << (arg *4 ))) ptr_err_raw_tp = true;break ; }
Signature · 1 line
2.49.0
Quoted 5 lines · Shung-Hsi Yu
From
bda8bb8011d865cebf066350c8625e8be1625656Mon Sep 17 00:00:00 2001
From: Shung-Hsi Yu <[email protected]>
Date: Fri, 18 Apr 2025 15:22:00 +0800
Subject: [PATCH bpf-next 1/1] bpf: use proper type to calculate
bpf_raw_tp_null_args.mask index
...
Email headers are off, hence no subject. WIll resend.
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Quoted 11 lines · On Fri, 18 Apr 2025 15:46:31 +0800 you wrote:
Quoted 1 line
From
bda8bb8011d865cebf066350c8625e8be1625656Mon Sep 17 00:00:00 2001From: Shung-Hsi Yu <[email protected]>
Date: Fri, 18 Apr 2025 15:22:00 +0800
Subject: [PATCH bpf-next 1/1] bpf: use proper type to calculate
bpf_raw_tp_null_args.mask indexThe calculation of the index used to access the mask field in 'struct
bpf_raw_tp_null_args' is done with 'int' type, which could overflow when the tracepoint being attached has more than 8 arguments.[...]
Here is the summary with links:
-
https://git.kernel.org/bpf/bpf-next/c/53ebef53a657
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html