[tracker] libtracker-common: Whitelist dup/dup2/dup3



commit 435eca3325d2e27183de2e12c3d4cc840e362fb1
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Dec 17 15:45:21 2016 +0100

    libtracker-common: Whitelist dup/dup2/dup3
    
    dup2/3 have special requirements, as they can close underlying
    fds, they are not allowed on stdin/out/err.

 src/libtracker-common/tracker-seccomp.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-common/tracker-seccomp.c b/src/libtracker-common/tracker-seccomp.c
index 9906a6a..81ddb09 100644
--- a/src/libtracker-common/tracker-seccomp.c
+++ b/src/libtracker-common/tracker-seccomp.c
@@ -118,6 +118,7 @@ tracker_seccomp_init (void)
        ALLOW_RULE (fadvise64);
        ALLOW_RULE (write);
        ALLOW_RULE (writev);
+       ALLOW_RULE (dup);
        /* Needed by some GStreamer modules doing crazy stuff, less
         * scary thanks to the restriction below about sockets being
         * local.
@@ -168,6 +169,14 @@ tracker_seccomp_init (void)
                              SCMP_CMP(1, SCMP_CMP_MASKED_EQ, O_RDWR, O_RDWR)) < 0)
                goto out;
 
+       /* Special requirements for dup2/dup3, no fiddling with stdin/out/err */
+       if (seccomp_rule_add (ctx, SCMP_ACT_ALLOW, SCMP_SYS(dup2), 1,
+                             SCMP_CMP(1, SCMP_CMP_GT, 2)) < 0)
+               goto out;
+       if (seccomp_rule_add (ctx, SCMP_ACT_ALLOW, SCMP_SYS(dup3), 1,
+                             SCMP_CMP(1, SCMP_CMP_GT, 2)) < 0)
+               goto out;
+
        g_debug ("Loading seccomp rules.");
 
        if (seccomp_load (ctx) >= 0)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]