]> www.infradead.org Git - users/jedix/linux-maple.git/commit
aio: mark AIO pseudo-fs noexec
authorJann Horn <jann@thejh.net>
Thu, 15 Sep 2016 22:31:22 +0000 (00:31 +0200)
committerTim Tianyang Chen <tianyang.chen@oracle.com>
Thu, 24 Aug 2017 21:08:20 +0000 (14:08 -0700)
commit9fdfc7ae569b7644af5c0fe4ff2cc8dee5c86a53
tree6596cb99090bfaad1dbf41597d87734693b21ef5
parentb6c65324836b91bfa3bbd8b4b9db2f0109216b44
aio: mark AIO pseudo-fs noexec

This ensures that do_mmap() won't implicitly make AIO memory mappings
executable if the READ_IMPLIES_EXEC personality flag is set.  Such
behavior is problematic because the security_mmap_file LSM hook doesn't
catch this case, potentially permitting an attacker to bypass a W^X
policy enforced by SELinux.

I have tested the patch on my machine.

To test the behavior, compile and run this:

    #define _GNU_SOURCE
    #include <unistd.h>
    #include <sys/personality.h>
    #include <linux/aio_abi.h>
    #include <err.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <sys/syscall.h>

    int main(void) {
        personality(READ_IMPLIES_EXEC);
        aio_context_t ctx = 0;
        if (syscall(__NR_io_setup, 1, &ctx))
            err(1, "io_setup");

        char cmd[1000];
        sprintf(cmd, "cat /proc/%d/maps | grep -F '/[aio]'",
            (int)getpid());
        system(cmd);
        return 0;
    }

In the output, "rw-s" is good, "rwxs" is bad.

Signed-off-by: Jann Horn <jann@thejh.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 22f6b4d34fcf039c63a94e7670e0da24f8575a5a)

Orabug: 26540416
CVE: CVE-2016-10044

Signed-off-by: Tim Tianyang Chen <tianyang.chen@oracle.com>
Reviewed-by: Jack Vogel <jack.vogel@oracle.com>
fs/aio.c