Article View: linux.kernel.netdev
Article #27464Re: [PATCH net v3] pppox: drop queued packets on channel handoff
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 17:54
Date: Sat, 05 Dec 2026 17:54
156 lines
13475 bytes
13475 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 0
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).
- [Medium] A deferred purge callback from an earlier binding can empty
the receive queue of a later, still-readable PPPoE connection.
- [Medium] `po->purge_pending` is the only signal that `po->purge_rcu`
may be passed to call_rcu() again, but it is published without…
--
pppox: drop queued packets on channel handoff
This patch removes the synchronize_net() and the drain to ppp_input()
from PPPIOCGCHAN. In their place it takes a socket reference and queues
an RCU callback that purges the receive queue. If a purge from an
earlier binding is still pending, PPPIOCGCHAN waits for a grace period
and purges synchronously, and pppox_exit() now calls rcu_barrier().
> diff --git a/drivers/net/ppp/pppox.c b/drivers/net/ppp/pppox.c
> index a6f72c813bef9..605054013a34d 100644
> --- a/drivers/net/ppp/pppox.c
> +++ b/drivers/net/ppp/pppox.c
> @@ -64,6 +64,17 @@ EXPORT_SYMBOL(register_pppox_proto);
> EXPORT_SYMBOL(unregister_pppox_proto);
> EXPORT_SYMBOL(pppox_unbind_sock);
>
> +static void pppox_purge_rcv_queue(struct rcu_head *head)
> +{
> + struct pppox_sock *po = container_of(head, struct pppox_sock,
> + purge_rcu);
> + struct sock *sk = &po->sk;
> +
> + skb_queue_purge(&sk->sk_receive_queue);
[Severity: Medium]
Can this callback drop frames that belong to a later connection on the
same socket?
pppox_purge_rcv_queue() empties sk_receive_queue every time it runs. It
does not check whether the socket is still in the binding that queued
the callback. Consider this sequence:
1. connect(sid=A), then PPPIOCGCHAN. pppox_ioctl() sets PPPOX_BOUND and
purge_pending = true, then calls call_rcu().
2. Before the callback runs, userspace calls connect(sid=0) and then
connect(sid=B). A PADT or flush that sets PPPOX_DEAD before the
reconnect works too. pppoe_connect() then does:
drivers/net/ppp/pppoe.c:pppoe_connect() {
...
if (stage_session(po->pppoe_pa.sid)) {
pppox_unbind_sock(sk);
...
synchronize_net();
...
sk->sk_state = PPPOX_NONE;
}
...
sk->sk_state = PPPOX_CONNECTED;
...
}
pppoe_connect() never touches purge_rcu or purge_pending. Its
synchronize_net() also does not wait for callbacks queued earlier to
run. With CONFIG_RCU_LAZY, call_rcu() can wait several seconds before
starting the grace period.
3. The new session is CONNECTED but not BOUND, so pppoe_rcv_core()
queues its frames with sock_queue_rcv_skb(). pppoe_recvmsg() only
returns -EIO for BOUND sockets, so userspace can read these frames.
4. The stale callback then runs and drops the new session's frames.
The purge_pending branch in pppox_ioctl() only helps when PPPIOCGCHAN
is issued a second time. It does nothing for the window between the
reconnect and the rebind.
The new comment says the purge is meant to "drop the packets queued
before the handoff". The commit message only describes the case where
the socket is "reconnected and bound again within a grace period".
Before this patch, the drain ran synchronously in the same PPPIOCGCHAN
that set PPPOX_BOUND, so it could not reach a later connection. Is it
intended that a pending purge can now empty the queue of a reconnected,
still readable session?
> + WRITE_ONCE(po->purge_pending, false);
[Severity: Medium]
Is purge_pending ordered strongly enough to make reusing purge_rcu
safe?
rcu_do_batch() clears the callback pointer just before calling the
callback:
kernel/rcu/tree.c:rcu_do_batch() {
...
f = rhp->func;
debug_rcu_head_callback(rhp);
WRITE_ONCE(rhp->func, (rcu_callback_t)0L);
f(rhp);
...
}
When the queue is empty, skb_queue_purge() in pppox_purge_rcv_queue()
returns with no barrier at all. When it is not empty, the spin_lock and
spin_unlock pair does not order an earlier store before a later one. So
the func = 0 store and the purge_pending = false store are unordered.
The callback does not take lock_sock(). That means the socket lock held
in pppox_ioctl() does not serialize against it. On another CPU, a
PPPIOCGCHAN on a reconnected socket can run:
if (READ_ONCE(po->purge_pending)) {
...
} else {
WRITE_ONCE(po->purge_pending, true);
sock_hold(sk);
call_rcu(&po->purge_rcu, pppox_purge_rcv_queue);
}
call_rcu() then writes head->func with a plain store in
rcu_do_enqueue().
On weakly ordered architectures such as arm64 or POWER, can the
func = 0 store from rcu_do_batch() become visible after the new
head->func store? That would leave a queued rcu_head with a NULL func,
and the next rcu_do_batch() would call it.
Hitting this needs a PPPIOCGCHAN, a reconnect through pppoe_connect(),
and a second PPPIOCGCHAN that races with the running callback on
another CPU. It cannot happen on x86.
Would one of these close the race?
- smp_store_release() in the callback paired with smp_load_acquire()
in pppox_ioctl()
- test_and_set_bit_lock() paired with clear_bit_unlock()
> + sock_put(sk);
> +}
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201173520.3359805-1-nicolas.dichtel%406wind.com
Technical Details
Message-ID:
<179649328278.3146.6698236366190635617@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.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-378088-linux-kernel-netdev=dewy.ruReferences:
<20261201173520.3359805-1-nicolas.dichtel@6wind.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.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-378088-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v3] pppox: drop queued packets on channel handoff Date: Sat, 05 Dec 2026 17:54:42 +0000 Organization: Usenet Network Message-ID: <179649328278.3146.6698236366190635617@kernel.org> References: <20261201173520.3359805-1-nicolas.dichtel@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3084835"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:N6nLiA8mPpTpu3XSpqv9a64AH/8= sha256:FK8yncoeMSSxW/jbyFFG8MgeMFYfrcQ8pRkSI0MtDLk= sha1:0n0JKK4WY+w1YwiQgkBCuZGwSiQ= sha256:+BSn8Kh8MmAWherYYMrM68CgE6So74XcQZNGPkzh7Uw= 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 8D518117E36; Sat, 5 Dec 2026 20:55:04 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.539 X-Spam-Status: No, score=-3.539 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.14, 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, URIBL_BLOCKED=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 xd7V5ufytX9W; Sat, 5 Dec 2026 20:55:01 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-378088-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 990DC117E02; Sat, 5 Dec 2026 20:54:49 +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 9EA252F69C; Sat, 5 Dec 2026 17:54: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=1796493285; b=lcIae6+V0mvGmOUeTf8jOUkAz7FzFNSKqzwUFrUs89BcxLT5Xc9O2wuQmc8RIb4Bt3fU nRu8XPCJLpuUGW0jWHvPXxDNWJph4TrJ7AbXEfi5S+txG06KsdkPpuXJyclNunww9W5Q6 QAYzigdkClf3lzWLp3thdDCSSkl5aJbKhXG6i6mb2K3eOI4SMkw6khHuMCYw5tZj2Wx/g aS6gmRcJkyMlE3E3YAAs2BGGR76XLqQl7bgf4crLrJT90YWw13MVmT+wl2JpHYDovR4yc V9FvMwdyEBhwFuYpV4PUBCUhU7vRK9mIXRlRWrel+HP39FZj3QzZVxRcoOCaV4WCIyQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796493285; 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=Ek2BORJHv64Rwr21CH08EPcSg9jsuZMB05oYloDGnNk=; b=zMxZUfpWSjlzoe4dIIcR0rKUylzV09xgb8oL7CEHxC90DJ3GoN+GVqK/DT7ZhTu1P7NN gFE6x/4j12FeFDVQ0EOLAJY9OEYgSb6XonfnVie1voZfFEb0+fYtKJtFPvAvFrQ7GfqDm OXOWGJLXLqEyeC1pw/hvIkSRrLRZwFidoeV1PJpix0TAnQkaMOoNQNc4sC2PLHYlQ9SfT 0ThNxlrbfjIaH/gH6x3TTCzwHomph1WnUrgaEYmERxUEqnchhNTExpwRJkQ4I0bc5yA4i TpF6TI8l0pEWN5BzzxDEe0q1kkEZwLuiGfrWjdJklZ22SiRDnleJVbxSbPbuhPl/+FA== 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=NY+ISkcp; 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 2AC8D606A336; Sat, 5 Dec 2026 17:54: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=NY+ISkcp 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=1796493284; b=LPhajBTtZfHJsxnSPUsdkhxfMCkuLTAhWyUH15AiaUFwKA4TQEDnagkq9Cw/w6luepXJ jeAt1Am588o+OpZu33Wu5j99tnHwLTnk0UEABd5exD3UBZaowlDbS4Z9irw9NCAW97Kye DHOSXkL8m+fRG2BzkwOW5NHPW/NfrAQwrlv/GEHIGsmXHRZ5rLns+axBpGK+smcjo0cJd RnRQtox5gi3piESjsj/kGnCxLYn3pQppsaU+CPdsTZd09EUhMnI/UJGw44Nj4bf8teqyA Wtgm/kpf1bIFRoE726eNRb/Wvj0xP38YsVJgPHXs6QyTM3lBN/YUiexNXfeR4QlmaZg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796493284; 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=Ek2BORJHv64Rwr21CH08EPcSg9jsuZMB05oYloDGnNk=; b=3cR1RYfTwtJH9KsY+2cejvtsZZSSkEpPUHPefNJfP90vYXXzwiyxb7MfamGDfOsLYgMf YjI1j80TvFutDJrnsshb0z2pr3TpFf0mi8lvUxwy+NDcqIAOJN9UrnNEDXKIYS478PMF2 M9GvEHvgLP4Y3t1R+SM6kzhyJL7IfHXzDDOhu57DoPzaoWoMf/PhkM4ZN8lILn9uZWIW3 oAqGarFhqfWBoX5vmf75yW5WqVQfjLyg/wYd6aZB7fqUu9p+ox45H3RtluCOOoPLTlHrO 2w+/t6ZXe04Qpk3Wd/W6i9Do2veLQJI1mtdArSG/kV6dZMb9+ONbLVap1i8GTa8eVoA== 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=NY+ISkcp; 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 49EE6606A31F; Sat, 5 Dec 2026 17:54:44 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45F4E1F0092B; Sat, 5 Dec 2026 17:54:43 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796493283; bh=Ek2BORJHv64Rwr21CH08EPcSg9jsuZMB05oYloDGnNk=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=NY+ISkcpr+txUnDLrrQ9VOFNo4qZaDbMvNdbF4Zo7ssROzzcTGBvEF7NeOy5hhHfI OOyXbQd7USmO3BskLxj6PoamW9ngOlyePUVxKiimGBTN/pvbsz5Wcfh6oOu8o+fIbQ i3/rG1wsRTL9xiYGAyNseYzPPARK76YjiluxLwwCMRuD0qh05qBGos7vnrGOMfI7+K jDxJF0G3ycJVLjy3kvznhI1unWn4gfD5Ft9bgcffa9BzutLPfWNNNOq6gwYTWF7UZv N42h9zF/XPdjjN/0VtSlZxzlMdKoBB1nj+bXTkENdXMHvhySNOuBubN3mhU2nDdNKY Ej9gPhf7PK5yw== X-Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org, willemb@google.com, andrew+netdev@lunn.ch, jchapman@katalix.com, horms@kernel.org, qingfang.deng@linux.dev, netdev@vger.kernel.org, stable@vger.kernel.org X-In-Reply-To: <20261201173520.3359805-1-nicolas.dichtel@6wind.com> X-sashiko-severity: Medium 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