Skip to content

Do not clean tempdir if we fail to unmount#2245

Open
Johan-Liebert1 wants to merge 1 commit into
bootc-dev:mainfrom
Johan-Liebert1:tmpdir-fix
Open

Do not clean tempdir if we fail to unmount#2245
Johan-Liebert1 wants to merge 1 commit into
bootc-dev:mainfrom
Johan-Liebert1:tmpdir-fix

Conversation

@Johan-Liebert1

@Johan-Liebert1 Johan-Liebert1 commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Ran into this issue by chance in bootupd where the following drop ordering

drop(tempdir)
drop(mount) // unmounts thing mounted at tempdir

was causing all the contents of the mounted device to be deleted because the tempdir was being deleted. We might run into the same issue with our Tempdir impl if we fail to unount the ESP and tempdir is dropped deleting everything in the ESP.

To prevent that, explicitly set disable_cleanup to false on the Tempdir and only enable cleanup after we've successfully unmounted whatever was mounted

Ran into this issue by chance in bootupd where the following drop ordering

```rust
drop(tempdir)
drop(mount) // unmounts thing mounted at tempdir
```

was causing all the contents of the mounted device to be deleted because
the tempdir was being deleted. We might run into the same issue with our
Tempdir impl if we fail to unount the ESP and tempdir is dropped
deleting everything in the ESP.

To prevent that, explicitly set `disable_cleanup` to false on the Tempdir
and only enable cleanup after we've successfully unmounted whatever was
mounted

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>

@cgwalters cgwalters left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that is horrifying.

How about this instead: We have a MountpointTempdir whose Drop only does rmdir (not recursively).

Of course, in many cases I think the real fix here is for us to always use the new mount API to just mount a fd, not a tempdir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants