mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eelco Chaudron <echaudro@redhat.com>
To: Norbert Szetei <norbert@doyensec.com>
Cc: netdev@vger.kernel.org, Aaron Conole <aconole@redhat.com>,
	Ilya Maximets <i.maximets@ovn.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	dev@openvswitch.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net: openvswitch: fix use-after-free of the flow table mask array
Date: Tue, 08 Sep 2026 09:19:36 +0200	[thread overview]
Message-ID: <FD8A4D46-E107-455C-8F3F-0F52D3CBAA74@redhat.com> (raw)
In-Reply-To: <DE115F9C-2545-423E-A702-986FC952FD62@doyensec.com>



On 6 Sep 2026, at 10:21, Norbert Szetei wrote:

> tbl_mask_array_realloc() retires the old mask_array before it stops being
> reachable:
>
> 	old = ovsl_dereference(tbl->mask_array);
> 	if (old) {
> 		...
> 		call_rcu(&old->rcu, mask_array_rcu_cb);
> 	}
>
> 	rcu_assign_pointer(tbl->mask_array, new);
>
> call_rcu() only waits for read-side critical sections already in flight.
> tbl->mask_array still points at old between the call_rcu() and the
> rcu_assign_pointer(), so a reader entering ovs_flow_tbl_lookup_stats() in
> that window picks up old in a fresh critical section that the pending
> grace period does not cover.
>
> tbl_mask_array_realloc() runs in process context under ovs_mutex, so the
> window is preemptible and can outlast the grace period. Then
> mask_array_rcu_cb() frees old before the swap runs:
>
>   BUG: KASAN: slab-use-after-free in flow_lookup.constprop.0+0x2bf/0x2f0
>   Read of size 8 at addr ffff888020b3e018 by task poc/741
>    flow_lookup.constprop.0+0x2bf/0x2f0
>    ovs_flow_tbl_lookup_stats+0x4a3/0x5c0
>    ovs_dp_process_packet+0x19c/0x710
>    ovs_vport_receive+0x243/0x390
>    internal_dev_xmit+0x81/0x170
>   Freed by task 728:
>    kfree+0x16a/0x4e0
>    rcu_core+0x853/0x1030
>
> Publish the new array before retiring the old one. The kfree_rcu() that
> call_rcu() replaced ran after the swap.
>
> Fixes: eac87c413bf9 ("net: openvswitch: reorder masks array based on usage")
> Cc: stable@vger.kernel.org
> Assisted-by: Claude:claude-opus-5
> Signed-off-by: Norbert Szetei <norbert@doyensec.com>
> ---

Changes look good to me. Although not really necessary, I did run all the kernel userspace tests, and they pass.

Acked-by: Eelco Chaudron echaudro@redhat.com


  parent reply	other threads:[~2026-09-08  7:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-06  8:21 Norbert Szetei
2026-09-07 19:43 ` Ilya Maximets
2026-09-08  7:19 ` Eelco Chaudron [this message]
2026-09-09  0:30 ` patchwork-bot+netdevbpf

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=FD8A4D46-E107-455C-8F3F-0F52D3CBAA74@redhat.com \
    --to=echaudro@redhat.com \
    --cc=aconole@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dev@openvswitch.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=i.maximets@ovn.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=norbert@doyensec.com \
    --cc=pabeni@redhat.com \
    /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

all inboxes | Powered by JetHome®