1. 21 11月, 2017 3 次提交
    • J
      apparmor: fix locking when creating a new complain profile. · 5d7c44ef
      John Johansen 提交于
      Break the per cpu buffer atomic section when creating a new null
      complain profile. In learning mode this won't matter and we can
      safely re-aquire the buffer.
      
      This fixes the following lockdep BUG trace
         nov. 14 14:09:09 cyclope audit[7152]: AVC apparmor="ALLOWED" operation="exec" profile="/usr/sbin/sssd" name="/usr/sbin/adcli" pid=7152 comm="sssd_be" requested_mask="x" denied_mask="x" fsuid=0 ouid=0 target="/usr/sbin/sssd//null-/usr/sbin/adcli"
          nov. 14 14:09:09 cyclope kernel: BUG: sleeping function called from invalid context at kernel/locking/mutex.c:747
          nov. 14 14:09:09 cyclope kernel: in_atomic(): 1, irqs_disabled(): 0, pid: 7152, name: sssd_be
          nov. 14 14:09:09 cyclope kernel: 1 lock held by sssd_be/7152:
          nov. 14 14:09:09 cyclope kernel:  #0:  (&sig->cred_guard_mutex){....}, at: [<ffffffff8182d53e>] prepare_bprm_creds+0x4e/0x100
          nov. 14 14:09:09 cyclope kernel: CPU: 3 PID: 7152 Comm: sssd_be Not tainted 4.14.0prahal+intel #150
          nov. 14 14:09:09 cyclope kernel: Hardware name: LENOVO 20CDCTO1WW/20CDCTO1WW, BIOS GQET53WW (1.33 ) 09/15/2017
          nov. 14 14:09:09 cyclope kernel: Call Trace:
          nov. 14 14:09:09 cyclope kernel:  dump_stack+0xb0/0x135
          nov. 14 14:09:09 cyclope kernel:  ? _atomic_dec_and_lock+0x15b/0x15b
          nov. 14 14:09:09 cyclope kernel:  ? lockdep_print_held_locks+0xc4/0x130
          nov. 14 14:09:09 cyclope kernel:  ___might_sleep+0x29c/0x320
          nov. 14 14:09:09 cyclope kernel:  ? rq_clock+0xf0/0xf0
          nov. 14 14:09:09 cyclope kernel:  ? __kernel_text_address+0xd/0x40
          nov. 14 14:09:09 cyclope kernel:  __might_sleep+0x95/0x190
          nov. 14 14:09:09 cyclope kernel:  ? aa_new_null_profile+0x50a/0x960
          nov. 14 14:09:09 cyclope kernel:  __mutex_lock+0x13e/0x1a20
          nov. 14 14:09:09 cyclope kernel:  ? aa_new_null_profile+0x50a/0x960
          nov. 14 14:09:09 cyclope kernel:  ? save_stack+0x43/0xd0
          nov. 14 14:09:09 cyclope kernel:  ? kmem_cache_alloc_trace+0x13f/0x290
          nov. 14 14:09:09 cyclope kernel:  ? mutex_lock_io_nested+0x1880/0x1880
          nov. 14 14:09:09 cyclope kernel:  ? profile_transition+0x932/0x2d40
          nov. 14 14:09:09 cyclope kernel:  ? apparmor_bprm_set_creds+0x1479/0x1f70
          nov. 14 14:09:09 cyclope kernel:  ? security_bprm_set_creds+0x5a/0x80
          nov. 14 14:09:09 cyclope kernel:  ? prepare_binprm+0x366/0x980
          nov. 14 14:09:09 cyclope kernel:  ? do_execveat_common.isra.30+0x12a9/0x2350
          nov. 14 14:09:09 cyclope kernel:  ? SyS_execve+0x2c/0x40
          nov. 14 14:09:09 cyclope kernel:  ? do_syscall_64+0x228/0x650
          nov. 14 14:09:09 cyclope kernel:  ? entry_SYSCALL64_slow_path+0x25/0x25
          nov. 14 14:09:09 cyclope kernel:  ? deactivate_slab.isra.62+0x49d/0x5e0
          nov. 14 14:09:09 cyclope kernel:  ? save_stack_trace+0x16/0x20
          nov. 14 14:09:09 cyclope kernel:  ? init_object+0x88/0x90
          nov. 14 14:09:09 cyclope kernel:  ? ___slab_alloc+0x520/0x590
          nov. 14 14:09:09 cyclope kernel:  ? ___slab_alloc+0x520/0x590
          nov. 14 14:09:09 cyclope kernel:  ? aa_alloc_proxy+0xab/0x200
          nov. 14 14:09:09 cyclope kernel:  ? lock_downgrade+0x7e0/0x7e0
          nov. 14 14:09:09 cyclope kernel:  ? memcg_kmem_get_cache+0x970/0x970
          nov. 14 14:09:09 cyclope kernel:  ? kasan_unpoison_shadow+0x35/0x50
          nov. 14 14:09:09 cyclope kernel:  ? kasan_unpoison_shadow+0x35/0x50
          nov. 14 14:09:09 cyclope kernel:  ? kasan_kmalloc+0xad/0xe0
          nov. 14 14:09:09 cyclope kernel:  ? aa_alloc_proxy+0xab/0x200
          nov. 14 14:09:09 cyclope kernel:  ? kmem_cache_alloc_trace+0x13f/0x290
          nov. 14 14:09:09 cyclope kernel:  ? aa_alloc_proxy+0xab/0x200
          nov. 14 14:09:09 cyclope kernel:  ? aa_alloc_proxy+0xab/0x200
          nov. 14 14:09:09 cyclope kernel:  ? _raw_spin_unlock+0x22/0x30
          nov. 14 14:09:09 cyclope kernel:  ? vec_find+0xa0/0xa0
          nov. 14 14:09:09 cyclope kernel:  ? aa_label_init+0x6f/0x230
          nov. 14 14:09:09 cyclope kernel:  ? __label_insert+0x3e0/0x3e0
          nov. 14 14:09:09 cyclope kernel:  ? kmem_cache_alloc_trace+0x13f/0x290
          nov. 14 14:09:09 cyclope kernel:  ? aa_alloc_profile+0x58/0x200
          nov. 14 14:09:09 cyclope kernel:  mutex_lock_nested+0x16/0x20
          nov. 14 14:09:09 cyclope kernel:  ? mutex_lock_nested+0x16/0x20
          nov. 14 14:09:09 cyclope kernel:  aa_new_null_profile+0x50a/0x960
          nov. 14 14:09:09 cyclope kernel:  ? aa_fqlookupn_profile+0xdc0/0xdc0
          nov. 14 14:09:09 cyclope kernel:  ? aa_compute_fperms+0x4b5/0x640
          nov. 14 14:09:09 cyclope kernel:  ? disconnect.isra.2+0x1b0/0x1b0
          nov. 14 14:09:09 cyclope kernel:  ? aa_str_perms+0x8d/0xe0
          nov. 14 14:09:09 cyclope kernel:  profile_transition+0x932/0x2d40
          nov. 14 14:09:09 cyclope kernel:  ? up_read+0x1a/0x40
          nov. 14 14:09:09 cyclope kernel:  ? ext4_xattr_get+0x15c/0xaf0 [ext4]
          nov. 14 14:09:09 cyclope kernel:  ? x_table_lookup+0x190/0x190
          nov. 14 14:09:09 cyclope kernel:  ? ext4_xattr_ibody_get+0x590/0x590 [ext4]
          nov. 14 14:09:09 cyclope kernel:  ? sched_clock+0x9/0x10
          nov. 14 14:09:09 cyclope kernel:  ? sched_clock+0x9/0x10
          nov. 14 14:09:09 cyclope kernel:  ? ext4_xattr_security_get+0x1a/0x20 [ext4]
          nov. 14 14:09:09 cyclope kernel:  ? __vfs_getxattr+0x6d/0xa0
          nov. 14 14:09:09 cyclope kernel:  ? get_vfs_caps_from_disk+0x114/0x720
          nov. 14 14:09:09 cyclope kernel:  ? sched_clock+0x9/0x10
          nov. 14 14:09:09 cyclope kernel:  ? sched_clock+0x9/0x10
          nov. 14 14:09:09 cyclope kernel:  ? tsc_resume+0x10/0x10
          nov. 14 14:09:09 cyclope kernel:  ? get_vfs_caps_from_disk+0x720/0x720
          nov. 14 14:09:09 cyclope kernel:  ? native_sched_clock_from_tsc+0x201/0x2b0
          nov. 14 14:09:09 cyclope kernel:  ? sched_clock+0x9/0x10
          nov. 14 14:09:09 cyclope kernel:  ? sched_clock_cpu+0x1b/0x170
          nov. 14 14:09:09 cyclope kernel:  ? find_held_lock+0x3c/0x1e0
          nov. 14 14:09:09 cyclope kernel:  ? rb_insert_color_cached+0x1660/0x1660
          nov. 14 14:09:09 cyclope kernel:  apparmor_bprm_set_creds+0x1479/0x1f70
          nov. 14 14:09:09 cyclope kernel:  ? sched_clock+0x9/0x10
          nov. 14 14:09:09 cyclope kernel:  ? handle_onexec+0x31d0/0x31d0
          nov. 14 14:09:09 cyclope kernel:  ? tsc_resume+0x10/0x10
          nov. 14 14:09:09 cyclope kernel:  ? graph_lock+0xd0/0xd0
          nov. 14 14:09:09 cyclope kernel:  ? tsc_resume+0x10/0x10
          nov. 14 14:09:09 cyclope kernel:  ? sched_clock_cpu+0x1b/0x170
          nov. 14 14:09:09 cyclope kernel:  ? sched_clock+0x9/0x10
          nov. 14 14:09:09 cyclope kernel:  ? sched_clock+0x9/0x10
          nov. 14 14:09:09 cyclope kernel:  ? sched_clock_cpu+0x1b/0x170
          nov. 14 14:09:09 cyclope kernel:  ? find_held_lock+0x3c/0x1e0
          nov. 14 14:09:09 cyclope kernel:  security_bprm_set_creds+0x5a/0x80
          nov. 14 14:09:09 cyclope kernel:  prepare_binprm+0x366/0x980
          nov. 14 14:09:09 cyclope kernel:  ? install_exec_creds+0x150/0x150
          nov. 14 14:09:09 cyclope kernel:  ? __might_fault+0x89/0xb0
          nov. 14 14:09:09 cyclope kernel:  ? up_read+0x40/0x40
          nov. 14 14:09:09 cyclope kernel:  ? get_user_arg_ptr.isra.18+0x2c/0x70
          nov. 14 14:09:09 cyclope kernel:  ? count.isra.20.constprop.32+0x7c/0xf0
          nov. 14 14:09:09 cyclope kernel:  do_execveat_common.isra.30+0x12a9/0x2350
          nov. 14 14:09:09 cyclope kernel:  ? prepare_bprm_creds+0x100/0x100
          nov. 14 14:09:09 cyclope kernel:  ? _raw_spin_unlock+0x22/0x30
          nov. 14 14:09:09 cyclope kernel:  ? deactivate_slab.isra.62+0x49d/0x5e0
          nov. 14 14:09:09 cyclope kernel:  ? save_stack_trace+0x16/0x20
          nov. 14 14:09:09 cyclope kernel:  ? init_object+0x88/0x90
          nov. 14 14:09:09 cyclope kernel:  ? ___slab_alloc+0x520/0x590
          nov. 14 14:09:09 cyclope kernel:  ? ___slab_alloc+0x520/0x590
          nov. 14 14:09:09 cyclope kernel:  ? kasan_check_write+0x14/0x20
          nov. 14 14:09:09 cyclope kernel:  ? memcg_kmem_get_cache+0x970/0x970
          nov. 14 14:09:09 cyclope kernel:  ? kasan_unpoison_shadow+0x35/0x50
          nov. 14 14:09:09 cyclope kernel:  ? glob_match+0x730/0x730
          nov. 14 14:09:09 cyclope kernel:  ? kmem_cache_alloc+0x225/0x280
          nov. 14 14:09:09 cyclope kernel:  ? getname_flags+0xb8/0x510
          nov. 14 14:09:09 cyclope kernel:  ? mm_fault_error+0x2e0/0x2e0
          nov. 14 14:09:09 cyclope kernel:  ? getname_flags+0xf6/0x510
          nov. 14 14:09:09 cyclope kernel:  ? ptregs_sys_vfork+0x10/0x10
          nov. 14 14:09:09 cyclope kernel:  SyS_execve+0x2c/0x40
          nov. 14 14:09:09 cyclope kernel:  do_syscall_64+0x228/0x650
          nov. 14 14:09:09 cyclope kernel:  ? syscall_return_slowpath+0x2f0/0x2f0
          nov. 14 14:09:09 cyclope kernel:  ? syscall_return_slowpath+0x167/0x2f0
          nov. 14 14:09:09 cyclope kernel:  ? prepare_exit_to_usermode+0x220/0x220
          nov. 14 14:09:09 cyclope kernel:  ? prepare_exit_to_usermode+0xda/0x220
          nov. 14 14:09:09 cyclope kernel:  ? perf_trace_sys_enter+0x1060/0x1060
          nov. 14 14:09:09 cyclope kernel:  ? __put_user_4+0x1c/0x30
          nov. 14 14:09:09 cyclope kernel:  entry_SYSCALL64_slow_path+0x25/0x25
          nov. 14 14:09:09 cyclope kernel: RIP: 0033:0x7f9320f23637
          nov. 14 14:09:09 cyclope kernel: RSP: 002b:00007fff783be338 EFLAGS: 00000202 ORIG_RAX: 000000000000003b
          nov. 14 14:09:09 cyclope kernel: RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f9320f23637
          nov. 14 14:09:09 cyclope kernel: RDX: 0000558c35002a70 RSI: 0000558c3505bd10 RDI: 0000558c35018b90
          nov. 14 14:09:09 cyclope kernel: RBP: 0000558c34b63ae8 R08: 0000558c3505bd10 R09: 0000000000000080
          nov. 14 14:09:09 cyclope kernel: R10: 0000000000000095 R11: 0000000000000202 R12: 0000000000000001
          nov. 14 14:09:09 cyclope kernel: R13: 0000558c35018b90 R14: 0000558c3505bd18 R15: 0000558c3505bd10
      
      Fixes: 4227c333 ("apparmor: Move path lookup to using preallocated buffers")
      BugLink: http://bugs.launchpad.net/bugs/173228Reported-by: NAlban Browaeys <prahal@yahoo.com>
      Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
      5d7c44ef
    • J
      apparmor: fix profile attachment for special unconfined profiles · 06d426d1
      John Johansen 提交于
      It used to be that unconfined would never attach. However that is not
      the case anymore as some special profiles can be marked as unconfined,
      that are not the namespaces unconfined profile, and may have an
      attachment.
      
      Fixes: f1bd9041 ("apparmor: add the base fns() for domain labels")
      Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
      06d426d1
    • J
      apparmor: ensure that undecidable profile attachments fail · 844b8292
      John Johansen 提交于
      Profiles that have an undecidable overlap in their attachments are
      being incorrectly handled. Instead of failing to attach the first one
      encountered is being used.
      
      eg.
        profile A /** { .. }
        profile B /*foo { .. }
      
      have an unresolvable longest left attachment, they both have an exact
      match on / and then have an overlapping expression that has no clear
      winner.
      
      Currently the winner will be the profile that is loaded first which
      can result in non-deterministic behavior. Instead in this situation
      the exec should fail.
      
      Fixes: 898127c3 ("AppArmor: functions for domain transitions")
      Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
      844b8292
  2. 23 9月, 2017 1 次提交
    • 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
  3. 02 8月, 2017 2 次提交
  4. 11 6月, 2017 10 次提交
  5. 09 6月, 2017 2 次提交
  6. 24 1月, 2017 1 次提交
  7. 16 1月, 2017 7 次提交
  8. 21 11月, 2016 1 次提交
  9. 12 7月, 2016 2 次提交
  10. 12 5月, 2015 1 次提交
    • C
      LSM: Switch to lists of hooks · b1d9e6b0
      Casey Schaufler 提交于
      Instead of using a vector of security operations
      with explicit, special case stacking of the capability
      and yama hooks use lists of hooks with capability and
      yama hooks included as appropriate.
      
      The security_operations structure is no longer required.
      Instead, there is a union of the function pointers that
      allows all the hooks lists to use a common mechanism for
      list management while retaining typing. Each module
      supplies an array describing the hooks it provides instead
      of a sparsely populated security_operations structure.
      The description includes the element that gets put on
      the hook list, avoiding the issues surrounding individual
      element allocation.
      
      The method for registering security modules is changed to
      reflect the information available. The method for removing
      a module, currently only used by SELinux, has also changed.
      It should be generic now, however if there are potential
      race conditions based on ordering of hook removal that needs
      to be addressed by the calling module.
      
      The security hooks are called from the lists and the first
      failure is returned.
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      Acked-by: NJohn Johansen <john.johansen@canonical.com>
      Acked-by: NKees Cook <keescook@chromium.org>
      Acked-by: NPaul Moore <paul@paul-moore.com>
      Acked-by: NStephen Smalley <sds@tycho.nsa.gov>
      Acked-by: NTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: NJames Morris <james.l.morris@oracle.com>
      b1d9e6b0
  11. 19 7月, 2014 1 次提交
  12. 30 10月, 2013 2 次提交
  13. 15 8月, 2013 4 次提交
  14. 28 4月, 2013 3 次提交