Bug 275570 - self-referential nullfs mount over tmpfs in combination with MNT_UPDATE results in a hang
Summary: self-referential nullfs mount over tmpfs in combination with MNT_UPDATE resul...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 14.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-fs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-06 13:48 UTC by Alex S
Modified: 2023-12-13 01:49 UTC (History)
4 users (show)

See Also:


Attachments
deadlock.c (2.12 KB, text/plain)
2023-12-06 13:48 UTC, Alex S
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex S 2023-12-06 13:48:25 UTC
Created attachment 246821 [details]
deadlock.c

Update the issue title as you see fit.

The attached repro works in 14 and CURRENT. I admit mounting a path on itself is a bit silly (and probably should be forbidden), but the hang is still worth a look.
Comment 1 Kyle Evans freebsd_committer freebsd_triage 2023-12-13 01:37:32 UTC
Let's start with dfr@, since the sample in question is specifically null-mounting a file over itself.

With the deadlock.c attached, I hit it best with a stupid simple loop:

```
#!/bin/sh

iteration=1

while true; do
        echo "Iteration $iteration"
        ./a.out
        iteration=$((iteration + 1))
done
```

Took me about 15 tries. When it deadlocks on my machine, it's in the nmount(2) that would be null-mounting the file over itself rather than the follow-up MNT_UPDATE of the tmpfs mount holding it.
Comment 2 Kyle Evans freebsd_committer freebsd_triage 2023-12-13 01:49:37 UTC
Oh, let's CC pho@ too, as this might have some good inspiration for his testing...