diff options
author | Wei Yongjun <weiyongjun1@huawei.com> | 2020-04-30 10:18:51 +0200 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2020-04-30 16:19:08 +0200 |
commit | 7f645462ca01d01abb94d75e6768c8b3ed3a188b (patch) | |
tree | 9b4fe3e64486b14b38c6598a089e5ca6bc5107cb | |
parent | bpf: Fix sk_psock refcnt leak when receiving message (diff) | |
download | linux-7f645462ca01d01abb94d75e6768c8b3ed3a188b.tar.xz linux-7f645462ca01d01abb94d75e6768c8b3ed3a188b.zip |
bpf: Fix error return code in map_lookup_and_delete_elem()
Fix to return negative error code -EFAULT from the copy_to_user() error
handling case instead of 0, as done elsewhere in this function.
Fixes: bd513cd08f10 ("bpf: add MAP_LOOKUP_AND_DELETE_ELEM syscall")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20200430081851.166996-1-weiyongjun1@huawei.com
-rw-r--r-- | kernel/bpf/syscall.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 7626b8024471..2843bbba9ca1 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -1485,8 +1485,10 @@ static int map_lookup_and_delete_elem(union bpf_attr *attr) if (err) goto free_value; - if (copy_to_user(uvalue, value, value_size) != 0) + if (copy_to_user(uvalue, value, value_size) != 0) { + err = -EFAULT; goto free_value; + } err = 0; |