21 May, 2019

1 commit

  • Based on 2 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details you
    should have received a copy of the gnu general public license along
    with this program if not see http www gnu org licenses

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details [based]
    [from] [clk] [highbank] [c] you should have received a copy of the
    gnu general public license along with this program if not see http
    www gnu org licenses

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 355 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Kate Stewart
    Reviewed-by: Jilayne Lovejoy
    Reviewed-by: Steve Winslow
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190519154041.837383322@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

25 Mar, 2019

1 commit

  • clang correctly points out a code path that would lead
    to an uninitialized variable use:

    security/selinux/netlabel.c:310:6: error: variable 'addr' is used uninitialized whenever 'if' condition is false
    [-Werror,-Wsometimes-uninitialized]
    if (ip_hdr(skb)->version == 4) {
    ^~~~~~~~~~~~~~~~~~~~~~~~~
    security/selinux/netlabel.c:322:40: note: uninitialized use occurs here
    rc = netlbl_conn_setattr(ep->base.sk, addr, &secattr);
    ^~~~
    security/selinux/netlabel.c:310:2: note: remove the 'if' if its condition is always true
    if (ip_hdr(skb)->version == 4) {
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    security/selinux/netlabel.c:291:23: note: initialize the variable 'addr' to silence this warning
    struct sockaddr *addr;
    ^
    = NULL

    This is probably harmless since we should not see ipv6 packets
    of CONFIG_IPV6 is disabled, but it's better to rearrange the code
    so this cannot happen.

    Signed-off-by: Arnd Bergmann
    [PM: removed old patchwork link, fixed checkpatch.pl style errors]
    Signed-off-by: Paul Moore

    Arnd Bergmann
     

21 Mar, 2018

1 commit

  • Wrap the AVC state within the selinux_state structure and
    pass it explicitly to all AVC functions. The AVC private state
    is encapsulated in a selinux_avc structure that is referenced
    from the selinux_state.

    This change should have no effect on SELinux behavior or
    APIs (userspace or LSM).

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

    Stephen Smalley
     

02 Mar, 2018

1 commit

  • Define a selinux state structure (struct selinux_state) for
    global SELinux state and pass it explicitly to all security server
    functions. The public portion of the structure contains state
    that is used throughout the SELinux code, such as the enforcing mode.
    The structure also contains a pointer to a selinux_ss structure whose
    definition is private to the security server and contains security
    server specific state such as the policy database and SID table.

    This change should have no effect on SELinux behavior or APIs
    (userspace or LSM). It merely wraps SELinux state and passes it
    explicitly as needed.

    Signed-off-by: Stephen Smalley
    [PM: minor fixups needed due to collisions with the SCTP patches]
    Signed-off-by: Paul Moore

    Stephen Smalley
     

27 Feb, 2018

1 commit


21 Nov, 2017

1 commit

  • A few years ago the FSF moved and "59 Temple Place" is wrong. Having this
    still in our source files feels old and unmaintained.

    Let's take the license statement serious and not confuse users.

    As https://www.gnu.org/licenses/gpl-howto.html suggests, we replace the
    postal address with "" in the security
    directory.

    Signed-off-by: Martin Kepplinger
    Acked-by: Serge Hallyn
    Signed-off-by: Paul Moore

    Martin Kepplinger
     

28 Jun, 2016

5 commits


09 Nov, 2015

1 commit


05 Dec, 2013

1 commit


27 Sep, 2013

1 commit

  • The SELinux/NetLabel glue code has a locking bug that affects systems
    with NetLabel enabled, see the kernel error message below. This patch
    corrects this problem by converting the bottom half socket lock to a
    more conventional, and correct for this call-path, lock_sock() call.

    ===============================
    [ INFO: suspicious RCU usage. ]
    3.11.0-rc3+ #19 Not tainted
    -------------------------------
    net/ipv4/cipso_ipv4.c:1928 suspicious rcu_dereference_protected() usage!

    other info that might help us debug this:

    rcu_scheduler_active = 1, debug_locks = 0
    2 locks held by ping/731:
    #0: (slock-AF_INET/1){+.-...}, at: [...] selinux_netlbl_socket_connect
    #1: (rcu_read_lock){.+.+..}, at: [] netlbl_conn_setattr

    stack backtrace:
    CPU: 1 PID: 731 Comm: ping Not tainted 3.11.0-rc3+ #19
    Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
    0000000000000001 ffff88006f659d28 ffffffff81726b6a ffff88003732c500
    ffff88006f659d58 ffffffff810e4457 ffff88006b845a00 0000000000000000
    000000000000000c ffff880075aa2f50 ffff88006f659d90 ffffffff8169bec7
    Call Trace:
    [] dump_stack+0x54/0x74
    [] lockdep_rcu_suspicious+0xe7/0x120
    [] cipso_v4_sock_setattr+0x187/0x1a0
    [] netlbl_conn_setattr+0x187/0x190
    [] ? netlbl_conn_setattr+0x5/0x190
    [] selinux_netlbl_socket_connect+0xae/0xc0
    [] selinux_socket_connect+0x135/0x170
    [] ? might_fault+0x57/0xb0
    [] security_socket_connect+0x16/0x20
    [] SYSC_connect+0x73/0x130
    [] ? sysret_check+0x22/0x5d
    [] ? trace_hardirqs_on_caller+0xfd/0x1c0
    [] ? trace_hardirqs_on_thunk+0x3a/0x3f
    [] SyS_connect+0xe/0x10
    [] system_call_fastpath+0x16/0x1b

    Cc: stable@vger.kernel.org
    Signed-off-by: Paul Moore

    Paul Moore
     

02 Aug, 2011

1 commit


31 Mar, 2011

1 commit


06 May, 2010

1 commit


08 Apr, 2010

1 commit


30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

04 Dec, 2009

1 commit

  • That is "success", "unknown", "through", "performance", "[re|un]mapping"
    , "access", "default", "reasonable", "[con]currently", "temperature"
    , "channel", "[un]used", "application", "example","hierarchy", "therefore"
    , "[over|under]flow", "contiguous", "threshold", "enough" and others.

    Signed-off-by: André Goddard Rosa
    Signed-off-by: Jiri Kosina

    André Goddard Rosa
     

17 Aug, 2009

1 commit

  • Convert avc_audit in security/selinux/avc.c to use lsm_audit.h,
    for better maintainability.

    - changed selinux to use common_audit_data instead of
    avc_audit_data
    - eliminated code in avc.c and used code from lsm_audit.h instead.

    Had to add a LSM_AUDIT_NO_AUDIT to lsm_audit.h so that avc_audit
    can call common_lsm_audit and do the pre and post callbacks without
    doing the actual dump. This makes it so that the patched version
    behaves the same way as the unpatched version.

    Also added a denied field to the selinux_audit_data private space,
    once again to make it so that the patched version behaves like the
    unpatched.

    I've tested and confirmed that AVCs look the same before and after
    this patch.

    Signed-off-by: Thomas Liu
    Acked-by: Stephen Smalley
    Signed-off-by: James Morris

    Thomas Liu
     

13 Jul, 2009

2 commits

  • This reverts commit 8113a8d80f4c6a3dc3724b39b470f3fee9c426b6.

    The patch causes a stack overflow on my system during boot.

    Signed-off-by: James Morris

    James Morris
     
  • Convert avc_audit in security/selinux/avc.c to use lsm_audit.h,
    for better maintainability and for less code duplication.

    - changed selinux to use common_audit_data instead of
    avc_audit_data
    - eliminated code in avc.c and used code from lsm_audit.h instead.

    I have tested to make sure that the avcs look the same before and
    after this patch.

    Signed-off-by: Thomas Liu
    Acked-by: Eric Paris
    Signed-off-by: James Morris

    Thomas Liu
     

28 Mar, 2009

1 commit

  • The current NetLabel/SELinux behavior for incoming TCP connections works but
    only through a series of happy coincidences that rely on the limited nature of
    standard CIPSO (only able to convey MLS attributes) and the write equality
    imposed by the SELinux MLS constraints. The problem is that network sockets
    created as the result of an incoming TCP connection were not on-the-wire
    labeled based on the security attributes of the parent socket but rather based
    on the wire label of the remote peer. The issue had to do with how IP options
    were managed as part of the network stack and where the LSM hooks were in
    relation to the code which set the IP options on these newly created child
    sockets. While NetLabel/SELinux did correctly set the socket's on-the-wire
    label it was promptly cleared by the network stack and reset based on the IP
    options of the remote peer.

    This patch, in conjunction with a prior patch that adjusted the LSM hook
    locations, works to set the correct on-the-wire label format for new incoming
    connections through the security_inet_conn_request() hook. Besides the
    correct behavior there are many advantages to this change, the most significant
    is that all of the NetLabel socket labeling code in SELinux now lives in hooks
    which can return error codes to the core stack which allows us to finally get
    ride of the selinux_netlbl_inode_permission() logic which greatly simplfies
    the NetLabel/SELinux glue code. In the process of developing this patch I
    also ran into a small handful of AF_INET6 cleanliness issues that have been
    fixed which should make the code safer and easier to extend in the future.

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

    Paul Moore
     

02 Mar, 2009

1 commit

  • Rick McNeal from LSI identified a panic in selinux_netlbl_inode_permission()
    caused by a certain sequence of SUNRPC operations. The problem appears to be
    due to the lack of NULL pointer checking in the function; this patch adds the
    pointer checks so the function will exit safely in the cases where the socket
    is not completely initialized.

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

    Paul Moore
     

23 Feb, 2009

1 commit

  • At some point we (okay, I) managed to break the ability for users to use the
    setsockopt() syscall to set IPv4 options when NetLabel was not active on the
    socket in question. The problem was noticed by someone trying to use the
    "-R" (record route) option of ping:

    # ping -R 10.0.0.1
    ping: record route: No message of desired type

    The solution is relatively simple, we catch the unlabeled socket case and
    clear the error code, allowing the operation to succeed. Please note that we
    still deny users the ability to override IPv4 options on socket's which have
    NetLabel labeling active; this is done to ensure the labeling remains intact.

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

    Paul Moore
     

10 Oct, 2008

5 commits

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

21 Apr, 2008

1 commit

  • This patch changes netlabel.c to fix whitespace and syntax issues. Things that
    are fixed may include (does not not have to include)

    whitespace at end of lines
    spaces followed by tabs
    spaces used instead of tabs
    spacing around parenthesis
    locateion of { around struct and else clauses
    location of * in pointer declarations
    removal of initialization of static data to keep it in the right section
    useless {} in if statemetns
    useless checking for NULL before kfree
    fixing of the indentation depth of switch statements
    and any number of other things I forgot to mention

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

    Eric Paris
     

18 Apr, 2008

2 commits


30 Jan, 2008

3 commits

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

22 Jan, 2008

1 commit


02 Aug, 2007

1 commit

  • A small fix to the SELinux/NetLabel glue code to ensure that the NetLabel
    cache is utilized when possible. This was broken when the SELinux/NetLabel
    glue code was reorganized in the last kernel release.

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

    Paul Moore
     

19 Jul, 2007

1 commit

  • These changes will make NetLabel behave like labeled IPsec where there is an
    access check for both labeled and unlabeled packets as well as providing the
    ability to restrict domains to receiving only labeled packets when NetLabel is
    in use. The changes to the policy are straight forward with the following
    necessary to receive labeled traffic (with SECINITSID_NETMSG defined as
    "netlabel_peer_t"):

    allow mydom_t netlabel_peer_t:{ tcp_socket udp_socket rawip_socket } recvfrom;

    The policy for unlabeled traffic would be:

    allow mydom_t unlabeled_t:{ tcp_socket udp_socket rawip_socket } recvfrom;

    These policy changes, as well as more general NetLabel support, are included in
    the latest SELinux Reference Policy release 20070629 or later. Users who make
    use of NetLabel are strongly encouraged to upgrade their policy to avoid
    network problems. Users who do not make use of NetLabel will not notice any
    difference.

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

    Paul Moore