From nobody Sat Jul 25 03:46:05 2026 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 200DE380FD1 for ; Sun, 19 Jul 2026 17:50:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784483456; cv=none; b=txeYLYU5JRy4jvZHDrbqXzDuGfavVzOX2iUCzYaR1zGzs0Gj+4xpnzysZFMFHUCR9EYDpTRQVxRd7ui+JstT10bMq7PWZqmK1n04Tn43w5fWnFVfHBMRPl8YS4NVBO1CgUASId038Qc9rU0zZa0M8iyn/x1DU1GXoxqI2KlJMq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784483456; c=relaxed/simple; bh=1pN32S2baW0QTY05fmozR5sB5cIXnuaBLTrX1Su/s9Q=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=AFbB3qfC+yFyaMvmypo+tVHD4TQw0oG9aZ6Rq6bNtuGsKmhYpa+e/crca48juEQYWGTrQqJY+iOIrujFdEq/SoQ+7MfTdnqEikcgJn1IbFh5kAy3xbLlizI9fbUqHkEzIR6aCrqx9qY1ZAxYmW0gFOMf3XQyqFFXs5GQVNDhOYk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bvJtKtV5; arc=none smtp.client-ip=209.85.216.47 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.b="bvJtKtV5" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-385ea3ce80dso9408741a91.2 for ; Sun, 19 Jul 2026 10:50:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784483454; x=1785088254; 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=W6kSz/qjXQ0gTFAPWdJ8WtRiGAzWRY2MZwa0jKAIf2A=; b=bvJtKtV5VxaBWBvksjALdqenXnw30sZXqrjneIx2V5yAO6+lBV9ej+jDdbUnobx7zB kn35Dwiiv9UORrHfTZ71zX+xjIvGvFmQecbC6v+zBGyFZpRrtvdXhGP+F6dvl9vqpAqu zdSbEs5263U0Ni3wQ2x8+xIU6MZZz53L/RbcuIAnRlHgAEI07WJy5W9ifhU4dMfwTxx0 PwvRBO+uOBzWfQRO2MrOvPd4I4xJrKqWhkkKBrPn6NhELLeF05qsOsBlupQigKog7BhE NGPLEOpKOh2ucJGIhQH2zT26yPWDbnzKeE3rT3jbXPVAOhgdkmfDq5eLP8zP0ybR6q0C 3Vfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784483454; x=1785088254; 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=W6kSz/qjXQ0gTFAPWdJ8WtRiGAzWRY2MZwa0jKAIf2A=; b=Y5lkgZzHkkOOjKHMi2IEefJUCpw8tDvbEhq0r6a2J/oa1TIC0yi9bsDTxEUoNHGoKw x2x6W3Wc04utByB3iNarSBt6xXxS6GTYgo7pCtmMn/wZRfwSNSwz1y7KRgnVpNNmZ26G BpiHTrocxY39PKDfiqFaFpVb/SIIkjtT7OFo2JMamZ1V7WAO+QPRjHDoF30oBUiohfT5 9jRFDevBGkGggHcnKJMxEVdru9j/rhIK9vxX3xn2YtfDvVrUxsDzW+73rou4dAY4pU+y fHNhaMUubjH0aU+uiy6Xh17BxGT24EQ26T0dgGuVFJui84hAax0/Vx5l54Enq2v71bcu xzKQ== X-Forwarded-Encrypted: i=1; AHgh+Ro1in8+CHuO+2d4SIIMeTbPxJDO/q7NJTHYNm9aiiM7dUk4L+AIO0fidX6qqXwOGRrAXR6gUweIaZKdTas=@vger.kernel.org X-Gm-Message-State: AOJu0Yz+cSoNAMfF+AXpO+afzzMKJTHW+NeWG99wmifWTB+eItRGMC9k znm1otaf8IXDFx6EyMWbOtTK1FAWNjl5s4TBUtITNIay1PjzhwsyM2+u X-Gm-Gg: AfdE7cn2zJBivxofL1Jv9iMZuKG4/9BOOUr3MAWMU4Yt27131M6QnG5SHObnMnIpMoT JpWfnnEiYsbnwEUwD5BNmMxMD+bQpqrFK3xQ6YO2VxNW1WjnzMz14B30I6TZgYqB4dv/1DrATMK Eavvawal9uc2+nG7s1Ns1tJ7wWoLu9wYK/p9s756cIliebc3opoNoXIuJojtW+Rhk5CJOdhgAoe PYCg8laNwT7iWWYfws5OIb2Fduk6oDjJ1tfuHXdFOJvJhBIeg6qsyVbZnDbE+g/ew9AJrxEHf46 k9Q4PJGFKPNRxIdemdJUpWItTkjc60Ewrdx46sMY/4kFF+wQ0l/AKABgpdgZCAjN0cUf7NXvi8V mvLQQeAoQn5/Pxm3/tuXXoEfKQWCkhpc2H/WIbCy9ZLEL2FPp2429isMykXug08fUiq/xAFrLa1 fGv6kCiD7o6QOCGnx6MKGjH/jTi+k0zPEAvVwDLRO2dYEB7tU= X-Received: by 2002:a17:90a:d40f:b0:38e:542:6485 with SMTP id 98e67ed59e1d1-38e4b4461e1mr11236442a91.12.1784483454468; Sun, 19 Jul 2026 10:50:54 -0700 (PDT) Received: from fx.tailc0aff1.ts.net ([206.206.192.132]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13ce29c2a48sm20625345c88.2.2026.07.19.10.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jul 2026 10:50:53 -0700 (PDT) From: Weiming Shi To: Jakub Kicinski , Andrew Lunn , "David S . Miller" , Eric Dumazet , Paolo Abeni Cc: Pablo Neira Ayuso , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Xiang Mei , Weiming Shi , stable@vger.kernel.org Subject: [PATCH net] netdevsim: tc: serialize access to nsim_block_cb_list Date: Sun, 19 Jul 2026 10:50:29 -0700 Message-ID: <20260719175028.988301-2-bestswngs@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" nsim_setup_tc() passes a single global nsim_block_cb_list, shared by every netdevsim device, to flow_block_cb_setup_simple(). That helper does list_add_tail()/list_del() on the list on block bind/unbind and walks it in flow_block_cb_is_busy(); it takes no lock of its own and relies on the caller for serialization. The tc control path calls ndo_setup_tc(TC_SETUP_BLOCK) under rtnl, but the nf_tables hardware offload path reaches it under the per-netns nftables commit_mutex only. Two nft transactions committing offload chains from different netns thus run flow_block_cb_setup_simple() on the same list concurrently, corrupting it and freeing a flow_block_cb that the other CPU still walks: list_del corruption. prev->next should be ffff88801f18ff00, but was ffff88= 801de82b00. kernel BUG at lib/list_debug.c:62! RIP: 0010:__list_del_entry_valid_or_report (lib/list_debug.c:62) flow_block_cb_setup_simple (net/core/flow_offload.c:369) nsim_setup_tc (drivers/net/netdevsim/tc.c) nft_block_offload_cmd (net/netfilter/nf_tables_offload.c:394) nft_flow_rule_offload_commit (net/netfilter/nf_tables_offload.c:585) nf_tables_commit (net/netfilter/nf_tables_api.c:10490) nfnetlink_rcv_batch (net/netfilter/nfnetlink.c:577) nfnetlink_rcv (net/netfilter/nfnetlink.c:649) netlink_unicast (net/netlink/af_netlink.c:1314) netlink_sendmsg (net/netlink/af_netlink.c:1889) __sys_sendto (net/socket.c:729) With KASAN the same race is reported as a slab-use-after-free read of the freed flow_block_cb (kmalloc-192) in flow_block_cb_setup_simple(). The trace above is from a 6.12.y reproduction. Serialize the list with a mutex. ndo_setup_tc(TC_SETUP_BLOCK) always runs in process context, so sleeping on the mutex is fine. Fixes: 955bcb6ea0df ("drivers: net: use flow block API") Reported-by: Xiang Mei Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Weiming Shi --- drivers/net/netdevsim/tc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/netdevsim/tc.c b/drivers/net/netdevsim/tc.c index a415e02a6df1..30dd7f924b71 100644 --- a/drivers/net/netdevsim/tc.c +++ b/drivers/net/netdevsim/tc.c @@ -72,11 +72,13 @@ static int nsim_setup_tc_ets(struct net_device *dev, } =20 static LIST_HEAD(nsim_block_cb_list); +static DEFINE_MUTEX(nsim_block_cb_lock); =20 int nsim_setup_tc(struct net_device *dev, enum tc_setup_type type, void *type_= data) { struct netdevsim *ns =3D netdev_priv(dev); + int err; =20 switch (type) { case TC_SETUP_QDISC_TAPRIO: @@ -84,10 +86,13 @@ nsim_setup_tc(struct net_device *dev, enum tc_setup_typ= e type, void *type_data) case TC_SETUP_QDISC_ETS: return nsim_setup_tc_ets(dev, type_data); case TC_SETUP_BLOCK: - return flow_block_cb_setup_simple(type_data, - &nsim_block_cb_list, - nsim_setup_tc_block_cb, - ns, ns, true); + mutex_lock(&nsim_block_cb_lock); + err =3D flow_block_cb_setup_simple(type_data, + &nsim_block_cb_list, + nsim_setup_tc_block_cb, + ns, ns, true); + mutex_unlock(&nsim_block_cb_lock); + return err; case TC_SETUP_FT: return 0; default: --=20 2.43.0