Bug 275570

Summary: self-referential nullfs mount over tmpfs in combination with MNT_UPDATE results in a hang
Product: Base System Reporter: Alex S <iwtcex>
Component: kernAssignee: freebsd-fs (Nobody) <fs>
Status: New ---    
Severity: Affects Only Me CC: arrowd, dfr, kevans, pho
Priority: ---    
Version: 14.0-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
deadlock.c none

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...