Linux virtualization list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: virtualization@lists.linux.dev, "Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH net v5 2/7] um: vector: trim skbs before verifying the header
Date: Fri, 23 Oct 2026 12:59:05 +0000	[thread overview]
Message-ID: <sashiko-outbox-182801@kernel.org> (raw)
In-Reply-To: <1b2a0697662501fd4fe896a7dc2bba2d97885101.1792668082.git.mst@redhat.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] um: vector: NULL pointer dereference in vector_mmsg_rx() via pskb_trim()
--

commit 869705112c565c7836b0dd95f8fcf315b6c19398
Author: Michael S. Tsirkin <mst@redhat.com>

um: vector: trim skbs before verifying the header

This commit moves the pskb_trim() call in vector_legacy_rx() and
vector_mmsg_rx() ahead of vp->verify_header() so that the skb is trimmed to
the received packet length before header verification.

> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
> index 8a70b3a625537..1afbef78df725 100644
> --- a/arch/um/drivers/vector_kern.c
> +++ b/arch/um/drivers/vector_kern.c

[ ... ]

> @@ -981,6 +981,8 @@ static int vector_mmsg_rx(struct vector_private *vp, int budget)
>  	for (i = 0; i < packet_count; i++) {
>  		skb = (*skbuff_vector);
>  		if (mmsg_vector->msg_len > vp->header_size) {
> +			pskb_trim(skb,
> +				mmsg_vector->msg_len - vp->rx_header_size);

[Severity: High]
Can skb be null here when pskb_trim() is called in vector_mmsg_rx() in
arch/um/drivers/vector_kern.c?

During vector_poll() -> vector_mmsg_rx() -> prep_queue_for_rx() -> prep_skb(),
if alloc_skb_with_frags() fails under memory pressure, prep_skb() leaves the
header iov[0] active with msg->msg_iovlen = 1 and stores a null skb pointer in
skbuff_vector:

arch/um/drivers/vector_kern.c:prep_skb() {
	...
	if (vp->header_size > 0)
		iov_index++;
	if (result == NULL) {
		iov[iov_index].iov_base = NULL;
		iov[iov_index].iov_len = 0;
		goto done;
	}
	...
done:
	msg->msg_iovlen = iov_index;
	return result;
}

On IPv4 gre or IPv4 raw l2tpv3 interfaces, build_gre_transport_data() and
build_l2tpv3_transport_data() add sizeof(struct iphdr) to vp->rx_header_size,
and vector_net_open() initializes the rx queue with iov[0].iov_len set to
vp->rx_header_size.

When uml_vector_recvmmsg() receives a packet larger than vp->header_size into
iov[0] for a slot where skb allocation failed, mmsg_vector->msg_len is greater
than vp->header_size while skb is null:

arch/um/drivers/vector_kern.c:vector_mmsg_rx() {
	...
		} else {
			/* Overlay header too short to do anything - discard.
			 * We can actually keep this skb and reuse it,
			 * but that will make the prep logic too complex.
			 */
			if (skb != NULL)
				dev_kfree_skb_irq(skb);
		}
}

Previously, invalid tunnel packets that failed vp->verify_header() were
discarded via dev_kfree_skb_irq(skb) without dereferencing skb. With
pskb_trim(skb, ...) moved before vp->verify_header(), wouldn't this
immediately dereference a null skb, and shouldn't vector_mmsg_rx() check for a
null skb first like vector_legacy_rx() and the else branch do?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.v5.git.mst@redhat.com?part=2

  reply	other threads:[~2026-10-23 12:59 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22 12:57 [PATCH net v5 0/7] more virtio-net csum hardening Michael S. Tsirkin
2026-10-22 12:57 ` [PATCH net v5 1/7] net: account for ingress-resolved virtio net hdr state Michael S. Tsirkin
2026-10-22 14:37   ` Willem de Bruijn
2026-10-23 12:59   ` sashiko-bot
2026-10-25  5:30   ` netdev-bot+sashiko
2026-10-22 12:58 ` [PATCH net v5 2/7] um: vector: trim skbs before verifying the header Michael S. Tsirkin
2026-10-23 12:59   ` sashiko-bot [this message]
2026-10-25  5:31   ` netdev-bot+sashiko
2026-10-22 12:58 ` [PATCH net v5 3/7] virtio_net: parse tunnel csum_start little-endian Michael S. Tsirkin
2026-10-23 12:59   ` sashiko-bot
2026-10-22 12:58 ` [PATCH net v5 4/7] net: resolve uncommon partial checksums at ingress Michael S. Tsirkin
2026-10-22 14:52   ` Willem de Bruijn
2026-10-22 15:49     ` Michael S. Tsirkin
2026-10-22 17:52     ` Chris Arges
2026-10-22 23:38       ` Michael S. Tsirkin
2026-10-23  1:38         ` Chris Arges
2026-10-23 12:59   ` sashiko-bot
2026-10-25  5:31   ` netdev-bot+sashiko
2026-10-22 12:58 ` [PATCH net v5 5/7] net: add a sysctl to opt out of virtio net hdr checksum validation Michael S. Tsirkin
2026-10-23 12:59   ` sashiko-bot
2026-10-25  5:31   ` netdev-bot+sashiko
2026-10-22 12:58 ` [PATCH net v5 6/7] net: add ip4_parse() Michael S. Tsirkin
2026-10-23 12:59   ` sashiko-bot
2026-10-25  5:31   ` netdev-bot+sashiko
2026-10-22 12:58 ` [PATCH net v5 7/7] virtio_net: cleanup protocol calculation Michael S. Tsirkin
2026-10-23 12:59   ` sashiko-bot
2026-10-25  5:31   ` netdev-bot+sashiko
2026-10-22 17:54 ` [PATCH net v5 0/7] more virtio-net csum hardening Chris Arges

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-182801@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=eperezma@redhat.com \
    --cc=mst@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=virtualization@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox