Article View: linux.kernel.netdev
Article #24668Re: [PATCH net-next 2/3] pppoe: transmit without the PPP channel lock
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 15:46
Date: Mon, 30 Nov 2026 15:46
207 lines
16010 bytes
16010 bytes
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
Technical Details
Message-ID:
<179605359860.3146.12572744025587000630@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374279-linux-kernel-netdev=dewy.ruReferences:
<20261129144319.1489366-3-julius@bairaktaris.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374279-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 2/3] pppoe: transmit without the PPP channel lock Date: Mon, 30 Nov 2026 15:46:38 +0000 Organization: Usenet Network Message-ID: <179605359860.3146.12572744025587000630@kernel.org> References: <20261129144319.1489366-3-julius@bairaktaris.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1459712"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:b7RTzqotwN6uOQV8AWxbFiZIrXA= sha256:hIz4ZvVShX5CmfIkN4s8Xx8Nh3KzAAurqdy6DCJH8Nc= sha1:hR8USv3z/ueD65dsfPsErRCbaSs= sha256:Aeyj/NUsUsI0Uw4gzm1AO9c2AaA26g7hD3PBwNCTscY= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 630D8125FF4; Mon, 30 Nov 2026 18:47:26 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mIvxjn8H9Qag; Mon, 30 Nov 2026 18:47:22 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374279-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 74426125FEE; Mon, 30 Nov 2026 18:47:14 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 2301A329FB; Mon, 30 Nov 2026 15:46:50 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796053605; b=fWOoordxD6OQhYeewkOpf/kEkFK149MpUUJFdRMyg+6o2tl0MVUdnA+LXXYFVTScsVT2 sgOrONtdA9O2ToufHJTeii5ffl7dGSA+PpEP4csezssCT4um2MYjtPSXnzxUxL1Ij4BRj X+d40ybB+Cru5R5JmAQEWTwmKErrhmFqkbaMubiei5nrUbv/q2IdDttXNhf0VXG0/ojpS BUwz6itql7UjPtt3B3A/qhKyE5St5Z2tz4uAwytRBrC4HuKfV2G6ZFmZQ3DMrsvAUquSA EgVI3MHnu1ej+xl7Ii0QRn/Ic02+3/DuucOM1vN0mwJCj0SmwUBnpeUYNKGeklw/qLQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796053605; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=e6D1QR3Ai1k830hR2HflRPJ0omuAvHpmCeZw0hmRac0=; b=mlSAHxweKT4U7o+x0Czn/GmGU3KdUe6kcvmLPGGi9j66Dd6AHl8x2Z9IBoBCLvqU4TL0 r5YIhihV31NwM6ha9bHVGUmGAAunXbXz5GMr0EWdzzjC7lmmyGiIIC4vCz4OluGRS1VF6 lIdRxWUKT4K7e47g5Q/sGe4i+CgEnnMuHVP8zleKZeUZLEEf8vi5lhCokQS+8PT1lCfcx wwiz+dPoX4bE1eFCHdMZDA8a4vPsc40+2ftCip3h3hsqNMqU3m0061idRiEMyWXjBQ/e0 VtfkQqyJCLxYBNSjuO+Qey7T6nZmbk8f0uZZ1edOcaphEaSTlU1Kx2hRgsDYWIoumog== X-ARC-Authentication-Results: i=2; 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=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D57ED606A682; Mon, 30 Nov 2026 15:46:45 +0000 (UTC) X-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 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-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== X-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== X-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 X-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) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04FCC1F0089F; Mon, 30 Nov 2026 15:46:38 +0000 (UTC) X-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== X-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 X-In-Reply-To: <20261129144319.1489366-3-julius@bairaktaris.de> X-sashiko-severity: High X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list