]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bpf, x86: initialize the variable "first_off" in save_args()
authorMenglong Dong <imagedong@tencent.com>
Wed, 19 Jul 2023 11:03:30 +0000 (19:03 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:57:26 +0000 (11:57 +0100)
commit 492e797fdab25f2d8eb1b6bb3236f4aac474f878 upstream.

As Dan Carpenter reported, the variable "first_off" which is passed to
clean_stack_garbage() in save_args() can be uninitialized, which can
cause runtime warnings with KMEMsan. Therefore, init it with 0.

Fixes: 473e3150e30a ("bpf, x86: allow function arguments up to 12 for TRACING")
Cc: Hao Peng <flyingpeng@tencent.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/bpf/09784025-a812-493f-9829-5e26c8691e07@moroto.mountain/
Signed-off-by: Menglong Dong <imagedong@tencent.com>
Link: https://lore.kernel.org/r/20230719110330.2007949-1-imagedong@tencent.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/net/bpf_jit_comp.c

index 7ee72917f13cb71ef6462a5b8447b0b1ec9d5392..7172b0740abf911213cb616a8fd296e58b90ab1a 100644 (file)
@@ -1927,7 +1927,7 @@ static int get_nr_used_regs(const struct btf_func_model *m)
 static void save_args(const struct btf_func_model *m, u8 **prog,
                      int stack_size, bool for_call_origin)
 {
-       int arg_regs, first_off, nr_regs = 0, nr_stack_slots = 0;
+       int arg_regs, first_off = 0, nr_regs = 0, nr_stack_slots = 0;
        int i, j;
 
        /* Store function arguments to stack.