1. 23 9月, 2017 6 次提交
    • J
      apparmor: add mount mediation · 2ea3ffb7
      John Johansen 提交于
      Add basic mount mediation. That allows controlling based on basic
      mount parameters. It does not include special mount parameters for
      apparmor, super block labeling, or any triggers for apparmor namespace
      parameter modifications on pivot root.
      
      default userspace policy rules have the form of
        MOUNT RULE = ( MOUNT | REMOUNT | UMOUNT )
      
        MOUNT = [ QUALIFIERS ] 'mount' [ MOUNT CONDITIONS ] [ SOURCE FILEGLOB ]
                [ '->' MOUNTPOINT FILEGLOB ]
      
        REMOUNT = [ QUALIFIERS ] 'remount' [ MOUNT CONDITIONS ]
                  MOUNTPOINT FILEGLOB
      
        UMOUNT = [ QUALIFIERS ] 'umount' [ MOUNT CONDITIONS ] MOUNTPOINT FILEGLOB
      
        MOUNT CONDITIONS = [ ( 'fstype' | 'vfstype' ) ( '=' | 'in' )
                             MOUNT FSTYPE EXPRESSION ]
      		       [ 'options' ( '=' | 'in' ) MOUNT FLAGS EXPRESSION ]
      
        MOUNT FSTYPE EXPRESSION = ( MOUNT FSTYPE LIST | MOUNT EXPRESSION )
      
        MOUNT FSTYPE LIST = Comma separated list of valid filesystem and
                            virtual filesystem types (eg ext4, debugfs, etc)
      
        MOUNT FLAGS EXPRESSION = ( MOUNT FLAGS LIST | MOUNT EXPRESSION )
      
        MOUNT FLAGS LIST = Comma separated list of MOUNT FLAGS.
      
        MOUNT FLAGS = ( 'ro' | 'rw' | 'nosuid' | 'suid' | 'nodev' | 'dev' |
                        'noexec' | 'exec' | 'sync' | 'async' | 'remount' |
      		  'mand' | 'nomand' | 'dirsync' | 'noatime' | 'atime' |
      		  'nodiratime' | 'diratime' | 'bind' | 'rbind' | 'move' |
      		  'verbose' | 'silent' | 'loud' | 'acl' | 'noacl' |
      		  'unbindable' | 'runbindable' | 'private' | 'rprivate' |
      		  'slave' | 'rslave' | 'shared' | 'rshared' |
      		  'relatime' | 'norelatime' | 'iversion' | 'noiversion' |
      		  'strictatime' | 'nouser' | 'user' )
      
        MOUNT EXPRESSION = ( ALPHANUMERIC | AARE ) ...
      
        PIVOT ROOT RULE = [ QUALIFIERS ] pivot_root [ oldroot=OLD PUT FILEGLOB ]
                          [ NEW ROOT FILEGLOB ]
      
        SOURCE FILEGLOB = FILEGLOB
      
        MOUNTPOINT FILEGLOB = FILEGLOB
      
      eg.
        mount,
        mount /dev/foo,
        mount options=ro /dev/foo -> /mnt/,
        mount options in (ro,atime) /dev/foo -> /mnt/,
        mount options=ro options=atime,
      Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
      Acked-by: NSeth Arnold <seth.arnold@canonical.com>
      2ea3ffb7
    • J
      apparmor: add the ability to mediate signals · cd1dbf76
      John Johansen 提交于
      Add signal mediation where the signal can be mediated based on the
      signal, direction, or the label or the peer/target. The signal perms
      are verified on a cross check to ensure policy consistency in the case
      of incremental policy load/replacement.
      
      The optimization of skipping the cross check when policy is guaranteed
      to be consistent (single compile unit) remains to be done.
      
      policy rules have the form of
        SIGNAL_RULE = [ QUALIFIERS ] 'signal' [ SIGNAL ACCESS PERMISSIONS ]
                      [ SIGNAL SET ] [ SIGNAL PEER ]
      
        SIGNAL ACCESS PERMISSIONS = SIGNAL ACCESS | SIGNAL ACCESS LIST
      
        SIGNAL ACCESS LIST = '(' Comma or space separated list of SIGNAL
                                 ACCESS ')'
      
        SIGNAL ACCESS = ( 'r' | 'w' | 'rw' | 'read' | 'write' | 'send' |
                          'receive' )
      
        SIGNAL SET = 'set' '=' '(' SIGNAL LIST ')'
      
        SIGNAL LIST = Comma or space separated list of SIGNALS
      
        SIGNALS = ( 'hup' | 'int' | 'quit' | 'ill' | 'trap' | 'abrt' |
                    'bus' | 'fpe' | 'kill' | 'usr1' | 'segv' | 'usr2' |
      	      'pipe' | 'alrm' | 'term' | 'stkflt' | 'chld' | 'cont' |
      	      'stop' | 'stp' | 'ttin' | 'ttou' | 'urg' | 'xcpu' |
      	      'xfsz' | 'vtalrm' | 'prof' | 'winch' | 'io' | 'pwr' |
      	      'sys' | 'emt' | 'exists' | 'rtmin+0' ... 'rtmin+32'
                  )
      
        SIGNAL PEER = 'peer' '=' AARE
      
      eg.
        signal,                                 # allow all signals
        signal send set=(hup, kill) peer=foo,
      Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
      Acked-by: NSeth Arnold <seth.arnold@canonical.com>
      cd1dbf76
    • J
    • D
      apparmor: Fix an error code in aafs_create() · 5d314a81
      Dan Carpenter 提交于
      We accidentally forgot to set the error code on this path.  It means we
      return NULL instead of an error pointer.  I looked through a bunch of
      callers and I don't think it really causes a big issue, but the
      documentation says we're supposed to return error pointers here.
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Acked-by: NSerge Hallyn <serge@hallyn.com>
      Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
      5d314a81
    • C
      apparmor: Fix logical error in verify_header() · 86aea56f
      Christos Gkekas 提交于
      verify_header() is currently checking whether interface version is less
      than 5 *and* greater than 7, which always evaluates to false. Instead it
      should check whether it is less than 5 *or* greater than 7.
      Signed-off-by: NChristos Gkekas <chris.gekas@gmail.com>
      Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
      86aea56f
    • G
      apparmor: Fix shadowed local variable in unpack_trans_table() · 19fe43a5
      Geert Uytterhoeven 提交于
      with W=2:
      
          security/apparmor/policy_unpack.c: In function ‘unpack_trans_table’:
          security/apparmor/policy_unpack.c:469: warning: declaration of ‘pos’ shadows a previous local
          security/apparmor/policy_unpack.c:451: warning: shadowed declaration is here
      
      Rename the old "pos" to "saved_pos" to fix this.
      
      Fixes: 5379a331 ("apparmor: support v7 transition format compatible with label_parse")
      Signed-off-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Reviewed-by: NSerge Hallyn <serge@hallyn.com>
      Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
      19fe43a5
  2. 14 7月, 2017 1 次提交
  3. 13 7月, 2017 1 次提交
    • D
      include/linux/string.h: add the option of fortified string.h functions · 6974f0c4
      Daniel Micay 提交于
      This adds support for compiling with a rough equivalent to the glibc
      _FORTIFY_SOURCE=1 feature, providing compile-time and runtime buffer
      overflow checks for string.h functions when the compiler determines the
      size of the source or destination buffer at compile-time.  Unlike glibc,
      it covers buffer reads in addition to writes.
      
      GNU C __builtin_*_chk intrinsics are avoided because they would force a
      much more complex implementation.  They aren't designed to detect read
      overflows and offer no real benefit when using an implementation based
      on inline checks.  Inline checks don't add up to much code size and
      allow full use of the regular string intrinsics while avoiding the need
      for a bunch of _chk functions and per-arch assembly to avoid wrapper
      overhead.
      
      This detects various overflows at compile-time in various drivers and
      some non-x86 core kernel code.  There will likely be issues caught in
      regular use at runtime too.
      
      Future improvements left out of initial implementation for simplicity,
      as it's all quite optional and can be done incrementally:
      
      * Some of the fortified string functions (strncpy, strcat), don't yet
        place a limit on reads from the source based on __builtin_object_size of
        the source buffer.
      
      * Extending coverage to more string functions like strlcat.
      
      * It should be possible to optionally use __builtin_object_size(x, 1) for
        some functions (C strings) to detect intra-object overflows (like
        glibc's _FORTIFY_SOURCE=2), but for now this takes the conservative
        approach to avoid likely compatibility issues.
      
      * The compile-time checks should be made available via a separate config
        option which can be enabled by default (or always enabled) once enough
        time has passed to get the issues it catches fixed.
      
      Kees said:
       "This is great to have. While it was out-of-tree code, it would have
        blocked at least CVE-2016-3858 from being exploitable (improper size
        argument to strlcpy()). I've sent a number of fixes for
        out-of-bounds-reads that this detected upstream already"
      
      [arnd@arndb.de: x86: fix fortified memcpy]
        Link: http://lkml.kernel.org/r/20170627150047.660360-1-arnd@arndb.de
      [keescook@chromium.org: avoid panic() in favor of BUG()]
        Link: http://lkml.kernel.org/r/20170626235122.GA25261@beast
      [keescook@chromium.org: move from -mm, add ARCH_HAS_FORTIFY_SOURCE, tweak Kconfig help]
      Link: http://lkml.kernel.org/r/20170526095404.20439-1-danielmicay@gmail.com
      Link: http://lkml.kernel.org/r/1497903987-21002-8-git-send-email-keescook@chromium.orgSigned-off-by: NDaniel Micay <danielmicay@gmail.com>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Acked-by: NKees Cook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Daniel Axtens <dja@axtens.net>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Chris Metcalf <cmetcalf@ezchip.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6974f0c4
  4. 01 7月, 2017 1 次提交
    • K
      randstruct: Mark various structs for randomization · 3859a271
      Kees Cook 提交于
      This marks many critical kernel structures for randomization. These are
      structures that have been targeted in the past in security exploits, or
      contain functions pointers, pointers to function pointer tables, lists,
      workqueues, ref-counters, credentials, permissions, or are otherwise
      sensitive. This initial list was extracted from Brad Spengler/PaX Team's
      code in the last public patch of grsecurity/PaX based on my understanding
      of the code. Changes or omissions from the original code are mine and
      don't reflect the original grsecurity/PaX code.
      
      Left out of this list is task_struct, which requires special handling
      and will be covered in a subsequent patch.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      3859a271
  5. 30 6月, 2017 1 次提交
  6. 28 6月, 2017 1 次提交
  7. 22 6月, 2017 15 次提交
  8. 21 6月, 2017 2 次提交
  9. 20 6月, 2017 1 次提交
    • I
      sched/wait: Split out the wait_bit*() APIs from <linux/wait.h> into <linux/wait_bit.h> · 5dd43ce2
      Ingo Molnar 提交于
      The wait_bit*() types and APIs are mixed into wait.h, but they
      are a pretty orthogonal extension of wait-queues.
      
      Furthermore, only about 50 kernel files use these APIs, while
      over 1000 use the regular wait-queue functionality.
      
      So clean up the main wait.h by moving the wait-bit functionality
      out of it, into a separate .h and .c file:
      
        include/linux/wait_bit.h  for types and APIs
        kernel/sched/wait_bit.c   for the implementation
      
      Update all header dependencies.
      
      This reduces the size of wait.h rather significantly, by about 30%.
      
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      5dd43ce2
  10. 13 6月, 2017 1 次提交
  11. 11 6月, 2017 10 次提交