Skip to content

Commit 83cf5c6

Browse files
magnus-karlssonborkmann
authored andcommitted
xsk: Fix use-after-free in failed shared_umem bind
Fix use-after-free when a shared umem bind fails. The code incorrectly tried to free the allocated buffer pool both in the bind code and then later also when the socket was released. Fix this by setting the buffer pool pointer to NULL after the bind code has freed the pool, so that the socket release code will not try to free the pool. This is the same solution as the regular, non-shared umem code path has. This was missing from the shared umem path. Fixes: b5aea28 ("xsk: Add shared umem support between queue ids") Reported-by: [email protected] Signed-off-by: Magnus Karlsson <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 1d6fd78 commit 83cf5c6

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

net/xdp/xsk.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
711711
dev, qid);
712712
if (err) {
713713
xp_destroy(xs->pool);
714+
xs->pool = NULL;
714715
sockfd_put(sock);
715716
goto out_unlock;
716717
}

0 commit comments

Comments
 (0)