1
0
Fork 0

bpf: Fix error return code in map_lookup_and_delete_elem()

[ Upstream commit 7f645462ca ]

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: bd513cd08f ("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>
5.4-rM2-2.2.x-imx-squashed
Wei Yongjun 2020-04-30 08:18:51 +00:00 committed by Greg Kroah-Hartman
parent 5b96668b63
commit 5d47b3d6b4
1 changed files with 3 additions and 1 deletions

View File

@ -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;