mirror of
https://github.com/torvalds/linux.git
synced 2026-06-07 14:04:54 +02:00
libbpf: Fix potential NULL pointer dereference
commitafd0be7299upstream. Wait until after the UMEM is checked for null to dereference it. Fixes:43f1bc1eff("libbpf: Restore umem state after socket create failure") Signed-off-by: Ciara Loftus <ciara.loftus@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20210408052009.7844-1-ciara.loftus@intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
7824d5a993
commit
7f8e59c4c5
|
|
@ -703,18 +703,19 @@ int xsk_socket__create_shared(struct xsk_socket **xsk_ptr,
|
||||||
struct xsk_ring_cons *comp,
|
struct xsk_ring_cons *comp,
|
||||||
const struct xsk_socket_config *usr_config)
|
const struct xsk_socket_config *usr_config)
|
||||||
{
|
{
|
||||||
|
bool unmap, rx_setup_done = false, tx_setup_done = false;
|
||||||
void *rx_map = NULL, *tx_map = NULL;
|
void *rx_map = NULL, *tx_map = NULL;
|
||||||
struct sockaddr_xdp sxdp = {};
|
struct sockaddr_xdp sxdp = {};
|
||||||
struct xdp_mmap_offsets off;
|
struct xdp_mmap_offsets off;
|
||||||
struct xsk_socket *xsk;
|
struct xsk_socket *xsk;
|
||||||
struct xsk_ctx *ctx;
|
struct xsk_ctx *ctx;
|
||||||
int err, ifindex;
|
int err, ifindex;
|
||||||
bool unmap = umem->fill_save != fill;
|
|
||||||
bool rx_setup_done = false, tx_setup_done = false;
|
|
||||||
|
|
||||||
if (!umem || !xsk_ptr || !(rx || tx))
|
if (!umem || !xsk_ptr || !(rx || tx))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
|
unmap = umem->fill_save != fill;
|
||||||
|
|
||||||
xsk = calloc(1, sizeof(*xsk));
|
xsk = calloc(1, sizeof(*xsk));
|
||||||
if (!xsk)
|
if (!xsk)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user