Skip to content

Commit 8ad3bcd

Browse files
Wei Yongjungregkh
authored andcommitted
bpf: Fix error return code in map_lookup_and_delete_elem()
[ Upstream commit 7f64546 ] 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: bd513cd ("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>
1 parent 31eaf61 commit 8ad3bcd

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎kernel/bpf/syscall.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1480,8 +1480,10 @@ static int map_lookup_and_delete_elem(union bpf_attr *attr)
14801480
if (err)
14811481
goto free_value;
14821482

1483-
if (copy_to_user(uvalue, value, value_size) != 0)
1483+
if (copy_to_user(uvalue, value, value_size) != 0) {
1484+
err = -EFAULT;
14841485
goto free_value;
1486+
}
14851487

14861488
err = 0;
14871489

0 commit comments

Comments
 (0)