From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796530189; b=GrBlACYVUsvFQ4WfReT8f7Aiss8yFFvvj4mVz0bDQ0oQM8QuiyYXCIV/QisWx9lH7L2D d/v5zy25ksiznN7Arbrbll0BCjBWkyKu55w+AxLPS556v7gcrgfgZ0li1Bh0jgJrjKKj4 TCoXhgydIVA/2QwYo6yZjAFTJVU26H58WsuVeyy1/llioqg2uL2TNGE+H8H5xpUHdGtkA pfELECMe8CCRzi51IOmGFwsSMw1mRhLKFvlzDq7XFrMYNBI5EjhDxBZTY3OV2CXK7gjbf rtVFFoUxlPfnU78+vrhYiD2IaTM0uf7LtceX4RwlHMwapvlN/y3qrudFTiRvytOsi9w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796530189; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=wAjlm6P0MbVH/NbdioQwPdO2CEg62p+9xn5/GAOZ4kI=; b=0EsvKzNOM6ygjQQmXS6espf6mztpRVj/M5EqJuU1UGKaWfeWoNYA+qqGScEroSnqohNn MgkQThZVugrBDbyRT00JGydNc05QXDrCO5+EZEo9Dou06FlTJynabaiXrIX4LacZqsbX1 gBFBsBH6jP3vW/69sW6Sk7o1Rhxp/mYMcyzGZM9MHycEkPTpwst8DGPbhxt2Fg3TgvS5u 8U+LHlKBB38ibA5sYfWnhOF+PAo5e5aGPN3EFi9Fq9JBc2/FjOy1yB0u2LD+GUr2c/O00 XBKWfSZ15kfl1CMko66InSBNWZgkgqnoEgdh8H7RJmSBeTGOtOQkjJFJlRuc4OuUVvw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=zy6KX+74; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5327F606A31F; Sun, 6 Dec 2026 04:09:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=zy6KX+74 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A58831F0092B; Sun, 6 Dec 2026 04:09:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796530188; bh=wAjlm6P0MbVH/NbdioQwPdO2CEg62p+9xn5/GAOZ4kI=; h=Date:To:From:In-Reply-To:References:Subject; b=zy6KX+745XlI5DBJB2mQlwBEm3LkrVmmSkKbY9BUA1LXde6S/3ovUTL8Wj86j+jAv uxYQXjU5ONr/m3XBLKagODOSHqmsM7jzCVS5yXtPzNoG21zmCa8wrCqcAuZmfs/Xgt OgYLILXLDgnbv88AEcGd+EYvulWzyPJBtmlF1cYk= Date: Sat, 05 Dec 2026 20:09:48 -0800 To: mm-commits@vger.kernel.org,stable@vger.kernel.org,osalvador@suse.de, muchun.song@linux.dev,davidlohr@hp.com,david@kernel.org,zcliangcn@gmail.com, akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261206004239.3250411-1-zcliangcn@gmail.com> References: <20261206004239.3250411-1-zcliangcn@gmail.com> Subject: + mm-hugetlb-stop-hashing-address_space-pointers-for-fault-mutexes.patch added to mm-unstable branch Message-Id: <20261206040948.A58831F0092B@smtp.kernel.org> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: mm/hugetlb: stop hashing address_space pointers for fault mutexes has been added to the -mm mm-unstable branch. Its filename is mm-hugetlb-stop-hashing-address_space-pointers-for-fault-mutexes.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-hugetlb-stop-hashing-address_space-pointers-for-fault-mutexes.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Zhengchuan Liang Subject: mm/hugetlb: stop hashing address_space pointers for fault mutexes Date: Sat, 5 Dec 2026 16:42:39 -0800 hugetlb_fault_mutex_hash() hashes an address_space pointer and huge page index to select a mutex from a global table. An unprivileged process can exercise it by faulting a HugeTLB memfd mapped with MAP_NORESERVE. The mutex is selected before allocation, so the hash remains reachable when no huge pages are available and the fault returns SIGBUS. Fault timing under contention reveals whether chosen indices share a bucket. These collisions allow exact recovery of the mapping pointer over the allocator-valid address range. Since address_space is embedded at a fixed offset in struct hugetlbfs_inode_info, the leak also identifies the containing hugetlbfs_inode_cache object and replacement objects if its slab page is later reused. Hash only the page index and use mapping->host->i_ino as the seed. hugetlbfs assigns each inode a nonzero 32-bit value from get_next_ino() before exposing the inode, and the value remains stable for the inode's lifetime. jhash2() mixes the inode number before reducing the result to the mutex table size; the seed does not need to be unique, random, or secret. This keeps the same mapping and index on the same mutex while varying bucket selection by inode, without encoding a kernel address. Link: https://patch.msgid.link/20261206004239.3250411-1-zcliangcn@gmail.com Fixes: 8382d914ebf7 ("mm, hugetlb: improve page-fault scalability") Signed-off-by: Zhengchuan Liang Signed-off-by: Andrew Morton Acked-by: Muchun Song (ByteDance) Cc: Oscar Salvador Cc: David Hildenbrand Cc: Davidlohr Bueso Cc: mm/hugetlb.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) --- a/mm/hugetlb.c~mm-hugetlb-stop-hashing-address_space-pointers-for-fault-mutexes +++ a/mm/hugetlb.c @@ -6295,13 +6295,8 @@ backout_unlocked: #ifdef CONFIG_SMP u32 hugetlb_fault_mutex_hash(struct address_space *mapping, pgoff_t idx) { - unsigned long key[2]; - u32 hash; - - key[0] = (unsigned long) mapping; - key[1] = idx; - - hash = jhash2((u32 *)&key, sizeof(key)/(sizeof(u32)), 0); + const u32 hash = jhash2((u32 *)&idx, sizeof(idx) / sizeof(u32), + mapping->host->i_ino); return hash & (num_fault_mutexes - 1); } _ Patches currently in -mm which might be from zcliangcn@gmail.com are mm-hugetlb-stop-hashing-address_space-pointers-for-fault-mutexes.patch