]> git.baikalelectronics.ru Git - kernel.git/commit
bpf/xskmap: Return ERR_PTR for failure case instead of NULL.
authorJonathan Lemon <jonathan.lemon@gmail.com>
Tue, 24 Sep 2019 16:25:21 +0000 (09:25 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 25 Sep 2019 20:14:16 +0000 (22:14 +0200)
commitb42d9347686c0989340ba0122c05b609d779f7d2
tree2adc59ffd81cc960357f76910e7df660c9bb30f2
parent4121c822a947e694e347ce5ba8f1ba77f3e7a3e6
bpf/xskmap: Return ERR_PTR for failure case instead of NULL.

When kzalloc() failed, NULL was returned to the caller, which
tested the pointer with IS_ERR(), which didn't match, so the
pointer was used later, resulting in a NULL dereference.

Return ERR_PTR(-ENOMEM) instead of NULL.

Reported-by: syzbot+491c1b7565ba9069ecae@syzkaller.appspotmail.com
Fixes: 24e4e13e60f3 ("xsk: remove AF_XDP socket from map when the socket is released")
Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Acked-by: Björn Töpel <bjorn.topel@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/xskmap.c