diff --git a/tests/regression/apparmor/mount.c b/tests/regression/apparmor/mount.c index 73e771eec..9c66be204 100644 --- a/tests/regression/apparmor/mount.c +++ b/tests/regression/apparmor/mount.c @@ -114,6 +114,7 @@ static void usage(char *prog_name) fprintf(stderr, "Options are:\n"); fprintf(stderr, "-o flags sent to the mount syscall\n"); fprintf(stderr, "-d data sent to the mount syscall\n"); + fprintf(stderr, "-t type of synthetic filesystem (e.g. proc) for mount syscall\n"); exit(1); } @@ -121,12 +122,13 @@ int main(int argc, char *argv[]) { char *options = NULL; char *data = NULL; + char *type = NULL; int index; int c; char *op, *source, *target, *token; unsigned long flags = 0; - while ((c = getopt (argc, argv, "o:d:h")) != -1) { + while ((c = getopt (argc, argv, "o:d:t:h")) != -1) { switch (c) { case 'o': @@ -135,6 +137,9 @@ int main(int argc, char *argv[]) case 'd': data = optarg; break; + case 't': + type = optarg; + break; case 'h': usage(argv[0]); break; @@ -162,10 +167,18 @@ int main(int argc, char *argv[]) } if (strcmp(op, "mount") == 0) { - if (mount(source, target, "ext2", flags, data) == -1) { - fprintf(stderr, "FAIL: mount %s on %s failed - %s\n", - source, target, strerror(errno)); - return errno; + if (!type) { + if (mount(source, target, "ext2", flags, data) == -1) { + fprintf(stderr, "FAIL: mount %s on %s failed - %s\n", + source, target, strerror(errno)); + return errno; + } + } else { + if (mount(source, target, type, flags, data) == -1) { + fprintf(stderr, "FAIL: mount %s on %s failed - %s\n", + source, target, strerror(errno)); + return errno; + } } } else if (strcmp(op, "umount") == 0) { if (umount(target) == -1) { diff --git a/tests/regression/apparmor/mount.sh b/tests/regression/apparmor/mount.sh index f73e77531..37c5f3193 100755 --- a/tests/regression/apparmor/mount.sh +++ b/tests/regression/apparmor/mount.sh @@ -547,6 +547,12 @@ else runchecktest "UMOUNT (confined cap umount:ALL)" pass umount ${loop_device} ${mount_point} remove_mnt + # https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1597017 + # CVE-2016-1585 + genprofile cap:sys_admin "mount:options=(rw,make-slave) -> **" + runchecktest "MOUNT (confined cap mount -> mntpnt, CVE-2016-1585)" fail mount -t proc proc ${mount_point} + remove_mnt + # MR:https://gitlab.com/apparmor/apparmor/-/merge_requests/1054 # https://bugs.launchpad.net/apparmor/+bug/2023814 # https://bugzilla.opensuse.org/show_bug.cgi?id=1211989