14 Oct, 2008

4 commits

  • This is a much better version of a previous patch to make the parser
    tables constant. Rather than changing the typedef, we put the "const" in
    all the various places where its required, allowing the __initconst
    exception for nfsroot which was the cause of the previous trouble.

    This was posted for review some time ago and I believe its been in -mm
    since then.

    Signed-off-by: Steven Whitehouse
    Cc: Alexander Viro
    Signed-off-by: Linus Torvalds

    Steven Whitehouse
     
  • …s/security-testing-2.6

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6: (24 commits)
    integrity: special fs magic
    As pointed out by Jonathan Corbet, the timer must be deleted before
    ERROR: code indent should use tabs where possible
    The tpm_dev_release function is only called for platform devices, not pnp
    Protect tpm_chip_list when transversing it.
    Renames num_open to is_open, as only one process can open the file at a time.
    Remove the BKL calls from the TPM driver, which were added in the overall
    netlabel: Add configuration support for local labeling
    cipso: Add support for native local labeling and fixup mapping names
    netlabel: Changes to the NetLabel security attributes to allow LSMs to pass full contexts
    selinux: Cache NetLabel secattrs in the socket's security struct
    selinux: Set socket NetLabel based on connection endpoint
    netlabel: Add functionality to set the security attributes of a packet
    netlabel: Add network address selectors to the NetLabel/LSM domain mapping
    netlabel: Add a generic way to create ordered linked lists of network addrs
    netlabel: Replace protocol/NetLabel linking with refrerence counts
    smack: Fix missing calls to netlbl_skbuff_err()
    selinux: Fix missing calls to netlbl_skbuff_err()
    selinux: Fix a problem in security_netlbl_sid_to_secattr()
    selinux: Better local/forward check in selinux_ip_postroute()
    ...

    Linus Torvalds
     
  • Currently it is sometimes locked by the tty mutex and sometimes by the
    sighand lock. The latter is in fact correct and now we can hand back referenced
    objects we can fix this up without problems around sleeping functions.

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • We now return a kref covered tty reference. That ensures the tty structure
    doesn't go away when you have a return from get_current_tty. This is not
    enough to protect you from most of the resources being freed behind your
    back - yet.

    [Updated to include fixes for SELinux problems found by Andrew Morton and
    an s390 leak found while debugging the former]

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     

13 Oct, 2008

1 commit

  • Discussion on the mailing list questioned the use of these
    magic values in userspace, concluding these values are already
    exported to userspace via statfs and their correct/incorrect
    usage is left up to the userspace application.

    - Move special fs magic number definitions to magic.h
    - Add magic.h include

    Signed-off-by: Mimi Zohar
    Reviewed-by: James Morris
    Signed-off-by: James Morris

    Mimi Zohar
     

11 Oct, 2008

1 commit


10 Oct, 2008

11 commits

  • This patch provides support for including the LSM's secid in addition to
    the LSM's MLS information in the NetLabel security attributes structure.

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

    Paul Moore
     
  • Previous work enabled the use of address based NetLabel selectors, which
    while highly useful, brought the potential for additional per-packet overhead
    when used. This patch attempts to mitigate some of that overhead by caching
    the NetLabel security attribute struct within the SELinux socket security
    structure. This should help eliminate the need to recreate the NetLabel
    secattr structure for each packet resulting in less overhead.

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

    Paul Moore
     
  • Previous work enabled the use of address based NetLabel selectors, which while
    highly useful, brought the potential for additional per-packet overhead when
    used. This patch attempts to solve that by applying NetLabel socket labels
    when sockets are connect()'d. This should alleviate the per-packet NetLabel
    labeling for all connected sockets (yes, it even works for connected DGRAM
    sockets).

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

    Paul Moore
     
  • This patch builds upon the new NetLabel address selector functionality by
    providing the NetLabel KAPI and CIPSO engine support needed to enable the
    new packet-based labeling. The only new addition to the NetLabel KAPI at
    this point is shown below:

    * int netlbl_skbuff_setattr(skb, family, secattr)

    ... and is designed to be called from a Netfilter hook after the packet's
    IP header has been populated such as in the FORWARD or LOCAL_OUT hooks.

    This patch also provides the necessary SELinux hooks to support this new
    functionality. Smack support is not currently included due to uncertainty
    regarding the permissions needed to expand the Smack network access controls.

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

    Paul Moore
     
  • NetLabel has always had a list of backpointers in the CIPSO DOI definition
    structure which pointed to the NetLabel LSM domain mapping structures which
    referenced the CIPSO DOI struct. The rationale for this was that when an
    administrator removed a CIPSO DOI from the system all of the associated
    NetLabel LSM domain mappings should be removed as well; a list of
    backpointers made this a simple operation.

    Unfortunately, while the backpointers did make the removal easier they were
    a bit of a mess from an implementation point of view which was making
    further development difficult. Since the removal of a CIPSO DOI is a
    realtively rare event it seems to make sense to remove this backpointer
    list as the optimization was hurting us more then it was helping. However,
    we still need to be able to track when a CIPSO DOI definition is being used
    so replace the backpointer list with a reference count. In order to
    preserve the current functionality of removing the associated LSM domain
    mappings when a CIPSO DOI is removed we walk the LSM domain mapping table,
    removing the relevant entries.

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

    Paul Moore
     
  • Smack needs to call netlbl_skbuff_err() to let NetLabel do the necessary
    protocol specific error handling.

    Signed-off-by: Paul Moore
    Acked-by: Casey Schaufler

    Paul Moore
     
  • At some point I think I messed up and dropped the calls to netlbl_skbuff_err()
    which are necessary for CIPSO to send error notifications to remote systems.
    This patch re-introduces the error handling calls into the SELinux code.

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

    Paul Moore
     
  • Currently when SELinux fails to allocate memory in
    security_netlbl_sid_to_secattr() the NetLabel LSM domain field is set to
    NULL which triggers the default NetLabel LSM domain mapping which may not
    always be the desired mapping. This patch fixes this by returning an error
    when the kernel is unable to allocate memory. This could result in more
    failures on a system with heavy memory pressure but it is the "correct"
    thing to do.

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

    Paul Moore
     
  • It turns out that checking to see if skb->sk is NULL is not a very good
    indicator of a forwarded packet as some locally generated packets also have
    skb->sk set to NULL. Fix this by not only checking the skb->sk field but also
    the IP[6]CB(skb)->flags field for the IP[6]SKB_FORWARDED flag. While we are
    at it, we are calling selinux_parse_skb() much earlier than we really should
    resulting in potentially wasted cycles parsing packets for information we
    might no use; so shuffle the code around a bit to fix this.

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

    Paul Moore
     
  • We did the right thing in a few cases but there were several areas where we
    determined a packet's address family based on the socket's address family which
    is not the right thing to do since we can get IPv4 packets on IPv6 sockets.
    This patch fixes these problems by either taking the address family directly
    from the packet.

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

    Paul Moore
     
  • We were doing a lot of extra work in selinux_netlbl_sock_graft() what wasn't
    necessary so this patch removes that code. It also removes the redundant
    second argument to selinux_netlbl_sock_setsid() which allows us to simplify a
    few other functions.

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

    Paul Moore
     

04 Oct, 2008

2 commits

  • At some point during the 2.6.27 development cycle two new fields were added
    to the SELinux context structure, a string pointer and a length field. The
    code in selinux_secattr_to_sid() was not modified and as a result these two
    fields were left uninitialized which could result in erratic behavior,
    including kernel panics, when NetLabel is used. This patch fixes the
    problem by fully initializing the context in selinux_secattr_to_sid() before
    use and reducing the level of direct context manipulation done to help
    prevent future problems.

    Please apply this to the 2.6.27-rcX release stream.

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

    Paul Moore
     
  • At some point during the 2.6.27 development cycle two new fields were added
    to the SELinux context structure, a string pointer and a length field. The
    code in selinux_secattr_to_sid() was not modified and as a result these two
    fields were left uninitialized which could result in erratic behavior,
    including kernel panics, when NetLabel is used. This patch fixes the
    problem by fully initializing the context in selinux_secattr_to_sid() before
    use and reducing the level of direct context manipulation done to help
    prevent future problems.

    Please apply this to the 2.6.27-rcX release stream.

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

    Paul Moore
     

29 Sep, 2008

1 commit

  • As we are not concerned with fine-grained control over reading of
    symlinks in proc, always use the default proc SID for all proc symlinks.
    This should help avoid permission issues upon changes to the proc tree
    as in the /proc/net -> /proc/self/net example.
    This does not alter labeling of symlinks within /proc/pid directories.
    ls -Zd /proc/net output before and after the patch should show the difference.

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

    Stephen Smalley
     

27 Sep, 2008

1 commit


22 Sep, 2008

1 commit


11 Sep, 2008

1 commit


04 Sep, 2008

1 commit

  • Fix a bug and a philosophical decision about who handles errors.

    security_context_to_sid_core() was leaking a context in the common case.
    This was causing problems on fedora systems which recently have started
    making extensive use of this function.

    In discussion it was decided that if string_to_context_struct() had an
    error it was its own responsibility to clean up any mess it created
    along the way.

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

    Eric Paris
     

03 Sep, 2008

1 commit

  • During the use of a dev_cgroup, we should guarantee the corresponding
    cgroup won't be deleted (i.e. via rmdir). This can be done through
    css_get(&dev_cgroup->css), but here we can just get and use the dev_cgroup
    under rcu_read_lock.

    And also remove checking NULL dev_cgroup, it won't be NULL since a task
    always belongs to a cgroup.

    Signed-off-by: Li Zefan
    Acked-by: Serge Hallyn
    Cc: Paul Menage
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Li Zefan
     

28 Aug, 2008

3 commits

  • The purpose of this patch is to assign per-thread security context
    under a constraint. It enables multi-threaded server application
    to kick a request handler with its fair security context, and
    helps some of userspace object managers to handle user's request.

    When we assign a per-thread security context, it must not have wider
    permissions than the original one. Because a multi-threaded process
    shares a single local memory, an arbitary per-thread security context
    also means another thread can easily refer violated information.

    The constraint on a per-thread security context requires a new domain
    has to be equal or weaker than its original one, when it tries to assign
    a per-thread security context.

    Bounds relationship between two types is a way to ensure a domain can
    never have wider permission than its bounds. We can define it in two
    explicit or implicit ways.

    The first way is using new TYPEBOUNDS statement. It enables to define
    a boundary of types explicitly. The other one expand the concept of
    existing named based hierarchy. If we defines a type with "." separated
    name like "httpd_t.php", toolchain implicitly set its bounds on "httpd_t".

    This feature requires a new policy version.
    The 24th version (POLICYDB_VERSION_BOUNDARY) enables to ship them into
    kernel space, and the following patch enables to handle it.

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

    KaiGai Kohei
     
  • Add a new Kconfig option SECURITYFS which will build securityfs support
    but does not require CONFIG_SECURITY. The only current user of
    securityfs does not depend on CONFIG_SECURITY and there is no reason the
    full LSM needs to be built to build this fs.

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

    Eric Paris
     
  • James Morris
     

20 Aug, 2008

1 commit


15 Aug, 2008

1 commit


14 Aug, 2008

1 commit

  • Fix the setting of PF_SUPERPRIV by __capable() as it could corrupt the flags
    the target process if that is not the current process and it is trying to
    change its own flags in a different way at the same time.

    __capable() is using neither atomic ops nor locking to protect t->flags. This
    patch removes __capable() and introduces has_capability() that doesn't set
    PF_SUPERPRIV on the process being queried.

    This patch further splits security_ptrace() in two:

    (1) security_ptrace_may_access(). This passes judgement on whether one
    process may access another only (PTRACE_MODE_ATTACH for ptrace() and
    PTRACE_MODE_READ for /proc), and takes a pointer to the child process.
    current is the parent.

    (2) security_ptrace_traceme(). This passes judgement on PTRACE_TRACEME only,
    and takes only a pointer to the parent process. current is the child.

    In Smack and commoncap, this uses has_capability() to determine whether
    the parent will be permitted to use PTRACE_ATTACH if normal checks fail.
    This does not set PF_SUPERPRIV.

    Two of the instances of __capable() actually only act on current, and so have
    been changed to calls to capable().

    Of the places that were using __capable():

    (1) The OOM killer calls __capable() thrice when weighing the killability of a
    process. All of these now use has_capability().

    (2) cap_ptrace() and smack_ptrace() were using __capable() to check to see
    whether the parent was allowed to trace any process. As mentioned above,
    these have been split. For PTRACE_ATTACH and /proc, capable() is now
    used, and for PTRACE_TRACEME, has_capability() is used.

    (3) cap_safe_nice() only ever saw current, so now uses capable().

    (4) smack_setprocattr() rejected accesses to tasks other than current just
    after calling __capable(), so the order of these two tests have been
    switched and capable() is used instead.

    (5) In smack_file_send_sigiotask(), we need to allow privileged processes to
    receive SIGIO on files they're manipulating.

    (6) In smack_task_wait(), we let a process wait for a privileged process,
    whether or not the process doing the waiting is privileged.

    I've tested this with the LTP SELinux and syscalls testscripts.

    Signed-off-by: David Howells
    Acked-by: Serge Hallyn
    Acked-by: Casey Schaufler
    Acked-by: Andrew G. Morgan
    Acked-by: Al Viro
    Signed-off-by: James Morris

    David Howells
     

07 Aug, 2008

1 commit

  • expr_isvalid() in conditional.c was off-by-one and allowed
    invalid expression type COND_LAST. However, it is this header file
    that needs to be fixed. That way the if-statement's disjunction's
    second component reads more naturally, "if expr type is greater than
    the last allowed value" ( rather than using ">=" in conditional.c):

    if (expr->expr_type expr_type > COND_LAST)

    Signed-off-by: Vesa-Matti Kari
    Signed-off-by: James Morris

    Vesa-Matti Kari
     

05 Aug, 2008

5 commits

  • There have been a number of requests to make the Smack LSM
    enforce MAC even in the face of privilege, either capability
    based or superuser based. This is not universally desired,
    however, so it seems desirable to make it optional. Further,
    at least one legacy OS implemented a scheme whereby only
    processes running with one particular label could be exempt
    from MAC. This patch supports these three cases.

    If /smack/onlycap is empty (unset or null-string) privilege
    is enforced in the normal way.

    If /smack/onlycap contains a label only processes running with
    that label may be MAC exempt.

    If the label in /smack/onlycap is the star label ("*") the
    semantics of the star label combine with the privilege
    restrictions to prevent any violations of MAC, even in the
    presence of privilege.

    Again, this will be independent of the privilege scheme.

    Signed-off-by: Casey Schaufler
    Reviewed-by: James Morris

    Casey Schaufler
     
  • Fix a potentially uninitialised variable in SELinux hooks that's given a
    pointer to the network address by selinux_parse_skb() passing a pointer back
    through its argument list. By restructuring selinux_parse_skb(), the compiler
    can see that the error case need not set it as the caller will return
    immediately.

    Signed-off-by: David Howells
    Signed-off-by: James Morris

    David Howells
     
  • Hello,

    Remove unneeded local variable:

    struct avtab_node *newnode

    Signed-off-by: Vesa-Matti Kari
    Signed-off-by: James Morris

    Vesa-Matti J Kari
     
  • Trivial minor fixes that change C null character style.

    Signed-off-by: Vesa-Matti Kari
    Signed-off-by: James Morris

    Vesa-Matti J Kari
     
  • This patch makes the needlessly global selinux_write_opts() static.

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

    Adrian Bunk
     

30 Jul, 2008

1 commit

  • Given a hosed SELinux config in which a system never loads policy or
    disables SELinux we currently just return -EINVAL for anyone trying to
    read /proc/mounts. This is a configuration problem but we can certainly
    be more graceful. This patch just ignores -EINVAL when displaying LSM
    options and causes /proc/mounts display everything else it can. If
    policy isn't loaded the obviously there are no options, so we aren't
    really loosing any information here.

    This is safe as the only other return of EINVAL comes from
    security_sid_to_context_core() in the case of an invalid sid. Even if a
    FS was mounted with a now invalidated context that sid should have been
    remapped to unlabeled and so we won't hit the EINVAL and will work like
    we should. (yes, I tested to make sure it worked like I thought)

    Signed-off-by: Eric Paris
    Tested-by: Marc Dionne
    Signed-off-by: James Morris

    Eric Paris
     

27 Jul, 2008

2 commits

  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6: (39 commits)
    [PATCH] fix RLIM_NOFILE handling
    [PATCH] get rid of corner case in dup3() entirely
    [PATCH] remove remaining namei_{32,64}.h crap
    [PATCH] get rid of indirect users of namei.h
    [PATCH] get rid of __user_path_lookup_open
    [PATCH] f_count may wrap around
    [PATCH] dup3 fix
    [PATCH] don't pass nameidata to __ncp_lookup_validate()
    [PATCH] don't pass nameidata to gfs2_lookupi()
    [PATCH] new (local) helper: user_path_parent()
    [PATCH] sanitize __user_walk_fd() et.al.
    [PATCH] preparation to __user_walk_fd cleanup
    [PATCH] kill nameidata passing to permission(), rename to inode_permission()
    [PATCH] take noexec checks to very few callers that care
    Re: [PATCH 3/6] vfs: open_exec cleanup
    [patch 4/4] vfs: immutable inode checking cleanup
    [patch 3/4] fat: dont call notify_change
    [patch 2/4] vfs: utimes cleanup
    [patch 1/4] vfs: utimes: move owner check into inode_change_ok()
    [PATCH] vfs: use kstrdup() and check failing allocation
    ...

    Linus Torvalds
     
  • * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6:
    netns: fix ip_rt_frag_needed rt_is_expired
    netfilter: nf_conntrack_extend: avoid unnecessary "ct->ext" dereferences
    netfilter: fix double-free and use-after free
    netfilter: arptables in netns for real
    netfilter: ip{,6}tables_security: fix future section mismatch
    selinux: use nf_register_hooks()
    netfilter: ebtables: use nf_register_hooks()
    Revert "pkt_sched: sch_sfq: dump a real number of flows"
    qeth: use dev->ml_priv instead of dev->priv
    syncookies: Make sure ECN is disabled
    net: drop unused BUG_TRAP()
    net: convert BUG_TRAP to generic WARN_ON
    drivers/net: convert BUG_TRAP to generic WARN_ON

    Linus Torvalds