From a350f216b30c5841b8eb0303c9c3fd32a2b2245b Mon Sep 17 00:00:00 2001 From: Daniel Pinto Date: Tue, 17 Apr 2018 01:31:49 +0100 Subject: [PATCH 1/2] Fix crash when calling openat with sandbox enabled #25440 The seccomp rule for the openat syscall checks for the AT_FDCWD constant. Because this constant is usually a negative value, a cast to unsigned int is necessary to make sure it does not get converted to uint64_t used by seccomp. More info on: https://github.com/seccomp/libseccomp/issues/69#issuecomment-273805980 --- src/common/sandbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/sandbox.c b/src/common/sandbox.c index 3d27ea66b5..0a972d496b 100644 --- a/src/common/sandbox.c +++ b/src/common/sandbox.c @@ -469,7 +469,7 @@ allow_file_open(scmp_filter_ctx ctx, int use_openat, const char *file) { if (use_openat) { return seccomp_rule_add_2(ctx, SCMP_ACT_ALLOW, SCMP_SYS(openat), - SCMP_CMP_STR(0, SCMP_CMP_EQ, AT_FDCWD), + SCMP_CMP(0, SCMP_CMP_EQ, (unsigned int)AT_FDCWD), SCMP_CMP_STR(1, SCMP_CMP_EQ, file)); } else { return seccomp_rule_add_1(ctx, SCMP_ACT_ALLOW, SCMP_SYS(open), From 27a2a6cb9b8a590a88c479539efae7bd31a4102f Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 8 Aug 2018 09:26:21 -0400 Subject: [PATCH 2/2] Changes file for 25440 --- changes/bug25440 | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changes/bug25440 diff --git a/changes/bug25440 b/changes/bug25440 new file mode 100644 index 0000000000..f8d9dd4fab --- /dev/null +++ b/changes/bug25440 @@ -0,0 +1,5 @@ + o Minor bugfixes (linux seccomp2 sandbox): + - Fix a bug in out sandboxing rules for the openat() syscall. + Previously, no openat() call would be permitted, which would break + filesystem operations on recent glibc versions. Fixes bug 25440; + bugfix on 0.2.9.15. Diagnosis and patch from Daniel Pinto.