From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.84.47 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796026819; b=PCUldiPuE/g33+vPg4HRfTPaLcDhk/JnRUCgkrBE7t/8GhBBUTZ/yOUFtMaAew7xciQ0 F3cQfdjAn2QVsF+wOb7PKAWFmDKGC4x+J+onnqvT3fyFHz2MdDHTuTzAJQ8kanhckEuva k1ZmQEHLGaUNC7Cbg6nnMm1gSd7f0Wt2Z5NrubJ0WVSYTs+I9VBRySo37HBu9McHRI3wm viSSEUSKxR1FSWLTyCSQCeMvnZoUqk7eWgwuF/mC6w7EisdmdqaCaFAxUFYSnxxdqCdjZ AmFELwrGeGGczqnre29d6FSRsOfAloF3EezTSQXUxuBhw7OnbueUqbFGVLgyWEq0ArA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796026819; h=DMARC-Filter:DKIM-Signature:Received:Received:From:To:CC:Subject: Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To: Accept-Language:Content-Language:X-MS-Has-Attach:X-MS-TNEF-Correlator: msip_labels:x-ms-publictraffictype:x-ms-traffictypediagnostic: x-ms-office365-filtering-correlation-id:x-ms-exchange-senderadcheck: x-ms-exchange-antispam-relay:x-microsoft-antispam: x-microsoft-antispam-message-info:x-forefront-antispam-report: x-ms-exchange-antispam-messagedata-chunkcount: x-ms-exchange-antispam-messagedata-0: x-ms-exchange-antispam-messagedata-1:Content-Type: Content-Transfer-Encoding:MIME-Version:X-OriginatorOrg: X-MS-Exchange-CrossTenant-AuthAs:X-MS-Exchange-CrossTenant-AuthSource: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-originalarrivaltime: X-MS-Exchange-CrossTenant-fromentityheader: X-MS-Exchange-CrossTenant-id:X-MS-Exchange-CrossTenant-mailboxtype: X-MS-Exchange-CrossTenant-userprincipalname: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=+5wsM8EQ9mVAYq1GE9b3rdKFnizn7wdBaVnzVhOahWw=; b=Bh4luOtiPafGZiuocj8ym6iRzR3UwJoZFoAPpVGzzV7euRuEgUX8x+q4cwK2IPFrNWBK JXCciHcMVTOPVX8ucjpQ3lVXqq4p05kuvd95WK7xLsg51LHPxUsaXFcWoLKP10ISNcc0+ Rn2aJVDznbuzVHhImpgPl97cNG8OnvBDpRHeJIK0q9V6STEJQOvkaVVKHES1a7RQg38kj saRf/BTbKDrS9kghY1N5In/nZWiNidrgrS9aPyyXCNYdsSi1cJcPPfNyrC51BCqdi0gBJ 5nsw/z3yApzcI5xuv2Dy57nRjZxoUvJ8pgSs9o4kzL/akc4K5AkMpNS4xLrWMNLe1fA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=est.tech; spf=pass smtp.mailfrom=est.tech; dkim=pass header.d=est.tech header.i=@est.tech header.a=rsa-sha256 header.s=selector1 header.b=tvz2VIBK; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.84.47 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11010047.outbound.protection.outlook.com [52.101.84.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5F9B606A687; Mon, 30 Nov 2026 08:20:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B5F9B606A687 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=est.tech Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=est.tech Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=est.tech header.i=@est.tech header.a=rsa-sha256 header.s=selector1 header.b=tvz2VIBK ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EnGuLke7nq/Bxv3q+Yv4m0Y8Nsu98QVnxDl4xvok5GNFVa6WvFH5w/SpYnkw7f1gVXq2Viyz4JZyZci+LiCohph6NAvgqrvpxVIUe+Bv5HJiysNV+QMYkNb2fAHesCpLeeopAfSX/icDH+001PmK/+z6BGEWh9oYBfR0bfqP3ciKPXEAfiOxdiLd+mRISwFotVRmZiJjx7rnMWy0ogHfvmN9+y73uYrnoitU6YGzAtqeVUVMWvJmvQmcFwwgWrTCDvKwvtwZlVjgPOqEbz5R7+gnrm5BBuLtkSEEnQBHKKkuFqbYnQR7az1MifkryP9ZKkAp6OYAAnXJ4KtqxdRyZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+5wsM8EQ9mVAYq1GE9b3rdKFnizn7wdBaVnzVhOahWw=; b=UWCwAkPXre9qQptg1KdC2dzTujhVbfgnbnNRzyAdwG3HgcvidGsu+7cD5TGpDVqGtObpDP80vQ2c5insUUj5sitUWagoBdy7ZbCx8ttnpsU4/cU3ClbTaP1GgPEHO1Orvg+REFpdwFPUZBMpxU28B5EyBYh39XxCdin1IggPOTy0Y78roOEyPu2LT2uNzcXr715hKon5CEzgznNCeHl5Nucwjigp6HAsxov9KBJNzXN4LNHVcMuJerrzql1Eood197rx+Gy9sAL+jePoF25IoiOpgOr3TXxQP/iM1GnjIwzzrFFpB4ZJ5+t3yEiqXWNUqG4RWybca7Z4vJdINvvF8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=est.tech; dmarc=pass action=none header.from=est.tech; dkim=pass header.d=est.tech; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=est.tech; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+5wsM8EQ9mVAYq1GE9b3rdKFnizn7wdBaVnzVhOahWw=; b=tvz2VIBKbJxcq1/Q2zbvWn6alKOcPD/FOHcgfc5bMnaLUApR33rru3wtn0mVWNZET+kWjNOCdPjGW63/fr8Lbd5Z68xCiBxp7J2/xq3mGsZL/D0pUCRaRh57Dzp+MoQtG1xm+cBDr9IWH3LD7jspyHgC8UOKveCq5KpYoRtB6c3wsvEXgPV/2XmdivvwKCgYdUDci37rUHlZivgSTQlEd3tg7pxVxgSQIu+UL08I8n1YlLn9fGzzS5J07nms2RR3pLt7fTo1RaW/9i/btZCIDU9aSUKrKAivY1hs6WBcGogw3xto+EZaofrJC6LsnxiwtkXdFNqCiTT4NXvUl9tBEQ== Received: from AM7P189MB1137.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:17e::23) by AM7P189MB0791.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:11d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.13; Mon, 30 Nov 2026 08:20:14 +0000 Received: from AM7P189MB1137.EURP189.PROD.OUTLOOK.COM ([fe80::86f0:8ce1:a437:b2d5]) by AM7P189MB1137.EURP189.PROD.OUTLOOK.COM ([fe80::86f0:8ce1:a437:b2d5%6]) with mapi id 15.21.0662.007; Mon, 30 Nov 2026 08:20:14 +0000 From: Tung Quang Nguyen To: Andrew Stellman CC: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , "netdev@vger.kernel.org" , "tipc-discussion@lists.sourceforge.net" , "linux-kernel@vger.kernel.org" , Jon Maloy Subject: RE: [PATCH net] tipc: don't update capabilities from duplicate discovery requests Thread-Topic: [PATCH net] tipc: don't update capabilities from duplicate discovery requests Thread-Index: AQHdf5cU4OOIeh638EGSHYOOMTvkbrdGQy4w Date: Mon, 30 Nov 2026 08:20:14 +0000 Message-ID: References: <20261129001748.78733-1-bugs@stellman-greene.com> In-Reply-To: <20261129001748.78733-1-bugs@stellman-greene.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=est.tech; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM7P189MB1137:EE_|AM7P189MB0791:EE_ x-ms-office365-filtering-correlation-id: 5faee729-5cf3-480d-499e-08df4ebac257 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|366016|1800799024|23010399003|10070799003|376014|7416014|38070700021|10067099003|56012099006|261028144727099003|261026140227099003|261026130827099003|261026121527099003|261026135527099003|261022115727099003|261021135927099003|261021133027099003|261021130227099003|261021123027099003|261021121427099003|261022113327099003|261022105027099003|261022075727099003|261102123227099003|261009223027099003|18002099003|22082099003|5023799004|11063799006|6133799003; x-microsoft-antispam-message-info: xdFuB/QUCDIcWCJ6TdBgMIhg0Hg6w0tZ6VVVvTwqdp++lwrlvp7ecX7ygh/HDWIm2uWqaBCW6E7f+ZuN5Um74xPH776GvxI9vyOXSO6Oq6D+RbuxjybZ1oQVtawQJheGgqY+6pKKobZv62IE9ymzOGA8Mty6dqqL0E166Ap1Y3RNszs9HMZONaC8dULZjQufPsVEP0Lx7xufWt0DxT2Cwk+A69v1lLEC2+Uv3z5xA827kjUKgMg6vsO8MHvRJrnC+vgixGa3YJpi8LCpAolTPjUNeGoL4kVgWRtSIDoO4f6IdcRvb5JTl+ju/2HUYE4Mmjsk4cgcXYi24nYxOSTWndqWbVp8bQycSCgYdFWyxb4Wbtw/RxoaCSMEA/grSJfS8CGXsJNOrhW7aE0RL4VMKxivd96adQVMHpeyKXKoeld3wh1MyNte9aD76dlvUPB+9jZ9rkXpc5rpIyWuPaKR7D6pONKsUWrPIiChqK6puDIELAO+k3+ESRhPkGRvSQZxxj86ASI3MJPS7Pymjt9a514okJRZGTJH1lZei4S71yPUD+od0yJ7mC7hvJNa6dE9qcrXq967I0U4oUel7tFeOjZDWpWxv8vFI9+ik+BraONBns+HUfusCTBVxk5/g91IXLSDmfE4XknvcLFf2uGwvNbvhvoZiRTUSDn8bKkGgOin8+AoNv210xAXNWlHBSmn8XISqUG1AVt0G8kUWp7YhgK8Dv8BfiLmUK3wQSLV61s= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM7P189MB1137.EURP189.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(23010399003)(10070799003)(376014)(7416014)(38070700021)(10067099003)(56012099006)(261028144727099003)(261026140227099003)(261026130827099003)(261026121527099003)(261026135527099003)(261022115727099003)(261021135927099003)(261021133027099003)(261021130227099003)(261021123027099003)(261021121427099003)(261022113327099003)(261022105027099003)(261022075727099003)(261102123227099003)(261009223027099003)(18002099003)(22082099003)(5023799004)(11063799006)(6133799003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 2 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?JErJNsQO6ijNII5cQugYIjo+Hh5hPL+cbNB0TSpk4Pt88cH/+H0vjwkaNS?= =?iso-8859-1?Q?1kUjfpNQng703I0xonaZ2SUEqG+54WpixHG4q5zljiTfO9QpenU0xN81Mb?= =?iso-8859-1?Q?w5kORPmfLuSjiimlWPCnqHuigu9GIaQpYI6zJmGBuNJKBCroalFtB/JCN0?= =?iso-8859-1?Q?NclY8Z+D93WGLHQdAtMBbFAXeOAvCEzXYBqJijsNtGgN5IZSmndFbSE8sV?= =?iso-8859-1?Q?3hzXobL5NhaQqy91uZ2jvCwlKHFKrH8LhaT4+m+ji3oFyr4Qx2f3woqDgl?= =?iso-8859-1?Q?TcUd4+qmhlsGdb9lnaunhm5jh/7HJgFgUAH9K/OkpsDwkQ2IwqOzec7VMB?= =?iso-8859-1?Q?rcZCHQZe4xeEHnSUty3Vv/6h63/TvaNdUH6k8K8Jk05LFUzgh+mIqEYHyL?= =?iso-8859-1?Q?hoiJHTGU0Soqm46IarGG2RX/IeOVL7fkJCRFC3gYk822ZRUn8vLEZWxOmd?= =?iso-8859-1?Q?r4v7MMRPXYo1soeD5D5aKijreqn/kL3N2OpHURg2HGR5PDOUIww63SDGIV?= =?iso-8859-1?Q?2bcQPldecDCj3YvVJ/KBnKNWzSkOoZOqfRBHXB8bg1TALALd7F0P/YRxpu?= =?iso-8859-1?Q?D7W5abCIUOrLjHpPFuJaLg4msinsJ8e4CQkf3U9mTYHgmRUaQ5RB7wp1xo?= =?iso-8859-1?Q?XghoetZ+5OHCzr2jp46FZAhTjAP2Etpw0FC4gK5nGqoDS+jMysIBn95kzY?= =?iso-8859-1?Q?Kfci9Gaaqyf2cEwDk6Xg9y5LrsLeW8lwCpHxTrTnRqEujGe+tTUC2G/nmW?= =?iso-8859-1?Q?F17JhQFLDS4Lq6Q4gbblUvK1BxRXyJjeEAfAPX3oswyNo8q5iSfO8sBBMv?= =?iso-8859-1?Q?nDWqznWtmagl9u4YG6TZbZtr+IsSwJIxJV2PEoKSt9MFDFJBUEpVRXC/2a?= =?iso-8859-1?Q?scbzGl0LkFHtc9IFO8kv5kBHYHc2yJWgceOANtmtXDGXiJ0pJDKAxTcOhQ?= =?iso-8859-1?Q?PxDEvxy+JCizVbUm6NWVbMTuTeZb231VSXjMzW42yrGoMFBN5QKbvr0rZJ?= =?iso-8859-1?Q?OBmAjYarGOfAsSnO3Amlkp3cDxm4KHdhNWPPQ9fjk5gZC3YJjN3bX9vAEB?= =?iso-8859-1?Q?HDr8yaxltq4qZyms1ujh4Dx8sAD6Lddo51FDohtlFEY9ZpvmjEq0yfroUi?= =?iso-8859-1?Q?NKOx+j815f6xEEDy2gnkH+Xx6W4Yuvt3I/8fJUBz/lTdQfyvlS67O4YlrQ?= =?iso-8859-1?Q?Ywpr9f+3+sRxSQUk0halj3PgOvdUSrpP7Lwc8Uo//Ll9Oq8dpG4hLSlUAC?= =?iso-8859-1?Q?H121K1rb7frI6m1VUKPA/gH+qLRz1J19aEHpOvMiy7jHOd8/uBDUMyZNEe?= =?iso-8859-1?Q?BmLWS+JkRFEkX6D8OhKrk7AvLiEBuDK19+nbtbNsKaLmQQH2TO/jQaLwop?= =?iso-8859-1?Q?bSsqH0goP0qIN3hnt++CYrsgSrWMgJ81RDS627Gen6fUy/ImtemJWuFi34?= =?iso-8859-1?Q?4wZW5JjkVjJ+vBvDre7d33oPyakEzRw/4ALAV/lW9Hl3MGWvfI252N1jvL?= =?iso-8859-1?Q?tlmuQxmbYyYu8wKB1X+EOgqd47ozDsUEZBnQNWZjeqdp/mrDwfEhHRxOsP?= =?iso-8859-1?Q?RYqWzbmypCOSi0fgm23Ylir/Wr30lY7edMJg2hfZ7O/QZuXgthdeARd+HL?= =?iso-8859-1?Q?UmAP8rzoDaWlj3XL9n0gx1qZLsJZmKtLAi8/8T928/SiYsdWpM0k4r5RpT?= =?iso-8859-1?Q?CwELXFODVlfHVtyLDM5BcZoO5WsQUflhDHsjoexUDlxIdne33SFc0x5TJK?= =?iso-8859-1?Q?hcq0kMEj20cPCpl7ovqb7ul677fgXCXVBFQdcOguc5OTtOfKGVaKFMueoN?= =?iso-8859-1?Q?hVPl1LCCmQiAhjSCHRqWvI5ZnEDPUICQYGMNLE4Wg8Lbs8L/yxoUcgtl+3?= =?iso-8859-1?Q?ER?= x-ms-exchange-antispam-messagedata-1: Ou4jFxh/EG3Djg== Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-OriginatorOrg: est.tech X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM7P189MB1137.EURP189.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 5faee729-5cf3-480d-499e-08df4ebac257 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2026 08:20:14.1207 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d2585e63-66b9-44b6-a76e-4f4b217d97fd X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ZoI0WRy3aOTMaprJdwV/Wa+BTrP08yXYHCjwxIrGXZf2ojNi5c9rf7yNIVAjksV9/W+9+LPc5VRb5mQWKCUht3PDoti73De1qZKgqg73oy4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7P189MB0791 >Subject: [PATCH net] tipc: don't update capabilities from duplicate discov= ery=0A= >requests=0A= >=0A= >From: Andrew Stellman =0A= >=0A= >tipc_node_check_dest() calls tipc_node_create() before it classifies a dis= covery=0A= >request. For an established node, found by node address or by peer ID,=0A= >tipc_node_create() overwrites the node and link capabilities. A request th= at is=0A= >then rejected as a duplicate address has already changed them. Because of = the=0A= >peer ID lookup, this also happens when the request carries a node address = the=0A= >receiver doesn't know.=0A= >=0A= >Look up the node by address or peer ID first, as tipc_node_create() does. = For=0A= >an established node, do the peer net update that=0A= >tipc_node_create() did at that point, and call tipc_node_create() only aft= er the=0A= >request is known not to be a duplicate. New and preliminary nodes still go= =0A= >through tipc_node_create() first.=0A= >=0A= >Tested on mainline (7cd8495c0f16) in arm64 QEMU with KASAN, replaying=0A= >discovery requests over veth between two network namespaces and logging=0A= >the result with a test-only pr_info. Without this patch, in both of two ru= ns, a=0A= >duplicate with the peer's node address but a new signature and media addre= ss=0A= >changed the capabilities from 0xfff to 0x1, and one with an unknown node= =0A= >address and the peer's ID changed them to 0x21. With it, both stayed 0xfff= in=0A= =0A= [sashiko]:=0A= The changelog gives the raw capability values (0xfff to 0x1 and 0x21).=0A= What is the user-visible impact of the overwrite?=0A= =0A= >one run. In all three runs, a request with the peer's signature and media= =0A= >address still updated them, and a request with a new signature and media= =0A= >address sent while the link was down was accepted and set them to 0x1.=0A= >KASAN reported nothing. No selftests were run.=0A= >=0A= >Fixes: 60020e185704 ("tipc: propagate peer node capabilities to socket lay= er")=0A= >Signed-off-by: Andrew Stellman =0A= >---=0A= >The issue was found by Claude Opus 5.5 and Claude Fable 5.2 running Qualit= y=0A= >Playbook, an LLM-driven code review tool:=0A= >https://github.com/andrewstellman/quality-playbook=0A= >The fix was drafted with OpenAI GPT-6 (Codex) and this changelog with Clau= de=0A= >Opus 5.5, and both were reviewed by me.=0A= >=0A= >A reproducer is available on request.=0A= >=0A= > net/tipc/node.c | 27 +++++++++++++++++++++++++--=0A= > 1 file changed, 25 insertions(+), 2 deletions(-)=0A= >=0A= >diff --git a/net/tipc/node.c b/net/tipc/node.c index=0A= >53b0993c2c2333..f0e3e06ff8c7bf 100644=0A= >--- a/net/tipc/node.c=0A= >+++ b/net/tipc/node.c=0A= >@@ -1176,6 +1176,7 @@ void tipc_node_check_dest(struct net *net, u32=0A= >addr,=0A= > struct tipc_media_addr *maddr,=0A= > bool *respond, bool *dupl_addr)=0A= > {=0A= >+ struct tipc_net *tn =3D tipc_net(net);=0A= > struct tipc_node *n;=0A= > struct tipc_link *l;=0A= > struct tipc_link_entry *le;=0A= >@@ -1185,6 +1186,7 @@ void tipc_node_check_dest(struct net *net, u32=0A= >addr,=0A= > bool link_is_reset =3D false;=0A= > bool accept_addr =3D false;=0A= > bool reset =3D false;=0A= >+ bool existing;=0A= > char *if_name;=0A= > unsigned long intv;=0A= > u16 session;=0A= >@@ -1192,8 +1194,20 @@ void tipc_node_check_dest(struct net *net, u32=0A= >addr,=0A= > *dupl_addr =3D false;=0A= > *respond =3D false;=0A= >=0A= >- n =3D tipc_node_create(net, addr, peer_id, capabilities, hash_mixes,=0A= >- false);=0A= >+ spin_lock_bh(&tn->node_list_lock);=0A= >+ n =3D tipc_node_find(net, addr);=0A= >+ if (!n)=0A= >+ n =3D tipc_node_find_by_id(net, peer_id);=0A= >+ existing =3D n && !n->preliminary;=0A= >+ if (existing && (n->peer_hash_mix ^ hash_mixes))=0A= >+ tipc_node_assign_peer_net(n, hash_mixes);=0A= =0A= [sashiko]:=0A= Can calling tipc_node_assign_peer_net() here before classifying the request= =0A= allow a rejected duplicate discovery message to bind n->peer_net?=0A= =0A= If an established remote peer has n->peer_net =3D=3D NULL and a duplicate n= ode in=0A= a local network namespace uses the same net_id and node_id, a discovery=0A= request from that namespace that is later rejected as *dupl_addr =3D true w= ill=0A= still set n->peer_net to the local namespace. Because=0A= tipc_node_assign_peer_net() returns early once n->peer_net is set,=0A= tipc_node_xmit() will divert traffic for the remote peer into that local=0A= namespace via tipc_lxc_xmit().=0A= =0A= This also mutates n->peer_net and n->peer_hash_mix under tn->node_list_lock= =0A= without n->lock, racing with node_lost_contact() and tipc_node_xmit() which= =0A= access those fields under n->lock.=0A= =0A= >+ spin_unlock_bh(&tn->node_list_lock);=0A= >+ if (!existing) {=0A= >+ if (n)=0A= >+ tipc_node_put(n);=0A= >+ n =3D tipc_node_create(net, addr, peer_id, capabilities,=0A= >+ hash_mixes, false);=0A= >+ }=0A= =0A= [sashiko]:=0A= Does open-coding the node lookup and peer_net assignment here duplicate wor= k=0A= on every discovery packet?=0A= =0A= When existing is false, tipc_node_create() immediately re-acquires=0A= tn->node_list_lock and repeats tipc_node_find() and the linear=0A= tipc_node_find_by_id() scan of tn->node_list. When existing is true and th= e=0A= request is not a duplicate, tipc_node_check_dest() already holds a referenc= e=0A= to n, yet calls tipc_node_create() after tipc_node_write_unlock() even when= =0A= n->capabilities =3D=3D capabilities, repeating the lock acquisition, lookup= ,=0A= kref get/put, and for_each_net_rcu() scan in tipc_node_assign_peer_net().= =0A= =0A= > if (!n)=0A= > return;=0A= >=0A= >@@ -1310,6 +1324,15 @@ void tipc_node_check_dest(struct net *net, u32=0A= >addr,=0A= > memcpy(&le->maddr, maddr, sizeof(*maddr));=0A= > exit:=0A= > tipc_node_write_unlock(n);=0A= >+ /* Rejected duplicates must not update capabilities. */=0A= >+ if (existing && !*dupl_addr) {=0A= >+ struct tipc_node *updated;=0A= >+=0A= >+ updated =3D tipc_node_create(net, addr, peer_id, capabilities,=0A= >+ hash_mixes, false);=0A= >+ if (updated)=0A= >+ tipc_node_put(updated);=0A= >+ }=0A= =0A= Can splitting the initial lookup, link setup, and capability update across= =0A= separate lock critical sections race with node removal or concurrent=0A= discovery?=0A= =0A= CPU0 CPU1=0A= tipc_node_check_dest()=0A= existing =3D true=0A= tipc_node_write_lock(n)=0A= ...=0A= tipc_node_write_unlock(n)=0A= tipc_node_timeout()=0A= tipc_node_cleanup()=0A= list_del_rcu(&n->list)=0A= hlist_del_rcu(&n->hash)=0A= tipc_node_create()=0A= tipc_node_find() -> NULL=0A= kzalloc_obj(*n, ...) <-- inserts blank duplicate node=0A= =0A= Because tipc_node_check_dest() does not mark n up or refresh n->delete_at,= =0A= tipc_node_cleanup() (or tipc_nl_peer_rm()) can remove a down node from=0A= tn->node_list and tn->node_htable after tipc_node_write_unlock(n), causing= =0A= the deferred tipc_node_create() call to allocate and insert a new tipc_node= =0A= with INVALID_NODE_SIG and no links.=0A= Separately, when existing is false on entry, dropping tn->node_list_lock an= d=0A= n before calling tipc_node_create() leaves a window where another CPU can= =0A= create or promote the node from preliminary to established and bring a link= =0A= up; tipc_node_create() then takes its update path and overwrites capabiliti= es=0A= before duplicate detection runs. And when existing is true,=0A= tipc_link_create() is passed the old n->capabilities under=0A= tipc_node_write_lock(n), exposing the node and new link with stale=0A= n->capabilities and l->peer_caps after tipc_node_write_unlock(n) until=0A= tipc_node_create() re-locks the node.=0A= =0A= ---=0A= pw-bot: cr=0A= =0A=