Re: [PATCH] btrfs: do not leak -ERESTARTSYS from FITRIM to userspace

From: zhiwei . liang

Date: Wed Oct 28 2026 - 16:13:59 EST


> > static inline bool btrfs_trim_interrupted(void)
> > {
> > - return fatal_signal_pending(current) || freezing(current);
> > + return fatal_signal_pending(current) ||
> > + (freezing(current) && signal_pending(current));
>

> What if pm freeze has began but a real signal is also pending before the
> fake pm signal?

I think when a real signal is already pending as the freeze begins, both
freezing(current) and signal_pending(current) are true, so the loop stops
with -ERESTARTSYS, same as for any interrupted syscall. On the way back
to user mode the task is parked for the suspend first, and the real
signal is handled after thaw.

That said, I agree the ext4/xfs approach is the better fix. Luca's series
doing that supersedes this patch.

One correction to my tags: 69313850dce3 was never backported to 5.15 or
6.1, only 6.6.y and later have it, so the stable range should have been
6.6+ rather than 5.15+.

Attachment: signature.asc
Description: OpenPGP digital signature