From: Jakub Kicinski <kuba@kernel.org>
To: kiran.kella@broadcom.com
Cc: Jakub Kicinski <kuba@kernel.org>,
davem@davemloft.net, ajit.khaparde@broadcom.com,
jayakrishnan.udayavarma@broadcom.com, netdev@vger.kernel.org,
akhilesh.samineni@broadcom.com, pabeni@redhat.com,
edumazet@google.com, andrew+netdev@lunn.ch,
linux-kernel@vger.kernel.org, horms@kernel.org
Subject: Re: [net-next,1/2] psp: Support for transmit on logical device when the underlying transport device supports PSP.
Date: Wed, 21 Jan 2026 20:19:09 -0800 [thread overview]
Message-ID: <20260122041908.2602647-2-kuba@kernel.org> (raw)
In-Reply-To: <20260121073517.3323332-2-kiran.kella@broadcom.com>
Haven't had the time to think about this TBH but FWIW:
This is an AI-generated review of your patch.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
psp: Support for transmit on logical device when the underlying transport
device supports PSP.
This patch propagates psp_dev pointers from lower devices to upper devices
(e.g., VLANs) via a netdevice notifier. Upper devices borrow the pointer
without taking a reference, and the borrowed pointer is cleared when the
link changes.
> diff --git a/net/psp/psp_main.c b/net/psp/psp_main.c
> index a8534124f626..0bff50c9314d 100644
> --- a/net/psp/psp_main.c
> +++ b/net/psp/psp_main.c
> @@ -313,10 +313,124 @@ int psp_dev_rcv(struct sk_buff *skb, u16 dev_id, u8 generation, bool strip_icv)
> }
> EXPORT_SYMBOL(psp_dev_rcv);
>
> +/**
> + * psp_netdevice_event() - Handle netdevice events for PSP device propagation
[ ... ]
> + * Propagates psp_dev pointer from lower devices to upper devices when
> + * upper devices are created (e.g., VLAN subinterfaces).
> + */
> +static int psp_netdevice_event(struct notifier_block *nb,
> + unsigned long event, void *ptr)
> +{
[ ... ]
> + /* Get psp_dev from the immediate lower device */
> + psd = rcu_dereference(dev->psp_dev);
> + rcu_read_unlock();
> +
> + /* Propagate psp_dev to upper device if found */
> + if (psd)
> + rcu_assign_pointer(upper_dev->psp_dev, psd);
The commit message states that borrowed pointers are cleared when the lower
device is "unlinked". However, what happens if psp_dev_unregister() is
called on the lower device without first unlinking the upper devices?
Looking at nsim_psp_rereg_write() in drivers/net/netdevsim/psp.c, it calls
nsim_psp_uninit()->psp_dev_unregister() without unregistering the netdevice.
If there are upper devices (e.g., VLANs) that have borrowed the psp_dev
pointer, would they be left with a dangling pointer after the RCU grace
period completes?
Similarly, nsim_destroy() calls nsim_psp_uninit() before calling
unregister_netdevice(), so the upper devices would still have borrowed
pointers when psp_dev_unregister() frees the psp_dev structure.
Could this lead to use-after-free if an upper device's psp_dev pointer is
accessed after the underlying psp_dev has been freed?
Would it make sense to either:
(a) Document that netdevice must be unregistered before psp_dev_unregister()
is called, or
(b) Walk the upper device stack in psp_dev_unregister() to clear borrowed
pointers, or
(c) Update existing callers (netdevsim) to ensure proper ordering?
> + } else {
[ ... ]
> + return NOTIFY_DONE;
> +}
--
pw-bot: cr
next prev parent reply other threads:[~2026-01-22 4:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-21 7:35 [net-next 0/2] psp: Support PSP Tx on logical devices like VLAN Kiran Kella
2026-01-21 7:35 ` [net-next 1/2] psp: Support for transmit on logical device when the underlying transport device supports PSP Kiran Kella
2026-01-22 4:19 ` Jakub Kicinski [this message]
2026-01-21 7:35 ` [net-next 2/2] selftests: drv-net: psp: add test for VLAN sub-interface Kiran Kella
2026-01-22 4:18 ` Jakub Kicinski
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=20260122041908.2602647-2-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=ajit.khaparde@broadcom.com \
--cc=akhilesh.samineni@broadcom.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jayakrishnan.udayavarma@broadcom.com \
--cc=kiran.kella@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--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