Skip to content

udiskslinuxfilesystem: Fix TOCTOU race in mount point directory creation - #1515

Merged
tbzatek merged 1 commit into
storaged-project:masterfrom
ajax-semenko-d:master_mounting-toctou-fix
Aug 27, 2026
Merged

tbzatek merged 1 commit into
storaged-project:masterfrom
ajax-semenko-d:master_mounting-toctou-fix

Conversation

@ajax-semenko-d

Copy link
Copy Markdown
Contributor

Rename calculate_mount_point() to create_mount_point() and move the g_mkdir(2) call inside the uniquification loop. Using mkdir(2) as the existence check instead of g_file_test() + a separate mkdir(2) closes the window where two concurrent mount requests could compute the same candidate path and both succeed the test before either creates the directory.

On failure after the directory is already created, callers now call g_rmdir() to release the reserved directory before returning an error.

Fixes: #1513

@tbzatek tbzatek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sounds good and less racy, thanks! Please just rebase your branch.

Rename calculate_mount_point() to create_mount_point() and move the
g_mkdir(2) call inside the uniquification loop.  Using mkdir(2) as the
existence check instead of g_file_test() + a separate mkdir(2) closes
the window where two concurrent mount requests could compute the same
candidate path and both succeed the test before either creates the
directory.

On failure after the directory is already created, callers now call
g_rmdir() to release the reserved directory before returning an error.

Fixes: storaged-project#1513

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ajax-semenko-d
ajax-semenko-d force-pushed the master_mounting-toctou-fix branch from 31f9c0c to d0379bf Compare August 27, 2026 08:29
@packit-as-a-service

Copy link
Copy Markdown

Cockpit tests failed for commit d0379bf. @martinpitt, @jelly, @mvollmer please check.

@jelly

jelly commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

The rawhide tests fail on some mirror issue, so likely have to be retried:

Librepo error: Cannot download 10909659-cockpit/cockpit-storaged-366.dev34%2bgeceba97aa-1.fc46.noarch.rpm: All mirrors were tried

@ajax-semenko-d
ajax-semenko-d requested a review from tbzatek August 27, 2026 09:16
@tbzatek

tbzatek commented Aug 27, 2026

Copy link
Copy Markdown
Member

The rawhide tests fail on some mirror issue, so likely have to be retried:

I've noticed more Testing Farm breakage yesterday, looks like infra issues - unrelated, ignoring.

@tbzatek

tbzatek commented Aug 27, 2026

Copy link
Copy Markdown
Member

Jenkins, ok to test.

@tbzatek
tbzatek merged commit 5c1847d into storaged-project:master Aug 27, 2026
17 of 25 checks passed
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.

Mounting two filesystems with the same label at the same time fails with "File exists"

3 participants