diff options
author | Magnus Karlsson <magnus.karlsson@intel.com> | 2020-09-26 11:26:13 +0200 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2020-09-28 21:18:01 +0200 |
commit | 1fd17c8cd0aa636afcf441ee23023b5a7cba4efa (patch) | |
tree | b1ba6171b35d6320f166fec1d4bebb60bd2963d4 /net/xdp | |
parent | ba5f4cfeac77fca981b199ec7f2396a3616e5216 (diff) | |
download | linux-1fd17c8cd0aa636afcf441ee23023b5a7cba4efa.tar.bz2 |
xsk: Fix possible crash in socket_release when out-of-memory
Fix possible crash in socket_release when an out-of-memory error has
occurred in the bind call. If a socket using the XDP_SHARED_UMEM flag
encountered an error in xp_create_and_assign_umem, the bind code
jumped to the exit routine but erroneously forgot to set the err value
before jumping. This meant that the exit routine thought the setup
went well and set the state of the socket to XSK_BOUND. The xsk socket
release code will then, at application exit, think that this is a
properly setup socket, when it is not, leading to a crash when all
fields in the socket have in fact not been initialized properly. Fix
this by setting the err variable in xsk_bind so that the socket is not
set to XSK_BOUND which leads to the clean-up in xsk_release not being
triggered.
Fixes: 1c1efc2af158 ("xsk: Create and free buffer pool independently from umem")
Reported-by: syzbot+ddc7b4944bc61da19b81@syzkaller.appspotmail.com
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/1601112373-10595-1-git-send-email-magnus.karlsson@gmail.com
Diffstat (limited to 'net/xdp')
-rw-r--r-- | net/xdp/xsk.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c index 3895697f8540..ba4dfb17c666 100644 --- a/net/xdp/xsk.c +++ b/net/xdp/xsk.c @@ -703,6 +703,7 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len) xs->pool = xp_create_and_assign_umem(xs, umem_xs->umem); if (!xs->pool) { + err = -ENOMEM; sockfd_put(sock); goto out_unlock; } |