Re: [PATCH] overlayfs: mask d_type high bits before whiteout check
From: Amir Goldstein
Date: Thu Jan 08 2026 - 02:22:22 EST
On Thu, Jan 8, 2026 at 4:48 AM Chunsheng Luo <luochunsheng@xxxxxxxx> wrote:
>
>
>
> On 1/8/26 4:43 AM, Amir Goldstein wrote:
> > On Wed, Jan 7, 2026 at 4:46 AM Chunsheng Luo <luochunsheng@xxxxxxxx> wrote:
> >>
> >> Commit c31f91c6af96 ("fuse: don't allow signals to interrupt getdents
> >> copying") introduced the use of high bits in d_type as flags. However,
> >> overlayfs was not adapted to handle this change.
> >>
> >> In ovl_cache_entry_new(), the code checks if d_type == DT_CHR to
> >> determine if an entry might be a whiteout. When fuse is used as the
> >> lower layer and sets high bits in d_type, this comparison fails,
> >> causing whiteout files to not be recognized properly and resulting in
> >> incorrect overlayfs behavior.
> >>
> >> Fix this by masking out the high bits with S_DT_MASK before checking.
> >>
> >> Fixes: c31f91c6af96 ("fuse: don't allow signals to interrupt getdents copying")
> >> Link: https://github.com/containerd/stargz-snapshotter/issues/2214
> >> Signed-off-by: Chunsheng Luo <luochunsheng@xxxxxxxx>
> >
> > Hi Chunsheng,
> >
> > Thanks for the report and the suggested fix.
> >
> > This time overlayfs was surprised by unexpected d_type flags and next
> > time it could be another user.
> >
> > I prefer to fix this in a more profound way -
> > Instead of making overlafys aware of d_type flags, require the users that
> > use the d_type flags to opt-in for them.
> >
> > Please test/review the attached patch.
> >
> > Thanks,
> > Amir.
> >
>
> Thank you for the profound solution!
>
> The attached patch has been tested and verified to effectively address
> the d_type high bits usage issue by enforcing the opt-in mechanism.
>
> The variable `dt_flag_mask` might be clearer if renamed to
> `dt_flags_mask` (plural "flags").
Agreed.
>
> Reviewed-by: Chunsheng Luo <luochunsheng@xxxxxxxx>
> Tested-by: Chunsheng Luo <luochunsheng@xxxxxxxx>
>
Thanks for review and testing!
Amir.