Commit 20c715e2 authored by Carlos Garnacho's avatar Carlos Garnacho

libtracker-common: Whitelist openat()

With the same caveats than open().

https://bugzilla.gnome.org/show_bug.cgi?id=782514
parent 5ee8251e
......@@ -182,8 +182,8 @@ tracker_seccomp_init (void)
SCMP_CMP(0, SCMP_CMP_EQ, 2)) < 0)
goto out;
/* Special requirements for open, allow O_RDONLY calls, but fail
* if write permissions are requested.
/* Special requirements for open/openat, allow O_RDONLY calls,
* but fail if write permissions are requested.
*/
if (seccomp_rule_add (ctx, SCMP_ACT_ALLOW, SCMP_SYS(open), 1,
SCMP_CMP(1, SCMP_CMP_MASKED_EQ, O_WRONLY | O_RDWR, 0)) < 0)
......@@ -195,6 +195,16 @@ tracker_seccomp_init (void)
SCMP_CMP(1, SCMP_CMP_MASKED_EQ, O_RDWR, O_RDWR)) < 0)
goto out;
if (seccomp_rule_add (ctx, SCMP_ACT_ALLOW, SCMP_SYS(openat), 1,
SCMP_CMP(2, SCMP_CMP_MASKED_EQ, O_WRONLY | O_RDWR, 0)) < 0)
goto out;
if (seccomp_rule_add (ctx, SCMP_ACT_ERRNO (EACCES), SCMP_SYS(openat), 1,
SCMP_CMP(2, SCMP_CMP_MASKED_EQ, O_WRONLY, O_WRONLY)) < 0)
goto out;
if (seccomp_rule_add (ctx, SCMP_ACT_ERRNO (EACCES), SCMP_SYS(openat), 1,
SCMP_CMP(2, SCMP_CMP_MASKED_EQ, O_RDWR, O_RDWR)) < 0)
goto out;
g_debug ("Loading seccomp rules.");
if (seccomp_load (ctx) >= 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment