31 Oct, 2005

7 commits

  • This patch simplifies some checks for magic siginfo values. It should not
    change the behaviour in any way.

    Signed-off-by: Oleg Nesterov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • This patch replaces hardcoded SEND_SIG_xxx constants with
    their symbolic names.

    No changes in affected .o files.

    Signed-off-by: Oleg Nesterov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • Now that RCU applied on 'struct file' seems stable, we can place f_rcuhead
    in a memory location that is not anymore used at call_rcu(&f->f_rcuhead,
    file_free_rcu) time, to reduce the size of this critical kernel object.

    The trick I used is to move f_rcuhead and f_list in an union called f_u

    The callers are changed so that f_rcuhead becomes f_u.fu_rcuhead and f_list
    becomes f_u.f_list

    Signed-off-by: Eric Dumazet
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Dumazet
     
  • This patch removes a bunch of unecessary checks for (size_t < 0) in
    selinuxfs.

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

    Davi Arnaut
     
  • security/selinux/hooks.c: In function `selinux_inode_getxattr':
    security/selinux/hooks.c:2193: warning: unused variable `sbsec'

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

    Andrew Morton
     
  • This patch allows SELinux to canonicalize the value returned from
    getxattr() via the security_inode_getsecurity() hook, which is called after
    the fs level getxattr() function.

    The purpose of this is to allow the in-core security context for an inode
    to override the on-disk value. This could happen in cases such as
    upgrading a system to a different labeling form (e.g. standard SELinux to
    MLS) without needing to do a full relabel of the filesystem.

    In such cases, we want getxattr() to return the canonical security context
    that the kernel is using rather than what is stored on disk.

    The implementation hooks into the inode_getsecurity(), adding another
    parameter to indicate the result of the preceding fs-level getxattr() call,
    so that SELinux knows whether to compare a value obtained from disk with
    the kernel value.

    We also now allow getxattr() to work for mountpoint labeled filesystems
    (i.e. mount with option context=foo_t), as we are able to return the
    kernel value to the user.

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

    James Morris
     
  • This patch converts SELinux code from kmalloc/memset to the new kazalloc
    unction. On i386, this results in a text saving of over 1K.

    Before:
    text data bss dec hex filename
    86319 4642 15236 106197 19ed5 security/selinux/built-in.o

    After:
    text data bss dec hex filename
    85278 4642 15236 105156 19ac4 security/selinux/built-in.o

    Signed-off-by: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    James Morris
     

28 Oct, 2005

1 commit


24 Oct, 2005

2 commits


01 Oct, 2005

1 commit

  • The following patch updates the way SELinux classifies and handles IP
    based protocols.

    Currently, IP sockets are classified by SELinux as being either TCP, UDP
    or 'Raw', the latter being a default for IP socket that is not TCP or UDP.

    The classification code is out of date and uses only the socket type
    parameter to socket(2) to determine the class of IP socket. So, any
    socket created with SOCK_STREAM will be classified by SELinux as TCP, and
    SOCK_DGRAM as UDP. Also, other socket types such as SOCK_SEQPACKET and
    SOCK_DCCP are currently ignored by SELinux, which classifies them as
    generic sockets, which means they don't even get basic IP level checking.

    This patch changes the SELinux IP socket classification logic, so that
    only an IPPROTO_IP protocol value passed to socket(2) classify the socket
    as TCP or UDP. The patch also drops the check for SOCK_RAW and converts
    it into a default, so that socket types like SOCK_DCCP and SOCK_SEQPACKET
    are classified as SECCLASS_RAWIP_SOCKET (instead of generic sockets).

    Note that protocol-specific support for SCTP, DCCP etc. is not addressed
    here, we're just getting these protocols checked at the IP layer.

    This fixes a reported problem where SCTP sockets were being recognized as
    generic SELinux sockets yet still being passed in one case to an IP level
    check, which then fails for generic sockets.

    It will also fix bugs where any SOCK_STREAM socket is classified as TCP or
    any SOCK_DGRAM socket is classified as UDP.

    This patch also unifies the way IP sockets classes are determined in
    selinux_socket_bind(), so we use the already calculated value instead of
    trying to recalculate it.

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

    James Morris
     

14 Sep, 2005

1 commit


10 Sep, 2005

6 commits

  • With the use of RCU in files structure, the look-up of files using fds can now
    be lock-free. The lookup is protected by rcu_read_lock()/rcu_read_unlock().
    This patch changes the readers to use lock-free lookup.

    Signed-off-by: Maneesh Soni
    Signed-off-by: Ravikiran Thirumalai
    Signed-off-by: Dipankar Sarma
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dipankar Sarma
     
  • In order for the RCU to work, the file table array, sets and their sizes must
    be updated atomically. Instead of ensuring this through too many memory
    barriers, we put the arrays and their sizes in a separate structure. This
    patch takes the first step of putting the file table elements in a separate
    structure fdtable that is embedded withing files_struct. It also changes all
    the users to refer to the file table using files_fdtable() macro. Subsequent
    applciation of RCU becomes easier after this.

    Signed-off-by: Dipankar Sarma
    Signed-Off-By: David Howells
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dipankar Sarma
     
  • This patch removes the inode_post_link and inode_post_rename LSM hooks as
    they are unused (and likely useless).

    Signed-off-by: Stephen Smalley
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Smalley
     
  • This patch removes the inode_post_create/mkdir/mknod/symlink LSM hooks as
    they are obsoleted by the new inode_init_security hook that enables atomic
    inode security labeling.

    If anyone sees any reason to retain these hooks, please speak now. Also,
    is anyone using the post_rename/link hooks; if not, those could also be
    removed.

    Signed-off-by: Stephen Smalley
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Smalley
     
  • This patch modifies tmpfs to call the inode_init_security LSM hook to set
    up the incore inode security state for new inodes before the inode becomes
    accessible via the dcache.

    As there is no underlying storage of security xattrs in this case, it is
    not necessary for the hook to return the (name, value, len) triple to the
    tmpfs code, so this patch also modifies the SELinux hook function to
    correctly handle the case where the (name, value, len) pointers are NULL.

    The hook call is needed in tmpfs in order to support proper security
    labeling of tmpfs inodes (e.g. for udev with tmpfs /dev in Fedora). With
    this change in place, we should then be able to remove the
    security_inode_post_create/mkdir/... hooks safely.

    Signed-off-by: Stephen Smalley
    Cc: Hugh Dickins
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Smalley
     
  • The following patch set enables atomic security labeling of newly created
    inodes by altering the fs code to invoke a new LSM hook to obtain the security
    attribute to apply to a newly created inode and to set up the incore inode
    security state during the inode creation transaction. This parallels the
    existing processing for setting ACLs on newly created inodes. Otherwise, it
    is possible for new inodes to be accessed by another thread via the dcache
    prior to complete security setup (presently handled by the
    post_create/mkdir/... LSM hooks in the VFS) and a newly created inode may be
    left unlabeled on the disk in the event of a crash. SELinux presently works
    around the issue by ensuring that the incore inode security label is
    initialized to a special SID that is inaccessible to unprivileged processes
    (in accordance with policy), thereby preventing inappropriate access but
    potentially causing false denials on legitimate accesses. A simple test
    program demonstrates such false denials on SELinux, and the patch solves the
    problem. Similar such false denials have been encountered in real
    applications.

    This patch defines a new inode_init_security LSM hook to obtain the security
    attribute to apply to a newly created inode and to set up the incore inode
    security state for it, and adds a corresponding hook function implementation
    to SELinux.

    Signed-off-by: Stephen Smalley
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Smalley
     

05 Sep, 2005

2 commits

  • This patch adds endian notations to the SELinux code.

    Signed-off-by: Stephen Smalley
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     
  • This patch improves memory use by SELinux by both reducing the avtab node
    size and reducing the number of avtab nodes. The memory savings are
    substantial, e.g. on a 64-bit system after boot, James Morris reported the
    following data for the targeted and strict policies:

    #objs objsize kernmem
    Targeted:
    Before: 237888 40 9.1MB
    After: 19968 24 468KB

    Strict:
    Before: 571680 40 21.81MB
    After: 221052 24 5.06MB

    The improvement in memory use comes at a cost in the speed of security
    server computations of access vectors, but these computations are only
    required on AVC cache misses, and performance measurements by James Morris
    using a number of benchmarks have shown that the change does not cause any
    significant degradation.

    Note that a rebuilt policy via an updated policy toolchain
    (libsepol/checkpolicy) is required in order to gain the full benefits of
    this patch, although some memory savings benefits are immediately applied
    even to older policies (in particular, the reduction in avtab node size).
    Sources for the updated toolchain are presently available from the
    sourceforge CVS tree (http://sourceforge.net/cvs/?group_id=21266), and
    tarballs are available from http://www.flux.utah.edu/~sds.

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

    Stephen Smalley
     

30 Aug, 2005

5 commits


09 Aug, 2005

1 commit


29 Jul, 2005

1 commit

  • This patch fixes the address length checks in the selinux_socket_connect
    hook to be no more restrictive than the underlying ipv4 and ipv6 code;
    otherwise, this hook can reject valid connect calls. This patch is in
    response to a bug report where an application was calling connect on an
    INET6 socket with an address that didn't include the optional scope id and
    failing due to these checks.

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

    Stephen Smalley
     

28 Jul, 2005

1 commit

  • Implement kernel labeling of the MLS (multilevel security) field of
    security contexts for files which have no existing MLS field. This is to
    enable upgrades of a system from non-MLS to MLS without performing a full
    filesystem relabel including all of the mountpoints, which would be quite
    painful for users.

    With this patch, with MLS enabled, if a file has no MLS field, the kernel
    internally adds an MLS field to the in-core inode (but not to the on-disk
    file). This MLS field added is the default for the superblock, allowing
    per-mountpoint control over the values via fixed policy or mount options.

    This patch has been tested by enabling MLS without relabeling its
    filesystem, and seems to be working correctly.

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

    James Morris
     

02 Jul, 2005

1 commit


30 Jun, 2005

1 commit

  • Currently selinux_sb_copy_data requires an entire page be allocated to
    *orig when the function is called. This "requirement" is based on the fact
    that we call copy_page(in_save, nosec_save) and in_save = orig when the
    data is not FS_BINARY_MOUNTDATA. This means that if a caller were to call
    do_kern_mount with only about 10 bytes of options, they would get passed
    here and then we would corrupt PAGE_SIZE - 10 bytes of memory (with all
    zeros.)

    Currently it appears all in kernel FS's use one page of data so this has
    not been a problem. An out of kernel FS did just what is described above
    and it would almost always panic shortly after they tried to mount. From
    looking else where in the kernel it is obvious that this string of data
    must always be null terminated. (See example in do_mount where it always
    zeros the last byte.) Thus I suggest we use strcpy in place of copy_page.
    In this way we make sure the amount we copy is always less than or equal to
    the amount we received and since do_mount is zeroing the last byte this
    should be safe for all.

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

    Eric Paris
     

26 Jun, 2005

3 commits

  • kfree(NULL) is legal.

    Signed-off-by: Jesper Juhl
    Acked-by: Stephen Smalley
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jesper Juhl
     
  • This patch,based on sample code by Roland McGrath, adds an execheap
    permission check that controls the ability to make the heap executable so
    that this can be prevented in almost all cases (the X server is presently
    an exception, but this will hopefully be resolved in the future) so that
    even programs with execmem permission will need to have the anonymous
    memory mapped in order to make it executable.

    The only reason that we use a permission check for such restriction (vs.
    making it unconditional) is that the X module loader presently needs it; it
    could possibly be made unconditional in the future when X is changed.

    The policy patch for the execheap permission is available at:
    http://pearls.tuxedo-es.org/patches/selinux/policy-execheap.patch

    Signed-off-by: Lorenzo Hernandez Garcia-Hierro
    Acked-by: James Morris
    Acked-by: Stephen Smalley
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Lorenzo Hernández García-Hierro
     
  • This patch adds an execstack permission check that controls the ability to
    make the main process stack executable so that attempts to make the stack
    executable can still be prevented even if the process is allowed the
    existing execmem permission in order to e.g. perform runtime code
    generation. Note that this does not yet address thread stacks. Note also
    that unlike the execmem check, the execstack check is only applied on
    mprotect calls, not mmap calls, as the current security_file_mmap hook is
    not passed the necessary information presently.

    The original author of the code that makes the distinction of the stack
    region, is Ingo Molnar, who wrote it within his patch for
    /proc//maps markers.
    (http://marc.theaimsgroup.com/?l=linux-kernel&m=110719881508591&w=2)

    The patches also can be found at:
    http://pearls.tuxedo-es.org/patches/selinux/policy-execstack.patch
    http://pearls.tuxedo-es.org/patches/selinux/kernel-execstack.patch

    policy-execstack.patch is the patch that needs to be applied to the policy in
    order to support the execstack permission and exclude it
    from general_domain_access within macros/core_macros.te.

    kernel-execstack.patch adds such permission to the SELinux code within
    the kernel and adds the proper permission check to the selinux_file_mprotect() hook.

    Signed-off-by: Lorenzo Hernandez Garcia-Hierro
    Acked-by: James Morris
    Acked-by: Stephen Smalley
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Lorenzo Hernandez García-Hierro
     

22 Jun, 2005

2 commits

  • Add a gfp_mask to audit_log_start() and audit_log(), to reduce the
    amount of GFP_ATOMIC allocation -- most of it doesn't need to be
    GFP_ATOMIC. Also if the mask includes __GFP_WAIT, then wait up to
    60 seconds for the auditd backlog to clear instead of immediately
    abandoning the message.

    The timeout should probably be made configurable, but for now it'll
    suffice that it only happens if auditd is actually running.

    Signed-off-by: David Woodhouse

    David Woodhouse
     
  • There is a memory leak during mount when SELinux is active and mount
    options are specified.

    Signed-off-by: Gerald Schaefer
    Acked-by: Stephen Smalley
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Gerald Schaefer
     

19 Jun, 2005

1 commit

  • To retrieve the neighbour tables send RTM_GETNEIGHTBL with the
    NLM_F_DUMP flag set. Every neighbour table configuration is
    spread over multiple messages to avoid running into message
    size limits on systems with many interfaces. The first message
    in the sequence transports all not device specific data such as
    statistics, configuration, and the default parameter set.
    This message is followed by 0..n messages carrying device
    specific parameter sets.

    Although the ordering should be sufficient, NDTA_NAME can be
    used to identify sequences. The initial message can be identified
    by checking for NDTA_CONFIG. The device specific messages do
    not contain this TLV but have NDTPA_IFINDEX set to the
    corresponding interface index.

    To change neighbour table attributes, send RTM_SETNEIGHTBL
    with NDTA_NAME set. Changeable attribute include NDTA_THRESH[1-3],
    NDTA_GC_INTERVAL, and all TLVs in NDTA_PARMS unless marked
    otherwise. Device specific parameter sets can be changed by
    setting NDTPA_IFINDEX to the interface index of the corresponding
    device.

    Signed-off-by: Thomas Graf
    Signed-off-by: David S. Miller

    Thomas Graf
     

25 May, 2005

1 commit

  • Per Steve Grubb's observation that there are some remaining cases where
    avc_audit() directly logs untrusted strings without escaping them, here
    is a patch that changes avc_audit() to use audit_log_untrustedstring()
    or audit_log_hex() as appropriate. Note that d_name.name is nul-
    terminated by d_alloc(), and that sun_path is nul-terminated by
    unix_mkname(), so it is not necessary for the AVC to create nul-
    terminated copies or to alter audit_log_untrustedstring to take a length
    argument. In the case of an abstract name, we use audit_log_hex() with
    an explicit length.

    Signed-off-by: Stephen Smalley
    Signed-off-by: David Woodhouse

    Stephen Smalley
     

21 May, 2005

2 commits


19 May, 2005

1 commit