From: Wei Yongjun Date: Thu, 30 Apr 2020 08:18:51 +0000 (+0000) Subject: bpf: Fix error return code in map_lookup_and_delete_elem() X-Git-Tag: v5.4.42~88 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d47b3d6b4d2d554d075823d572706cfd958484a;p=platform%2Fkernel%2Flinux-rpi.git 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 Signed-off-by: Daniel Borkmann Link: https://lore.kernel.org/bpf/20200430081851.166996-1-weiyongjun1@huawei.com Signed-off-by: Sasha Levin --- diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 14f4a76..946cfdd 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -1146,8 +1146,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;