Re: [BUG] fanotify: destroy/add race leaves a mark on a detached connector

From: Amir Goldstein

Date: Thu Sep 03 2026 - 09:23:39 EST


On Wed, Sep 2, 2026 at 11:51 PM Daehyeon Ko <4ncienth@xxxxxxxxx> wrote:
>
> Hi Amir,
>
> I was able to make the handle-reopen sequence reliable on ext4 and drafted
> an LTP test for it.
>
> The test keeps 120 auxiliary inode marks on the victim to widen the interval
> after the first FAN_DELETE_SELF, pins the unlink and handle-reopen workers to
> different CPUs, and has the reopen worker read the event queue nonblocking
> before calling open_by_handle_at().
>
> I ran the exact final test for 100 iterations in each of two fresh 2-vCPU
> KASAN boots per kernel:
>
> - unmodified v7.2: 200/200 iterations reopened the unlinked inode, and
> closing the reopened fd generated a second FAN_DELETE_SELF;
> - v7.2 with your patch: 200/200 iterations returned ESTALE from
> open_by_handle_at(), with no duplicate FAN_DELETE_SELF.
>
> The test is based on LTP master commit
> 12724413534a6d4160ff9694ba6f09daa4ccb6bd. The attached patch adds
> fanotify26 and the corresponding build and runtest entries.

Very nice!

I think we should wait for Christian to pick up the fix or suggest an
alternative, but after that please post this test to LTP.

Thanks for following up on this!
Amir.