public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Zahka <daniel.zahka@gmail.com>
To: Wei Wang <weibunny.kernel@gmail.com>
Cc: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
	Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	David Wei <dw@davidwei.uk>, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Simon Horman <horms@kernel.org>, Wei Wang <weibunny@fb.com>
Subject: Re: [PATCH v9 net-next 3/5] psp: add a new netdev event for dev unregister
Date: Wed, 1 Apr 2026 09:02:35 -0400	[thread overview]
Message-ID: <1ec0c6e5-4c5a-436f-8d43-6f6e31e66b02@gmail.com> (raw)
In-Reply-To: <CAGqc4nX096xJKyxdXrpXkHert6uCqHLKo3Z2idw4UXSdKw0O0g@mail.gmail.com>


On 3/31/26 5:51 PM, Wei Wang wrote:
> On Tue, Mar 31, 2026 at 6:30 AM Daniel Zahka <daniel.zahka@gmail.com> wrote:
>>
>> On 3/30/26 6:31 PM, Wei Wang wrote:
>>> +static bool psp_notifier_registered;
>>> +
>>> +/**
>>> + * psp_attach_netdev_notifier() - register netdev notifier on first use
>>> + *
>>> + * Register the netdevice notifier when the first device association
>>> + * is created. In many installations no associations will be created and
>>> + * the notifier won't be needed.
>>> + *
>>> + * Must be called without psd->lock held, due to lock ordering:
>>> + * rtnl_lock -> psd->lock (the notifier callback runs under rtnl_lock
>>> + * and takes psd->lock).
>>> + */
>>> +void psp_attach_netdev_notifier(void)
>>> +{
>>> +     if (READ_ONCE(psp_notifier_registered))
>>> +             return;
>>> +
>>> +     mutex_lock(&psp_devs_lock);
>>> +     if (!psp_notifier_registered) {
>>> +             if (!register_netdevice_notifier(&psp_netdev_notifier))
>>> +                     WRITE_ONCE(psp_notifier_registered, true);
>>> +     }
>>> +     mutex_unlock(&psp_devs_lock);
>>> +}
>> ...
>>> +int psp_device_get_locked_dev_assoc(const struct genl_split_ops *ops,
>>> +                                 struct sk_buff *skb, struct genl_info *info)
>>> +{
>>> +     psp_attach_netdev_notifier();
>>> +
>>> +     return __psp_device_get_locked(ops, skb, info, false);
>>> +}
>>
>>   From an AI review, but seems plausible to me:
>>
>> psp_device_get_locked_dev_assoc() will proceed even in the path where
>> register_netdevice_notifier() and psp_notifier_registered stays false.
>>
> This behavior is intended. In case register_netdevice_notifier() fails
> for some reason, this current dev_assoc will proceed but the next
> dev_assoc operation will try to register_netdevice_notifier() again.


That doesn't sound correct to me. If the notifier is not registered, but 
the dev-assoc command succeeds, then an entry can leak in the 
psd->assoc_dev_list during a NETDEV_UNREGISTER.


  reply	other threads:[~2026-04-01 13:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-30 22:31 [PATCH v9 net-next 0/5] psp: Add support for dev-assoc/disassoc Wei Wang
2026-03-30 22:31 ` [PATCH v9 net-next 1/5] psp: add admin/non-admin version of psp_device_get_locked Wei Wang
2026-03-30 22:31 ` [PATCH v9 net-next 2/5] psp: add new netlink cmd for dev-assoc and dev-disassoc Wei Wang
2026-03-31 13:03   ` Daniel Zahka
2026-03-31 21:48     ` Wei Wang
2026-03-31 23:43   ` kernel test robot
2026-03-30 22:31 ` [PATCH v9 net-next 3/5] psp: add a new netdev event for dev unregister Wei Wang
2026-03-31 13:30   ` Daniel Zahka
2026-03-31 21:51     ` Wei Wang
2026-04-01 13:02       ` Daniel Zahka [this message]
2026-04-01 21:39         ` Wei Wang
2026-03-30 22:31 ` [PATCH v9 net-next 4/5] selftests/net: Add bpf skb forwarding program Wei Wang
2026-03-30 22:31 ` [PATCH v9 net-next 5/5] selftest/net: psp: Add test for dev-assoc/disassoc Wei Wang
2026-03-31 14:04   ` Daniel Zahka
2026-03-31 22:09     ` Wei Wang

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=1ec0c6e5-4c5a-436f-8d43-6f6e31e66b02@gmail.com \
    --to=daniel.zahka@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dw@davidwei.uk \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=weibunny.kernel@gmail.com \
    --cc=weibunny@fb.com \
    --cc=willemdebruijn.kernel@gmail.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