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 9FF1B3769F5; Thu, 30 Jul 2026 15:17:57 +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=1785424678; cv=none; b=lqF0jXh8FTL1u2B4U0qH8cJX8PabsCgJLleL4FVyGsQqr1DaXc9HzIXP5toWYHD0GAubApDW+8D/r01hZUhJvz00Gi74O/bPpy5iJcll++jjCF5Ht+lDdZSWVvrvuxqSzbdMtifIeBa2DFUZO6X1BdoVZ+gJJgW9+a/TJ9dgtY0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785424678; c=relaxed/simple; bh=blmpiq24J8Q3331Wt5O9G/TNBwpgf9yB8dCEAJ4Dmno=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AYsf2czRgimerl5pHkCiMPGEywr67UFEt61V6Wo29G7WrYk4Xw+/ulYw6bZLdj9XSvVjyWBO2Fa1bLI4obMkknx78GQTZgpZwvykNc0RRWFhuRD0EYmQOroaEHCBVGZpywM7/3p5ITpwdW/g9gijRySp01cyFOGKLZAU61l6Xt4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ruhNX5ym; 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="ruhNX5ym" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 086C11F000E9; Thu, 30 Jul 2026 15:17:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1785424677; bh=M8RZoeDSrR5NmlqvdZi4XhoQB3Wd9acCl2+nJYKDwlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ruhNX5ymf+9OqP8MyL8tUe2k9I/c/VnV5lkuPD/XT6QkHvkAh53v66NxVFOu0QOam EjxZ6eHExdWso2lNWxFG+9+qIqgAq7YrOOcj5jop7er4G4cleamwI9YGmxY6EGNo94 VPesRSzJ3NrX1B4yp5h5Ea5dvnBmGA+78zKWQxW8= 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 6.18 478/675] rhashtable: clear stale iter->p on table restart Date: Thu, 30 Jul 2026 16:13:28 +0200 Message-ID: <20260730141455.285311385@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260730141445.110192266@linuxfoundation.org> References: <20260730141445.110192266@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 6.18-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 @@ -742,6 +742,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; }