Skip to content

Commit 7f64546

Browse files
Wei Yongjunborkmann
authored andcommitted
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: 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
1 parent 18f02ad commit 7f64546

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
@@ -1485,8 +1485,10 @@ static int map_lookup_and_delete_elem(union bpf_attr *attr)
14851485
if (err)
14861486
goto free_value;
14871487

1488-
if (copy_to_user(uvalue, value, value_size) != 0)
1488+
if (copy_to_user(uvalue, value, value_size) != 0) {
1489+
err = -EFAULT;
14891490
goto free_value;
1491+
}
14901492

14911493
err = 0;
14921494

0 commit comments

Comments
 (0)