bpf: Fix an error code in check_btf_func()
Subsystems (3)
PATCH 1/1 bpf: Fix an error code in check_btf_func()
This code returns success if kcalloc() but it should return -ENOMEM.
--- kernel/bpf/verifier.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/bpf/verifier.c +3 -1
@@ -7581,8 +7581,10 @@ static int check_btf_func(struct bpf_verifier_env *env,if (!krecord)return -ENOMEM ; info_aux =kcalloc (nfuncs,sizeof (*info_aux),GFP_KERNEL | __GFP_NOWARN); -if (!info_aux) +if (!info_aux) { + ret = -ENOMEM ; goto err_free; + }for (i =0 ; i < nfuncs; i++) { ret =bpf_check_uarg_tail_zero (urecord, krec_size, urec_size);
Signature · 1 line
2.26.2
Quoted 14 lines · Dan Carpenter
This code returns success if
kcalloc()but it should return-ENOMEM.Fixes 8c1b6e69dcc1 ("bpf: Compare BTF types of functions arguments with actual types")Signed-off-by Dan Carpenter <[email protected]>--- kernel/bpf/verifier.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)kernel/bpf/verifier.c +0
-0
kernel/bpf/verifier.c static int check_btf_func(struct bpf_verifier_env *env, · line 7587
Quoted 8 lines
kernel/bpf/verifier.c +3
-1@@ -7581,8 +7581,10 @@ static int check_btf_func(struct bpf_verifier_env *env,if (!krecord)return -ENOMEM ; info_aux =kcalloc (nfuncs,sizeof (*info_aux),GFP_KERNEL | __GFP_NOWARN); -if (!info_aux) +if (!info_aux) { + ret = -ENOMEM ; goto err_free; + }
Thanks for the fix.
I think it's better to do 'int ret = -ENOMEM;' instead.
PATCH v2 1/1 bpf: Fix an error code in check_btf_func()
This code returns success if the "info_aux" allocation fails but it should return -ENOMEM.
---
v2: style change
kernel/bpf/verifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/verifier.c +1 -1
@@ -7552,7 +7552,7 @@ static int check_btf_func(struct bpf_verifier_env *env,const struct btf *btf;void __user *urecord;u32 prev_offset =0 ; -int ret =0 ; +int ret = -ENOMEM ; nfuncs = attr->func_info_cnt;if (!nfuncs)
Signature · 1 line
2.26.2
Quoted 6 lines · Dan Carpenter
This code returns success if the "
info_aux" allocation fails but it should return-ENOMEM.Fixes 8c1b6e69dcc1 ("bpf: Compare BTF types of functions arguments with actual types")Signed-off-by Dan Carpenter <[email protected]>
Quoted 3 lines
---
v2: style change
Quoted 9 lines · Song Liu
Quoted 6 lines · Dan Carpenter
This code returns success if the "
info_aux" allocation fails but it should return-ENOMEM.Fixes 8c1b6e69dcc1 ("bpf: Compare BTF types of functions arguments with actual types")Signed-off-by Dan Carpenter <[email protected]>Acked-by Song Liu <[email protected]>
Applied, thanks (my personal style preference would have been v1, but fair enough).