Article View: linux.kernel.netdev
Article #24666Re: [PATCH net-next 1/3] ppp: transmit data frames without the unit and channel locks
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 15:46
Date: Mon, 30 Nov 2026 15:46
237 lines
17209 bytes
17209 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] ppp: race with ppp_unregister_channel() causes NULL deref and
UAF in ppp_xmit_lockless()
- [Low] Baseline decision: false positive, resolved later in the series.
- [Low] When `ppp_set_compress()` (drivers/net/ppp/ppp_generic.c)
installs a transmit compressor while `ostate` is NULL, it now always…
- [Low] The channel API documentation was not updated for the new
`lockless_xmit` contract, and this is still true at the end of the…
--
ppp: transmit data frames without the unit and channel locks
This adds ppp_xmit_lockless(). It sends data frames straight to the first
channel under RCU, without ppp->wlock and pch->downl, as long as no
multilink, compression, VJ, loopback, filter or backlog work applies.
Channels opt in with a new lockless_xmit flag, and ppp_set_compress() now
waits for a grace period after it installs the first transmit compressor.
> diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
> index bd5a7630f297d..89a756ae3f4a2 100644
> --- a/drivers/net/ppp/ppp_generic.c
> +++ b/drivers/net/ppp/ppp_generic.c
[ ... ]
> @@ -1660,8 +1660,73 @@ static void ppp_xmit_flush(struct ppp *ppp)
[ ... ]
> +static bool ppp_xmit_lockless(struct ppp *ppp, struct sk_buff *skb)
> +{
[ ... ]
> + rcu_read_lock();
> + pch = list_first_or_null_rcu(&ppp->channels, struct channel, clist);
> + if (!pch)
> + goto out;
> + chan = pch->chan;
> + if (!chan->lockless_xmit)
> + goto out;
> +
> + skb->dev = dev;
> + /* Do not dirty a cache line shared by all CPUs for every frame. */
> + if (READ_ONCE(ppp->last_xmit) != now)
> + WRITE_ONCE(ppp->last_xmit, now);
> + dev_sw_netstats_tx_add(dev, 1, skb->len - PPP_PROTO_LEN);
> +
> + if (unlikely(!chan->direct_xmit && skb_linearize(skb)))
> + kfree_skb(skb);
> + else if (WARN_ON_ONCE(!chan->ops->start_xmit(chan, skb)))
> + kfree_skb(skb);
[Severity: High]
Can ppp_xmit_lockless() see a channel that ppp_unregister_channel()
has already torn down?
The lockless path reads pch->chan without downl and without a NULL
check. It then dereferences chan->lockless_xmit and calls
chan->ops->start_xmit(). The comment above the function says this is
safe because the channel stays registered until
ppp_disconnect_channel() has unlinked pch->clist and waited for a
grace period. That only holds when the ppp_disconnect_channel() call
made by ppp_unregister_channel() is the one that does the unlinking.
PPPIOCDISCONN calls ppp_disconnect_channel() with ppp_mutex held, but
ppp_unregister_channel() calls it without ppp_mutex, so the two can
run at the same time:
CPU0 (PPPIOCDISCONN) CPU1 (channel teardown)
ppp_disconnect_channel()
pch->ppp = NULL under upl
ppp_unregister_channel()
ppp_disconnect_channel()
sees pch->ppp == NULL, returns
pch->chan = NULL under downl
returns, driver frees chan
ppp_lock(ppp)
list_del_rcu(&pch->clist)
synchronize_net()
Until CPU0 reaches list_del_rcu(), pch is still the first entry on
ppp->channels. A sender on another CPU can then load pch->chan as
NULL and oops on chan->lockless_xmit. A sender that loaded chan just
before CPU1 cleared it can still be inside chan->ops->start_xmit()
after the driver has freed the channel. Nothing waits for a grace
period between pch->chan = NULL and the driver freeing chan.
PPPIOCCONNECT has a similar window. If ppp_connect_channel() takes
downl after ppp_unregister_channel() has returned from
ppp_disconnect_channel() but before it clears pch->chan, it sees a
non-NULL chan and links pch onto ppp->channels. pch->chan then goes
to NULL while pch stays on the list.
The locked path survives both, because ppp_push() checks pch->chan for
NULL under downl and drops the frame. The new path doesn't take downl,
so the same races now end in a NULL deref or a use-after-free. They
are reachable from ordinary teardown, for example a PPPoE PADT or a
socket close racing with pppd's PPPIOCDISCONN. A process with
CAP_NET_ADMIN in a user namespace can also trigger them on purpose.
Would it be enough to read pch->chan with READ_ONCE() and bail out on
NULL here? ppp_unregister_channel() would then clear it with
WRITE_ONCE() and wait for a grace period before it returns to the
driver. Or would you rather serialise the two ppp_disconnect_channel()
callers so that the existing synchronize_net() always runs before
pch->chan is cleared? The second option would not cover the
PPPIOCCONNECT case on its own.
[Severity: Low]
Should Documentation/networking/ppp_generic.rst and the start_xmit comment
in include/linux/ppp_channel.h be updated for the new lockless_xmit
contract?
ppp_generic.rst still lists this as a guarantee of the generic layer:
* 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.
It also says start_xmit() may return 0 for flow control, and that the
generic layer will retry the frame after ppp_output_wakeup(). The
struct ppp_channel_ops comment for start_xmit still says "Returns 1 if it
was accepted, 0 if not".
For channels that set lockless_xmit, ppp_xmit_lockless() calls start_xmit()
from several CPUs at once without pch->downl. It can also run at the same
time as ppp_push() and __ppp_channel_push(), which do hold downl. A 0
return here gives a WARN and drops the skb instead of queuing it.
The downl comment in struct channel says it protects chan and the
file.xq dequeue. That is now incomplete, because pch->chan is read here
under RCU only.
The only place the new rules are written down is the field comment
"concurrent start_xmit, never 0". As far as I can tell, no Documentation/
files change anywhere in the series.
> + ret = true;
> +out:
> + rcu_read_unlock();
> + return ret;
> +}
[ ... ]
> @@ -3153,11 +3218,17 @@ ppp_set_compress(struct ppp *ppp, struct ppp_option_data *data)
> ocomp = ppp->xcomp;
> ostate = ppp->xc_state;
> ppp->xcomp = cp;
> - ppp->xc_state = state;
> + WRITE_ONCE(ppp->xc_state, state);
> ppp_xmit_unlock(ppp);
> if (ostate) {
> ocomp->comp_free(ostate);
> module_put(ocomp->owner);
> + } else {
> + /* Compression can start with the next CCP
> + * frame from pppd; let lockless senders that
> + * saw no compressor finish first.
> + */
> + synchronize_net();
> }
[Severity: Low]
Does this need to hold up every PPP ioctl on the system for a full grace
period?
ppp_ioctl() and ppp_compat_ioctl() call ppp_set_compress() with the global
ppp_mutex held:
ppp_ioctl()
mutex_lock(&ppp_mutex);
...
ppp_set_compress()
synchronize_net();
This happens on the first transmit PPPIOCSCOMPRESS of a session and again
after every ppp_ccp_closed(). While it runs, all other PPP ioctls on every
unit in every namespace wait behind it.
The wait only matters for units whose first channel sets lockless_xmit.
pptp, l2tp, async and sync units pay for it too, even though they can never
take the lockless path. Could the wait be skipped for those units?
PPPIOCDISCONN already calls synchronize_net() under ppp_mutex through
ppp_disconnect_channel(), and this one runs once per CCP negotiation, so
the cost is modest. The commit message mentions the wait. It doesn't say
that the wait runs under the global mutex or that every unit pays for it.
[ ... ]
> diff --git a/include/linux/ppp_channel.h b/include/linux/ppp_channel.h
> index 15bc3aa4f1715..a0de060623a11 100644
> --- a/include/linux/ppp_channel.h
> +++ b/include/linux/ppp_channel.h
> @@ -44,6 +44,7 @@ struct ppp_channel {
> int speed; /* transfer rate (bytes/second) */
> bool direct_xmit; /* no qdisc, xmit directly */
> bool xmit_offload; /* accepts GSO and CHECKSUM_PARTIAL skbs */
> + bool lockless_xmit; /* concurrent start_xmit, never 0 */
[Severity: Low]
Nothing in this patch sets lockless_xmit. With this patch applied on its
own, ppp_xmit_lockless() always takes the goto out after this check:
if (!chan->lockless_xmit)
goto out;
So the new path is never used.
The next patch in the series, "pppoe: transmit without the PPP channel
lock", adds po->chan.lockless_xmit = true in pppoe_connect(), so this is
resolved by the end of the series. pptp and l2tp intentionally don't opt
in.
Would it help to say in the commit message that the first user comes in
the next patch?
> };
>
> #ifdef __KERNEL__
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129144319.1489366-1-julius%40bairaktaris.de
Technical Details
Message-ID:
<179605359638.3146.9210576638379871377@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-374278-linux-kernel-netdev=dewy.ruReferences:
<20261129144319.1489366-2-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-374278-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 1/3] ppp: transmit data frames without the unit and channel locks Date: Mon, 30 Nov 2026 15:46:36 +0000 Organization: Usenet Network Message-ID: <179605359638.3146.9210576638379871377@kernel.org> References: <20261129144319.1489366-2-julius@bairaktaris.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1459556"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:E2CYkkE4cdS97CbbbNGlS6ZUH4I= sha256:DzIqqU8ktPhzaAbGVPHgQQSrODEtEbLewOuHaGpoS4U= sha1:fy2z6EfjUqOLpowcDkryJxKp3oQ= sha256:oWx2X/sL/CnLvE3jdQAt3V8wcUvQEtKKB9XzYu7YCsE= 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 66916125FED; Mon, 30 Nov 2026 18:47:10 +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 vrQ3dEmq8ZJq; Mon, 30 Nov 2026 18:47:06 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374278-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 1A1C9125FEE; Mon, 30 Nov 2026 18:46:58 +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 41C57320C2; Mon, 30 Nov 2026 15:46:45 +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=1796053603; b=ETxThXgpzfs1zXl47fKa04t/GFv5fXYN9Y/uvyw+XmRE9WilXbE5ewaISAjIUC5hGraf w7Vw02FFIATOR0KuR/B0NSAnkSoWBBxzsJf0/wqOktSLKqgJhuL1BCOvgB8wPhKiU0sZA zpUe7qZJlsq0+fJ8gaBFENB8q840hzRXU4t9iOeIWNrsj31O17QcWlvWDGLh7VZF/Wq7Z peiiqT1/Ag/VnE10sErfKhC3RSkXiieAHYPlpM09ZiUNt107IUE0SiP8WU4FjvI5XDDRr IiGJ09pdP01ifsHNIqryWR31z/PKukx4byjMOQMX/Q7WT2B3caBknPx5X0/90MVhnQg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796053603; 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=gDdKiggkySBAFnnsDf69yNOmQ+ztJYO0Va1e67d+OvQ=; b=duMDuapE6ddA8lZykeFBatTOk3I4D/mcrFV/Plv5iAe3poGW9OfaLUDCGzsIZTVp1DSL U8NpBlVorTn15IcEil3kMVVNUyba+RHwAC7PpR0auZfdTRYMzam8rOHefTf3Mhwoxw0U6 mdr5UIAJlY1yurQ4iGPFtyjJFt4NH07tTIBFCgXfpzytX2Ou3jk4ColVCWuIZ0c7nF/IH qwNUhE/tlyyzSr3Rc8OKJ6JbjTY8j8FTKCsO5a6NBrAvJKlX9Xh4oggWzGroMsHYmPGtG pt8AJqS2LW4AtIaHQigzPffc0GvIKg5kJtR3tR8XrEKso9t4qjcfPat/IEOm5q4Xuqw== 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="NhVs/bFi"; 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 CF546606A682; Mon, 30 Nov 2026 15:46:43 +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=NhVs/bFi 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=1796053598; b=v7axMdrc/ip8vwT84uItQFAK7XDHfw6hNcqAKvRz6XpHY0hRbUwebi7+QsMsitNfYUvC X9H5pIKv7+be3TVepFk0ESYbZZ//ynjUmws1lR6+08eRsvH/tqOIHwYjubLz8WfygHNji 1UAk8Z+XhWXs/8MyMhK9TuJ/Dyi5M4p02wgMakK4/h2t7fJNDeBrZklDEsQVvqA6dQQFx bba/iMucThyMQZGpwyPk2cv5mAPJSnayjuwgZ24Xu0gik3qf0eKdI/4VUtPsf1kYdOhOp AQjOnxGHkoDQi82Mtih7VyYllK3fmzAjsPhoT+0kwSb2l9DXxbJP4ZgMUV75/XFdoNA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796053598; 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=gDdKiggkySBAFnnsDf69yNOmQ+ztJYO0Va1e67d+OvQ=; b=OLGzhK5TFU/1ea86qqTWvdiztZaw5vOSq6JQJQzwCX0F7pBQDa8BpSdYFae5of1QeiUF Fwq3NUyMpKCXrpvHMS8DipM5RJv2GdVPDcJ/zjjpqAuOtT+00nd6t5/ZqVnIIR2ERS+Da +3Sw13nNqazKXbHrbxbVlr7tpTIipDKuyK0NUnWZ8Pew2E7j/LwtT7R6I4CYb8JwUlyg8 eJGlm8Hsmjq4w59036rRsErrvzPiyhHQGDjo2xv6CZpgCYESSQkpu4MgnVpsMjhhiX+hl 4Wt7JjB+Ko4vmZixrUGt3verrXBIXAAsYZs+PtWjIt83C54nsf45MNCHbkDCwRynRBQ== 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="NhVs/bFi"; 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 ECDAD606A31C; Mon, 30 Nov 2026 15:46:37 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D63AB1F000C1; Mon, 30 Nov 2026 15:46:36 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796053597; bh=gDdKiggkySBAFnnsDf69yNOmQ+ztJYO0Va1e67d+OvQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=NhVs/bFilKwxUP9eimAmQ4uIJV9M6CjQnvO/ekuxA2jQ3lzIPR5NdUWJBgd1UBLTW Lsm0Ri7mvru2Cbfi1Smqose4H4vIQqFsCchT9KW2oRSBrd0MPpW7HCWfZK1AHEPfwn pl2++44Xcd2CDGBsVsbub2BMVnU1vfQq7bqKuozXWEgk8LPxzuBeHrYdBRF7odgZDZ a/b88BmEfqhlM4OrVZNg6mMMq50wjgMrB7U01RkuMigJITotFAxMJ9bvxzf7jyEPhx 6q5VOlLPVvYRxga0dCM3hfjD58SAOVuNHhSj4SFNnq5c69dfw7PRaQk6uq6qT/ITJ3 hWn2mt9QkHoAA== 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-2-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