From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796111740; b=gVfqebwFGauidl1Q/nNFoNFbpF2lJwonKSWXdC6Ex1HfX4nNyXF5ifiTPDu2O4sJTc70 1cBfQdvJJTf17U1LAdYz5L1IhrLxCdzHO+siBZi+z0Gx99o1jf+QVEPbVYoV1IUFh+Tm7 hAsO6FfWxWW0SqfA1QKtQm+ptckd1C7ZUCvAww36Kfn8EaRhJU86hX9NakbrXjG1htptn O6Z2IpWqr9wpqHpSGPQbvTuX5xdblpUj+rovzAF+4pcocdMpR+xaInJtXs3WxQHlcSe85 ll6NPD2IYZnKtBUfis6Yj2h8uxYLrzLnYTXk97o4NN+wt3nkb6cT/8Oas6s8LX0gozw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796111740; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=RCPP47sxEPwmydHxDeBSAihWq19vUajNGVuVIaiFTOE=; b=Ol7AldSJg/cS1yLTPED3mGwE43h74W1BehcUscxiTQ82DHr297MWWcgLDMcO0hfyzojT 9cn2Hg4Tmr/bBvzajTVlWxGd1klAO/xKDU3J2cjH/1WzSH2XJDpcD1N7EwwuFR59YTfWX bxNvsAjFGIAYiaaWkCFHWEpwYHfjufUe0kxEFBP5E9pnD6MQ9fXXdxDm9M3ctrnq3Q62A SGT7x294gRqurcwdVeMWETqhj0V73jsHs6/w5f8ECXx+jRR0gu4n3s2ZW3TOUxm9zbQYX XEHEWyqy7lwRpWm8RygGhNp1SVMzvc9iOnwLZ8Dsh/w750uXD+YDk8L5jzOMvvLq69Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=C3aVjpqU; arc=none smtp.remote-ip=209.85.210.170 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 E92CB606A31A for ; Tue, 1 Dec 2026 07:55:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E92CB606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=C3aVjpqU Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-8c20d68c83fso6458379b3a.0 for ; Mon, 30 Nov 2026 23:55:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796111739; x=1796716539; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=RCPP47sxEPwmydHxDeBSAihWq19vUajNGVuVIaiFTOE=; b=C3aVjpqUYB07MHMdb3mT+DIyZ4PkzTvo9rvwfBI1WL1HHAO/JVUf339yD4Mmt9n8Ol diQ2eGvv0eIvgmZLs1IXB29vjsQVmERjTS+5srjYC+2tgMZmaMiO25pM13rZ+Bc2b5hW n7FlHlEuNBcnx0LEjCYzriw4uWjy6Y/dLUJ2zor695EIVGxpd0nYSp+FMQ2apTN0Ghwa yY110lUhiJVqVfC/m3miUXIVygv/nHO/2jx/XcKtXNqW+FEa5qBetILrwALuo0j1+e74 iwqjTxJxOVtTRoTou1woy3FWBru1eq0miCVFjae3iV3YrHAsR4ng/pJ7AUs6OAM8GCNt fFwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796111739; x=1796716539; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RCPP47sxEPwmydHxDeBSAihWq19vUajNGVuVIaiFTOE=; b=akZq60X80KzmOsBm+CO+e88IuEfuoywzEASaKpr1X8dP+IHLBgq1JVrwehSzFuwiMH mmlXMMOrJk7HNGBOerwXgvC5yxRjXf+E3rtt/miR1Jsgdg/dstDISybIObNxVLle4iOt nzBsWRHvt1/lHDWpgyn9k8HJXpEKjcoQRyK30e47LKnZMBxUfX9i6Bk82ECDeTepV676 EQw3GLpdFouV6Ngm/TrORwyYKKDGhcievCLF6ETvfZOtSzkewUVL500mliSz68ooUlCa nyWXq19mh+RReJJYVx4ioDOVzA94bfPdDZs7czvRV+EnCT8VM14rVeRKujd9qSTsJcNa VfdQ== X-Gm-Message-State: APuU4Z/f2q81nWAgEMwJ+OVDqEYMiyP6QQtPOVKS9Jm+dt9YGGQeiFEI 9PQABXjXukio9fX5Mws/OQODNee59WiZqaxoVfZKTDMBCkuah41uZmt3 X-Gm-Gg: AZFdTZc8MPwNUf8Y09KGG88LgkQevqWe67wpGXY3XnPt5DCMA+XYlyNqR1FmIoKUuz5 AvyeH+TrQcrQozQOsybu12H1WN0fPBJ7zqtXEFOV0YJu+7DVpMpC3NAA7gogJ/LnP8a40xK+dh5 3ES2kmpjDwoD+bPFlxQJIULWgnSmxnPiFxzLEr+XayaTF/JGfwEKr28RfIM4lhuZ88UWB4NxCX2 C5TPfIOfpHOmpQHRLVHjOLjA5AZW8hydtMhVUE+1Uw6ZPw2QANQ+XcK0O95pWSJyWFUjYbVkt0m Mv10VQfmszWG98vFqnJsSxnXdOgPVvHWZxn1qqpjRVggSNSs1YaRdF9eVAksF5VKwYwZRZ0cCTE +6nG+gRsh5UvtQqqJnDYXEawEfvF2EhTeb+LaIlghmZt+R8G5Arue5a3xgAot3rEB1Crd2o0n1H ZHscDXwl6eatpcRSKnqEnOZZ375X1CR3zyJjhfkTy7Py8z7hO6z8HV90MPSYLKtKP/re/R2HxWO HpjwoJnGzbfAbKdmMYVzik1cVPSmgLUDfjfWprtfgWWgX3h6BnO6qmd8yLqg3kmEGfvvVn6qEso dj/hATTCFfZf++wzkn8e7DckwnEtix0dW4hIvdvIxtVST/FFG92W X-Received: by 2002:a05:6300:4049:b0:3e2:4e6e:6ca3 with SMTP id adf61e73a8af0-4014e45d179mr27314140637.34.1796111738929; Mon, 30 Nov 2026 23:55:38 -0800 (PST) Received: from [127.0.0.1] ([43.132.141.20]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c87344184fsm19733898b3a.35.2026.11.30.23.55.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 23:55:38 -0800 (PST) From: zhuorao yang To: Jamal Hadi Salim , Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn Cc: netdev@vger.kernel.org Subject: [PATCH net] net/sched: cls_u32: fix hnode UAF in u32_change Date: Tue, 1 Dec 2026 15:50:58 +0800 Message-ID: <20261201075058.64049-1-alex000young@gmail.com> X-Mailer: git-send-email 2.56.0 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 Content-Transfer-Encoding: 8bit u32_change() looks up a non-root hash node and keeps only a bare pointer while it allocates a filter handle in that node. The subsequent action initialization can drop RTNL to request an unregistered action module. A concurrent RTM_DELTFILTER can then delete and eventually free the hash node. When action initialization fails, the error cleanup removes the handle from the hash node's IDR through the stale pointer, causing a use-after-free read and write. Hold a reference on the hash node from before action initialization until all uses of the pointer on both the success and error paths are complete. This makes a concurrent deletion return -EBUSY. Fixes: e7614370d6f0 ("net_sched: use idr to allocate u32 filter handles") Signed-off-by: zhuorao yang --- Vulnerability report Affected versions: Linux 7.4.0-rc5 at fe6ff8d5d675c01793b9f051d16055dd4aa75244; the defect dates to v4.15 and applies to later kernels with CONFIG_NET_CLS_U32. Trigger conditions: CONFIG_NET_CLS_U32 and CONFIG_NET_CLS_ACT, with CAP_NET_ADMIN in the target network namespace. An RTM_NEWTFILTER request selects a non-root hash node and references an unregistered tc action, so request_module() drops RTNL. A concurrent RTM_DELTFILTER can delete the hash node during that window. Reproducer status: A QEMU test with a test-only modprobe delay showed that the unpatched kernel deletes the hash node and later runs idr_remove() through the stale pointer; kprobes recorded the destroyed IDR and the later access. With the patch, concurrent deletion returns -EBUSY and the error path only accesses the live hash node. Reproducer material is available to maintainers on request. Reproducer material is intentionally withheld from this public message. AI assistance: DeepSeek identified the issue and drafted the patch. The submitter reviewed the code and certified the Developer Certificate of Origin. net/sched/cls_u32.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 91f4e6458785..506640323335 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -1188,6 +1188,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, } #endif + refcount_inc(&ht->refcnt); err = u32_set_parms(net, tp, n, tb, tca[TCA_RATE], flags, n->flags, extack); @@ -1216,6 +1217,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, rcu_assign_pointer(*ins, n); tp_c->knodes++; *arg = n; + refcount_dec(&ht->refcnt); return 0; } @@ -1235,6 +1237,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, kfree(n); erridr: idr_remove(&ht->handle_idr, handle); + refcount_dec(&ht->refcnt); return err; } -- 2.56.0