Re: [PATCH v2 25/35] hugetlbfs: zero all hugetlbfs-specific fields of new inodes

From: Muchun Song

Date: Fri Dec 04 2026 - 01:41:05 EST




> On Dec 3, 2026, at 19:37, David Hildenbrand (Arm) <david@xxxxxxxxxx> wrote:
>
> hugetlbfs_get_inode() initializes the seals of new hugetlbfs inodes, and
> the hugetlbfs inode tracepoints record them.
>
> However, we don't initialize the seals in two cases:
>
> (1) For the root inode through hugetlbfs_get_root()
>
> (2) For an inode that alloc_inode() destroys right away because
> inode_init_always() failed.
>
> Consequently, when such an inode is evicted or destroyed with the
> tracepoints enabled, we record stale seals, and KMSAN reports an
> uninit-value.
>
> Reproduced by closing a hugetlb memfd with seals, and mounting and
> unmounting hugetlbfs with the hugetlbfs_evict_inode tracepoint enabled:
> the root inode reports the seals of the memfd.
>
> Let's fix it by zeroing all hugetlbfs-specific inode fields when
> allocating the inode in hugetlbfs_alloc_inode().
>
> We can now drop the manual initialization of resv_map in
> hugetlbfs_get_root().
>
> This has low urgency, as it only affects the tracepoints. No need to CC
> stable.
>
> Fixes: 318580ad7f28 ("hugetlbfs: support tracepoint")
> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

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

Thanks.