08 Feb, 2008

1 commit


06 Feb, 2008

7 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
     
  • Since it was decided that low memory protection from userspace couldn't
    be turned on by default add a Kconfig option to allow users/distros to
    set a default at compile time. This value is still tunable after boot
    in /proc/sys/vm/mmap_min_addr

    Discussion:
    http://www.mail-archive.com/linux-security-module@vger.kernel.org/msg02543.html

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

    Eric Paris
     
  • Smack is the Simplified Mandatory Access Control Kernel.

    Smack implements mandatory access control (MAC) using labels
    attached to tasks and data containers, including files, SVIPC,
    and other tasks. Smack is a kernel based scheme that requires
    an absolute minimum of application support and a very small
    amount of configuration data.

    Smack uses extended attributes and
    provides a set of general mount options, borrowing technics used
    elsewhere. Smack uses netlabel for CIPSO labeling. Smack provides
    a pseudo-filesystem smackfs that is used for manipulation of
    system Smack attributes.

    The patch, patches for ls and sshd, a README, a startup script,
    and x86 binaries for ls and sshd are also available on

    http://www.schaufler-ca.com

    Development has been done using Fedora Core 7 in a virtual machine
    environment and on an old Sony laptop.

    Smack provides mandatory access controls based on the label attached
    to a task and the label attached to the object it is attempting to
    access. Smack labels are deliberately short (1-23 characters) text
    strings. Single character labels using special characters are reserved
    for system use. The only operation applied to Smack labels is equality
    comparison. No wildcards or expressions, regular or otherwise, are
    used. Smack labels are composed of printable characters and may not
    include "/".

    A file always gets the Smack label of the task that created it.

    Smack defines and uses these labels:

    "*" - pronounced "star"
    "_" - pronounced "floor"
    "^" - pronounced "hat"
    "?" - pronounced "huh"

    The access rules enforced by Smack are, in order:

    1. Any access requested by a task labeled "*" is denied.
    2. A read or execute access requested by a task labeled "^"
    is permitted.
    3. A read or execute access requested on an object labeled "_"
    is permitted.
    4. Any access requested on an object labeled "*" is permitted.
    5. Any access requested by a task on an object with the same
    label is permitted.
    6. Any access requested that is explicitly defined in the loaded
    rule set is permitted.
    7. Any other access is denied.

    Rules may be explicitly defined by writing subject,object,access
    triples to /smack/load.

    Smack rule sets can be easily defined that describe Bell&LaPadula
    sensitivity, Biba integrity, and a variety of interesting
    configurations. Smack rule sets can be modified on the fly to
    accommodate changes in the operating environment or even the time
    of day.

    Some practical use cases:

    Hierarchical levels. The less common of the two usual uses
    for MLS systems is to define hierarchical levels, often
    unclassified, confidential, secret, and so on. To set up smack
    to support this, these rules could be defined:

    C Unclass rx
    S C rx
    S Unclass rx
    TS S rx
    TS C rx
    TS Unclass rx

    A TS process can read S, C, and Unclass data, but cannot write it.
    An S process can read C and Unclass. Note that specifying that
    TS can read S and S can read C does not imply TS can read C, it
    has to be explicitly stated.

    Non-hierarchical categories. This is the more common of the
    usual uses for an MLS system. Since the default rule is that a
    subject cannot access an object with a different label no
    access rules are required to implement compartmentalization.

    A case that the Bell & LaPadula policy does not allow is demonstrated
    with this Smack access rule:

    A case that Bell&LaPadula does not allow that Smack does:

    ESPN ABC r
    ABC ESPN r

    On my portable video device I have two applications, one that
    shows ABC programming and the other ESPN programming. ESPN wants
    to show me sport stories that show up as news, and ABC will
    only provide minimal information about a sports story if ESPN
    is covering it. Each side can look at the other's info, neither
    can change the other. Neither can see what FOX is up to, which
    is just as well all things considered.

    Another case that I especially like:

    SatData Guard w
    Guard Publish w

    A program running with the Guard label opens a UDP socket and
    accepts messages sent by a program running with a SatData label.
    The Guard program inspects the message to ensure it is wholesome
    and if it is sends it to a program running with the Publish label.
    This program then puts the information passed in an appropriate
    place. Note that the Guard program cannot write to a Publish
    file system object because file system semanitic require read as
    well as write.

    The four cases (categories, levels, mutual read, guardbox) here
    are all quite real, and problems I've been asked to solve over
    the years. The first two are easy to do with traditonal MLS systems
    while the last two you can't without invoking privilege, at least
    for a while.

    Signed-off-by: Casey Schaufler
    Cc: Joshua Brindle
    Cc: Paul Moore
    Cc: Stephen Smalley
    Cc: Chris Wright
    Cc: James Morris
    Cc: "Ahmed S. Darwish"
    Cc: Andrew G. Morgan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Casey Schaufler
     
  • The capability bounding set is a set beyond which capabilities cannot grow.
    Currently cap_bset is per-system. It can be manipulated through sysctl,
    but only init can add capabilities. Root can remove capabilities. By
    default it includes all caps except CAP_SETPCAP.

    This patch makes the bounding set per-process when file capabilities are
    enabled. It is inherited at fork from parent. Noone can add elements,
    CAP_SETPCAP is required to remove them.

    One example use of this is to start a safer container. For instance, until
    device namespaces or per-container device whitelists are introduced, it is
    best to take CAP_MKNOD away from a container.

    The bounding set will not affect pP and pE immediately. It will only
    affect pP' and pE' after subsequent exec()s. It also does not affect pI,
    and exec() does not constrain pI'. So to really start a shell with no way
    of regain CAP_MKNOD, you would do

    prctl(PR_CAPBSET_DROP, CAP_MKNOD);
    cap_t cap = cap_get_proc();
    cap_value_t caparray[1];
    caparray[0] = CAP_MKNOD;
    cap_set_flag(cap, CAP_INHERITABLE, 1, caparray, CAP_DROP);
    cap_set_proc(cap);
    cap_free(cap);

    The following test program will get and set the bounding
    set (but not pI). For instance

    ./bset get
    (lists capabilities in bset)
    ./bset drop cap_net_raw
    (starts shell with new bset)
    (use capset, setuid binary, or binary with
    file capabilities to try to increase caps)

    ************************************************************
    cap_bound.c
    ************************************************************
    #include
    #include
    #include
    #include
    #include
    #include
    #include

    #ifndef PR_CAPBSET_READ
    #define PR_CAPBSET_READ 23
    #endif

    #ifndef PR_CAPBSET_DROP
    #define PR_CAPBSET_DROP 24
    #endif

    int usage(char *me)
    {
    printf("Usage: %s get\n", me);
    printf(" %s drop \n", me);
    return 1;
    }

    #define numcaps 32
    char *captable[numcaps] = {
    "cap_chown",
    "cap_dac_override",
    "cap_dac_read_search",
    "cap_fowner",
    "cap_fsetid",
    "cap_kill",
    "cap_setgid",
    "cap_setuid",
    "cap_setpcap",
    "cap_linux_immutable",
    "cap_net_bind_service",
    "cap_net_broadcast",
    "cap_net_admin",
    "cap_net_raw",
    "cap_ipc_lock",
    "cap_ipc_owner",
    "cap_sys_module",
    "cap_sys_rawio",
    "cap_sys_chroot",
    "cap_sys_ptrace",
    "cap_sys_pacct",
    "cap_sys_admin",
    "cap_sys_boot",
    "cap_sys_nice",
    "cap_sys_resource",
    "cap_sys_time",
    "cap_sys_tty_config",
    "cap_mknod",
    "cap_lease",
    "cap_audit_write",
    "cap_audit_control",
    "cap_setfcap"
    };

    int getbcap(void)
    {
    int comma=0;
    unsigned long i;
    int ret;

    printf("i know of %d capabilities\n", numcaps);
    printf("capability bounding set:");
    for (i=0; i< 0)
    perror("prctl");
    else if (ret==1)
    printf("%s%s", (comma++) ? ", " : " ", captable[i]);
    }
    printf("\n");
    return 0;
    }

    int capdrop(char *str)
    {
    unsigned long i;

    int found=0;
    for (i=0; i
    Signed-off-by: Andrew G. Morgan
    Cc: Stephen Smalley
    Cc: James Morris
    Cc: Chris Wright
    Cc: Casey Schaufler a
    Signed-off-by: "Serge E. Hallyn"
    Tested-by: Jiri Slaby
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Serge E. Hallyn
     
  • The patch supports legacy (32-bit) capability userspace, and where possible
    translates 32-bit capabilities to/from userspace and the VFS to 64-bit
    kernel space capabilities. If a capability set cannot be compressed into
    32-bits for consumption by user space, the system call fails, with -ERANGE.

    FWIW libcap-2.00 supports this change (and earlier capability formats)

    http://www.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.6/

    [akpm@linux-foundation.org: coding-syle fixes]
    [akpm@linux-foundation.org: use get_task_comm()]
    [ezk@cs.sunysb.edu: build fix]
    [akpm@linux-foundation.org: do not initialise statics to 0 or NULL]
    [akpm@linux-foundation.org: unused var]
    [serue@us.ibm.com: export __cap_ symbols]
    Signed-off-by: Andrew G. Morgan
    Cc: Stephen Smalley
    Acked-by: Serge Hallyn
    Cc: Chris Wright
    Cc: James Morris
    Cc: Casey Schaufler
    Signed-off-by: Erez Zadok
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morgan
     
  • Revert b68680e4731abbd78863063aaa0dca2a6d8cc723 to make way for the next
    patch: "Add 64-bit capability support to the kernel".

    We want to keep the vfs_cap_data.data[] structure, using two 'data's for
    64-bit caps (and later three for 96-bit caps), whereas
    b68680e4731abbd78863063aaa0dca2a6d8cc723 had gotten rid of the 'data' struct
    made its members inline.

    The 64-bit caps patch keeps the stack abuse fix at get_file_caps(), which was
    the more important part of that patch.

    [akpm@linux-foundation.org: coding-style fixes]
    Cc: Stephen Smalley
    Cc: Serge Hallyn
    Cc: Chris Wright
    Cc: James Morris
    Cc: Casey Schaufler
    Cc: Andrew Morgan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     
  • 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

14 commits

  • Capabilities have long been the default when CONFIG_SECURITY=n,
    and its help text suggests turning it on when CONFIG_SECURITY=y.
    But it is set to default n.

    Default it to y instead.

    Signed-off-by: Serge Hallyn
    Acked-by: Matt LaPlante
    Signed-off-by: James Morris

    sergeh@us.ibm.com
     
  • 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

2 commits

  • 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
     
  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/selinux-2.6:
    selinux: make mls_compute_sid always polyinstantiate
    security/selinux: constify function pointer tables and fields
    security: add a secctx_to_secid() hook
    security: call security_file_permission from rw_verify_area
    security: remove security_sb_post_mountroot hook
    Security: remove security.h include from mm.h
    Security: remove security_file_mmap hook sparse-warnings (NULL as 0).
    Security: add get, set, and cloning of superblock security information
    security/selinux: Add missing "space"

    Linus Torvalds
     

25 Jan, 2008

11 commits

  • There is no need for kobject_unregister() anymore, thanks to Kay's
    kobject cleanup changes, so replace all instances of it with
    kobject_put().

    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • kernel_kset does not need to be a kset, but a much simpler kobject now
    that we have kobj_attributes.

    We also rename kernel_kset to kernel_kobj to catch all users of this
    symbol with a build error instead of an easy-to-ignore build warning.

    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • Dynamically create the kset instead of declaring it statically. We also
    rename kernel_subsys to kernel_kset to catch all users of this symbol
    with a build error instead of an easy-to-ignore build warning.

    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • We don't need a kset here, a simple kobject will do just fine, so
    dynamically create the kobject and use it.

    Cc: Kay Sievers
    Acked-by: Chris Wright
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • We don't need a "default" ktype for a kset. We should set this
    explicitly every time for each kset. This change is needed so that we
    can make ksets dynamic, and cleans up one of the odd, undocumented
    assumption that the kset/kobject/ktype model has.

    This patch is based on a lot of help from Kay Sievers.

    Nasty bug in the block code was found by Dave Young

    Cc: Kay Sievers
    Cc: Dave Young
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • 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
     
  • The security_sb_post_mountroot() hook is long-since obsolete, and is
    fundamentally broken: it is never invoked if someone uses initramfs.
    This is particularly damaging, because the existence of this hook has
    been used as motivation for not using initramfs.

    Stephen Smalley confirmed on 2007-07-19 that this hook was originally
    used by SELinux but can now be safely removed:

    http://marc.info/?l=linux-kernel&m=118485683612916&w=2

    Cc: Stephen Smalley
    Cc: James Morris
    Cc: Eric Paris
    Cc: Chris Wright
    Signed-off-by: H. Peter Anvin
    Signed-off-by: James Morris

    H. Peter Anvin
     
  • 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