linux-um archives
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Michael Bommarito <michael.bommarito@gmail.com>,
	richard@nod.at,  anton.ivanov@cambridgegreys.com
Cc: linux-um@lists.infradead.org, linux-kernel@vger.kernel.org,
	 stable@vger.kernel.org
Subject: Re: [PATCH] um: vector: fix NULL pointer derefs in queue-less transports
Date: Wed, 22 Apr 2026 09:03:00 +0200	[thread overview]
Message-ID: <2fd57f98e3149ba56c83994a9181e92a0104cfe3.camel@sipsolutions.net> (raw)
In-Reply-To: <20260410203028.3717914-1-michael.bommarito@gmail.com>

Sorry, I didn't pay much attention to this before...

On Fri, 2026-04-10 at 16:30 -0400, Michael Bommarito wrote:
> TAP transport sets neither VECTOR_RX nor VECTOR_TX, so
> vector_net_open() never allocates rx_queue or tx_queue.  HYBRID sets
> VECTOR_RX but not VECTOR_TX, so tx_queue is NULL there too.
> 
> vector_reset_stats(), vector_poll(), vector_get_ethtool_stats(), and
> vector_get_ringparam() unconditionally deref these queue pointers,
> causing a NULL pointer crash on SMP or with any lock debugging option.
> 
> Guard all queue pointer accesses with NULL checks.

I see how that fixes the crash, but maybe you could write a few words on
why it's still correct?

> -	spin_lock(&vp->tx_queue->head_lock);
> -	spin_lock(&vp->rx_queue->head_lock);
> +	if (vp->tx_queue)
> +		spin_lock(&vp->tx_queue->head_lock);
> +	if (vp->rx_queue)
> +		spin_lock(&vp->rx_queue->head_lock);
>  	memcpy(tmp_stats, &vp->estats, sizeof(struct vector_estats));

I could imagine for example this memcpy() observing a torn write or
something like that and getting strange results out?

Or is that just not a thing because UML is (still) mostly non-SMP?


Also I think there are related issues that wouldn't show up for a broken
configuration, such as if create_queue() fails to allocate memory and we
get an inconsistency between tx_queue / rx_queue pointers and VECTOR_TX
/ VECTOR_RX flags? Though I'll admit that seems highly unlikely.

johannes


      parent reply	other threads:[~2026-04-22  7:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-10 20:30 [PATCH] um: vector: fix NULL pointer derefs in queue-less transports Michael Bommarito
2026-04-10 20:37 ` Anton Ivanov
2026-04-22  7:03 ` Johannes Berg [this message]

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=2fd57f98e3149ba56c83994a9181e92a0104cfe3.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-um@lists.infradead.org \
    --cc=michael.bommarito@gmail.com \
    --cc=richard@nod.at \
    --cc=stable@vger.kernel.org \
    /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