netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xen-netfront: handle NULL returned by xdp_convert_buff_to_frame()
@ 2025-04-14 18:34 Alexey Nepomnyashih
  2025-04-17  0:58 ` Jakub Kicinski
  0 siblings, 1 reply; 9+ messages in thread
From: Alexey Nepomnyashih @ 2025-04-14 18:34 UTC (permalink / raw)
  To: Juergen Gross
  Cc: Alexey Nepomnyashih, Stefano Stabellini, Oleksandr Tyshchenko,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
	John Fastabend, xen-devel, netdev, linux-kernel, bpf, lvc-project,
	stable

The function xdp_convert_buff_to_frame() may return NULL if it fails
to correctly convert the XDP buffer into an XDP frame due to memory
constraints, internal errors, or invalid data. Failing to check for NULL
may lead to a NULL pointer dereference if the result is used later in
processing, potentially causing crashes, data corruption, or undefined
behavior.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Cc: stable@vger.kernel.org # v5.9+
Fixes: 6c5aa6fc4def ("xen networking: add basic XDP support for xen-netfront")
Signed-off-by: Alexey Nepomnyashih <sdl@nppct.ru>
---
 drivers/net/xen-netfront.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 8425226c09f0..e99561de3cda 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -987,6 +987,10 @@ static u32 xennet_run_xdp(struct netfront_queue *queue, struct page *pdata,
 	case XDP_TX:
 		get_page(pdata);
 		xdpf = xdp_convert_buff_to_frame(xdp);
+		if (unlikely(!xdpf)) {
+			trace_xdp_exception(queue->info->netdev, prog, act);
+			break;
+		}
 		err = xennet_xdp_xmit(queue->info->netdev, 1, &xdpf, 0);
 		if (unlikely(!err))
 			xdp_return_frame_rx_napi(xdpf);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-04-17 13:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-14 18:34 [PATCH] xen-netfront: handle NULL returned by xdp_convert_buff_to_frame() Alexey Nepomnyashih
2025-04-17  0:58 ` Jakub Kicinski
2025-04-17  7:00   ` Alexey
2025-04-17  7:12     ` Jürgen Groß
2025-04-17  8:45       ` Alexey
2025-04-17  8:51         ` Juergen Gross
     [not found]           ` <8264519a-d58a-486e-b3c5-dba400658513@nppct.ru>
2025-04-17 10:23             ` Jürgen Groß
2025-04-17 11:19               ` Alexey
2025-04-17 13:22                 ` Jürgen Groß

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).