Re: [PATCH v2] mm/hugetlb: stop hashing address_space pointers for fault mutexes

From: Muchun Song

Date: Sat Dec 05 2026 - 21:53:46 EST




> On Dec 6, 2026, at 08:42, Zhengchuan Liang <zcliangcn@xxxxxxxxx> wrote:
>
> 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.
>
> Fixes: 8382d914ebf7 ("mm, hugetlb: improve page-fault scalability")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Zhengchuan Liang <zcliangcn@xxxxxxxxx>

Acked-by: Muchun Song (ByteDance) <muchun.song@xxxxxxxxx>

Thanks.