30 Sep, 2006

4 commits

  • Accepted connections of types other than AF_INET, AF_INET6, AF_UNIX won't
    have an appropriate label derived from the peer, so don't use it.

    Signed-off-by: David Woodhouse
    Acked-by: Stephen Smalley
    Acked-by: James Morris
    Acked-by: Paul Moore
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Woodhouse
     
  • This is an updated version of Eric Biederman's is_init() patch.
    (http://lkml.org/lkml/2006/2/6/280). It applies cleanly to 2.6.18-rc3 and
    replaces a few more instances of ->pid == 1 with is_init().

    Further, is_init() checks pid and thus removes dependency on Eric's other
    patches for now.

    Eric's original description:

    There are a lot of places in the kernel where we test for init
    because we give it special properties. Most significantly init
    must not die. This results in code all over the kernel test
    ->pid == 1.

    Introduce is_init to capture this case.

    With multiple pid spaces for all of the cases affected we are
    looking for only the first process on the system, not some other
    process that has pid == 1.

    Signed-off-by: Eric W. Biederman
    Signed-off-by: Sukadev Bhattiprolu
    Cc: Dave Hansen
    Cc: Serge Hallyn
    Cc: Cedric Le Goater
    Cc:
    Acked-by: Paul Mackerras
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sukadev Bhattiprolu
     
  • This code has suffered from broken core design and lack of developer
    attention. Broken security modules are too dangerous to leave around. It
    is time to remove this one.

    Signed-off-by: Chris Wright
    Acked-by: Michael Halcrow
    Acked-by: Serge Hallyn
    Cc: Davi Arnaut
    Acked-by: Greg Kroah-Hartman
    Acked-by: James Morris
    Acked-by: Alan Cox
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Chris Wright
     
  • Allows commas to be embedded into context mount options (i.e. "-o
    context=some_selinux_context_t"), to better support multiple categories,
    which are separated by commas and confuse mount.

    For example, with the current code:

    mount -t iso9660 /dev/cdrom /media/cdrom -o \
    ro,context=system_u:object_r:iso9660_t:s0:c1,c3,c4,exec

    The context option that will be interpreted by SELinux is
    context=system_u:object_r:iso9660_t:s0:c1

    instead of
    context=system_u:object_r:iso9660_t:s0:c1,c3,c4

    The options that will be passed on to the file system will be
    ro,c3,c4,exec.

    The proposed solution is to allow/require the SELinux context option
    specified to mount to use quotes when the context contains a comma.

    This patch modifies the option parsing in parse_opts(), contained in
    mount.c, to take options after finding a comma only if it hasn't seen a
    quote or if the quotes are matched. It also introduces a new function that
    will strip the quotes from the context option prior to translation. The
    quotes are replaced after the translation is completed to insure that in
    the event the raw context contains commas the kernel will be able to
    interpret the correct context.

    Signed-off-by: Cory Olmo
    Signed-off-by: James Morris
    Acked-by: Stephen Smalley
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Cory Olmo
     

27 Sep, 2006

2 commits

  • This eliminates the i_blksize field from struct inode. Filesystems that want
    to provide a per-inode st_blksize can do so by providing their own getattr
    routine instead of using the generic_fillattr() function.

    Note that some filesystems were providing pretty much random (and incorrect)
    values for i_blksize.

    [bunk@stusta.de: cleanup]
    [akpm@osdl.org: generic_fillattr() fix]
    Signed-off-by: "Theodore Ts'o"
    Signed-off-by: Adrian Bunk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Theodore Ts'o
     
  • The following patches reduce the size of the VFS inode structure by 28 bytes
    on a UP x86. (It would be more on an x86_64 system). This is a 10% reduction
    in the inode size on a UP kernel that is configured in a production mode
    (i.e., with no spinlock or other debugging functions enabled; if you want to
    save memory taken up by in-core inodes, the first thing you should do is
    disable the debugging options; they are responsible for a huge amount of bloat
    in the VFS inode structure).

    This patch:

    The filesystem or device-specific pointer in the inode is inside a union,
    which is pretty pointless given that all 30+ users of this field have been
    using the void pointer. Get rid of the union and rename it to i_private, with
    a comment to explain who is allowed to use the void pointer. This is just a
    cleanup, but it allows us to reuse the union 'u' for something something where
    the union will actually be used.

    [judith@osdl.org: powerpc build fix]
    Signed-off-by: "Theodore Ts'o"
    Signed-off-by: Judith Lebzelter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Theodore Ts'o
     

26 Sep, 2006

11 commits

  • Take tty_mutex when accessing ->signal->tty in selinux code. Noted by Alan
    Cox. Longer term, we are looking at refactoring the code to provide better
    encapsulation of the tty layer, but this is a simple fix that addresses the
    immediate bug.

    Signed-off-by: Stephen Smalley
    Acked-by: Alan Cox
    Acked-by: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Smalley
     
  • This patch converts the semaphore in the superblock security struct to a
    mutex. No locking changes or other code changes are done.

    Signed-off-by: Eric Paris
    Acked-by: Stephen Smalley
    Acked-by: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Paris
     
  • This patch converts the remaining isec->sem into a mutex. Very similar
    locking is provided as before only in the faster smaller mutex rather than a
    semaphore. An out_unlock path is introduced rather than the conditional
    unlocking found in the original code.

    Signed-off-by: Eric Paris
    Acked-by: Stephen Smalley
    Acked-by: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Paris
     
  • inode_security_set_sid is only called by security_inode_init_security, which
    is called when a new file is being created and needs to have its incore
    security state initialized and its security xattr set. This helper used to be
    called in other places in the past, but now only has the one. So this patch
    rolls inode_security_set_sid directly back into security_inode_init_security.
    There also is no need to hold the isec->sem while doing this, as the inode is
    not available to other threads at this point in time.

    Signed-off-by: Eric Paris
    Acked-by: Stephen Smalley
    Acked-by: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Paris
     
  • Introduces support for policy version 21. This version of the binary
    kernel policy allows for defining range transitions on security classes
    other than the process security class. As always, backwards compatibility
    for older formats is retained. The security class is read in as specified
    when using the new format, while the "process" security class is assumed
    when using an older policy format.

    Signed-off-by: Darrel Goeddel
    Signed-off-by: Stephen Smalley
    Acked-by: James Morris
    Acked-by: Eric Paris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Darrel Goeddel
     
  • Enable configuration of SELinux maximum supported policy version to support
    legacy userland (init) that does not gracefully handle kernels that support
    newer policy versions two or more beyond the installed policy, as in FC3
    and FC4.

    [bunk@stusta.de: improve Kconfig help text]
    Signed-off-by: Stephen Smalley
    Acked-by: James Morris
    Acked-by: Eric Paris
    Signed-off-by: Adrian Bunk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Smalley
     
  • Replace ctxid with sid in selinux_audit_rule_match interface for
    consistency with other interfaces.

    Signed-off-by: Stephen Smalley
    Acked-by: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Smalley
     
  • Rename selinux_ctxid_to_string to selinux_sid_to_string to be
    consistent with other interfaces.

    Signed-off-by: Stephen Smalley
    Acked-by: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Smalley
     
  • Eliminate selinux_task_ctxid since it duplicates selinux_task_get_sid.

    Signed-off-by: Stephen Smalley
    Acked-by: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Smalley
     
  • Change NetLabel to use the 'recvfrom' socket permission and the
    SECINITSID_NETMSG SELinux SID as the NetLabel base SID for incoming packets.
    This patch effectively makes the old, and currently unused, SELinux NETMSG
    permissions NetLabel permissions.

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

    Paul Moore
     
  • Fix a problem where NetLabel would always set the value of
    sk_security_struct->peer_sid in selinux_netlbl_sock_graft() to the context of
    the socket, causing problems when users would query the context of the
    connection. This patch fixes this so that the value in
    sk_security_struct->peer_sid is only set when the connection is NetLabel based,
    otherwise the value is untouched.

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

    Paul Moore
     

23 Sep, 2006

16 commits

  • The following fixes a bug where random mem is being tampered with in the
    non-mls case; encountered by Jashua Brindle on a gentoo box.

    Signed-off-by: Venkat Yekkirala
    Acked-by: Stephen Smalley
    Signed-off-by: James Morris

    Venkat Yekkirala
     
  • Add some missing include files to the NetLabel related header files.

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

    Paul Moore
     
  • Uninline the selinux_netlbl_inode_permission() at the request of
    Andrew Morton.

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

    Paul Moore
     
  • Rewrite ebitmap_import() so it is a bit cleaner and easier to read.

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

    Paul Moore
     
  • Fix some incorrect comments.

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

    Paul Moore
     
  • Fix a problem where the NetLabel specific fields of the sk_security_struct
    structure were not being initialized early enough in some cases.

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

    Paul Moore
     
  • This patch makes four needlessly global functions static.

    Signed-off-by: Adrian Bunk
    Acked-by: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: David S. Miller

    Adrian Bunk
     
  • Add NetLabel support to the SELinux LSM and modify the
    socket_post_create() LSM hook to return an error code. The most
    significant part of this patch is the addition of NetLabel hooks into
    the following SELinux LSM hooks:

    * selinux_file_permission()
    * selinux_socket_sendmsg()
    * selinux_socket_post_create()
    * selinux_socket_sock_rcv_skb()
    * selinux_socket_getpeersec_stream()
    * selinux_socket_getpeersec_dgram()
    * selinux_sock_graft()
    * selinux_inet_conn_request()

    The basic reasoning behind this patch is that outgoing packets are
    "NetLabel'd" by labeling their socket and the NetLabel security
    attributes are checked via the additional hook in
    selinux_socket_sock_rcv_skb(). NetLabel itself is only a labeling
    mechanism, similar to filesystem extended attributes, it is up to the
    SELinux enforcement mechanism to perform the actual access checks.

    In addition to the changes outlined above this patch also includes
    some changes to the extended bitmap (ebitmap) and multi-level security
    (mls) code to import and export SELinux TE/MLS attributes into and out
    of NetLabel.

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

    Venkat Yekkirala
     
  • The following patch will fix the build problem (encountered by Andrew
    Morton) when SECURITY_NETWORK_XFRM is not enabled.

    As compared to git-net-selinux_xfrm_decode_session-build-fix.patch in
    -mm, this patch sets the return parameter sid to SECSID_NULL in
    selinux_xfrm_decode_session() and handles this value in the caller
    selinux_inet_conn_request() appropriately.

    Signed-off-by: Venkat Yekkirala
    Acked-by: James Morris
    Signed-off-by: David S. Miller

    Venkat Yekkirala
     
  • This automatically labels the TCP, Unix stream, and dccp child sockets
    as well as openreqs to be at the same MLS level as the peer. This will
    result in the selection of appropriately labeled IPSec Security
    Associations.

    This also uses the sock's sid (as opposed to the isec sid) in SELinux
    enforcement of secmark in rcv_skb and postroute_last hooks.

    Signed-off-by: Venkat Yekkirala
    Signed-off-by: David S. Miller

    Venkat Yekkirala
     
  • This defaults the label of socket-specific IPSec policies to be the
    same as the socket they are set on.

    Signed-off-by: Venkat Yekkirala
    Signed-off-by: David S. Miller

    Venkat Yekkirala
     
  • This labels the flows that could utilize IPSec xfrms at the points the
    flows are defined so that IPSec policy and SAs at the right label can
    be used.

    The following protos are currently not handled, but they should
    continue to be able to use single-labeled IPSec like they currently
    do.

    ipmr
    ip_gre
    ipip
    igmp
    sit
    sctp
    ip6_tunnel (IPv6 over IPv6 tunnel device)
    decnet

    Signed-off-by: Venkat Yekkirala
    Signed-off-by: David S. Miller

    Venkat Yekkirala
     
  • This implements a seemless mechanism for xfrm policy selection and
    state matching based on the flow sid. This also includes the necessary
    SELinux enforcement pieces.

    Signed-off-by: Venkat Yekkirala
    Signed-off-by: David S. Miller

    Venkat Yekkirala
     
  • This adds security for IP sockets at the sock level. Security at the
    sock level is needed to enforce the SELinux security policy for
    security associations even when a sock is orphaned (such as in the TCP
    LAST_ACK state).

    This will also be used to enforce SELinux controls over data arriving
    at or leaving a child socket while it's still waiting to be accepted.

    Signed-off-by: Venkat Yekkirala
    Signed-off-by: David S. Miller

    Venkat Yekkirala
     
  • This defines a routine that combines the Type Enforcement portion of
    one sid with the MLS portion from the other sid to arrive at a new
    sid. This would be used to define a sid for a security association
    that is to be negotiated by IKE as well as for determing the sid for
    open requests and connection-oriented child sockets.

    Signed-off-by: Venkat Yekkirala
    Signed-off-by: David S. Miller

    Venkat Yekkirala
     
  • The current approach to labeling Security Associations for SELinux
    purposes uses a one-to-one mapping between xfrm policy rules and
    security associations.

    This doesn't address the needs of real world MLS (Multi-level System,
    traditional Bell-LaPadula) environments where a single xfrm policy
    rule (pertaining to a range, classified to secret for example) might
    need to map to multiple Security Associations (one each for
    classified, secret, top secret and all the compartments applicable to
    these security levels).

    This patch set addresses the above problem by allowing for the mapping
    of a single xfrm policy rule to multiple security associations, with
    each association used in the security context it is defined for. It
    also includes the security context to be used in IKE negotiation in
    the acquire messages sent to the IKE daemon so that a unique SA can be
    negotiated for each unique security context. A couple of bug fixes are
    also included; checks to make sure the SAs used by a packet match
    policy (security context-wise) on the inbound and also that the bundle
    used for the outbound matches the security context of the flow. This
    patch set also makes the use of the SELinux sid in flow cache lookups
    seemless by including the sid in the flow key itself. Also, open
    requests as well as connection-oriented child sockets are labeled
    automatically to be at the same level as the peer to allow for use of
    appropriately labeled IPSec associations.

    Description of changes:

    A "sid" member has been added to the flow cache key resulting in the
    sid being available at all needed locations and the flow cache lookups
    automatically using the sid. The flow sid is derived from the socket
    on the outbound and the SAs (unlabeled where an SA was not used) on
    the inbound.

    Outbound case:
    1. Find policy for the socket.

    2. OLD: Find an SA that matches the policy.
    NEW: Find an SA that matches BOTH the policy and the flow/socket.
    This is necessary since not every SA that matches the policy
    can be used for the flow/socket. Consider policy range Secret-TS,
    and SAs each for Secret and TS. We don't want a TS socket to
    use the Secret SA. Hence the additional check for the SA Vs. flow/socket.

    3. NEW: When looking thru bundles for a policy, make sure the
    flow/socket can use the bundle. If a bundle is not found,
    create one, calling for IKE if necessary. If using IKE,
    include the security context in the acquire message to the IKE
    daemon.

    Inbound case:
    1. OLD: Find policy for the socket.
    NEW: Find policy for the incoming packet based on the sid of the
    SA(s) it used or the unlabeled sid if no SAs were
    used. (Consider a case where a socket is "authorized" for two
    policies (unclassified-confidential, secret-top_secret). If the
    packet has come in using a secret SA, we really ought to be
    using the latter policy (secret-top_secret).)

    2. OLD: BUG: No check to see if the SAs used by the packet agree with
    the policy sec_ctx-wise.

    (It was indicated in selinux_xfrm_sock_rcv_skb() that
    this was being accomplished by
    (x->id.spi == tmpl->id.spi || !tmpl->id.spi) in xfrm_state_ok,
    but it turns out tmpl->id.spi
    would normally be zero (unless xfrm policy rules specify one
    at the template level, which they usually don't).
    NEW: The socket is checked for access to the SAs used (based on the
    sid of the SAs) in selinux_xfrm_sock_rcv_skb().

    Forward case:
    This would be Step 1 from the Inbound case, followed by Steps 2 and 3
    from the Outbound case.

    Outstanding items/issues:

    - Timewait acknowledgements and such are generated in the
    current/upstream implementation using a NULL socket resulting in the
    any_socket sid (SYSTEM_HIGH) to be used. This problem is not addressed
    by this patch set.

    This patch: Add new flask definitions to SELinux

    Adds a new avperm "polmatch" to arbitrate flow/state access to a xfrm
    policy rule.

    Signed-off-by: Venkat Yekkirala
    Signed-off-by: David S. Miller

    Venkat Yekkirala
     

21 Sep, 2006

1 commit


03 Aug, 2006

1 commit

  • From: Catherine Zhang

    This patch implements a cleaner fix for the memory leak problem of the
    original unix datagram getpeersec patch. Instead of creating a
    security context each time a unix datagram is sent, we only create the
    security context when the receiver requests it.

    This new design requires modification of the current
    unix_getsecpeer_dgram LSM hook and addition of two new hooks, namely,
    secid_to_secctx and release_secctx. The former retrieves the security
    context and the latter releases it. A hook is required for releasing
    the security context because it is up to the security module to decide
    how that's done. In the case of Selinux, it's a simple kfree
    operation.

    Acked-by: Stephen Smalley
    Signed-off-by: David S. Miller

    Catherine Zhang
     

01 Aug, 2006

2 commits


15 Jul, 2006

1 commit

  • After some discussion on the actual meaning of the filesystem class
    security check in try context mount it was determined that the checks for
    the context= mount options were not correct if fscontext mount option had
    already been used.

    When labeling the superblock we should be checking relabel_from and
    relabel_to. But if the superblock has already been labeled (with
    fscontext) then context= is actually labeling the inodes, and so we should
    be checking relabel_from and associate. This patch fixes which checks are
    called depending on the mount options.

    Signed-off-by: Eric Paris
    Acked-by: Stephen Smalley
    Acked-by: James Morris
    Cc: Chris Wright
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Paris
     

11 Jul, 2006

2 commits

  • Introduce a new rootcontext= option to FS mounting. This option will allow
    you to explicitly label the root inode of an FS being mounted before that
    FS or inode because visible to userspace. This was found to be useful for
    things like stateless linux, see
    https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=190001

    Signed-off-by: Eric Paris
    Acked-by: Stephen Smalley
    Signed-off-by: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Paris
     
  • Remove the conflict between fscontext and context mount options. If
    context= is specified without fscontext it will operate just as before, if
    both are specified we will use mount point labeling and all inodes will get
    the label specified by context=. The superblock will be labeled with the
    label of fscontext=, thus affecting operations which check the superblock
    security context, such as associate permissions.

    Signed-off-by: Eric Paris
    Acked-by: Stephen Smalley
    Signed-off-by: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Paris