🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #7329

[PATCH net v2] pppoe: wait for RCU readers before reusing a socket

#7329
From: Qingfang Deng
Date: Mon, 26 Oct 2026 06:12
64 lines
10175 bytes
When pppoe_connect() disconnects or reuses a socket, it removes the old
session from the hash table and resets the socket's fields. An RCU
reader that reached the entry before it was unlinked can still be using
its address, ifindex or next pointer.

If sockets A and B share a hash bucket with A preceding B, a concurrent
__get_item() looking for B can be traversing A when it is removed.
Clearing A->next then makes the lookup miss B and drop the packet.
Reinserting A can similarly redirect the reader into another hash chain.

Call synchronize_net() after unlinking the old session and before
clearing its fields. This allows existing receive-path and
/proc/net/pppoe readers to finish before the socket is cleared or reused.

This was found by Sashiko's static analysis, and reproduced on a VM
stress test with KCSAN.

 BUG: KCSAN: data-race in hash_item+0x1c/0x60

 race at unknown origin, with read to 0xffff888000a1c566 of 2 bytes by task 147 on cpu 2:
  hash_item+0x1c/0x60
  pppoe_seq_next+0x112/0x1b0
  seq_read_iter+0x595/0x700
  seq_read+0xb0/0xe0
  proc_reg_read+0xd0/0xf0
  vfs_read+0xbd/0x220
  ksys_read+0xa9/0x100
  __x64_sys_read+0x47/0x60
  x64_sys_call+0x98/0x1fd0
  do_syscall_64+0x5b/0x260
  entry_SYSCALL_64_after_hwframe+0x4b/0x53

 value changed: 0x0002 -> 0x0000

Fixes: 72cdc67e7fa7 ("pppoe: remove rwlock usage")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261020092118.47416-1-qingfang.deng@linux.dev
Signed-off-by: Qingfang Deng <qingfang.deng@linux.dev>
---
v2: call synchronize_net right after delete_item

v1: https://lore.kernel.org/netdev/20261023043729.219660-1-qingfang.deng@linux.dev/
---
 drivers/net/ppp/pppoe.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index ee0e318d6a2a..021b6c767294 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -618,6 +618,10 @@ static int pppoe_connect(struct socket *sock, struct sockaddr_unsized *uservaddr
 		pppox_unbind_sock(sk);
 		pn = pppoe_pernet(sock_net(sk));
 		delete_item(pn, po);
+
+		/* wait for concurrent readers before clearing the fields */
+		synchronize_net();
+
 		if (po->pppoe_dev) {
 			dev_put(po->pppoe_dev);
 			po->pppoe_dev = NULL;
-- 
2.43.0
Technical Details
Message-ID: <20261026061300.256009-1-qingfang.deng@linux.dev>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351697-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351697-linux-kernel-netdev=dewy.ru
From: qingfang.deng@linux.dev (Qingfang Deng)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2] pppoe: wait for RCU readers before reusing a socket
Date: Mon, 26 Oct 2026 14:12:58 +0800
Organization: Usenet Network
Message-ID: <20261026061300.256009-1-qingfang.deng@linux.dev>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1238209"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:3eCtGGIF4+8GckNMP3jEpVkSMGo= sha256:hAYPYG8O4n4Q4wXy5wozB6qAYLiw0Jo5IPZWUbD5gIs=
	sha1:op1JDrJTl6VyJFAvusnRyzBdTAM= sha256:WdiIi6yAF4JAAgmruv/kOqAHvu4ALjpLq1WRuGIRCmk=
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 1D477125B87; Mon, 26 Oct 2026 09:14:03 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	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 (1024-bit key)
	header.d=linux.dev
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 a48TP9Ad9Ug2;
	Mon, 26 Oct 2026 09:13:59 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-351697-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 31581125B7B; Mon, 26 Oct 2026 09:13:50 +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 B58C127C7B; Mon, 26 Oct 2026 06:13:16 +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=1792995195;
	b=Kvb8CzO6CHIoqAfwTx56trCN3S4KzpCqknopm71/QzlVCYcJB4dY4OSmi0ue3V0/gFev
	 WibWZ8tgpk64p0JNFCGOELgklqd1LnxG8S2kaHHkd9iHQXkRgZoXG9wWSClbakkJM9X8V
	 HhUntwIKZhpqW5u3709S/I8Bq+WUoJlZsc75ItYlkIzZC4dAwZSDd5S/sAVNWxk2PVkMA
	 CYceJhFK+EUISGKk22Nzxg3J34tJiyeQF8tg1bFsvEU0TAi+HXeUm8oKOW5L6+6XDkxDp
	 WA4BSfxgrHDEnlkw5JuUXOyyE1EGnnNeiF1+SQIvqRDK+J2e1rILup1vUhjBHblVgAQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792995195;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:
	 Subject:Date:Message-ID:X-Mailer:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Transfer-Encoding;
	bh=LYDxwtGCEaaeKY+BqFPhzjs+smK1jNiVay0L/T+8eWE=;
	b=yrfGCHgqNFteOZjrq/syHwHedga1iLwR3LLloh2hVruw9PpfMYigxvmsa+U1zAx3W90K
	 d5prhMraT4NeC+Hq9Y+Ru5MTDqFeSoibn72kEKDQwyJ7Ez4Kh/nHUKhTuW5+ugxnQB0Ts
	 I6HsSXRqnGxZQmF8ECvv2PYqkqfQjxvz/tBfxPOMe6hAeM+tBo+TShpzJtR3pJBk5vtPp
	 jQKPPUQkbWSeUW08bREfXrXlMtJBArCJzDBHQv6UI8cgymWsm/wCOuBpQVc9KqYVTKEAA
	 jDBylLWXDMScjl4gNcJYkpRgctJwtx4NS1LJd2Q5BH+NN3FEZT0vjKOdfxEH7Nh2TXQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="NFW/1L9L";
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	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 7CB08606A32C;
	Mon, 26 Oct 2026 06:13:15 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=NFW/1L9L
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.73
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792995194;
	b=x3xJb/MycPI7UtWTPCdki+LGqY64qYG+he1ZtWabR1bk9QkZXgf/1r6PLSYDeBorZiyW
	 f4/aHXc6xFuXALaDXESJ38JQKolkxqE6n4JzlaNQb6tZpw9tpJbKK8AIv8J7uOf+QdHeR
	 qaXA+WEtRWu+VJhXbSAWVJlAQTh9I7auTL2CuplWWrGMTIuBqL9LUMfpkRQdrLTK8ubeG
	 81Og5/Xx9xdeVbX/wPRqUEei6DH+0xBJU8vtp1n4E8K/JADMiStSv8h9dRqUSTXDe0Zjo
	 D52+5jmoo5yBgi2x4mt08YlerKfgnYHvxI8C5p9uAwFVdhW51AjOw4T9BjZRayoiuSg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792995194;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID:
	 X-Mailer:MIME-Version:Content-Transfer-Encoding;
	bh=LYDxwtGCEaaeKY+BqFPhzjs+smK1jNiVay0L/T+8eWE=;
	b=i8+u1Kx8xGazIJfDnuRN3XFvfjw5GPcIMq+WWDT7Kj7LqRyeoINBf9cmywYfUE5qltPN
	 0t0A0k99/Vsvjz0wCz8J6X3j8/4tYU/2ZgRXqa5HhgJnQ6wNOaPYEpECpT2RicjBWL0in
	 YqbyF6IjyOCYOopnRf4RtW9PHxKx6iIa1NAqefOwZro174EvD1t3ERVnl3EjB+TDgCVz0
	 T/8tvqTCcmC/WI4QYfTam2xfcQtOqPzjazrfWIKTlthDWTDalu/GEZY2097NWfZmYmKDd
	 osiv8peeHFX4eDvr4t7kP8vCz8KXabwW7NwmRJKT2cD8kkj6/PqpORkqj0srmXmt5/Q==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="NFW/1L9L";
	arc=none smtp.remote-ip=95.215.58.73
X-Received: from mta1.migadu.com (out-73.mta1.migadu.com [95.215.58.73])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 796DD606A31B
	for <netdev@vger.kernel.org>; Mon, 26 Oct 2026 06:13:13 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 796DD606A31B
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=nxLeUxoA2cNqllgMNF6jbihXV5eKKESlAmd5sput3C8=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1792995191; v=1; x=1793599991;
 b=NFW/1L9L8HOt2sI73VzCd9fXdbd+UNz2pKUHGfg6xFvuG/73qVpMjyzp/OZNi11ey1uHRDQW
 4vOlG4d8DQ2w6yLXoyhp21iDwXDRkbIqCvmT9awThwdNHgM9gnEshtIGZ1ZZuaq2+ABw6Ns/Eyj
 5ZN/8uC2m9G2bsGH7BtIALyU=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by smtp.migadu.com with ESMTPS id 062b43fba1f871ab;
	Mon, 26 Oct 2026 06:13:11 +0000
X-Mizu-Trace-ID: 062b43fba1f871ab
X-Migadu-Flow: FLOW_OUT
X-Cc: Sashiko <sashiko-bot@kernel.org>
X-Mailer: git-send-email 2.43.0
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