From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1271D41F362; Thu, 30 Jul 2026 14:47:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785422846; cv=none; b=E2rvbWZDkHKtQolHwNNscKgLPKWSRQ/6Onn+qupgH/eqJ/LLzwRINXTwUR7dUuqAGQzWnWhh3ka81ZtX7rOSCl3IoSK0QUkt/Q9qAPYxuABoKyEAbVOH3JEq4AL7ptEGjAodOKsybAjKCYCA8VdwXWMKPneYiawfqVwPBnZA37s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785422846; c=relaxed/simple; bh=JSI8Lx5IkbnHfXiNsgn/55XliJH1SwN1hgCcahbLdwY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HxZF9EIQoQB7zl2Uqs1skOi+SSqD8KNkBpHktCsj/iSVZF7pTcqbZ0Bobr1ywqOYt0jiJTNBYyIHaPAEwb8iAgOHH12iQYC5cyzCub3EAOKOIRobKKPdeeWlu/hqUOHNdSvWWFHlUU07qYwYbdNtgryiNC7jui0vY5wY7n8DKG4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uzjtaePQ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="uzjtaePQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 275B31F00A3A; Thu, 30 Jul 2026 14:47:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1785422844; bh=JQwdc+uekTT/OoPTlwPxg4+onhAbY+Ae2pPcMzh3qcA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uzjtaePQrgeNlngAcLGuj3PSuKEdogkaOldTXgdRMz2ncpX0YGZmXF9SIE7nHqPR8 FS1MijLdJfy0BxMbwitB3MuDAZJusIX0aVJTGeo3M+nF0/Yn4UFKZ4xsGuzdVVrW18 miIFQmgu+akLQLrpL3q4VDqdMH9zjp3XQYKS7eNo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, AutonomousCodeSecurity@microsoft.com, Yuan Tan , "Cen Zhang (Microsoft)" , NeilBrown , Herbert Xu Subject: [PATCH 7.1 576/744] rhashtable: clear stale iter->p on table restart Date: Thu, 30 Jul 2026 16:14:09 +0200 Message-ID: <20260730141456.526605524@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260730141444.267951807@linuxfoundation.org> References: <20260730141444.267951807@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cen Zhang (Microsoft) commit 8173f7e2ce67e6ca1d4763f3da14e5b01ce77456 upstream. rhashtable_walk_start_check() has two restart paths when resuming a walk. When iter->walker.tbl is valid, it re-validates iter->p against the table and sets iter->p = NULL if the object is gone. When iter->walker.tbl is NULL (table was freed during resize), it resets slot and skip but forgets to clear iter->p. rhashtable_walk_next() then dereferences the stale iter->p, reading freed memory. This is a use-after-free. Any caller that does multi-fragment rhashtable walks across walk_stop/walk_start boundaries is affected. Concrete cases include netlink_diag (__netlink_diag_dump in net/netlink/diag.c) and TIPC (tipc_nl_sk_walk in net/tipc/socket.c). Crash stack (netlink_diag): BUG: KASAN: slab-use-after-free in rhashtable_walk_next+0x365/0x3c0 Read of size 8 at addr ffff88801a9d2438 (freed kmalloc-2k, offset 1080) Call Trace: rhashtable_walk_next+0x365/0x3c0 (lib/rhashtable.c:1016) __netlink_diag_dump+0x160/0x760 (net/netlink/diag.c:122) netlink_diag_dump+0xc2/0x240 netlink_dump+0x5bc/0x1270 netlink_recvmsg+0x7a3/0x980 sock_recvmsg+0x1bc/0x200 __sys_recvfrom+0x1d4/0x2c0 Fixes: 5d240a8936f6 ("rhashtable: improve rhashtable_walk stability when stop/start used.") Cc: Reported-by: AutonomousCodeSecurity@microsoft.com Reported-by: Yuan Tan Closes: https://lore.kernel.org/linux-crypto/CAB8m9Wh559e+=n8z51gB8DrbEyCc2mc0MgGjrRR6_VXBmU=2AQ@mail.gmail.com Signed-off-by: Cen Zhang (Microsoft) Reviewed-by: NeilBrown Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- lib/rhashtable.c | 1 + 1 file changed, 1 insertion(+) --- a/lib/rhashtable.c +++ b/lib/rhashtable.c @@ -776,6 +776,7 @@ int rhashtable_walk_start_check(struct r iter->walker.tbl = rht_dereference_rcu(ht->tbl, ht); iter->slot = 0; iter->skip = 0; + iter->p = NULL; return -EAGAIN; }