diff options
author | Wei Yongjun <weiyongjun1@huawei.com> | 2020-04-30 08:18:51 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-05-20 08:22:12 +0200 |
commit | 8ad3bcd4e0aa55a5cf3c059ee31b09efb90ac788 (patch) | |
tree | 511c10ce5988b31aea5e6d6a4fec380a4d79383f | |
parent | 31eaf61c714f03a239ac3b193bf47513d201e13e (diff) |
bpf: Fix error return code in map_lookup_and_delete_elem()
[ Upstream commit 7f645462ca01d01abb94d75e6768c8b3ed3a188b ]
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
Signed-off-by: Sasha Levin <sashal@kernel.org>
-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 3b92aea18ae75..e04ea4c8f9358 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -1480,8 +1480,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; |