linux-stable/net/xdp
Ciara Loftus a6e944f25c xsk: Fix generic transmit when completion queue reservation fails
Two points of potential failure in the generic transmit function are:

  1. completion queue (cq) reservation failure.
  2. skb allocation failure

Originally the cq reservation was performed first, followed by the skb
allocation. Commit 675716400d ("xdp: fix possible cq entry leak")
reversed the order because at the time there was no mechanism available
to undo the cq reservation which could have led to possible cq entry leaks
in the event of skb allocation failure. However if the skb allocation is
performed first and the cq reservation then fails, the xsk skb destructor
is called which blindly adds the skb address to the already full cq leading
to undefined behavior.

This commit restores the original order (cq reservation followed by skb
allocation) and uses the xskq_prod_cancel helper to undo the cq reserve
in event of skb allocation failure.

Fixes: 675716400d ("xdp: fix possible cq entry leak")
Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/bpf/20220614070746.8871-1-ciara.loftus@intel.com
2022-06-14 16:49:29 +02:00
..
Kconfig
Makefile
xdp_umem.c
xdp_umem.h
xsk.c xsk: Fix generic transmit when completion queue reservation fails 2022-06-14 16:49:29 +02:00
xsk.h
xsk_buff_pool.c xsk: Fix possible crash when multiple sockets are created 2022-04-26 16:19:54 +02:00
xsk_diag.c
xsk_queue.c
xsk_queue.h xsk: Fix handling of invalid descriptors in XSK TX batching API 2022-06-08 16:20:07 +02:00
xskmap.c bpf: Compute map_btf_id during build time 2022-04-26 11:35:21 -07:00