From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.137 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796525619; b=Jl0PNUuv5UFXv42GnT6CLxfvlUQYwwkx+kLMZ0NipvNbMHESYXGXyTuGhHTDC7aB5mgH sEKKL5GFgFnZzl3cEujbFz8HZJEIMvyMjlegL/JQVUIxYxWTwH+WqGsHEx1L8Iy5RdfIp P9/5AUbxWUwboZjdcpOZq0Kio/epoxia7pdf2TBJaVfkuCiZoZD1vl0yQxv0cCXUbC65K HFbbxUor2lciWe2A6RVoEWUomkB2WZVo223i6tOzdOcyj7aXk08uFeqRj10znSD5pj6yF C4IydVnhcM9NJqZcwbjF+w6IP3cYk/tMCjbt1IZaWrInmhTpVWWizs/uGowBTw3ZQLA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796525619; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Content-Type:Mime-Version:Subject:From: In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References: To:X-Mailer; bh=TFOlvLBf8TBQGV+Z92zvaxxIBfrppqs7fTCg8vRhEgQ=; b=e1PhLYkoSu54nyH/OK70zOXNWWHiCqiSs+03qmZ20G5zXXbUY8vPPIUuXjTZEO8l67Vq oJiTbAOExUz3jJ97NEByE5kcxLnCQsnbVlsdKvmn05bt45jQnLaJI2s6JbyP1AxFPAPKN 5+vx3uVtzdRue7YxJenjfQU5yu5pdrzlZJgTrQQ/O0z39o0Rqpjm7Dk3qWR9Flz7Bwmaa Z9d1nf5s+wTo36EXpJfdb4nabxpF0UFmb8IXk++btdxwh8mjxaWwaj6NNn8SQFKpKeJ/0 zaRl5iXUOy0e607Ax+AGx/drvmJRNF443yK0pPvet6o4cqHVhqGRK94mYEBJsiC23tw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=aGEn9BTH; arc=none smtp.remote-ip=91.218.175.137 Received: from mta0.migadu.com (out-137.mta0.migadu.com [91.218.175.137]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22F53606A31F for ; Sun, 6 Dec 2026 02:53:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 22F53606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=aGEn9BTH X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=5NNhGhGeGnDP21k81GdQtSlu/7a8m/gapHb6gyqgMw8=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796525616; v=1; x=1797130416; b=aGEn9BTHbKRepcqZu5isHaAdwf0vaOWWCbmMAOCHFkGU2pkKj1Krpc/89ns0P787o+D6zPB2 bIB3rgHeZMNbGODKx5VtTqTNbwbzQJuYOEPtrL1aRhXRxSIBxwSlBVQSfNE+CC9X4JyO0cYl3W7 1bpG+XF7REbjdyjT15303qEc= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 6ab2d6848286c078; Sun, 06 Dec 2026 02:53:36 +0000 X-Mizu-Trace-ID: 6ab2d6848286c078 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset=us-ascii X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3901.200.71.1.16\)) Subject: Re: [PATCH v2] mm/hugetlb: stop hashing address_space pointers for fault mutexes From: Muchun Song In-Reply-To: <20261206004239.3250411-1-zcliangcn@gmail.com> Date: Sun, 6 Dec 2026 10:53:21 +0800 Cc: Muchun Song , Oscar Salvador , David Hildenbrand , Andrew Morton , Davidlohr Bueso , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 7bit Message-Id: <1CFD7635-D3A6-42F6-9901-9E03FD43D2EB@linux.dev> References: <20261206004239.3250411-1-zcliangcn@gmail.com> To: Zhengchuan Liang X-Mailer: Apple Mail (2.3901.200.71.1.16) > On Dec 6, 2026, at 08:42, Zhengchuan Liang 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@vger.kernel.org > Signed-off-by: Zhengchuan Liang Acked-by: Muchun Song (ByteDance) Thanks.