mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] um: vector: fix use-after-free in vector_mmsg_rx()
@ 2026-06-22 12:47 Michael Bommarito
  2026-07-22 21:13 ` Richard Weinberger
  2026-07-23 19:39 ` Richard Weinberger
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Bommarito @ 2026-06-22 12:47 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg; +Cc: linux-um, linux-kernel

When vector_mmsg_rx() discards a packet whose overlay header fails
verify_header(), it frees the skb and continues the loop:

	if (header_check < 0) {
		dev_kfree_skb_irq(skb);
		vp->estats.rx_encaps_errors++;
		continue;
	}

The normal and short-packet paths fall through to the bottom of the
loop body, which clears the consumed slot and advances the cursors:

	(*skbuff_vector) = NULL;
	mmsg_vector++;
	skbuff_vector++;

The verify_header() < 0 path skips that via continue, so the freed skb
is left in skbuff_vector[] and the cursors do not advance. The next
iteration reads the same slot, gets the freed skb, and frees it again,
producing a refcount underflow / use-after-free in the RX path.

Discard the slot the same way the other paths do before continuing.

Only transports whose verify_header() can return negative are affected:
GRE and L2TPv3 do so on a cookie/session-id mismatch (raw/tap do not),
so any peer on such a transport can trigger it without authentication.

Fixes: 49da7e64f33e ("High Performance UML Vector Network Driver")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
---
Reproduced on a KASAN + refcount-full UML build: bring up a vec0
l2tpv3 device and send frames from the host with the right cookie but a
wrong session id. Stock kernel logs repeated "uml_l2tpv3: session
mismatch" then a refcount_t underflow / use-after-free in
dev_kfree_skb_irq_reason() <- vector_poll() <- vector_mmsg_rx(); with
this patch the mismatch is logged and the splat is gone (0 underflow, 0
use-after-free). Full dmesg and reproducer available on request.

 arch/um/drivers/vector_kern.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
index 2cc90055499a5..8a70b3a625537 100644
--- a/arch/um/drivers/vector_kern.c
+++ b/arch/um/drivers/vector_kern.c
@@ -995,6 +995,9 @@ static int vector_mmsg_rx(struct vector_private *vp, int budget)
 				 */
 					dev_kfree_skb_irq(skb);
 					vp->estats.rx_encaps_errors++;
+					(*skbuff_vector) = NULL;
+					mmsg_vector++;
+					skbuff_vector++;
 					continue;
 				}
 				if (header_check > 0) {

base-commit: ef0c9f75a19532d7675384708fc8621e10850104
-- 
2.53.0


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

* Re: [PATCH] um: vector: fix use-after-free in vector_mmsg_rx()
  2026-06-22 12:47 [PATCH] um: vector: fix use-after-free in vector_mmsg_rx() Michael Bommarito
@ 2026-07-22 21:13 ` Richard Weinberger
  2026-07-22 21:30   ` Anton Ivanov
  2026-07-23 19:39 ` Richard Weinberger
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Weinberger @ 2026-07-22 21:13 UTC (permalink / raw)
  To: Michael Bommarito
  Cc: Richard Weinberger, Anton Ivanov, Johannes Berg, linux-um, linux-kernel

On Mon, Jun 22, 2026 at 2:47 PM Michael Bommarito
<michael.bommarito@gmail.com> wrote:
>
> When vector_mmsg_rx() discards a packet whose overlay header fails
> verify_header(), it frees the skb and continues the loop:
>
>         if (header_check < 0) {
>                 dev_kfree_skb_irq(skb);
>                 vp->estats.rx_encaps_errors++;
>                 continue;
>         }
>
> The normal and short-packet paths fall through to the bottom of the
> loop body, which clears the consumed slot and advances the cursors:
>
>         (*skbuff_vector) = NULL;
>         mmsg_vector++;
>         skbuff_vector++;
>
> The verify_header() < 0 path skips that via continue, so the freed skb
> is left in skbuff_vector[] and the cursors do not advance. The next
> iteration reads the same slot, gets the freed skb, and frees it again,
> producing a refcount underflow / use-after-free in the RX path.
>
> Discard the slot the same way the other paths do before continuing.
>
> Only transports whose verify_header() can return negative are affected:
> GRE and L2TPv3 do so on a cookie/session-id mismatch (raw/tap do not),
> so any peer on such a transport can trigger it without authentication.
>
> Fixes: 49da7e64f33e ("High Performance UML Vector Network Driver")
> Cc: stable@vger.kernel.org
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
> ---
> Reproduced on a KASAN + refcount-full UML build: bring up a vec0
> l2tpv3 device and send frames from the host with the right cookie but a
> wrong session id. Stock kernel logs repeated "uml_l2tpv3: session
> mismatch" then a refcount_t underflow / use-after-free in
> dev_kfree_skb_irq_reason() <- vector_poll() <- vector_mmsg_rx(); with
> this patch the mismatch is logged and the splat is gone (0 underflow, 0
> use-after-free). Full dmesg and reproducer available on request.
>
>  arch/um/drivers/vector_kern.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
> index 2cc90055499a5..8a70b3a625537 100644
> --- a/arch/um/drivers/vector_kern.c
> +++ b/arch/um/drivers/vector_kern.c
> @@ -995,6 +995,9 @@ static int vector_mmsg_rx(struct vector_private *vp, int budget)
>                                  */
>                                         dev_kfree_skb_irq(skb);
>                                         vp->estats.rx_encaps_errors++;
> +                                       (*skbuff_vector) = NULL;
> +                                       mmsg_vector++;
> +                                       skbuff_vector++;

Anton, please have a look.

-- 
Thanks,
//richard

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

* Re: [PATCH] um: vector: fix use-after-free in vector_mmsg_rx()
  2026-07-22 21:13 ` Richard Weinberger
@ 2026-07-22 21:30   ` Anton Ivanov
  2026-07-22 21:33     ` Michael Bommarito
  0 siblings, 1 reply; 5+ messages in thread
From: Anton Ivanov @ 2026-07-22 21:30 UTC (permalink / raw)
  To: Richard Weinberger, Michael Bommarito
  Cc: Richard Weinberger, Johannes Berg, linux-um, linux-kernel



On 22/07/2026 22:13, Richard Weinberger wrote:
> On Mon, Jun 22, 2026 at 2:47 PM Michael Bommarito
> <michael.bommarito@gmail.com> wrote:
>>
>> When vector_mmsg_rx() discards a packet whose overlay header fails
>> verify_header(), it frees the skb and continues the loop:
>>
>>          if (header_check < 0) {
>>                  dev_kfree_skb_irq(skb);
>>                  vp->estats.rx_encaps_errors++;
>>                  continue;
>>          }
>>
>> The normal and short-packet paths fall through to the bottom of the
>> loop body, which clears the consumed slot and advances the cursors:
>>
>>          (*skbuff_vector) = NULL;
>>          mmsg_vector++;
>>          skbuff_vector++;
>>
>> The verify_header() < 0 path skips that via continue, so the freed skb
>> is left in skbuff_vector[] and the cursors do not advance. The next
>> iteration reads the same slot, gets the freed skb, and frees it again,
>> producing a refcount underflow / use-after-free in the RX path.
>>
>> Discard the slot the same way the other paths do before continuing.
>>
>> Only transports whose verify_header() can return negative are affected:
>> GRE and L2TPv3 do so on a cookie/session-id mismatch (raw/tap do not),
>> so any peer on such a transport can trigger it without authentication.
>>
>> Fixes: 49da7e64f33e ("High Performance UML Vector Network Driver")
>> Cc: stable@vger.kernel.org
>> Assisted-by: Claude:claude-opus-4-8
>> Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
>> ---
>> Reproduced on a KASAN + refcount-full UML build: bring up a vec0
>> l2tpv3 device and send frames from the host with the right cookie but a
>> wrong session id. Stock kernel logs repeated "uml_l2tpv3: session
>> mismatch" then a refcount_t underflow / use-after-free in
>> dev_kfree_skb_irq_reason() <- vector_poll() <- vector_mmsg_rx(); with
>> this patch the mismatch is logged and the splat is gone (0 underflow, 0
>> use-after-free). Full dmesg and reproducer available on request.
>>
>>   arch/um/drivers/vector_kern.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c
>> index 2cc90055499a5..8a70b3a625537 100644
>> --- a/arch/um/drivers/vector_kern.c
>> +++ b/arch/um/drivers/vector_kern.c
>> @@ -995,6 +995,9 @@ static int vector_mmsg_rx(struct vector_private *vp, int budget)
>>                                   */
>>                                          dev_kfree_skb_irq(skb);
>>                                          vp->estats.rx_encaps_errors++;
>> +                                       (*skbuff_vector) = NULL;
>> +                                       mmsg_vector++;
>> +                                       skbuff_vector++;
> 
> Anton, please have a look.
> 

I already did with Johannes a while back. Valid bug and can be triggered 
remotely.

I think I acked the patch at the time.

-- 
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/


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

* Re: [PATCH] um: vector: fix use-after-free in vector_mmsg_rx()
  2026-07-22 21:30   ` Anton Ivanov
@ 2026-07-22 21:33     ` Michael Bommarito
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Bommarito @ 2026-07-22 21:33 UTC (permalink / raw)
  To: Anton Ivanov
  Cc: Richard Weinberger, Richard Weinberger, Johannes Berg, linux-um,
	linux-kernel

On Wed, Jul 22, 2026 at 5:31 PM Anton Ivanov
<anton.ivanov@cambridgegreys.com> wrote:
> I already did with Johannes a while back. Valid bug and can be triggered
> remotely.
>
> I think I acked the patch at the time.

Yup, back in April.  I think it got lost in the security triage at the
time and I forgot to follow up until June.

Sorry for not providing that context.

Thanks,
Mike

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

* Re: [PATCH] um: vector: fix use-after-free in vector_mmsg_rx()
  2026-06-22 12:47 [PATCH] um: vector: fix use-after-free in vector_mmsg_rx() Michael Bommarito
  2026-07-22 21:13 ` Richard Weinberger
@ 2026-07-23 19:39 ` Richard Weinberger
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Weinberger @ 2026-07-23 19:39 UTC (permalink / raw)
  To: Michael Bommarito
  Cc: Richard Weinberger, Anton Ivanov, Johannes Berg, linux-um, linux-kernel

On Mon, Jun 22, 2026 at 2:47 PM Michael Bommarito
<michael.bommarito@gmail.com> wrote:
>
> When vector_mmsg_rx() discards a packet whose overlay header fails
> verify_header(), it frees the skb and continues the loop:
>
>         if (header_check < 0) {
>                 dev_kfree_skb_irq(skb);
>                 vp->estats.rx_encaps_errors++;
>                 continue;
>         }
>
> The normal and short-packet paths fall through to the bottom of the
> loop body, which clears the consumed slot and advances the cursors:
>
>         (*skbuff_vector) = NULL;
>         mmsg_vector++;
>         skbuff_vector++;
>
> The verify_header() < 0 path skips that via continue, so the freed skb
> is left in skbuff_vector[] and the cursors do not advance. The next
> iteration reads the same slot, gets the freed skb, and frees it again,
> producing a refcount underflow / use-after-free in the RX path.
>
> Discard the slot the same way the other paths do before continuing.
>
> Only transports whose verify_header() can return negative are affected:
> GRE and L2TPv3 do so on a cookie/session-id mismatch (raw/tap do not),
> so any peer on such a transport can trigger it without authentication.
>
> Fixes: 49da7e64f33e ("High Performance UML Vector Network Driver")
> Cc: stable@vger.kernel.org
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
> ---
> Reproduced on a KASAN + refcount-full UML build: bring up a vec0
> l2tpv3 device and send frames from the host with the right cookie but a
> wrong session id. Stock kernel logs repeated "uml_l2tpv3: session
> mismatch" then a refcount_t underflow / use-after-free in
> dev_kfree_skb_irq_reason() <- vector_poll() <- vector_mmsg_rx(); with
> this patch the mismatch is logged and the splat is gone (0 underflow, 0
> use-after-free). Full dmesg and reproducer available on request.
>
>  arch/um/drivers/vector_kern.c | 3 +++
>  1 file changed, 3 insertions(+)

Applied to fixes branch.

-- 
Thanks,
//richard

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

end of thread, other threads:[~2026-07-23 19:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-22 12:47 [PATCH] um: vector: fix use-after-free in vector_mmsg_rx() Michael Bommarito
2026-07-22 21:13 ` Richard Weinberger
2026-07-22 21:30   ` Anton Ivanov
2026-07-22 21:33     ` Michael Bommarito
2026-07-23 19:39 ` Richard Weinberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®