01 Jun, 2011

1 commit

  • When invalid parameters are passed to apparmor_setprocattr a NULL deref
    oops occurs when it tries to record an audit message. This is because
    it is passing NULL for the profile parameter for aa_audit. But aa_audit
    now requires that the profile passed is not NULL.

    Fix this by passing the current profile on the task that is trying to
    setprocattr.

    Signed-off-by: Kees Cook
    Signed-off-by: John Johansen
    Cc: stable@kernel.org
    Signed-off-by: James Morris

    Kees Cook
     

28 May, 2011

1 commit


27 May, 2011

3 commits

  • Right now security_get_user_sids() will pass in a NULL avd pointer to
    avc_has_perm_noaudit(), which then forces that function to have a dummy
    entry for that case and just generally test it.

    Don't do it. The normal callers all pass a real avd pointer, and this
    helper function is incredibly hot. So don't make avc_has_perm_noaudit()
    do conditional stuff that isn't needed for the common case.

    This also avoids some duplicated stack space.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • Add cgroup subsystem callbacks for per-thread attachment in atomic contexts

    Add can_attach_task(), pre_attach(), and attach_task() as new callbacks
    for cgroups's subsystem interface. Unlike can_attach and attach, these
    are for per-thread operations, to be called potentially many times when
    attaching an entire threadgroup.

    Also, the old "bool threadgroup" interface is removed, as replaced by
    this. All subsystems are modified for the new interface - of note is
    cpuset, which requires from/to nodemasks for attach to be globally scoped
    (though per-cpuset would work too) to persist from its pre_attach to
    attach_task and attach.

    This is a pre-patch for cgroup-procs-writable.patch.

    Signed-off-by: Ben Blum
    Cc: "Eric W. Biederman"
    Cc: Li Zefan
    Cc: Matt Helsley
    Reviewed-by: Paul Menage
    Cc: Oleg Nesterov
    Cc: David Rientjes
    Cc: Miao Xie
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ben Blum
     
  • Since this cred was not created with copy_creds(), it needs to get
    initialized. Otherwise use of syscall(__NR_keyctl, KEYCTL_SESSION_TO_PARENT);
    can lead to a NULL deref. Thanks to Robert for finding this.

    But introduced by commit 47a150edc2a ("Cache user_ns in struct cred").

    Signed-off-by: Serge E. Hallyn
    Reported-by: Robert Święcki
    Cc: David Howells
    Cc: stable@kernel.org (2.6.39)
    Signed-off-by: Linus Torvalds

    Serge E. Hallyn
     

24 May, 2011

3 commits

  • Conflicts:
    lib/flex_array.c
    security/selinux/avc.c
    security/selinux/hooks.c
    security/selinux/ss/policydb.c
    security/smack/smack_lsm.c

    Manually resolve conflicts.

    Signed-off-by: James Morris

    James Morris
     
  • James Morris
     
  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (39 commits)
    b43: fix comment typo reqest -> request
    Haavard Skinnemoen has left Atmel
    cris: typo in mach-fs Makefile
    Kconfig: fix copy/paste-ism for dell-wmi-aio driver
    doc: timers-howto: fix a typo ("unsgined")
    perf: Only include annotate.h once in tools/perf/util/ui/browsers/annotate.c
    md, raid5: Fix spelling error in comment ('Ofcourse' --> 'Of course').
    treewide: fix a few typos in comments
    regulator: change debug statement be consistent with the style of the rest
    Revert "arm: mach-u300/gpio: Fix mem_region resource size miscalculations"
    audit: acquire creds selectively to reduce atomic op overhead
    rtlwifi: don't touch with treewide double semicolon removal
    treewide: cleanup continuations and remove logging message whitespace
    ath9k_hw: don't touch with treewide double semicolon removal
    include/linux/leds-regulator.h: fix syntax in example code
    tty: fix typo in descripton of tty_termios_encode_baud_rate
    xtensa: remove obsolete BKL kernel option from defconfig
    m68k: fix comment typo 'occcured'
    arch:Kconfig.locks Remove unused config option.
    treewide: remove extra semicolons
    ...

    Linus Torvalds
     

20 May, 2011

4 commits

  • There is no point in counting hits - we can calculate it from the number
    of lookups and misses.

    This makes the avc statistics a bit smaller, and makes the code
    generation better too.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • You can turn off the avc cache stats, but distributions seem to not do
    that (perhaps because several performance tuning how-to's talk about the
    avc cache statistics).

    Which is sad, because the code it generates is truly horrendous, with
    the statistics update being sandwitched between get_cpu/put_cpu which in
    turn causes preemption disables etc. We're talking ten+ instructions
    just to increment a per-cpu variable in some pretty hot code.

    Fix the craziness by just using 'this_cpu_inc()' instead. Suddenly we
    only need a single 'inc' instruction to increment the statistics. This
    is quite noticeable in the incredibly hot avc_has_perm_noaudit()
    function (which triggers all the statistics by virtue of doing an
    avc_lookup() call).

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • * 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (78 commits)
    Revert "rcu: Decrease memory-barrier usage based on semi-formal proof"
    net,rcu: convert call_rcu(prl_entry_destroy_rcu) to kfree
    batman,rcu: convert call_rcu(softif_neigh_free_rcu) to kfree_rcu
    batman,rcu: convert call_rcu(neigh_node_free_rcu) to kfree()
    batman,rcu: convert call_rcu(gw_node_free_rcu) to kfree_rcu
    net,rcu: convert call_rcu(kfree_tid_tx) to kfree_rcu()
    net,rcu: convert call_rcu(xt_osf_finger_free_rcu) to kfree_rcu()
    net/mac80211,rcu: convert call_rcu(work_free_rcu) to kfree_rcu()
    net,rcu: convert call_rcu(wq_free_rcu) to kfree_rcu()
    net,rcu: convert call_rcu(phonet_device_rcu_free) to kfree_rcu()
    perf,rcu: convert call_rcu(swevent_hlist_release_rcu) to kfree_rcu()
    perf,rcu: convert call_rcu(free_ctx) to kfree_rcu()
    net,rcu: convert call_rcu(__nf_ct_ext_free_rcu) to kfree_rcu()
    net,rcu: convert call_rcu(net_generic_release) to kfree_rcu()
    net,rcu: convert call_rcu(netlbl_unlhsh_free_addr6) to kfree_rcu()
    net,rcu: convert call_rcu(netlbl_unlhsh_free_addr4) to kfree_rcu()
    security,rcu: convert call_rcu(sel_netif_free) to kfree_rcu()
    net,rcu: convert call_rcu(xps_dev_maps_release) to kfree_rcu()
    net,rcu: convert call_rcu(xps_map_release) to kfree_rcu()
    net,rcu: convert call_rcu(rps_map_release) to kfree_rcu()
    ...

    Linus Torvalds
     
  • move LSM-, credentials-, and keys-related files from Documentation/
    to Documentation/security/,
    add Documentation/security/00-INDEX, and
    update all occurrences of Documentation/
    to Documentation/security/.

    Randy Dunlap
     

19 May, 2011

1 commit


13 May, 2011

2 commits


12 May, 2011

2 commits

  • In tomoyo_correct_domain() since 2.6.36, TOMOYO was by error validating
    "" + "/foo/\" + "/bar" when " /foo/\* /bar" was given.
    As a result, legal domainnames like " /foo/\* /bar" are rejected.

    Reported-by: Hayama Yossihiro
    Signed-off-by: Tetsuo Handa
    Signed-off-by: James Morris

    Tetsuo Handa
     
  • In the interest of keeping userspace from having to create new root
    filesystems all the time, let's follow the lead of the other in-kernel
    filesystems and provide a proper mount point for it in sysfs.

    For selinuxfs, this mount point should be in /sys/fs/selinux/

    Cc: Stephen Smalley
    Cc: James Morris
    Cc: Eric Paris
    Cc: Lennart Poettering
    Cc: Daniel J Walsh
    Signed-off-by: Greg Kroah-Hartman
    [include kobject.h - Eric Paris]
    [use selinuxfs_obj throughout - Eric Paris]
    Signed-off-by: Eric Paris

    Greg Kroah-Hartman
     

08 May, 2011

2 commits


04 May, 2011

1 commit


29 Apr, 2011

11 commits

  • Change flex_array_prealloc to take the number of elements for which space
    should be allocated instead of the last (inclusive) element. Users
    and documentation are updated accordingly. flex_arrays got introduced before
    they had users. When folks started using it, they ended up needing a
    different API than was coded up originally. This swaps over to the API that
    folks apparently need.

    Based-on-patch-by: Steffen Klassert
    Signed-off-by: Eric Paris
    Tested-by: Chris Richards
    Acked-by: Dave Hansen
    Cc: stable@kernel.org [2.6.38+]

    Eric Paris
     
  • New inodes are created in a two stage process. We first will compute the
    label on a new inode in security_inode_create() and check if the
    operation is allowed. We will then actually re-compute that same label and
    apply it in security_inode_init_security(). The change to do new label
    calculations based in part on the last component of the path name only
    passed the path component information all the way down the
    security_inode_init_security hook. Down the security_inode_create hook the
    path information did not make it past may_create. Thus the two calculations
    came up differently and the permissions check might not actually be against
    the label that is created. Pass and use the same information in both places
    to harmonize the calculations and checks.

    Reported-by: Dominick Grift
    Signed-off-by: Eric Paris

    Eric Paris
     
  • We currently have inode_has_perm and dentry_has_perm. dentry_has_perm just
    calls inode_has_perm with additional audit data. But dentry_has_perm can
    take either a dentry or a path. Split those to make the code obvious and
    to fix the previous problem where I thought dentry_has_perm always had a
    valid dentry and mnt.

    Signed-off-by: Eric Paris

    Eric Paris
     
  • Change flex_array_prealloc to take the number of elements for which space
    should be allocated instead of the last (inclusive) element. Users
    and documentation are updated accordingly. flex_arrays got introduced before
    they had users. When folks started using it, they ended up needing a
    different API than was coded up originally. This swaps over to the API that
    folks apparently need.

    Based-on-patch-by: Steffen Klassert
    Signed-off-by: Eric Paris
    Tested-by: Chris Richards
    Acked-by: Dave Hansen
    Cc: stable@kernel.org [2.6.38+]

    Eric Paris
     
  • New inodes are created in a two stage process. We first will compute the
    label on a new inode in security_inode_create() and check if the
    operation is allowed. We will then actually re-compute that same label and
    apply it in security_inode_init_security(). The change to do new label
    calculations based in part on the last component of the path name only
    passed the path component information all the way down the
    security_inode_init_security hook. Down the security_inode_create hook the
    path information did not make it past may_create. Thus the two calculations
    came up differently and the permissions check might not actually be against
    the label that is created. Pass and use the same information in both places
    to harmonize the calculations and checks.

    Reported-by: Dominick Grift
    Signed-off-by: Eric Paris

    Eric Paris
     
  • To shorten the list we need to run if filename trans rules exist for the type
    of the given parent directory I put them in a hashtable. Given the policy we
    are expecting to use in Fedora this takes the worst case list run from about
    5,000 entries to 17.

    Signed-off-by: Eric Paris
    Reviewed-by: James Morris

    Eric Paris
     
  • Instead of a hashtab entry counter function only useful for range
    transition rules make a function generic for any hashtable to use.

    Signed-off-by: Eric Paris
    Reviewed-by: James Morris

    Eric Paris
     
  • We have custom debug functions like rangetr_hash_eval and symtab_hash_eval
    which do the same thing. Just create a generic function that takes the name
    of the hash table as an argument instead of having custom functions.

    Signed-off-by: Eric Paris
    Reviewed-by: James Morris

    Eric Paris
     
  • Right now we walk to filename trans rule list for every inode that is
    created. First passes at policy using this facility creates around 5000
    filename trans rules. Running a list of 5000 entries every time is a bad
    idea. This patch adds a new ebitmap to policy which has a bit set for each
    ttype that has at least 1 filename trans rule. Thus when an inode is
    created we can quickly determine if any rules exist for this parent
    directory type and can skip the list if we know there is definitely no
    relevant entry.

    Signed-off-by: Eric Paris
    Reviewed-by: James Morris

    Eric Paris
     
  • filename_compute_type() takes as arguments the numeric value of the type of
    the subject and target. It does not take a context. Thus the names are
    misleading. Fix the argument names.

    Signed-off-by: Eric Paris
    Reviewed-by: James Morris

    Eric Paris
     
  • filename_compute_type used to take a qstr, but it now takes just a name.
    Fix the comments to indicate it is an objname, not a qstr.

    Signed-off-by: Eric Paris

    Eric Paris
     

26 Apr, 2011

6 commits

  • Fast-forwarded to current state of Linus' tree as there are patches to be
    applied for files that didn't exist on the old branch.

    Jiri Kosina
     
  • Now that the security modules can decide whether they support the
    dcache RCU walk or not it's possible to make selinux a bit more
    RCU friendly. The SELinux AVC and security server access decision
    code is RCU safe. A specific piece of the LSM audit code may not
    be RCU safe.

    This patch makes the VFS RCU walk retry if it would hit the non RCU
    safe chunk of code. It will normally just work under RCU. This is
    done simply by passing the VFS RCU state as a flag down into the
    avc_audit() code and returning ECHILD there if it would have an issue.

    Based-on-patch-by: Andi Kleen
    Signed-off-by: Eric Paris
    Signed-off-by: Linus Torvalds

    Eric Paris
     
  • smack_file_lock has a struct path, so use that instead of only the
    dentry.

    Signed-off-by: Eric Paris
    Acked-by: Casey Schaufler

    Eric Paris
     
  • This patch separates and audit message that only contains a dentry from
    one that contains a full path. This allows us to make it harder to
    misuse the interfaces or for the interfaces to be implemented wrong.

    Signed-off-by: Eric Paris
    Acked-by: Casey Schaufler

    Eric Paris
     
  • The lsm common audit code has wacky contortions making sure which pieces
    of information are set based on if it was given a path, dentry, or
    inode. Split this into path and inode to get rid of some of the code
    complexity.

    Signed-off-by: Eric Paris
    Acked-by: Casey Schaufler

    Eric Paris
     
  • Now that the security modules can decide whether they support the
    dcache RCU walk or not it's possible to make selinux a bit more
    RCU friendly. The SELinux AVC and security server access decision
    code is RCU safe. A specific piece of the LSM audit code may not
    be RCU safe.

    This patch makes the VFS RCU walk retry if it would hit the non RCU
    safe chunk of code. It will normally just work under RCU. This is
    done simply by passing the VFS RCU state as a flag down into the
    avc_audit() code and returning ECHILD there if it would have an issue.

    Based-on-patch-by: Andi Kleen
    Signed-off-by: Eric Paris

    Eric Paris
     

25 Apr, 2011

3 commits