Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 0 · Low: 3 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] pppoe: premature unbind in ppp_unregister_channel() with lockless_xmit - [Low] The commit message says pppoe_xmit() only reads fields that 'are set before the channel is registered and stay valid until… - [Low] Documentation/networking/ppp_generic.rst still promises every channel (lines 236-238): 'The generic layer will not call the… - [Low] The patch marks the stores that clear po->pppoe_dev with WRITE_ONCE(), in pppoe_release() (pppoe.c:526) and… -- pppoe: transmit without the PPP channel lock This patch sets lockless_xmit on PPPoE channels. With it, ppp_generic calls pppoe_xmit() from several CPUs at once without the channel lock. It also uses WRITE_ONCE() for the stores that clear po->pppoe_dev in pppoe_release() and pppoe_unbind_sock_work(), and READ_ONCE() for the load in pppoe_xmit().
> pppoe_xmit() reads the session's device, session ID and peer address, > which are set before the channel is registered and stay valid until > pppox_unbind_sock() has unregistered it, and hands the frame to > dev_queue_xmit().
[Severity: Low] Is this accurate for the session ID? In pppoe_connect(), po->num is written only after the channel is registered and after PPPOX_CONNECTED is set: drivers/net/ppp/pppoe.c:pppoe_connect() { ... error = ppp_register_net_channel(dev_net(dev), &po->chan); if (error) { delete_item(pn, po); goto err_put; } sk->sk_state = PPPOX_CONNECTED; } po->num = sp->sa_addr.pppoe.sid; ... } pppoe_xmit() checks PPPOX_CONNECTED and then copies po->num into ph->sid without taking any lock. pppoe_xmit() also reads sk->sk_state without a lock. That field is still written while the channel is registered: pppox_ioctl() handles PPPIOCGCHAN with sk->sk_state |= PPPOX_BOUND under lock_sock(). What seems to protect these fields is that pppd gets the channel index through PPPIOCGCHAN. That ioctl takes lock_sock(), so it runs after pppoe_connect() has called release_sock(). Only a CAP_NET_ADMIN process that guesses the channel index and attaches it during connect could see po->num == 0. The old downl lock never ordered against pppoe_connect() either, so this patch adds no new race. Could the commit message state that invariant instead? Alternatively, pppoe_connect() could assign po->num before ppp_register_net_channel() so that the stated ordering holds.
> diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c > index de6edc31790fb..f14ed72eb9d56 100644 > --- a/drivers/net/ppp/pppoe.c > +++ b/drivers/net/ppp/pppoe.c
[ ... ]
> @@ -639,6 +639,7 @@ static int pppoe_connect(struct socket *sock, struct sockaddr_unsized *uservaddr > po->chan.ops = &pppoe_chan_ops; > po->chan.direct_xmit = true; > po->chan.xmit_offload = true; > + po->chan.lockless_xmit = true;
[Severity: High] Does ppp_unregister_channel() still wait for lockless senders in every case once this is set? ppp_xmit_lockless() finds pch on ppp->channels under rcu_read_lock() only. It then loads pch->chan and calls chan->ops->start_xmit() without ppp->wlock or pch->downl. That is only safe if ppp_disconnect_channel() has done list_del_rcu(&pch->clist) and synchronize_net() before ppp_unregister_channel() sets pch->chan to NULL. ppp_disconnect_channel() can be entered twice for the same channel, though: - ppp_ioctl() handles PPPIOCDISCONN under ppp_mutex, without lock_sock(). - pppox_unbind_sock() calls ppp_unregister_channel() under lock_sock(), without ppp_mutex. The first caller clears pch->ppp under pch->upl and drops upl. Only then does it take ppp_lock() for list_del_rcu() and sleep in synchronize_net(). A second caller that arrives in that window sees pch->ppp == NULL and returns -EINVAL at once. Consider pppd issuing PPPIOCDISCONN while a PADT runs pppoe_unbind_sock_work(), or while pppoe_release() or pppoe_flush_dev() unbinds the socket. ppp_unregister_channel() can then set pch->chan to NULL under downl and return in two states: with pch still on ppp->channels, or with the grace period still pending. A sender that already found pch then dereferences a NULL chan at the chan->lockless_xmit check in ppp_xmit_lockless(). A sender that is already inside pppoe_xmit() keeps using po->num, po->pppoe_pa.remote and the socket itself. It does so after pppox_unbind_sock() has returned, and possibly after pppoe_release() has dropped its reference with sock_put(). In the ppp_push() path, pch->downl covers this. ppp_push() holds downl across start_xmit(), and ppp_unregister_channel() takes downl before it clears pch->chan. The lockless path has nothing equivalent, and this patch is what routes PPPoE frames through it. How would you like to close this? An unconditional synchronize_net() in ppp_unregister_channel() alone does not look sufficient. The other caller may not have run list_del_rcu() yet when that grace period starts. Should the second ppp_disconnect_channel() caller wait for the first one to finish the list removal and the grace period? Or should the channel be unlinked from ppp->channels before pch->ppp is cleared, so that seeing NULL there implies it is already off the list? [Severity: Low] Should Documentation/networking/ppp_generic.rst be updated as well? pppoe is the first in-tree channel to set lockless_xmit, but the document still promises every channel: The generic layer will not call the start_xmit() function for a channel while any thread is already executing in that function for that channel. The document also says start_xmit() can return 0 for flow control, with the channel calling ppp_output_wakeup() later. For a lockless_xmit channel, ppp_xmit_lockless() calls chan->ops->start_xmit() under rcu_read_lock() only, from several CPUs at once. It also treats a 0 return as a bug, with WARN_ON_ONCE() and kfree_skb(). The only description of the new contract is the comment on struct ppp_channel::lockless_xmit in include/linux/ppp_channel.h ("concurrent start_xmit, never 0"). No patch in the series touches Documentation/.
> > error = ppp_register_net_channel(dev_net(dev), &po->chan); > if (error) {
[ ... ]
> @@ -814,7 +815,7 @@ static int pppoe_xmit(struct ppp_channel *chan, struct sk_buff *skb) > { > struct sock *sk = chan->private; > struct pppox_sock *po = pppox_sk(sk); > - struct net_device *dev = po->pppoe_dev; > + struct net_device *dev = READ_ONCE(po->pppoe_dev);
[Severity: Low] Should pppoe_fill_forward_path() use READ_ONCE() too? It still loads po->pppoe_dev without annotation. pppoe_release() and pppoe_unbind_sock_work() now clear that field with WRITE_ONCE(): drivers/net/ppp/pppoe.c:pppoe_fill_forward_path() { struct sock *sk = chan->private; struct pppox_sock *po = pppox_sk(sk); struct net_device *dev = po->pppoe_dev; if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED) || !dev) return -1; ... ctx->dev = dev; ... } pppoe_fill_forward_path() is called from ppp_fill_forward_path(). That function finds the channel with list_first_or_null_rcu() on ppp->channels and takes neither downl nor lock_sock(). This means it can run in pppoe_release() after WRITE_ONCE(po->pppoe_dev, NULL) and before pppox_unbind_sock(). KCSAN would still report that pair. In theory, the compiler could also reload the field between the NULL check and the use.
> struct pppoe_hdr *ph; > int data_len = skb->len; >
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40bairaktaris.de