* [PATCH net] virtio_net: fix header access in big_packets mode
@ 2025-10-16 22:33 Wen Xin
2025-10-17 0:57 ` Xuan Zhuo
0 siblings, 1 reply; 4+ messages in thread
From: Wen Xin @ 2025-10-16 22:33 UTC (permalink / raw)
To: netdev; +Cc: mst, jasowang, xuanzhuo, eperezma, virtualization, Wen Xin
In Linux virtio-net driver's (drivers/net/virtio_net.c) big packets mode (vi->big_packets && vi->mergeable_rx_bufs), the buf
pointer passed to receive_buf() is a struct page pointer, not a buffer
pointer. The current code incorrectly casts this page pointer directly as
a virtio_net_common_hdr, causing it to read flags from the page struct
memory instead of the actual packet data.
Signed-off-by: Wen Xin <w_xin@apple.com>
---
drivers/net/virtio_net.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 7646ddd9bef7..c10f5585bc88 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -2566,7 +2566,13 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
* virtnet_xdp_set()), so packets marked as
* VIRTIO_NET_HDR_F_NEEDS_CSUM get dropped during XDP processing.
*/
- flags = ((struct virtio_net_common_hdr *)buf)->hdr.flags;
+ if (vi->big_packets && !vi->mergeable_rx_bufs) {
+ struct virtio_net_common_hdr *hdr = page_address((struct page *)buf);
+
+ flags = hdr->hdr.flags;
+ } else {
+ flags = ((struct virtio_net_common_hdr *)buf)->hdr.flags;
+ }
if (vi->mergeable_rx_bufs)
skb = receive_mergeable(dev, vi, rq, buf, ctx, len, xdp_xmit,
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] virtio_net: fix header access in big_packets mode
2025-10-16 22:33 [PATCH net] virtio_net: fix header access in big_packets mode Wen Xin
@ 2025-10-17 0:57 ` Xuan Zhuo
2025-10-17 23:38 ` Jakub Kicinski
0 siblings, 1 reply; 4+ messages in thread
From: Xuan Zhuo @ 2025-10-17 0:57 UTC (permalink / raw)
To: Wen Xin; +Cc: mst, jasowang, eperezma, virtualization, Wen Xin, netdev
http://lore.kernel.org/all/20251013020629.73902-1-xuanzhuo@linux.alibaba.com
do the same thing.
On Thu, 16 Oct 2025 15:33:05 -0700, Wen Xin <w_xin@apple.com> wrote:
> In Linux virtio-net driver's (drivers/net/virtio_net.c) big packets mode (vi->big_packets && vi->mergeable_rx_bufs), the buf
> pointer passed to receive_buf() is a struct page pointer, not a buffer
> pointer. The current code incorrectly casts this page pointer directly as
> a virtio_net_common_hdr, causing it to read flags from the page struct
> memory instead of the actual packet data.
>
> Signed-off-by: Wen Xin <w_xin@apple.com>
> ---
> drivers/net/virtio_net.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 7646ddd9bef7..c10f5585bc88 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -2566,7 +2566,13 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
> * virtnet_xdp_set()), so packets marked as
> * VIRTIO_NET_HDR_F_NEEDS_CSUM get dropped during XDP processing.
> */
> - flags = ((struct virtio_net_common_hdr *)buf)->hdr.flags;
> + if (vi->big_packets && !vi->mergeable_rx_bufs) {
> + struct virtio_net_common_hdr *hdr = page_address((struct page *)buf);
> +
> + flags = hdr->hdr.flags;
> + } else {
> + flags = ((struct virtio_net_common_hdr *)buf)->hdr.flags;
> + }
>
> if (vi->mergeable_rx_bufs)
> skb = receive_mergeable(dev, vi, rq, buf, ctx, len, xdp_xmit,
> --
> 2.39.5 (Apple Git-154)
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] virtio_net: fix header access in big_packets mode
2025-10-17 0:57 ` Xuan Zhuo
@ 2025-10-17 23:38 ` Jakub Kicinski
2025-10-22 1:42 ` Xuan Zhuo
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2025-10-17 23:38 UTC (permalink / raw)
To: Xuan Zhuo; +Cc: Wen Xin, mst, jasowang, eperezma, virtualization, netdev
On Fri, 17 Oct 2025 08:57:36 +0800 Xuan Zhuo wrote:
> http://lore.kernel.org/all/20251013020629.73902-1-xuanzhuo@linux.alibaba.com
>
> do the same thing.
Could you repost that? looks like there were some questions,
but nobody sent review tags even tho they were answered..
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] virtio_net: fix header access in big_packets mode
2025-10-17 23:38 ` Jakub Kicinski
@ 2025-10-22 1:42 ` Xuan Zhuo
0 siblings, 0 replies; 4+ messages in thread
From: Xuan Zhuo @ 2025-10-22 1:42 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: Wen Xin, mst, jasowang, eperezma, virtualization, netdev
On Fri, 17 Oct 2025 16:38:56 -0700, Jakub Kicinski <kuba@kernel.org> wrote:
> On Fri, 17 Oct 2025 08:57:36 +0800 Xuan Zhuo wrote:
> > http://lore.kernel.org/all/20251013020629.73902-1-xuanzhuo@linux.alibaba.com
> >
> > do the same thing.
>
> Could you repost that? looks like there were some questions,
> but nobody sent review tags even tho they were answered..
YES. In my todo list.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-22 1:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-16 22:33 [PATCH net] virtio_net: fix header access in big_packets mode Wen Xin
2025-10-17 0:57 ` Xuan Zhuo
2025-10-17 23:38 ` Jakub Kicinski
2025-10-22 1:42 ` Xuan Zhuo
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).