06 Feb, 2008

2 commits

  • The security_get_policycaps() functions has a couple of bugs in it and it
    isn't currently used by any in-tree code, so get rid of it and all of it's
    bugginess.

    Signed-off-by: Paul Moore
    Signed-off-by: James Morris

    Paul Moore
     
  • This patch modifies the interface to inode_getsecurity to have the function
    return a buffer containing the security blob and its length via parameters
    instead of relying on the calling function to give it an appropriately sized
    buffer.

    Security blobs obtained with this function should be freed using the
    release_secctx LSM hook. This alleviates the problem of the caller having to
    guess a length and preallocate a buffer for this function allowing it to be
    used elsewhere for Labeled NFS.

    The patch also removed the unused err parameter. The conversion is similar to
    the one performed by Al Viro for the security_getprocattr hook.

    Signed-off-by: David P. Quigley
    Cc: Stephen Smalley
    Cc: Chris Wright
    Acked-by: James Morris
    Acked-by: Serge Hallyn
    Cc: Casey Schaufler
    Cc: Al Viro
    Cc: Christoph Hellwig
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David P. Quigley
     

02 Feb, 2008

2 commits


01 Feb, 2008

1 commit

  • As pointed out by Adrian Bunk, commit
    45c950e0f839fded922ebc0bfd59b1081cc71b70 ("fix memory leak in netlabel
    code") caused a double-free when security_netlbl_sid_to_secattr()
    fails. This patch fixes this by removing the netlbl_secattr_destroy()
    call from that function since we are already releasing the secattr
    memory in selinux_netlbl_sock_setsid().

    Signed-off-by: Paul Moore
    Signed-off-by: David S. Miller

    Paul Moore
     

30 Jan, 2008

13 commits

  • selinux_set_mnt_opts() can become static.

    Signed-off-by: Adrian Bunk
    Signed-off-by: James Morris

    Adrian Bunk
     
  • Currently network traffic can be sliently dropped due to non-avc errors which
    can lead to much confusion when trying to debug the problem. This patch adds
    warning messages so that when these events occur there is a user visible
    notification.

    Signed-off-by: Paul Moore
    Signed-off-by: James Morris

    Paul Moore
     
  • This patch implements packet ingress/egress controls for SELinux which allow
    SELinux security policy to control the flow of all IPv4 and IPv6 packets into
    and out of the system. Currently SELinux does not have proper control over
    forwarded packets and this patch corrects this problem.

    Special thanks to Venkat Yekkirala whose earlier
    work on this topic eventually led to this patch.

    Signed-off-by: Paul Moore
    Signed-off-by: James Morris

    Paul Moore
     
  • Now that the SELinux NetLabel "base SID" is always the netmsg initial SID we
    can do a big optimization - caching the SID and not just the MLS attributes.
    This not only saves a lot of per-packet memory allocations and copies but it
    has a nice side effect of removing a chunk of code.

    Signed-off-by: Paul Moore
    Signed-off-by: James Morris

    Paul Moore
     
  • This patch introduces a mechanism for checking when labeled IPsec or SECMARK
    are in use by keeping introducing a configuration reference counter for each
    subsystem. In the case of labeled IPsec, whenever a labeled SA or SPD entry
    is created the labeled IPsec/XFRM reference count is increased and when the
    entry is removed it is decreased. In the case of SECMARK, when a SECMARK
    target is created the reference count is increased and later decreased when the
    target is removed. These reference counters allow SELinux to quickly determine
    if either of these subsystems are enabled.

    NetLabel already has a similar mechanism which provides the netlbl_enabled()
    function.

    This patch also renames the selinux_relabel_packet_permission() function to
    selinux_secmark_relabel_packet_permission() as the original name and
    description were misleading in that they referenced a single packet label which
    is not the case.

    Signed-off-by: Paul Moore
    Signed-off-by: James Morris

    Paul Moore
     
  • Rework the handling of network peer labels so that the different peer labeling
    subsystems work better together. This includes moving both subsystems to a
    single "peer" object class which involves not only changes to the permission
    checks but an improved method of consolidating multiple packet peer labels.
    As part of this work the inbound packet permission check code has been heavily
    modified to handle both the old and new behavior in as sane a fashion as
    possible.

    Signed-off-by: Paul Moore
    Signed-off-by: James Morris

    Paul Moore
     
  • Add additional Flask definitions to support the new "peer" object class and
    additional permissions to the netif, node, and packet object classes. Also,
    bring the kernel Flask definitions up to date with the Fedora SELinux policies
    by adding the "flow_in" and "flow_out" permissions to the "packet" class.

    Signed-off-by: Paul Moore
    Signed-off-by: James Morris

    Paul Moore
     
  • Add a new policy capabilities bitmap to SELinux policy version 22. This bitmap
    will enable the security server to query the policy to determine which features
    it supports.

    Signed-off-by: Paul Moore
    Signed-off-by: James Morris

    Paul Moore
     
  • This patch adds a SELinux IP address/node SID caching mechanism similar to the
    sel_netif_*() functions. The node SID queries in the SELinux hooks files are
    also modified to take advantage of this new functionality. In addition, remove
    the address length information from the sk_buff parsing routines as it is
    redundant since we already have the address family.

    Signed-off-by: Paul Moore
    Signed-off-by: James Morris

    Paul Moore
     
  • Instead of storing the packet's network interface name store the ifindex. This
    allows us to defer the need to lookup the net_device structure until the audit
    record is generated meaning that in the majority of cases we never need to
    bother with this at all.

    Signed-off-by: Paul Moore
    Signed-off-by: James Morris

    Paul Moore
     
  • The current SELinux netif code requires the caller have a valid net_device
    struct pointer to lookup network interface information. However, we don't
    always have a valid net_device pointer so convert the netif code to use
    the ifindex values we always have as part of the sk_buff. This patch also
    removes the default message SID from the network interface record, it is
    not being used and therefore is "dead code".

    Signed-off-by: Paul Moore
    Signed-off-by: James Morris

    Paul Moore
     
  • In order to do any sort of IP header inspection of incoming packets we need to
    know which address family, AF_INET/AF_INET6/etc., it belongs to and since the
    sk_buff structure does not store this information we need to pass along the
    address family separate from the packet itself.

    Signed-off-by: Paul Moore
    Signed-off-by: James Morris

    Paul Moore
     
  • This patch adds support to the NetLabel LSM secattr struct for a secid token
    and a type field, paving the way for full LSM/SELinux context support and
    "static" or "fallback" labels. In addition, this patch adds a fair amount
    of documentation to the core NetLabel structures used as part of the
    NetLabel kernel API.

    Signed-off-by: Paul Moore
    Signed-off-by: James Morris

    Paul Moore
     

29 Jan, 2008

1 commit

  • The IPv4 and IPv6 hook values are identical, yet some code tries to figure
    out the "correct" value by looking at the address family. Introduce NF_INET_*
    values for both IPv4 and IPv6. The old values are kept in a #ifndef __KERNEL__
    section for userspace compatibility.

    Signed-off-by: Patrick McHardy
    Acked-by: Herbert Xu
    Signed-off-by: David S. Miller

    Patrick McHardy
     

26 Jan, 2008

1 commit

  • The proc net rewrite had a side effect on selinux, leading it to mislabel
    the /proc/net inodes, thereby leading to incorrect denials. Fix
    security_genfs_sid to ignore extra leading / characters in the path supplied
    by selinux_proc_get_sid since we now get "//net/..." rather than "/net/...".

    Signed-off-by: Stephen Smalley
    Signed-off-by: James Morris

    Stephen Smalley
     

25 Jan, 2008

5 commits

  • This patch removes the requirement that the new and related object types
    differ in order to polyinstantiate by MLS level. This allows MLS
    polyinstantiation to occur in the absence of explicit type_member rules or
    when the type has not changed.

    Potential users of this support include pam_namespace.so (directory
    polyinstantiation) and the SELinux X support (property polyinstantiation).

    Signed-off-by: Eamon Walsh
    Acked-by: Stephen Smalley
    Signed-off-by: James Morris

    Eamon Walsh
     
  • Constify function pointer tables and fields.

    Signed-off-by: Jan Engelhardt
    Signed-off-by: James Morris

    Jan Engelhardt
     
  • Add a secctx_to_secid() LSM hook to go along with the existing
    secid_to_secctx() LSM hook. This patch also includes the SELinux
    implementation for this hook.

    Signed-off-by: Paul Moore
    Acked-by: Stephen Smalley
    Signed-off-by: James Morris

    David Howells
     
  • Adds security_get_sb_mnt_opts, security_set_sb_mnt_opts, and
    security_clont_sb_mnt_opts to the LSM and to SELinux. This will allow
    filesystems to directly own and control all of their mount options if they
    so choose. This interface deals only with option identifiers and strings so
    it should generic enough for any LSM which may come in the future.

    Filesystems which pass text mount data around in the kernel (almost all of
    them) need not currently make use of this interface when dealing with
    SELinux since it will still parse those strings as it always has. I assume
    future LSM's would do the same. NFS is the primary FS which does not use
    text mount data and thus must make use of this interface.

    An LSM would need to implement these functions only if they had mount time
    options, such as selinux has context= or fscontext=. If the LSM has no
    mount time options they could simply not implement and let the dummy ops
    take care of things.

    An LSM other than SELinux would need to define new option numbers in
    security.h and any FS which decides to own there own security options would
    need to be patched to use this new interface for every possible LSM. This
    is because it was stated to me very clearly that LSM's should not attempt to
    understand FS mount data and the burdon to understand security should be in
    the FS which owns the options.

    Signed-off-by: Eric Paris
    Acked-by: Stephen D. Smalley
    Signed-off-by: James Morris

    Eric Paris
     
  • Add missing space.

    Signed-off-by: Joe Perches
    Signed-off-by: James Morris

    Joe Perches
     

22 Jan, 2008

1 commit


05 Dec, 2007

2 commits

  • Instead of using f_op to detect dead booleans, check the inode index
    against the number of booleans and check the dentry name against the
    boolean name for that index on reads and writes. This prevents
    incorrect use of a boolean file opened prior to a policy reload while
    allowing valid use of it as long as it still corresponds to the same
    boolean in the policy.

    Signed-off-by: Stephen Smalley
    Signed-off-by: James Morris

    Stephen Smalley
     
  • Do not clear f_op when removing entries since it isn't safe to do.

    Signed-off-by: Stephen Smalley
    Signed-off-by: James Morris

    Stephen Smalley
     

08 Nov, 2007

3 commits


23 Oct, 2007

1 commit

  • When checking if we can wait on a child we were looking at
    p->exit_signal and trying to make the decision based on if the signal
    would eventually be allowed. One big flaw is that p->exit_signal is -1
    for NPTL threads and so aignal_to_av was not actually checking SIGCHLD
    which is what would have been sent. Even is exit_signal was set to
    something strange it wouldn't change the fact that the child was there
    and needed to be waited on. This patch just assumes wait is based on
    SIGCHLD. Specific permission checks are made when the child actually
    attempts to send a signal.

    This resolves the problem of things like using GDB on confined domains
    such as in RH BZ 232371. The confined domain did not have permission to
    send a generic signal (exit_signal == -1) back to the unconfined GDB.
    With this patch the GDB wait works and since the actual signal sent is
    allowed everything functions as it should.

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

    Eric Paris
     

19 Oct, 2007

1 commit

  • Get rid of sparse related warnings from places that use integer as NULL
    pointer.

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Stephen Hemminger
    Cc: Andi Kleen
    Cc: Jeff Garzik
    Cc: Matt Mackall
    Cc: Ian Kent
    Cc: Arnd Bergmann
    Cc: Davide Libenzi
    Cc: Stephen Smalley
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Hemminger
     

17 Oct, 2007

7 commits

  • This patch contains the following cleanups that are now possible:
    - remove the unused security_operations->inode_xattr_getsuffix
    - remove the no longer used security_operations->unregister_security
    - remove some no longer required exit code
    - remove a bunch of no longer used exports

    Signed-off-by: Adrian Bunk
    Acked-by: James Morris
    Cc: Chris Wright
    Cc: Stephen Smalley
    Cc: Serge Hallyn
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Adrian Bunk
     
  • Implement file posix capabilities. This allows programs to be given a
    subset of root's powers regardless of who runs them, without having to use
    setuid and giving the binary all of root's powers.

    This version works with Kaigai Kohei's userspace tools, found at
    http://www.kaigai.gr.jp/index.php. For more information on how to use this
    patch, Chris Friedhoff has posted a nice page at
    http://www.friedhoff.org/fscaps.html.

    Changelog:
    Nov 27:
    Incorporate fixes from Andrew Morton
    (security-introduce-file-caps-tweaks and
    security-introduce-file-caps-warning-fix)
    Fix Kconfig dependency.
    Fix change signaling behavior when file caps are not compiled in.

    Nov 13:
    Integrate comments from Alexey: Remove CONFIG_ ifdef from
    capability.h, and use %zd for printing a size_t.

    Nov 13:
    Fix endianness warnings by sparse as suggested by Alexey
    Dobriyan.

    Nov 09:
    Address warnings of unused variables at cap_bprm_set_security
    when file capabilities are disabled, and simultaneously clean
    up the code a little, by pulling the new code into a helper
    function.

    Nov 08:
    For pointers to required userspace tools and how to use
    them, see http://www.friedhoff.org/fscaps.html.

    Nov 07:
    Fix the calculation of the highest bit checked in
    check_cap_sanity().

    Nov 07:
    Allow file caps to be enabled without CONFIG_SECURITY, since
    capabilities are the default.
    Hook cap_task_setscheduler when !CONFIG_SECURITY.
    Move capable(TASK_KILL) to end of cap_task_kill to reduce
    audit messages.

    Nov 05:
    Add secondary calls in selinux/hooks.c to task_setioprio and
    task_setscheduler so that selinux and capabilities with file
    cap support can be stacked.

    Sep 05:
    As Seth Arnold points out, uid checks are out of place
    for capability code.

    Sep 01:
    Define task_setscheduler, task_setioprio, cap_task_kill, and
    task_setnice to make sure a user cannot affect a process in which
    they called a program with some fscaps.

    One remaining question is the note under task_setscheduler: are we
    ok with CAP_SYS_NICE being sufficient to confine a process to a
    cpuset?

    It is a semantic change, as without fsccaps, attach_task doesn't
    allow CAP_SYS_NICE to override the uid equivalence check. But since
    it uses security_task_setscheduler, which elsewhere is used where
    CAP_SYS_NICE can be used to override the uid equivalence check,
    fixing it might be tough.

    task_setscheduler
    note: this also controls cpuset:attach_task. Are we ok with
    CAP_SYS_NICE being used to confine to a cpuset?
    task_setioprio
    task_setnice
    sys_setpriority uses this (through set_one_prio) for another
    process. Need same checks as setrlimit

    Aug 21:
    Updated secureexec implementation to reflect the fact that
    euid and uid might be the same and nonzero, but the process
    might still have elevated caps.

    Aug 15:
    Handle endianness of xattrs.
    Enforce capability version match between kernel and disk.
    Enforce that no bits beyond the known max capability are
    set, else return -EPERM.
    With this extra processing, it may be worth reconsidering
    doing all the work at bprm_set_security rather than
    d_instantiate.

    Aug 10:
    Always call getxattr at bprm_set_security, rather than
    caching it at d_instantiate.

    [morgan@kernel.org: file-caps clean up for linux/capability.h]
    [bunk@kernel.org: unexport cap_inode_killpriv]
    Signed-off-by: Serge E. Hallyn
    Cc: Stephen Smalley
    Cc: James Morris
    Cc: Chris Wright
    Cc: Andrew Morgan
    Signed-off-by: Andrew Morgan
    Signed-off-by: Adrian Bunk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Serge E. Hallyn
     
  • Convert LSM into a static interface, as the ability to unload a security
    module is not required by in-tree users and potentially complicates the
    overall security architecture.

    Needlessly exported LSM symbols have been unexported, to help reduce API
    abuse.

    Parameters for the capability and root_plug modules are now specified
    at boot.

    The SECURITY_FRAMEWORK_VERSION macro has also been removed.

    In a nutshell, there is no safe way to unload an LSM. The modular interface
    is thus unecessary and broken infrastructure. It is used only by out-of-tree
    modules, which are often binary-only, illegal, abusive of the API and
    dangerous, e.g. silently re-vectoring SELinux.

    [akpm@linux-foundation.org: cleanups]
    [akpm@linux-foundation.org: USB Kconfig fix]
    [randy.dunlap@oracle.com: fix LSM kernel-doc]
    Signed-off-by: James Morris
    Acked-by: Chris Wright
    Cc: Stephen Smalley
    Cc: "Serge E. Hallyn"
    Acked-by: Arjan van de Ven
    Signed-off-by: Randy Dunlap
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    James Morris
     
  • This patch kills ugly warnings when the "Improve SELinux performance
    when ACV misses" patch.

    Signed-off-by: KaiGai Kohei
    Signed-off-by: James Morris

    KaiGai Kohei
     
  • * We add ebitmap_for_each_positive_bit() which enables to walk on
    any positive bit on the given ebitmap, to improve its performance
    using common bit-operations defined in linux/bitops.h.
    In the previous version, this logic was implemented using a combination
    of ebitmap_for_each_bit() and ebitmap_node_get_bit(), but is was worse
    in performance aspect.
    This logic is most frequestly used to compute a new AVC entry,
    so this patch can improve SELinux performance when AVC misses are happen.
    * struct ebitmap_node is redefined as an array of "unsigned long", to get
    suitable for using find_next_bit() which is fasted than iteration of
    shift and logical operation, and to maximize memory usage allocated
    from general purpose slab.
    * Any ebitmap_for_each_bit() are repleced by the new implementation
    in ss/service.c and ss/mls.c. Some of related implementation are
    changed, however, there is no incompatibility with the previous
    version.
    * The width of any new line are less or equal than 80-chars.

    The following benchmark shows the effect of this patch, when we
    access many files which have different security context one after
    another. The number is more than /selinux/avc/cache_threshold, so
    any access always causes AVC misses.

    selinux-2.6 selinux-2.6-ebitmap
    AVG: 22.763 [s] 8.750 [s]
    STD: 0.265 0.019
    ------------------------------------------
    1st: 22.558 [s] 8.786 [s]
    2nd: 22.458 [s] 8.750 [s]
    3rd: 22.478 [s] 8.754 [s]
    4th: 22.724 [s] 8.745 [s]
    5th: 22.918 [s] 8.748 [s]
    6th: 22.905 [s] 8.764 [s]
    7th: 23.238 [s] 8.726 [s]
    8th: 22.822 [s] 8.729 [s]

    Signed-off-by: KaiGai Kohei
    Acked-by: Stephen Smalley
    Signed-off-by: James Morris

    KaiGai Kohei
     
  • Allow policy to select, in much the same way as it selects MLS support, how
    the kernel should handle access decisions which contain either unknown
    classes or unknown permissions in known classes. The three choices for the
    policy flags are

    0 - Deny unknown security access. (default)
    2 - reject loading policy if it does not contain all definitions
    4 - allow unknown security access

    The policy's choice is exported through 2 booleans in
    selinuxfs. /selinux/deny_unknown and /selinux/reject_unknown.

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

    Eric Paris
     
  • It reduces the selinux overhead on read/write by only revalidating
    permissions in selinux_file_permission if the task or inode labels have
    changed or the policy has changed since the open-time check. A new LSM
    hook, security_dentry_open, is added to capture the necessary state at open
    time to allow this optimization.

    (see http://marc.info/?l=selinux&m=118972995207740&w=2)

    Signed-off-by: Yuichi Nakamura
    Acked-by: Stephen Smalley
    Signed-off-by: James Morris

    Yuichi Nakamura