Skip to content

Commit 1d08e24

Browse files
committed
Added handling for calls to open and openat with write access when read-only mode is enforced
1 parent 3dbded8 commit 1d08e24

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: src/seccomp/policy/DefaultPolicy.cc

+10
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,16 @@ void DefaultPolicy::addFileSystemAccessRules(bool readOnly) {
188188
"openat",
189189
action::ActionAllow(),
190190
(filter::SyscallArg(2) & (O_RDWR | O_WRONLY)) == 0));
191+
for (const auto& mode: {O_RDWR, O_WRONLY}) {
192+
rules_.emplace_back(SeccompRule(
193+
"open",
194+
action::ActionErrno(EROFS),
195+
(filter::SyscallArg(1) & mode) == mode));
196+
rules_.emplace_back(SeccompRule(
197+
"openat",
198+
action::ActionErrno(EROFS),
199+
(filter::SyscallArg(2) & mode) == mode));
200+
}
191201

192202
for (const auto& syscall: {
193203
"unlink",

0 commit comments

Comments
 (0)