bpf: don't indicate success when copy_from_user fails
authorDaniel Borkmann <daniel@iogearbox.net>
Thu, 27 Jul 2017 19:02:46 +0000 (21:02 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 29 Jul 2017 21:28:54 +0000 (14:28 -0700)
err in bpf_prog_get_info_by_fd() still holds 0 at that time from prior
check_uarg_tail_zero() check. Explicitly return -EFAULT instead, so
user space can be notified of buggy behavior.

Fixes: 1e2709769086 ("bpf: Add BPF_OBJ_GET_INFO_BY_FD")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
kernel/bpf/syscall.c

index 045646da97cc5dc55a5063301a2e76e4178a8ea3..84bb39975ad49c98a018dd798180a1a218145901 100644 (file)
@@ -1289,7 +1289,7 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
        info_len = min_t(u32, sizeof(info), info_len);
 
        if (copy_from_user(&info, uinfo, info_len))
-               return err;
+               return -EFAULT;
 
        info.type = prog->type;
        info.id = prog->aux->id;