Message ID | 1663058433-14089-1-git-send-email-wangyufen@huawei.com (mailing list archive) |
---|---|
State | Accepted |
Commit | a02c118ee9e898612cbae42121b9e8663455b515 |
Delegated to: | BPF |
Headers | show |
Series | [bpf-next,v2] bpf: use kvmemdup_bpfptr helper | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Single patches do not need cover letters |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 2 this patch: 2 |
netdev/cc_maintainers | success | CCed 12 of 12 maintainers |
netdev/build_clang | success | Errors and warnings before: 5 this patch: 5 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 2 this patch: 2 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 23 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
bpf/vmtest-bpf-next-PR | success | PR summary |
bpf/vmtest-bpf-next-VM_Test-2 | success | Logs for build for x86_64 with gcc |
bpf/vmtest-bpf-next-VM_Test-3 | success | Logs for build for x86_64 with llvm-16 |
bpf/vmtest-bpf-next-VM_Test-1 | success | Logs for build for s390x with gcc |
bpf/vmtest-bpf-next-VM_Test-13 | success | Logs for test_progs_no_alu32 on x86_64 with gcc |
bpf/vmtest-bpf-next-VM_Test-14 | success | Logs for test_progs_no_alu32 on x86_64 with llvm-16 |
bpf/vmtest-bpf-next-VM_Test-16 | success | Logs for test_verifier on x86_64 with gcc |
bpf/vmtest-bpf-next-VM_Test-17 | success | Logs for test_verifier on x86_64 with llvm-16 |
bpf/vmtest-bpf-next-VM_Test-10 | success | Logs for test_progs on x86_64 with gcc |
bpf/vmtest-bpf-next-VM_Test-11 | success | Logs for test_progs on x86_64 with llvm-16 |
bpf/vmtest-bpf-next-VM_Test-7 | success | Logs for test_maps on x86_64 with gcc |
bpf/vmtest-bpf-next-VM_Test-8 | success | Logs for test_maps on x86_64 with llvm-16 |
bpf/vmtest-bpf-next-VM_Test-12 | success | Logs for test_progs_no_alu32 on s390x with gcc |
bpf/vmtest-bpf-next-VM_Test-15 | success | Logs for test_verifier on s390x with gcc |
bpf/vmtest-bpf-next-VM_Test-9 | success | Logs for test_progs on s390x with gcc |
bpf/vmtest-bpf-next-VM_Test-6 | success | Logs for test_maps on s390x with gcc |
bpf/vmtest-bpf-next-VM_Test-4 | success | Logs for llvm-toolchain |
bpf/vmtest-bpf-next-VM_Test-5 | success | Logs for set-matrix |
On Tue, Sep 13, 2022 at 1:29 AM Wang Yufen <wangyufen@huawei.com> wrote: > > Use kvmemdup_bpfptr helper instead of open-coding to > simplify the code. > > Signed-off-by: Wang Yufen <wangyufen@huawei.com> Acked-by: Stanislav Fomichev <sdf@google.com> > --- > kernel/bpf/syscall.c | 13 ++++--------- > 1 file changed, 4 insertions(+), 9 deletions(-) > > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c > index 4fb08c4..f862406 100644 > --- a/kernel/bpf/syscall.c > +++ b/kernel/bpf/syscall.c > @@ -1416,19 +1416,14 @@ static int map_update_elem(union bpf_attr *attr, bpfptr_t uattr) > } > > value_size = bpf_map_value_size(map); > - > - err = -ENOMEM; > - value = kvmalloc(value_size, GFP_USER | __GFP_NOWARN); > - if (!value) > + value = kvmemdup_bpfptr(uvalue, value_size); > + if (IS_ERR(value)) { > + err = PTR_ERR(value); > goto free_key; > - > - err = -EFAULT; > - if (copy_from_bpfptr(value, uvalue, value_size) != 0) > - goto free_value; > + } > > err = bpf_map_update_value(map, f, key, value, attr->flags); > > -free_value: > kvfree(value); > free_key: > kvfree(key); > -- > 1.8.3.1 >
Hello: This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <martin.lau@kernel.org>: On Tue, 13 Sep 2022 16:40:33 +0800 you wrote: > Use kvmemdup_bpfptr helper instead of open-coding to > simplify the code. > > Signed-off-by: Wang Yufen <wangyufen@huawei.com> > --- > kernel/bpf/syscall.c | 13 ++++--------- > 1 file changed, 4 insertions(+), 9 deletions(-) Here is the summary with links: - [bpf-next,v2] bpf: use kvmemdup_bpfptr helper https://git.kernel.org/bpf/bpf-next/c/a02c118ee9e8 You are awesome, thank you!
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 4fb08c4..f862406 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -1416,19 +1416,14 @@ static int map_update_elem(union bpf_attr *attr, bpfptr_t uattr) } value_size = bpf_map_value_size(map); - - err = -ENOMEM; - value = kvmalloc(value_size, GFP_USER | __GFP_NOWARN); - if (!value) + value = kvmemdup_bpfptr(uvalue, value_size); + if (IS_ERR(value)) { + err = PTR_ERR(value); goto free_key; - - err = -EFAULT; - if (copy_from_bpfptr(value, uvalue, value_size) != 0) - goto free_value; + } err = bpf_map_update_value(map, f, key, value, attr->flags); -free_value: kvfree(value); free_key: kvfree(key);
Use kvmemdup_bpfptr helper instead of open-coding to simplify the code. Signed-off-by: Wang Yufen <wangyufen@huawei.com> --- kernel/bpf/syscall.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)