Skip to content

Commit dfd43e9

Browse files
Sandboxed API Teamcopybara-github
authored andcommitted
sandbox2: Add LANDLOCK_ACCESS_FS_IOCTL_DEV for writable paths in Landlock mode.
PiperOrigin-RevId: 968652847 Change-Id: I4ab86d9e6729ba0838e1d9f929f7c607fd5ae716
1 parent f84dfdc commit dfd43e9

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

sandboxed_api/sandbox2/landlock.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,12 @@ void AddRulesRecursively(int ruleset_fd, const MountTree* tree,
200200
}
201201
if (writable) {
202202
// Include FS_TRUNCATE so writable paths support truncate(), ftruncate(),
203-
// and open(O_TRUNC)/creat().
204-
path_beneath.allowed_access |=
205-
LANDLOCK_ACCESS_FS_WRITE_FILE | LANDLOCK_ACCESS_FS_TRUNCATE;
203+
// and open(O_TRUNC)/creat(), and LANDLOCK_ACCESS_FS_IOCTL_DEV for ioctls.
204+
// TODO(cffsmith): Consider adding a separate function on the PolicyBuilder
205+
// to allow ioctls.
206+
path_beneath.allowed_access |= LANDLOCK_ACCESS_FS_WRITE_FILE |
207+
LANDLOCK_ACCESS_FS_TRUNCATE |
208+
LANDLOCK_ACCESS_FS_IOCTL_DEV;
206209
}
207210
if (is_dir) {
208211
path_beneath.allowed_access |= LANDLOCK_ACCESS_FS_READ_DIR;

0 commit comments

Comments
 (0)