Re: [PATCH 11/15] hugetlbfs: do not grow a sealed file in mmap()

From: Muchun Song

Date: Wed Nov 04 2026 - 04:59:50 EST




> On Oct 29, 2026, at 04:13, David Hildenbrand (Arm) <david@xxxxxxxxxx> wrote:
>
> From: Chris Mason <mason@xxxxxxxxxx>
>
> hugetlbfs_file_mmap() grows a file when a writable mapping extends beyond
> EOF. We are missing seal checks similar to hugetlbfs_setattr() and
> hugetlbfs_fallocate(), allowing a user to grow a file that has F_SEAL_GROW
> set.
>
> To fix it, skip the resize when F_SEAL_GROW is set; mmap() still succeeds
> without growing the file.
>
> We currently also allow CoW mappings to grow a file. Disallowing this,
> maybe even only for read-only file descriptors, could break existing
> userspace, so we have to be more careful. QEMU's file backend is an
> example user that might rely on such things, and would suddenly start
> getting SIGBUS when faulting in memory outside EOF.
>
> So be careful and focus on F_SEAL_GROW for now.
>
> Fix generated by an LLM and sent by Chris Mason in private.
>
> Fixes: ff62a3421044 ("hugetlb: implement memfd sealing")
> Cc: stable@xxxxxxxxxx
> Signed-off-by: Chris Mason <mason@xxxxxxxxxx>
> [ david: drop comment; simplify+extend description ]
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

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

Thanks.