mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 05:02:12 +00:00
537cf4e3cc
Fix a bug that is triggered when a partially setup socket is
destroyed. For a fully setup socket, a socket that has been bound to a
device, the cleanup of the umem is performed at the end of the buffer
pool's cleanup work queue item. This has to be performed in a work
queue, and not in RCU cleanup, as it is doing a vunmap that cannot
execute in interrupt context. However, when a socket has only been
partially set up so that a umem has been created but the buffer pool
has not, the code erroneously directly calls the umem cleanup function
instead of using a work queue, and this leads to a BUG_ON() in
vunmap().
As there in this case is no buffer pool, we cannot use its work queue,
so we need to introduce a work queue for the umem and schedule this for
the cleanup. So in the case there is no pool, we are going to use the
umem's own work queue to schedule the cleanup. But if there is a
pool, the cleanup of the umem is still being performed by the pool's
work queue, as it is important that the umem is cleaned up after the
pool.
Fixes: e5e1a4bc91
("xsk: Fix possible memory leak at socket close")
Reported-by: Marek Majtyka <marekx.majtyka@intel.com>
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Marek Majtyka <marekx.majtyka@intel.com>
Link: https://lore.kernel.org/bpf/1605873219-21629-1-git-send-email-magnus.karlsson@gmail.com
16 lines
377 B
C
16 lines
377 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/* XDP user-space packet buffer
|
|
* Copyright(c) 2018 Intel Corporation.
|
|
*/
|
|
|
|
#ifndef XDP_UMEM_H_
|
|
#define XDP_UMEM_H_
|
|
|
|
#include <net/xdp_sock_drv.h>
|
|
|
|
void xdp_get_umem(struct xdp_umem *umem);
|
|
void xdp_put_umem(struct xdp_umem *umem, bool defer_cleanup);
|
|
struct xdp_umem *xdp_umem_create(struct xdp_umem_reg *mr);
|
|
|
|
#endif /* XDP_UMEM_H_ */
|