20 May, 2011

3 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
     

13 May, 2011

2 commits


08 May, 2011

2 commits


04 May, 2011

1 commit


29 Apr, 2011

2 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
     

26 Apr, 2011

1 commit

  • 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
     

23 Apr, 2011

1 commit

  • Right now all RCU walks fall back to reference walk when CONFIG_SECURITY
    is enabled, even though just the standard capability module is active.
    This is because security_inode_exec_permission unconditionally fails
    RCU walks.

    Move this decision to the low level security module. This requires
    passing the RCU flags down the security hook. This way at least
    the capability module and a few easy cases in selinux/smack work
    with RCU walks with CONFIG_SECURITY=y

    Signed-off-by: Andi Kleen
    Acked-by: Eric Paris
    Signed-off-by: Linus Torvalds

    Andi Kleen
     

31 Mar, 2011

1 commit


29 Mar, 2011

1 commit

  • Commit 6f5317e730505d5cbc851c435a2dfe3d5a21d343 introduced a bug in the
    handling of userspace object classes that is causing breakage for Xorg
    when XSELinux is enabled. Fix the bug by changing map_class() to return
    SECCLASS_NULL when the class cannot be mapped to a kernel object class.

    Reported-by: "Justin P. Mattock"
    Signed-off-by: Stephen Smalley
    Signed-off-by: James Morris

    Stephen Smalley
     

24 Mar, 2011

3 commits

  • And give it a kernel-doc comment.

    [akpm@linux-foundation.org: btrfs changed in linux-next]
    Signed-off-by: Serge E. Hallyn
    Cc: "Eric W. Biederman"
    Cc: Daniel Lezcano
    Acked-by: David Howells
    Cc: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Serge E. Hallyn
     
  • ptrace is allowed to tasks in the same user namespace according to the
    usual rules (i.e. the same rules as for two tasks in the init user
    namespace). ptrace is also allowed to a user namespace to which the
    current task the has CAP_SYS_PTRACE capability.

    Changelog:
    Dec 31: Address feedback by Eric:
    . Correct ptrace uid check
    . Rename may_ptrace_ns to ptrace_capable
    . Also fix the cap_ptrace checks.
    Jan 1: Use const cred struct
    Jan 11: use task_ns_capable() in place of ptrace_capable().
    Feb 23: same_or_ancestore_user_ns() was not an appropriate
    check to constrain cap_issubset. Rather, cap_issubset()
    only is meaningful when both capsets are in the same
    user_ns.

    Signed-off-by: Serge E. Hallyn
    Cc: "Eric W. Biederman"
    Acked-by: Daniel Lezcano
    Acked-by: David Howells
    Cc: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Serge E. Hallyn
     
  • - Introduce ns_capable to test for a capability in a non-default
    user namespace.
    - Teach cap_capable to handle capabilities in a non-default
    user namespace.

    The motivation is to get to the unprivileged creation of new
    namespaces. It looks like this gets us 90% of the way there, with
    only potential uid confusion issues left.

    I still need to handle getting all caps after creation but otherwise I
    think I have a good starter patch that achieves all of your goals.

    Changelog:
    11/05/2010: [serge] add apparmor
    12/14/2010: [serge] fix capabilities to created user namespaces
    Without this, if user serge creates a user_ns, he won't have
    capabilities to the user_ns he created. THis is because we
    were first checking whether his effective caps had the caps
    he needed and returning -EPERM if not, and THEN checking whether
    he was the creator. Reverse those checks.
    12/16/2010: [serge] security_real_capable needs ns argument in !security case
    01/11/2011: [serge] add task_ns_capable helper
    01/11/2011: [serge] add nsown_capable() helper per Bastian Blank suggestion
    02/16/2011: [serge] fix a logic bug: the root user is always creator of
    init_user_ns, but should not always have capabilities to
    it! Fix the check in cap_capable().
    02/21/2011: Add the required user_ns parameter to security_capable,
    fixing a compile failure.
    02/23/2011: Convert some macros to functions as per akpm comments. Some
    couldn't be converted because we can't easily forward-declare
    them (they are inline if !SECURITY, extern if SECURITY). Add
    a current_user_ns function so we can use it in capability.h
    without #including cred.h. Move all forward declarations
    together to the top of the #ifdef __KERNEL__ section, and use
    kernel-doc format.
    02/23/2011: Per dhowells, clean up comment in cap_capable().
    02/23/2011: Per akpm, remove unreachable 'return -EPERM' in cap_capable.

    (Original written and signed off by Eric; latest, modified version
    acked by him)

    [akpm@linux-foundation.org: fix build]
    [akpm@linux-foundation.org: export current_user_ns() for ecryptfs]
    [serge.hallyn@canonical.com: remove unneeded extra argument in selinux's task_has_capability]
    Signed-off-by: Eric W. Biederman
    Signed-off-by: Serge E. Hallyn
    Acked-by: "Eric W. Biederman"
    Acked-by: Daniel Lezcano
    Acked-by: David Howells
    Cc: James Morris
    Signed-off-by: Serge E. Hallyn
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Serge E. Hallyn
     

17 Mar, 2011

2 commits

  • * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6: (1480 commits)
    bonding: enable netpoll without checking link status
    xfrm: Refcount destination entry on xfrm_lookup
    net: introduce rx_handler results and logic around that
    bonding: get rid of IFF_SLAVE_INACTIVE netdev->priv_flag
    bonding: wrap slave state work
    net: get rid of multiple bond-related netdevice->priv_flags
    bonding: register slave pointer for rx_handler
    be2net: Bump up the version number
    be2net: Copyright notice change. Update to Emulex instead of ServerEngines
    e1000e: fix kconfig for crc32 dependency
    netfilter ebtables: fix xt_AUDIT to work with ebtables
    xen network backend driver
    bonding: Improve syslog message at device creation time
    bonding: Call netif_carrier_off after register_netdevice
    bonding: Incorrect TX queue offset
    net_sched: fix ip_tos2prio
    xfrm: fix __xfrm_route_forward()
    be2net: Fix UDP packet detected status in RX compl
    Phonet: fix aligned-mode pipe socket buffer header reserve
    netxen: support for GbE port settings
    ...

    Fix up conflicts in drivers/staging/brcm80211/brcmsmac/wl_mac80211.c
    with the staging updates.

    Linus Torvalds
     
  • …s/security-testing-2.6

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6: (33 commits)
    AppArmor: kill unused macros in lsm.c
    AppArmor: cleanup generated files correctly
    KEYS: Add an iovec version of KEYCTL_INSTANTIATE
    KEYS: Add a new keyctl op to reject a key with a specified error code
    KEYS: Add a key type op to permit the key description to be vetted
    KEYS: Add an RCU payload dereference macro
    AppArmor: Cleanup make file to remove cruft and make it easier to read
    SELinux: implement the new sb_remount LSM hook
    LSM: Pass -o remount options to the LSM
    SELinux: Compute SID for the newly created socket
    SELinux: Socket retains creator role and MLS attribute
    SELinux: Auto-generate security_is_socket_class
    TOMOYO: Fix memory leak upon file open.
    Revert "selinux: simplify ioctl checking"
    selinux: drop unused packet flow permissions
    selinux: Fix packet forwarding checks on postrouting
    selinux: Fix wrong checks for selinux_policycap_netpeer
    selinux: Fix check for xfrm selinux context algorithm
    ima: remove unnecessary call to ima_must_measure
    IMA: remove IMA imbalance checking
    ...

    Linus Torvalds
     

16 Mar, 2011

1 commit

  • …l/git/tip/linux-2.6-tip

    * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (62 commits)
    posix-clocks: Check write permissions in posix syscalls
    hrtimer: Remove empty hrtimer_init_hres_timer()
    hrtimer: Update hrtimer->state documentation
    hrtimer: Update base[CLOCK_BOOTTIME].offset correctly
    timers: Export CLOCK_BOOTTIME via the posix timers interface
    timers: Add CLOCK_BOOTTIME hrtimer base
    time: Extend get_xtime_and_monotonic_offset() to also return sleep
    time: Introduce get_monotonic_boottime and ktime_get_boottime
    hrtimers: extend hrtimer base code to handle more then 2 clockids
    ntp: Remove redundant and incorrect parameter check
    mn10300: Switch do_timer() to xtimer_update()
    posix clocks: Introduce dynamic clocks
    posix-timers: Cleanup namespace
    posix-timers: Add support for fd based clocks
    x86: Add clock_adjtime for x86
    posix-timers: Introduce a syscall for clock tuning.
    time: Splitout compat timex accessors
    ntp: Add ADJ_SETOFFSET mode bit
    time: Introduce timekeeping_inject_offset
    posix-timer: Update comment
    ...

    Fix up new system-call-related conflicts in
    arch/x86/ia32/ia32entry.S
    arch/x86/include/asm/unistd_32.h
    arch/x86/include/asm/unistd_64.h
    arch/x86/kernel/syscall_table_32.S
    (name_to_handle_at()/open_by_handle_at() vs clock_adjtime()), and some
    due to movement of get_jiffies_64() in:
    kernel/time.c

    Linus Torvalds
     

13 Mar, 2011

1 commit


09 Mar, 2011

3 commits


08 Mar, 2011

6 commits


05 Mar, 2011

1 commit


04 Mar, 2011

7 commits

  • Netlink message processing in the kernel is synchronous these days,
    capabilities can be checked directly in security_netlink_recv() from
    the current process.

    Signed-off-by: Patrick McHardy
    Reviewed-by: James Morris
    [chrisw: update to include pohmelfs and uvesafb]
    Signed-off-by: Chris Wright
    Signed-off-by: David S. Miller

    Patrick McHardy
     
  • For SELinux we do not allow security information to change during a remount
    operation. Thus this hook simply strips the security module options from
    the data and verifies that those are the same options as exist on the
    current superblock.

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

    Eric Paris
     
  • The VFS mount code passes the mount options to the LSM. The LSM will remove
    options it understands from the data and the VFS will then pass the remaining
    options onto the underlying filesystem. This is how options like the
    SELinux context= work. The problem comes in that -o remount never calls
    into LSM code. So if you include an LSM specific option it will get passed
    to the filesystem and will cause the remount to fail. An example of where
    this is a problem is the 'seclabel' option. The SELinux LSM hook will
    print this word in /proc/mounts if the filesystem is being labeled using
    xattrs. If you pass this word on mount it will be silently stripped and
    ignored. But if you pass this word on remount the LSM never gets called
    and it will be passed to the FS. The FS doesn't know what seclabel means
    and thus should fail the mount. For example an ext3 fs mounted over loop

    # mount -o loop /tmp/fs /mnt/tmp
    # cat /proc/mounts | grep /mnt/tmp
    /dev/loop0 /mnt/tmp ext3 rw,seclabel,relatime,errors=continue,barrier=0,data=ordered 0 0
    # mount -o remount /mnt/tmp
    mount: /mnt/tmp not mounted already, or bad option
    # dmesg
    EXT3-fs (loop0): error: unrecognized mount option "seclabel" or missing value

    This patch passes the remount mount options to an new LSM hook.

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

    Eric Paris
     
  • The security context for the newly created socket shares the same
    user, role and MLS attribute as its creator but may have a different
    type, which could be specified by a type_transition rule in the relevant
    policy package.

    Signed-off-by: Harry Ciao
    [fix call to security_transition_sid to include qstr, Eric Paris]
    Signed-off-by: Eric Paris
    Acked-by: Stephen Smalley

    Harry Ciao
     
  • The socket SID would be computed on creation and no longer inherit
    its creator's SID by default. Socket may have a different type but
    needs to retain the creator's role and MLS attribute in order not
    to break labeled networking and network access control.

    The kernel value for a class would be used to determine if the class
    if one of socket classes. If security_compute_sid is called from
    userspace the policy value for a class would be mapped to the relevant
    kernel value first.

    Signed-off-by: Harry Ciao
    Signed-off-by: Eric Paris
    Acked-by: Stephen Smalley

    Harry Ciao
     
  • The security_is_socket_class() is auto-generated by genheaders based
    on classmap.h to reduce maintenance effort when a new class is defined
    in SELinux kernel. The name for any socket class should be suffixed by
    "socket" and doesn't contain more than one substr of "socket".

    Signed-off-by: Harry Ciao
    Signed-off-by: Eric Paris
    Acked-by: Stephen Smalley

    Harry Ciao
     
  • Netlink message processing in the kernel is synchronous these days, the
    session information can be collected when needed.

    Signed-off-by: Patrick McHardy
    Signed-off-by: David S. Miller

    Patrick McHardy
     

03 Mar, 2011

1 commit

  • In tomoyo_check_open_permission() since 2.6.36, TOMOYO was by error
    recalculating already calculated pathname when checking allow_rewrite
    permission. As a result, memory will leak whenever a file is opened for writing
    without O_APPEND flag. Also, performance will degrade because TOMOYO is
    calculating pathname regardless of profile configuration.
    This patch fixes the leak and performance degrade.

    Signed-off-by: Tetsuo Handa
    Signed-off-by: James Morris

    Tetsuo Handa
     

26 Feb, 2011

1 commit

  • This reverts commit 242631c49d4cf39642741d6627750151b058233b.

    Conflicts:

    security/selinux/hooks.c

    SELinux used to recognize certain individual ioctls and check
    permissions based on the knowledge of the individual ioctl. In commit
    242631c49d4cf396 the SELinux code stopped trying to understand
    individual ioctls and to instead looked at the ioctl access bits to
    determine in we should check read or write for that operation. This
    same suggestion was made to SMACK (and I believe copied into TOMOYO).
    But this suggestion is total rubbish. The ioctl access bits are
    actually the access requirements for the structure being passed into the
    ioctl, and are completely unrelated to the operation of the ioctl or the
    object the ioctl is being performed upon.

    Take FS_IOC_FIEMAP as an example. FS_IOC_FIEMAP is defined as:

    FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)

    So it has access bits R and W. What this really means is that the
    kernel is going to both read and write to the struct fiemap. It has
    nothing at all to do with the operations that this ioctl might perform
    on the file itself!

    Signed-off-by: Eric Paris
    Acked-by: Stephen Smalley

    Eric Paris