[PR #1359] [MERGED] Fix race condition when setting up /run/firejail files (#1013) #3925

Closed
opened 2026-05-05 10:10:29 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netblue30/firejail/pull/1359
Author: @BafDyce
Created: 6/30/2017
Status: Merged
Merged: 6/30/2017
Merged by: @netblue30

Base: masterHead: fix-1013


📝 Commits (1)

  • 968dc2a Fix race condition when setting up /run/firejail files (#1013)

📊 Changes

1 file changed (+3 additions, -1 deletions)

View changed files

📝 src/firejail/util.c (+3 -1)

📄 Description

This attempts to fix #1013

Which is caused by a race condition in create_empty_dir_as_root between stat and mkdir.

Note 1: I'm not quite sure what the comment /* coverity[toctou] */ does. Is it necessary that it stays in the line right above to the if statement? If yes, please tell me, then I'll reorder the comments.

Note 2: There are a bunch of calls to mkdir throughout the code, some of them behind a similar stat-gate. Should I also add a similar change to these?

Note 3: For testing, I forced race conditions by inserting a sleep right after the call to stat


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netblue30/firejail/pull/1359 **Author:** [@BafDyce](https://github.com/BafDyce) **Created:** 6/30/2017 **Status:** ✅ Merged **Merged:** 6/30/2017 **Merged by:** [@netblue30](https://github.com/netblue30) **Base:** `master` ← **Head:** `fix-1013` --- ### 📝 Commits (1) - [`968dc2a`](https://github.com/netblue30/firejail/commit/968dc2aba10e9b2c5c8d2975cde1337cf7586dea) Fix race condition when setting up /run/firejail files (#1013) ### 📊 Changes **1 file changed** (+3 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/firejail/util.c` (+3 -1) </details> ### 📄 Description This attempts to fix #1013 Which is caused by a race condition in `create_empty_dir_as_root` between `stat` and `mkdir`. Note 1: I'm not quite sure what the comment `/* coverity[toctou] */` does. Is it necessary that it stays in the line right above to the if statement? If yes, please tell me, then I'll reorder the comments. Note 2: There are a bunch of calls to `mkdir` throughout the code, some of them behind a similar `stat`-gate. Should I also add a similar change to these? Note 3: For testing, I forced race conditions by inserting a sleep right after the call to `stat` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 10:10:29 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/firejail#3925
No description provided.