14 Oct, 2020

1 commit

  • Replace commas with semicolons. Commas introduce unnecessary
    variability in the code structure and are hard to see. What is done
    is essentially described by the following Coccinelle semantic patch
    (http://coccinelle.lip6.fr/):

    //
    @@ expression e1,e2; @@
    e1
    -,
    +;
    e2
    ... when any
    //

    Signed-off-by: Julia Lawall
    Acked-by: Paul Moore
    Link: https://lore.kernel.org/r/1602412498-32025-5-git-send-email-Julia.Lawall@inria.fr
    Signed-off-by: Jakub Kicinski

    Julia Lawall
     

13 May, 2020

1 commit

  • The cipso and calipso code can set the MLS_CAT attribute on
    successful parsing, even if the corresponding catmap has
    not been allocated, as per current configuration and external
    input.

    Later, selinux code tries to access the catmap if the MLS_CAT flag
    is present via netlbl_catmap_getlong(). That may cause null ptr
    dereference while processing incoming network traffic.

    Address the issue setting the MLS_CAT flag only if the catmap is
    really allocated. Additionally let netlbl_catmap_getlong() cope
    with NULL catmap.

    Reported-by: Matthew Sheets
    Fixes: 4b8feff251da ("netlabel: fix the horribly broken catmap functions")
    Fixes: ceba1832b1b2 ("calipso: Set the calipso socket label to match the secattr.")
    Signed-off-by: Paolo Abeni
    Acked-by: Paul Moore
    Signed-off-by: David S. Miller

    Paolo Abeni
     

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
     

05 Jul, 2018

1 commit

  • At present the ipv6_renew_options_kern() function ends up calling into
    access_ok() which is problematic if done from inside an interrupt as
    access_ok() calls WARN_ON_IN_IRQ() on some (all?) architectures
    (x86-64 is affected). Example warning/backtrace is shown below:

    WARNING: CPU: 1 PID: 3144 at lib/usercopy.c:11 _copy_from_user+0x85/0x90
    ...
    Call Trace:

    ipv6_renew_option+0xb2/0xf0
    ipv6_renew_options+0x26a/0x340
    ipv6_renew_options_kern+0x2c/0x40
    calipso_req_setattr+0x72/0xe0
    netlbl_req_setattr+0x126/0x1b0
    selinux_netlbl_inet_conn_request+0x80/0x100
    selinux_inet_conn_request+0x6d/0xb0
    security_inet_conn_request+0x32/0x50
    tcp_conn_request+0x35f/0xe00
    ? __lock_acquire+0x250/0x16c0
    ? selinux_socket_sock_rcv_skb+0x1ae/0x210
    ? tcp_rcv_state_process+0x289/0x106b
    tcp_rcv_state_process+0x289/0x106b
    ? tcp_v6_do_rcv+0x1a7/0x3c0
    tcp_v6_do_rcv+0x1a7/0x3c0
    tcp_v6_rcv+0xc82/0xcf0
    ip6_input_finish+0x10d/0x690
    ip6_input+0x45/0x1e0
    ? ip6_rcv_finish+0x1d0/0x1d0
    ipv6_rcv+0x32b/0x880
    ? ip6_make_skb+0x1e0/0x1e0
    __netif_receive_skb_core+0x6f2/0xdf0
    ? process_backlog+0x85/0x250
    ? process_backlog+0x85/0x250
    ? process_backlog+0xec/0x250
    process_backlog+0xec/0x250
    net_rx_action+0x153/0x480
    __do_softirq+0xd9/0x4f7
    do_softirq_own_stack+0x2a/0x40

    ...

    While not present in the backtrace, ipv6_renew_option() ends up calling
    access_ok() via the following chain:

    access_ok()
    _copy_from_user()
    copy_from_user()
    ipv6_renew_option()

    The fix presented in this patch is to perform the userspace copy
    earlier in the call chain such that it is only called when the option
    data is actually coming from userspace; that place is
    do_ipv6_setsockopt(). Not only does this solve the problem seen in
    the backtrace above, it also allows us to simplify the code quite a
    bit by removing ipv6_renew_options_kern() completely. We also take
    this opportunity to cleanup ipv6_renew_options()/ipv6_renew_option()
    a small amount as well.

    This patch is heavily based on a rough patch by Al Viro. I've taken
    his original patch, converted a kmemdup() call in do_ipv6_setsockopt()
    to a memdup_user() call, made better use of the e_inval jump target in
    the same function, and cleaned up the use ipv6_renew_option() by
    ipv6_renew_options().

    CC: Al Viro
    Signed-off-by: Paul Moore
    Signed-off-by: David S. Miller

    Paul Moore
     

05 Jul, 2017

1 commit


01 Jul, 2017

1 commit

  • refcount_t type and corresponding API should be
    used instead of atomic_t when the variable is used as
    a reference counter. This allows to avoid accidental
    refcounter overflows that might lead to use-after-free
    situations.

    Signed-off-by: Elena Reshetova
    Signed-off-by: Hans Liljestrand
    Signed-off-by: Kees Cook
    Signed-off-by: David Windsor
    Signed-off-by: David S. Miller

    Reshetova, Elena
     

07 Jun, 2017

1 commit


14 Aug, 2016

1 commit


28 Jun, 2016

9 commits

  • This works in exactly the same way as the CIPSO label cache.
    The idea is to allow the lsm to cache the result of a secattr
    lookup so that it doesn't need to perform the lookup for
    every skbuff.

    It introduces two sysctl controls:
    calipso_cache_enable - enables/disables the cache.
    calipso_cache_bucket_size - sets the size of a cache bucket.

    Signed-off-by: Huw Davies
    Signed-off-by: Paul Moore

    Huw Davies
     
  • Lengths, checksum and the DOI are checked. Checking of the
    level and categories are left for the socket layer.

    CRC validation is performed in the calipso module to avoid
    unconditionally linking crc_ccitt() into ipv6.

    Signed-off-by: Huw Davies
    Signed-off-by: Paul Moore

    Huw Davies
     
  • In some cases, the lsm needs to add the label to the skbuff directly.
    A NF_INET_LOCAL_OUT IPv6 hook is added to selinux to match the IPv4
    behaviour. This allows selinux to label the skbuffs that it requires.

    Signed-off-by: Huw Davies
    Signed-off-by: Paul Moore

    Huw Davies
     
  • Request sockets need to have a label that takes into account the
    incoming connection as well as their parent's label. This is used
    for the outgoing SYN-ACK and for their child full-socket.

    Signed-off-by: Huw Davies
    Signed-off-by: Paul Moore

    Huw Davies
     
  • CALIPSO is a hop-by-hop IPv6 option. A lot of this patch is based on
    the equivalent CISPO code. The main difference is due to manipulating
    the options in the hop-by-hop header.

    Signed-off-by: Huw Davies
    Signed-off-by: Paul Moore

    Huw Davies
     
  • Remove a specified DOI through the NLBL_CALIPSO_C_REMOVE command.
    It requires the attribute:
    NLBL_CALIPSO_A_DOI.

    Signed-off-by: Huw Davies
    Signed-off-by: Paul Moore

    Huw Davies
     
  • Enumerate the DOI list through the NLBL_CALIPSO_C_LISTALL command.
    It takes no attributes.

    Signed-off-by: Huw Davies
    Signed-off-by: Paul Moore

    Huw Davies
     
  • Query a specified DOI through the NLBL_CALIPSO_C_LIST command.
    It requires the attribute:
    NLBL_CALIPSO_A_DOI.

    The reply will contain:
    NLBL_CALIPSO_A_MTYPE

    Signed-off-by: Huw Davies
    Signed-off-by: Paul Moore

    Huw Davies
     
  • CALIPSO is a packet labelling protocol for IPv6 which is very similar
    to CIPSO. It is specified in RFC 5570. Much of the code is based on
    the current CIPSO code.

    This adds support for adding passthrough-type CALIPSO DOIs through the
    NLBL_CALIPSO_C_ADD command. It requires attributes:

    NLBL_CALIPSO_A_TYPE which must be CALIPSO_MAP_PASS.
    NLBL_CALIPSO_A_DOI.

    In passthrough mode the CALIPSO engine will map MLS secattr levels
    and categories directly to the packet label.

    At this stage, the major difference between this and the CIPSO
    code is that IPv6 may be compiled as a module. To allow for
    this the CALIPSO functions are registered at module init time.

    Signed-off-by: Huw Davies
    Signed-off-by: Paul Moore

    Huw Davies