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=1796493284; b=LPhajBTtZfHJsxnSPUsdkhxfMCkuLTAhWyUH15AiaUFwKA4TQEDnagkq9Cw/w6luepXJ jeAt1Am588o+OpZu33Wu5j99tnHwLTnk0UEABd5exD3UBZaowlDbS4Z9irw9NCAW97Kye DHOSXkL8m+fRG2BzkwOW5NHPW/NfrAQwrlv/GEHIGsmXHRZ5rLns+axBpGK+smcjo0cJd RnRQtox5gi3piESjsj/kGnCxLYn3pQppsaU+CPdsTZd09EUhMnI/UJGw44Nj4bf8teqyA Wtgm/kpf1bIFRoE726eNRb/Wvj0xP38YsVJgPHXs6QyTM3lBN/YUiexNXfeR4QlmaZg== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45F4E1F0092B; Sat, 5 Dec 2026 17:54:43 +0000 (UTC) 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== Subject: Re: [PATCH net v3] pppox: drop queued packets on channel handoff From: netdev-bot+sashiko@kernel.org To: nicolas.dichtel@6wind.com 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 Date: Sat, 05 Dec 2026 17:54:42 +0000 Message-ID: <179649328278.3146.6698236366190635617@kernel.org> In-Reply-To: <20261201173520.3359805-1-nicolas.dichtel@6wind.com> References: <20261201173520.3359805-1-nicolas.dichtel@6wind.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@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 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