Message ID | 20200430081851.166996-1-weiyongjun1@huawei.com |
---|---|
State | Accepted |
Delegated to: | BPF Maintainers |
Headers | show |
Series | [-next] bpf: fix error return code in map_lookup_and_delete_elem() | expand |
On 4/30/20 10:18 AM, Wei Yongjun wrote: > 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> > --- > kernel/bpf/syscall.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c > index 3cea7602de78..68c22e9420fa 100644 > --- a/kernel/bpf/syscall.c > +++ b/kernel/bpf/syscall.c > @@ -1492,8 +1492,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; > + } > Good catch! Applied to bpf, thanks!
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 3cea7602de78..68c22e9420fa 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -1492,8 +1492,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;
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> --- kernel/bpf/syscall.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)