1. 09 1月, 2019 2 次提交
  2. 22 12月, 2018 8 次提交
  3. 13 12月, 2018 1 次提交
    • P
      security: audit and remove any unnecessary uses of module.h · 876979c9
      Paul Gortmaker 提交于
      Historically a lot of these existed because we did not have
      a distinction between what was modular code and what was providing
      support to modules via EXPORT_SYMBOL and friends.  That changed
      when we forked out support for the latter into the export.h file.
      This means we should be able to reduce the usage of module.h
      in code that is obj-y Makefile or bool Kconfig.
      
      The advantage in removing such instances is that module.h itself
      sources about 15 other headers; adding significantly to what we feed
      cpp, and it can obscure what headers we are effectively using.
      
      Since module.h might have been the implicit source for init.h
      (for __init) and for export.h (for EXPORT_SYMBOL) we consider each
      instance for the presence of either and replace as needed.
      
      Cc: James Morris <jmorris@namei.org>
      Cc: "Serge E. Hallyn" <serge@hallyn.com>
      Cc: John Johansen <john.johansen@canonical.com>
      Cc: Mimi Zohar <zohar@linux.ibm.com>
      Cc: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: linux-security-module@vger.kernel.org
      Cc: linux-integrity@vger.kernel.org
      Cc: keyrings@vger.kernel.org
      Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      Signed-off-by: NJames Morris <james.morris@microsoft.com>
      876979c9
  4. 11 10月, 2018 6 次提交
  5. 03 10月, 2018 1 次提交
    • E
      signal: Distinguish between kernel_siginfo and siginfo · ae7795bc
      Eric W. Biederman 提交于
      Linus recently observed that if we did not worry about the padding
      member in struct siginfo it is only about 48 bytes, and 48 bytes is
      much nicer than 128 bytes for allocating on the stack and copying
      around in the kernel.
      
      The obvious thing of only adding the padding when userspace is
      including siginfo.h won't work as there are sigframe definitions in
      the kernel that embed struct siginfo.
      
      So split siginfo in two; kernel_siginfo and siginfo.  Keeping the
      traditional name for the userspace definition.  While the version that
      is used internally to the kernel and ultimately will not be padded to
      128 bytes is called kernel_siginfo.
      
      The definition of struct kernel_siginfo I have put in include/signal_types.h
      
      A set of buildtime checks has been added to verify the two structures have
      the same field offsets.
      
      To make it easy to verify the change kernel_siginfo retains the same
      size as siginfo.  The reduction in size comes in a following change.
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      ae7795bc
  6. 23 8月, 2018 1 次提交
  7. 18 7月, 2018 3 次提交
    • M
      integrity: prevent deadlock during digsig verification. · 6eb864c1
      Mikhail Kurinnoi 提交于
      This patch aimed to prevent deadlock during digsig verification.The point
      of issue - user space utility modprobe and/or it's dependencies (ld-*.so,
      libz.so.*, libc-*.so and /lib/modules/ files) that could be used for
      kernel modules load during digsig verification and could be signed by
      digsig in the same time.
      
      First at all, look at crypto_alloc_tfm() work algorithm:
      crypto_alloc_tfm() will first attempt to locate an already loaded
      algorithm. If that fails and the kernel supports dynamically loadable
      modules, it will then attempt to load a module of the same name or alias.
      If that fails it will send a query to any loaded crypto manager to
      construct an algorithm on the fly.
      
      We have situation, when public_key_verify_signature() in case of RSA
      algorithm use alg_name to store internal information in order to construct
      an algorithm on the fly, but crypto_larval_lookup() will try to use
      alg_name in order to load kernel module with same name.
      
      1) we can't do anything with crypto module work, since it designed to work
      exactly in this way;
      2) we can't globally filter module requests for modprobe, since it
      designed to work with any requests.
      
      In this patch, I propose add an exception for "crypto-pkcs1pad(rsa,*)"
      module requests only in case of enabled integrity asymmetric keys support.
      Since we don't have any real "crypto-pkcs1pad(rsa,*)" kernel modules for
      sure, we are safe to fail such module request from crypto_larval_lookup().
      In this way we prevent modprobe execution during digsig verification and
      avoid possible deadlock if modprobe and/or it's dependencies also signed
      with digsig.
      
      Requested "crypto-pkcs1pad(rsa,*)" kernel module name formed by:
      1) "pkcs1pad(rsa,%s)" in public_key_verify_signature();
      2) "crypto-%s" / "crypto-%s-all" in crypto_larval_lookup().
      "crypto-pkcs1pad(rsa," part of request is a constant and unique and could
      be used as filter.
      Signed-off-by: NMikhail Kurinnoi <viewizard@viewizard.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      
       include/linux/integrity.h              | 13 +++++++++++++
       security/integrity/digsig_asymmetric.c | 23 +++++++++++++++++++++++
       security/security.c                    |  7 ++++++-
       3 files changed, 42 insertions(+), 1 deletion(-)
      6eb864c1
    • E
      security: check for kstrdup() failure in lsm_append() · 87ea5843
      Eric Biggers 提交于
      lsm_append() should return -ENOMEM if memory allocation failed.
      
      Fixes: d69dece5 ("LSM: Add /sys/kernel/security/lsm")
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NJames Morris <james.morris@microsoft.com>
      87ea5843
    • A
      security: export security_kernel_load_data function · 83a68a06
      Arnd Bergmann 提交于
      The firmware_loader can be built as a loadable module, which now
      fails when CONFIG_SECURITY is enabled, because a call to the
      security_kernel_load_data() function got added, and this is
      not exported to modules:
      
      ERROR: "security_kernel_load_data" [drivers/base/firmware_loader/firmware_class.ko] undefined!
      
      Add an EXPORT_SYMBOL_GPL() to make it available here.
      
      Fixes: 6e852651 ("firmware: add call to LSM hook before firmware sysfs fallback")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NJames Morris <james.morris@microsoft.com>
      83a68a06
  8. 17 7月, 2018 2 次提交
  9. 12 7月, 2018 2 次提交
  10. 05 5月, 2018 1 次提交
    • D
      security: add hook for socketpair() · aae7cfcb
      David Herrmann 提交于
      Right now the LSM labels for socketpairs are always uninitialized,
      since there is no security hook for the socketpair() syscall. This
      patch adds the required hooks so LSMs can properly label socketpairs.
      This allows SO_PEERSEC to return useful information on those sockets.
      
      Note that the behavior of socketpair() can be emulated by creating a
      listener socket, connecting to it, and then discarding the initial
      listener socket. With this workaround, SO_PEERSEC would return the
      caller's security context. However, with socketpair(), the uninitialized
      context is returned unconditionally. This is unexpected and makes
      socketpair() less useful in situations where the security context is
      crucial to the application.
      
      With the new socketpair-hook this disparity can be solved by making
      socketpair() return the expected security context.
      Acked-by: NSerge Hallyn <serge@hallyn.com>
      Signed-off-by: NTom Gundersen <teg@jklm.no>
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJames Morris <james.morris@microsoft.com>
      aae7cfcb
  11. 06 4月, 2018 1 次提交
  12. 31 3月, 2018 1 次提交
  13. 23 3月, 2018 4 次提交
  14. 07 3月, 2018 1 次提交
  15. 23 2月, 2018 1 次提交
  16. 20 10月, 2017 1 次提交
    • C
      security: bpf: Add LSM hooks for bpf object related syscall · afdb09c7
      Chenbo Feng 提交于
      Introduce several LSM hooks for the syscalls that will allow the
      userspace to access to eBPF object such as eBPF programs and eBPF maps.
      The security check is aimed to enforce a per object security protection
      for eBPF object so only processes with the right priviliges can
      read/write to a specific map or use a specific eBPF program. Besides
      that, a general security hook is added before the multiplexer of bpf
      syscall to check the cmd and the attribute used for the command. The
      actual security module can decide which command need to be checked and
      how the cmd should be checked.
      Signed-off-by: NChenbo Feng <fengc@google.com>
      Acked-by: NJames Morris <james.l.morris@oracle.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      afdb09c7
  17. 02 8月, 2017 1 次提交
  18. 18 7月, 2017 1 次提交
  19. 10 6月, 2017 1 次提交
    • S
      security/selinux: allow security_sb_clone_mnt_opts to enable/disable native labeling behavior · 0b4d3452
      Scott Mayhew 提交于
      When an NFSv4 client performs a mount operation, it first mounts the
      NFSv4 root and then does path walk to the exported path and performs a
      submount on that, cloning the security mount options from the root's
      superblock to the submount's superblock in the process.
      
      Unless the NFS server has an explicit fsid=0 export with the
      "security_label" option, the NFSv4 root superblock will not have
      SBLABEL_MNT set, and neither will the submount superblock after cloning
      the security mount options.  As a result, setxattr's of security labels
      over NFSv4.2 will fail.  In a similar fashion, NFSv4.2 mounts mounted
      with the context= mount option will not show the correct labels because
      the nfs_server->caps flags of the cloned superblock will still have
      NFS_CAP_SECURITY_LABEL set.
      
      Allowing the NFSv4 client to enable or disable SECURITY_LSM_NATIVE_LABELS
      behavior will ensure that the SBLABEL_MNT flag has the correct value
      when the client traverses from an exported path without the
      "security_label" option to one with the "security_label" option and
      vice versa.  Similarly, checking to see if SECURITY_LSM_NATIVE_LABELS is
      set upon return from security_sb_clone_mnt_opts() and clearing
      NFS_CAP_SECURITY_LABEL if necessary will allow the correct labels to
      be displayed for NFSv4.2 mounts mounted with the context= mount option.
      
      Resolves: https://github.com/SELinuxProject/selinux-kernel/issues/35Signed-off-by: NScott Mayhew <smayhew@redhat.com>
      Reviewed-by: NStephen Smalley <sds@tycho.nsa.gov>
      Tested-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      0b4d3452
  20. 24 5月, 2017 1 次提交
    • D
      IB/core: Enforce security on management datagrams · 47a2b338
      Daniel Jurgens 提交于
      Allocate and free a security context when creating and destroying a MAD
      agent.  This context is used for controlling access to PKeys and sending
      and receiving SMPs.
      
      When sending or receiving a MAD check that the agent has permission to
      access the PKey for the Subnet Prefix of the port.
      
      During MAD and snoop agent registration for SMI QPs check that the
      calling process has permission to access the manage the subnet  and
      register a callback with the LSM to be notified of policy changes. When
      notificaiton of a policy change occurs recheck permission and set a flag
      indicating sending and receiving SMPs is allowed.
      
      When sending and receiving MADs check that the agent has access to the
      SMI if it's on an SMI QP.  Because security policy can change it's
      possible permission was allowed when creating the agent, but no longer
      is.
      Signed-off-by: NDaniel Jurgens <danielj@mellanox.com>
      Acked-by: NDoug Ledford <dledford@redhat.com>
      [PM: remove the LSM hook init code]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      47a2b338