From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796053600; b=QN8rfNRjcn0Yw+otIx6du7vw7fvAYm0bK7elQWQbIanszsW+4uhsXlTw02pFyXqi1yuK w0JiraEkBExzo40Qoc6MrJ5jcEw+RJOGbhpsnCXxWRiHeEZN13se/OAxTYk6TQHvcqeqH bcauPLmGQDFpg/lMjZjFID0ZBwjgQN3n0GB+oDoTOtjq1raNHYC7iCvIUvRCAxZqoZTyJ wsKi/afioDct4zWLdatwZUBb+RVvQN+fclyHIouC2YGFyfkJCaZob74c0Q19FU1sUWMfo +8qvQ/WkZSRlTvaGPNN7tQ+6nmB2Ev8lrQOCNurlwH0FpT0g3U/Q6Xr9HzdrgrcqQdA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796053600; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=e6D1QR3Ai1k830hR2HflRPJ0omuAvHpmCeZw0hmRac0=; b=G1EaY80Hx/8zVauWf6fAcZQpWNWd9SyLSyvOWH5v6Qw6D5U84Qk//MkjeZ4yy4agl4Q6 xCYn3sqio92cj5liIBa/na0d9jOLL0bIorJ6x3u6byHh/qYGMdopVB8/SjdIFj8t/dYQq FsivYXwhrYjaKQtneU+QtbmpoBZJhOwqTldzUMLkNVciBtM8v3znMhZCedDyRC9utWvhk 018MFmHjPl3VHVaoa/ResNK92zLDzBTzkRy0Vio7akeQ9VX4sK1EdNjART5CPjVXz6Qjd FK49XQTNb6rvgMFr2rG9ZLTS/5FOQreReqwRKPWG0YicSr5aqjNuRaA6+nTweV2hF1w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aEtCc9dL; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01A40606A32D; Mon, 30 Nov 2026 15:46:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aEtCc9dL Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04FCC1F0089F; Mon, 30 Nov 2026 15:46:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796053599; bh=e6D1QR3Ai1k830hR2HflRPJ0omuAvHpmCeZw0hmRac0=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=aEtCc9dLQdYJ1yEkzD2HcTMVpA3+pN7CHQjsikJHrPBV9fO9EeGUM70QYJNWnBoaX oKrE6gqtpzdrHPznm4nfB15QfGkt6QcWhiXCDs6kNtfo8x+1Q5CIgLrzOqE8AXP2jF 7ioHI6ccl6ou+ZnfGdCbTgWaqW9BpCRsR0eQb1zuxZvsK/I2gpVZrt0FmMl9NG8aU0 9ZC9h9PWhLNS++qOkfcuju48VsmssNRIClSYB58rb4+WFLf4Z9kM0kI96EKwWNU5Jn uAHNCP//rxbP5xgIuNTkt3A64EjKN6GFKdIK3abBpS9FKWEYsa7BjySFcRr8/FTMdC 4THplRjLOFU2Q== Subject: Re: [PATCH net-next 2/3] pppoe: transmit without the PPP channel lock From: netdev-bot+sashiko@kernel.org To: julius@bairaktaris.de Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, shuah@kernel.org, qingfang.deng@linux.dev, gnault@redhat.com, bigeasy@linutronix.de, 26031212468@stu.xidian.edu.cn, linux-ppp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Date: Mon, 30 Nov 2026 15:46:38 +0000 Message-ID: <179605359860.3146.12572744025587000630@kernel.org> In-Reply-To: <20261129144319.1489366-3-julius@bairaktaris.de> References: <20261129144319.1489366-3-julius@bairaktaris.de> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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/20261129144319.1489366-1-julius%40bairaktaris.de