23 Jan, 2019

1 commit

  • commit a5795fd38ee8194451ba3f281f075301a3696ce2 upstream.

    From: Casey Schaufler

    Check that the cred security blob has been set before trying
    to clean it up. There is a case during credential initialization
    that could result in this.

    Signed-off-by: Casey Schaufler
    Acked-by: John Johansen
    Signed-off-by: James Morris
    Reported-by: syzbot+69ca07954461f189e808@syzkaller.appspotmail.com
    Signed-off-by: Greg Kroah-Hartman

    James Morris
     

23 Aug, 2018

1 commit

  • Allow the initcall tables to be emitted using relative references that
    are only half the size on 64-bit architectures and don't require fixups
    at runtime on relocatable kernels.

    Link: http://lkml.kernel.org/r/20180704083651.24360-5-ard.biesheuvel@linaro.org
    Acked-by: James Morris
    Acked-by: Sergey Senozhatsky
    Acked-by: Petr Mladek
    Acked-by: Michael Ellerman
    Acked-by: Ingo Molnar
    Signed-off-by: Ard Biesheuvel
    Cc: Arnd Bergmann
    Cc: Benjamin Herrenschmidt
    Cc: Bjorn Helgaas
    Cc: Catalin Marinas
    Cc: James Morris
    Cc: Jessica Yu
    Cc: Josh Poimboeuf
    Cc: Kees Cook
    Cc: Nicolas Pitre
    Cc: Paul Mackerras
    Cc: Russell King
    Cc: "Serge E. Hallyn"
    Cc: Steven Rostedt
    Cc: Thomas Garnier
    Cc: Thomas Gleixner
    Cc: Will Deacon
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ard Biesheuvel
     

16 Aug, 2018

2 commits

  • …morris/linux-security

    Pull integrity updates from James Morris:
    "This adds support for EVM signatures based on larger digests, contains
    a new audit record AUDIT_INTEGRITY_POLICY_RULE to differentiate the
    IMA policy rules from the IMA-audit messages, addresses two deadlocks
    due to either loading or searching for crypto algorithms, and cleans
    up the audit messages"

    * 'next-integrity' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
    EVM: fix return value check in evm_write_xattrs()
    integrity: prevent deadlock during digsig verification.
    evm: Allow non-SHA1 digital signatures
    evm: Don't deadlock if a crypto algorithm is unavailable
    integrity: silence warning when CONFIG_SECURITYFS is not enabled
    ima: Differentiate auditing policy rules from "audit" actions
    ima: Do not audit if CONFIG_INTEGRITY_AUDIT is not set
    ima: Use audit_log_format() rather than audit_log_string()
    ima: Call audit_log_string() rather than logging it untrusted

    Linus Torvalds
     
  • Pull security subsystem updates from James Morris:

    - kstrdup() return value fix from Eric Biggers

    - Add new security_load_data hook to differentiate security checking of
    kernel-loaded binaries in the case of there being no associated file
    descriptor, from Mimi Zohar.

    - Add ability to IMA to specify a policy at build-time, rather than
    just via command line params or by loading a custom policy, from
    Mimi.

    - Allow IMA and LSMs to prevent sysfs firmware load fallback (e.g. if
    using signed firmware), from Mimi.

    - Allow IMA to deny loading of kexec kernel images, as they cannot be
    measured by IMA, from Mimi.

    * 'next-general' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
    security: check for kstrdup() failure in lsm_append()
    security: export security_kernel_load_data function
    ima: based on policy warn about loading firmware (pre-allocated buffer)
    module: replace the existing LSM hook in init_module
    ima: add build time policy
    ima: based on policy require signed firmware (sysfs fallback)
    firmware: add call to LSM hook before firmware sysfs fallback
    ima: based on policy require signed kexec kernel images
    kexec: add call to LSM hook in original kexec_load syscall
    security: define new LSM hook named security_kernel_load_data
    MAINTAINERS: remove the outdated "LINUX SECURITY MODULE (LSM) FRAMEWORK" entry

    Linus Torvalds
     

18 Jul, 2018

3 commits

  • 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: Mikhail Kurinnoi
    Signed-off-by: Mimi Zohar

    include/linux/integrity.h | 13 +++++++++++++
    security/integrity/digsig_asymmetric.c | 23 +++++++++++++++++++++++
    security/security.c | 7 ++++++-
    3 files changed, 42 insertions(+), 1 deletion(-)

    Mikhail Kurinnoi
     
  • lsm_append() should return -ENOMEM if memory allocation failed.

    Fixes: d69dece5f5b6 ("LSM: Add /sys/kernel/security/lsm")
    Signed-off-by: Eric Biggers
    Signed-off-by: James Morris

    Eric Biggers
     
  • 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: 6e852651f28e ("firmware: add call to LSM hook before firmware sysfs fallback")
    Signed-off-by: Arnd Bergmann
    Signed-off-by: James Morris

    Arnd Bergmann
     

17 Jul, 2018

2 commits

  • The original kexec_load syscall can not verify file signatures, nor can
    the kexec image be measured. Based on policy, deny the kexec_load
    syscall.

    Signed-off-by: Mimi Zohar
    Cc: Eric Biederman
    Cc: Kees Cook
    Reviewed-by: Kees Cook
    Signed-off-by: James Morris

    Mimi Zohar
     
  • Differentiate between the kernel reading a file specified by userspace
    from the kernel loading a buffer containing data provided by userspace.
    This patch defines a new LSM hook named security_kernel_load_data().

    Signed-off-by: Mimi Zohar
    Cc: Eric Biederman
    Cc: Luis R. Rodriguez
    Cc: Kees Cook
    Cc: Casey Schaufler
    Acked-by: Serge Hallyn
    Acked-by: Kees Cook
    Signed-off-by: James Morris

    Mimi Zohar
     

12 Jul, 2018

2 commits


05 May, 2018

1 commit

  • 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: Serge Hallyn
    Signed-off-by: Tom Gundersen
    Signed-off-by: David Herrmann
    Signed-off-by: James Morris

    David Herrmann
     

11 Apr, 2018

1 commit

  • Pull tracing updates from Steven Rostedt:
    "New features:

    - Tom Zanussi's extended histogram work.

    This adds the synthetic events to have histograms from multiple
    event data Adds triggers "onmatch" and "onmax" to call the
    synthetic events Several updates to the histogram code from this

    - Allow way to nest ring buffer calls in the same context

    - Allow absolute time stamps in ring buffer

    - Rewrite of filter code parsing based on Al Viro's suggestions

    - Setting of trace_clock to global if TSC is unstable (on boot)

    - Better OOM handling when allocating large ring buffers

    - Added initcall tracepoints (consolidated initcall_debug code with
    them)

    And other various fixes and clean ups"

    * tag 'trace-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (68 commits)
    init: Have initcall_debug still work without CONFIG_TRACEPOINTS
    init, tracing: Have printk come through the trace events for initcall_debug
    init, tracing: instrument security and console initcall trace events
    init, tracing: Add initcall trace events
    tracing: Add rcu dereference annotation for test func that touches filter->prog
    tracing: Add rcu dereference annotation for filter->prog
    tracing: Fixup logic inversion on setting trace_global_clock defaults
    tracing: Hide global trace clock from lockdep
    ring-buffer: Add set/clear_current_oom_origin() during allocations
    ring-buffer: Check if memory is available before allocation
    lockdep: Add print_irqtrace_events() to __warn
    vsprintf: Do not preprocess non-dereferenced pointers for bprintf (%px and %pK)
    tracing: Uninitialized variable in create_tracing_map_fields()
    tracing: Make sure variable string fields are NULL-terminated
    tracing: Add action comparisons when testing matching hist triggers
    tracing: Don't add flag strings when displaying variable references
    tracing: Fix display of hist trigger expressions containing timestamps
    ftrace: Drop a VLA in module_exists()
    tracing: Mention trace_clock=global when warning about unstable clocks
    tracing: Default to using trace_global_clock if sched_clock is unstable
    ...

    Linus Torvalds
     

08 Apr, 2018

2 commits

  • …morris/linux-security

    Pull integrity updates from James Morris:
    "A mixture of bug fixes, code cleanup, and continues to close
    IMA-measurement, IMA-appraisal, and IMA-audit gaps.

    Also note the addition of a new cred_getsecid LSM hook by Matthew
    Garrett:

    For IMA purposes, we want to be able to obtain the prepared secid
    in the bprm structure before the credentials are committed. Add a
    cred_getsecid hook that makes this possible.

    which is used by a new CREDS_CHECK target in IMA:

    In ima_bprm_check(), check with both the existing process
    credentials and the credentials that will be committed when the new
    process is started. This will not change behaviour unless the
    system policy is extended to include CREDS_CHECK targets -
    BPRM_CHECK will continue to check the same credentials that it did
    previously"

    * 'next-integrity' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
    ima: Fallback to the builtin hash algorithm
    ima: Add smackfs to the default appraise/measure list
    evm: check for remount ro in progress before writing
    ima: Improvements in ima_appraise_measurement()
    ima: Simplify ima_eventsig_init()
    integrity: Remove unused macro IMA_ACTION_RULE_FLAGS
    ima: drop vla in ima_audit_measurement()
    ima: Fix Kconfig to select TPM 2.0 CRB interface
    evm: Constify *integrity_status_msg[]
    evm: Move evm_hmac and evm_hash from evm_main.c to evm_crypto.c
    fuse: define the filesystem as untrusted
    ima: fail signature verification based on policy
    ima: clear IMA_HASH
    ima: re-evaluate files on privileged mounted filesystems
    ima: fail file signature verification on non-init mounted filesystems
    IMA: Support using new creds in appraisal policy
    security: Add a cred_getsecid hook

    Linus Torvalds
     
  • Pull general security layer updates from James Morris:

    - Convert security hooks from list to hlist, a nice cleanup, saving
    about 50% of space, from Sargun Dhillon.

    - Only pass the cred, not the secid, to kill_pid_info_as_cred and
    security_task_kill (as the secid can be determined from the cred),
    from Stephen Smalley.

    - Close a potential race in kernel_read_file(), by making the file
    unwritable before calling the LSM check (vs after), from Kees Cook.

    * 'next-general' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
    security: convert security hooks to use hlist
    exec: Set file unwritable before LSM check
    usb, signal, security: only pass the cred, not the secid, to kill_pid_info_as_cred and security_task_kill

    Linus Torvalds
     

07 Apr, 2018

1 commit

  • Pull SELinux updates from Paul Moore:
    "A bigger than usual pull request for SELinux, 13 patches (lucky!)
    along with a scary looking diffstat.

    Although if you look a bit closer, excluding the usual minor
    tweaks/fixes, there are really only two significant changes in this
    pull request: the addition of proper SELinux access controls for SCTP
    and the encapsulation of a lot of internal SELinux state.

    The SCTP changes are the result of a multi-month effort (maybe even a
    year or longer?) between the SELinux folks and the SCTP folks to add
    proper SELinux controls. A special thanks go to Richard for seeing
    this through and keeping the effort moving forward.

    The state encapsulation work is a bit of janitorial work that came out
    of some early work on SELinux namespacing. The question of namespacing
    is still an open one, but I believe there is some real value in the
    encapsulation work so we've split that out and are now sending that up
    to you"

    * tag 'selinux-pr-20180403' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
    selinux: wrap AVC state
    selinux: wrap selinuxfs state
    selinux: fix handling of uninitialized selinux state in get_bools/classes
    selinux: Update SELinux SCTP documentation
    selinux: Fix ltp test connect-syscall failure
    selinux: rename the {is,set}_enforcing() functions
    selinux: wrap global selinux state
    selinux: fix typo in selinux_netlbl_sctp_sk_clone declaration
    selinux: Add SCTP support
    sctp: Add LSM hooks
    sctp: Add ip option support
    security: Add support for SCTP security hooks
    netlabel: If PF_INET6, check sk_buff ip header version

    Linus Torvalds
     

06 Apr, 2018

1 commit


31 Mar, 2018

1 commit

  • This changes security_hook_heads to use hlist_heads instead of
    the circular doubly-linked list heads. This should cut down
    the size of the struct by about half.

    In addition, it allows mutation of the hooks at the tail of the
    callback list without having to modify the head. The longer-term
    purpose of this is to enable making the heads read only.

    Signed-off-by: Sargun Dhillon
    Reviewed-by: Tetsuo Handa
    Acked-by: Casey Schaufler
    Signed-off-by: James Morris

    Sargun Dhillon
     

23 Mar, 2018

4 commits


07 Mar, 2018

1 commit

  • …ed and security_task_kill

    commit d178bc3a708f39cbfefc3fab37032d3f2511b4ec ("user namespace: usb:
    make usb urbs user namespace aware (v2)") changed kill_pid_info_as_uid
    to kill_pid_info_as_cred, saving and passing a cred structure instead of
    uids. Since the secid can be obtained from the cred, drop the secid fields
    from the usb_dev_state and async structures, and drop the secid argument to
    kill_pid_info_as_cred. Replace the secid argument to security_task_kill
    with the cred. Update SELinux, Smack, and AppArmor to use the cred, which
    avoids the need for Smack and AppArmor to use a secid at all in this hook.
    Further changes to Smack might still be required to take full advantage of
    this change, since it should now be possible to perform capability
    checking based on the supplied cred. The changes to Smack and AppArmor
    have only been compile-tested.

    Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
    Acked-by: Paul Moore <paul@paul-moore.com>
    Acked-by: Casey Schaufler <casey@schaufler-ca.com>
    Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Acked-by: John Johansen <john.johansen@canonical.com>
    Signed-off-by: James Morris <james.morris@microsoft.com>

    Stephen Smalley
     

23 Feb, 2018

1 commit


20 Oct, 2017

1 commit

  • 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: Chenbo Feng
    Acked-by: James Morris
    Signed-off-by: David S. Miller

    Chenbo Feng
     

13 Sep, 2017

1 commit

  • Pull selinux updates from Paul Moore:
    "A relatively quiet period for SELinux, 11 patches with only two/three
    having any substantive changes.

    These noteworthy changes include another tweak to the NNP/nosuid
    handling, per-file labeling for cgroups, and an object class fix for
    AF_UNIX/SOCK_RAW sockets; the rest of the changes are minor tweaks or
    administrative updates (Stephen's email update explains the file
    explosion in the diffstat).

    Everything passes the selinux-testsuite"

    [ Also a couple of small patches from the security tree from Tetsuo
    Handa for Tomoyo and LSM cleanup. The separation of security policy
    updates wasn't all that clean - Linus ]

    * tag 'selinux-pr-20170831' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
    selinux: constify nf_hook_ops
    selinux: allow per-file labeling for cgroupfs
    lsm_audit: update my email address
    selinux: update my email address
    MAINTAINERS: update the NetLabel and Labeled Networking information
    selinux: use GFP_NOWAIT in the AVC kmem_caches
    selinux: Generalize support for NNP/nosuid SELinux domain transitions
    selinux: genheaders should fail if too many permissions are defined
    selinux: update the selinux info in MAINTAINERS
    credits: update Paul Moore's info
    selinux: Assign proper class to PF_UNIX/SOCK_RAW sockets
    tomoyo: Update URLs in Documentation/admin-guide/LSM/tomoyo.rst
    LSM: Remove security_task_create() hook.

    Linus Torvalds
     

02 Aug, 2017

1 commit

  • This removes the bprm_secureexec hook since the logic has been folded into
    the bprm_set_creds hook for all LSMs now.

    Cc: Eric W. Biederman
    Signed-off-by: Kees Cook
    Reviewed-by: John Johansen
    Acked-by: James Morris
    Acked-by: Serge Hallyn

    Kees Cook
     

18 Jul, 2017

1 commit


10 Jun, 2017

1 commit

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

    Signed-off-by: Scott Mayhew
    Reviewed-by: Stephen Smalley
    Tested-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Scott Mayhew
     

24 May, 2017

3 commits

  • 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: Daniel Jurgens
    Acked-by: Doug Ledford
    [PM: remove the LSM hook init code]
    Signed-off-by: Paul Moore

    Daniel Jurgens
     
  • Add a generic notificaiton mechanism in the LSM. Interested consumers
    can register a callback with the LSM and security modules can produce
    events.

    Because access to Infiniband QPs are enforced in the setup phase of a
    connection security should be enforced again if the policy changes.
    Register infiniband devices for policy change notification and check all
    QPs on that device when the notification is received.

    Add a call to the notification mechanism from SELinux when the AVC
    cache changes or setenforce is cleared.

    Signed-off-by: Daniel Jurgens
    Acked-by: James Morris
    Acked-by: Doug Ledford
    Signed-off-by: Paul Moore

    Daniel Jurgens
     
  • Add new LSM hooks to allocate and free security contexts and check for
    permission to access a PKey.

    Allocate and free a security context when creating and destroying a QP.
    This context is used for controlling access to PKeys.

    When a request is made to modify a QP that changes the port, PKey index,
    or alternate path, check that the QP has permission for the PKey in the
    PKey table index on the subnet prefix of the port. If the QP is shared
    make sure all handles to the QP also have access.

    Store which port and PKey index a QP is using. After the reset to init
    transition the user can modify the port, PKey index and alternate path
    independently. So port and PKey settings changes can be a merge of the
    previous settings and the new ones.

    In order to maintain access control if there are PKey table or subnet
    prefix change keep a list of all QPs are using each PKey index on
    each port. If a change occurs all QPs using that device and port must
    have access enforced for the new cache settings.

    These changes add a transaction to the QP modify process. Association
    with the old port and PKey index must be maintained if the modify fails,
    and must be removed if it succeeds. Association with the new port and
    PKey index must be established prior to the modify and removed if the
    modify fails.

    1. When a QP is modified to a particular Port, PKey index or alternate
    path insert that QP into the appropriate lists.

    2. Check permission to access the new settings.

    3. If step 2 grants access attempt to modify the QP.

    4a. If steps 2 and 3 succeed remove any prior associations.

    4b. If ether fails remove the new setting associations.

    If a PKey table or subnet prefix changes walk the list of QPs and
    check that they have permission. If not send the QP to the error state
    and raise a fatal error event. If it's a shared QP make sure all the
    QPs that share the real_qp have permission as well. If the QP that
    owns a security structure is denied access the security structure is
    marked as such and the QP is added to an error_list. Once the moving
    the QP to error is complete the security structure mark is cleared.

    Maintaining the lists correctly turns QP destroy into a transaction.
    The hardware driver for the device frees the ib_qp structure, so while
    the destroy is in progress the ib_qp pointer in the ib_qp_security
    struct is undefined. When the destroy process begins the ib_qp_security
    structure is marked as destroying. This prevents any action from being
    taken on the QP pointer. After the QP is destroyed successfully it
    could still listed on an error_list wait for it to be processed by that
    flow before cleaning up the structure.

    If the destroy fails the QPs port and PKey settings are reinserted into
    the appropriate lists, the destroying flag is cleared, and access control
    is enforced, in case there were any cache changes during the destroy
    flow.

    To keep the security changes isolated a new file is used to hold security
    related functionality.

    Signed-off-by: Daniel Jurgens
    Acked-by: Doug Ledford
    [PM: merge fixup in ib_verbs.h and uverbs_cmd.c]
    Signed-off-by: Paul Moore

    Daniel Jurgens
     

22 May, 2017

1 commit


15 May, 2017

1 commit

  • The commit d69dece5f5b6 ("LSM: Add /sys/kernel/security/lsm") extend
    security_add_hooks() with a new parameter to register the LSM name,
    which may be useful to make the list of currently loaded LSM available
    to userspace. However, there is no clean way for an LSM to split its
    hook declarations into multiple files, which may reduce the mess with
    all the included files (needed for LSM hook argument types) and make the
    source code easier to review and maintain.

    This change allows an LSM to register multiple times its hook while
    keeping a consistent list of LSM names as described in
    Documentation/security/LSM.txt . The list reflects the order in which
    checks are made. This patch only check for the last registered LSM. If
    an LSM register multiple times its hooks, interleaved with other LSM
    registrations (which should not happen), its name will still appear in
    the same order that the hooks are called, hence multiple times.

    To sum up, "capability,selinux,foo,foo" will be replaced with
    "capability,selinux,foo", however "capability,foo,selinux,foo" will
    remain as is.

    Signed-off-by: Mickaël Salaün
    Acked-by: Kees Cook
    Acked-by: Casey Schaufler
    Signed-off-by: James Morris

    Mickaël Salaün
     

03 May, 2017

1 commit

  • Pull security subsystem updates from James Morris:
    "Highlights:

    IMA:
    - provide ">" and " of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (98 commits)
    tpm: Fix reference count to main device
    tpm_tis: convert to using locality callbacks
    tpm: fix handling of the TPM 2.0 event logs
    tpm_crb: remove a cruft constant
    keys: select CONFIG_CRYPTO when selecting DH / KDF
    apparmor: Make path_max parameter readonly
    apparmor: fix parameters so that the permission test is bypassed at boot
    apparmor: fix invalid reference to index variable of iterator line 836
    apparmor: use SHASH_DESC_ON_STACK
    security/apparmor/lsm.c: set debug messages
    apparmor: fix boolreturn.cocci warnings
    Smack: Use GFP_KERNEL for smk_netlbl_mls().
    smack: fix double free in smack_parse_opts_str()
    KEYS: add SP800-56A KDF support for DH
    KEYS: Keyring asymmetric key restrict method with chaining
    KEYS: Restrict asymmetric key linkage using a specific keychain
    KEYS: Add a lookup_restriction function for the asymmetric key type
    KEYS: Add KEYCTL_RESTRICT_KEYRING
    KEYS: Consistent ordering for __key_link_begin and restrict check
    KEYS: Add an optional lookup_restriction hook to key_type
    ...

    Linus Torvalds
     

03 Apr, 2017

1 commit

  • ./lib/string.c:134: WARNING: Inline emphasis start-string without end-string.
    ./mm/filemap.c:522: WARNING: Inline interpreted text or phrase reference start-string without end-string.
    ./mm/filemap.c:1283: ERROR: Unexpected indentation.
    ./mm/filemap.c:3003: WARNING: Inline interpreted text or phrase reference start-string without end-string.
    ./mm/vmalloc.c:1544: WARNING: Inline emphasis start-string without end-string.
    ./mm/page_alloc.c:4245: ERROR: Unexpected indentation.
    ./ipc/util.c:676: ERROR: Unexpected indentation.
    ./drivers/pci/irq.c:35: WARNING: Block quote ends without a blank line; unexpected unindent.
    ./security/security.c:109: ERROR: Unexpected indentation.
    ./security/security.c:110: WARNING: Definition list ends without a blank line; unexpected unindent.
    ./block/genhd.c:275: WARNING: Inline strong start-string without end-string.
    ./block/genhd.c:283: WARNING: Inline strong start-string without end-string.
    ./include/linux/clk.h:134: WARNING: Inline emphasis start-string without end-string.
    ./include/linux/clk.h:134: WARNING: Inline emphasis start-string without end-string.
    ./ipc/util.c:477: ERROR: Unknown target name: "s".

    Signed-off-by: Mauro Carvalho Chehab
    Acked-by: Bjorn Helgaas
    Signed-off-by: Jonathan Corbet

    mchehab@s-opensource.com
     

28 Mar, 2017

1 commit

  • We switched from "struct task_struct"->security to "struct cred"->security
    in Linux 2.6.29. But not all LSM modules were happy with that change.
    TOMOYO LSM module is an example which want to use per "struct task_struct"
    security blob, for TOMOYO's security context is defined based on "struct
    task_struct" rather than "struct cred". AppArmor LSM module is another
    example which want to use it, for AppArmor is currently abusing the cred
    a little bit to store the change_hat and setexeccon info. Although
    security_task_free() hook was revived in Linux 3.4 because Yama LSM module
    wanted to release per "struct task_struct" security blob,
    security_task_alloc() hook and "struct task_struct"->security field were
    not revived. Nowadays, we are getting proposals of lightweight LSM modules
    which want to use per "struct task_struct" security blob.

    We are already allowing multiple concurrent LSM modules (up to one fully
    armored module which uses "struct cred"->security field or exclusive hooks
    like security_xfrm_state_pol_flow_match(), plus unlimited number of
    lightweight modules which do not use "struct cred"->security nor exclusive
    hooks) as long as they are built into the kernel. But this patch does not
    implement variable length "struct task_struct"->security field which will
    become needed when multiple LSM modules want to use "struct task_struct"->
    security field. Although it won't be difficult to implement variable length
    "struct task_struct"->security field, let's think about it after we merged
    this patch.

    Signed-off-by: Tetsuo Handa
    Acked-by: John Johansen
    Acked-by: Serge Hallyn
    Acked-by: Casey Schaufler
    Tested-by: Djalal Harouni
    Acked-by: José Bollo
    Cc: Paul Moore
    Cc: Stephen Smalley
    Cc: Eric Paris
    Cc: Kees Cook
    Cc: James Morris
    Cc: José Bollo
    Signed-off-by: James Morris

    Tetsuo Handa
     

24 Mar, 2017

1 commit

  • "struct security_hook_heads" is an array of "struct list_head"
    where elements can be initialized just before registration.

    There is no need to waste 350+ lines for initialization. Let's
    initialize "struct security_hook_heads" just before registration.

    Signed-off-by: Tetsuo Handa
    Acked-by: Kees Cook
    Cc: John Johansen
    Cc: Kees Cook
    Cc: Paul Moore
    Cc: Stephen Smalley
    Cc: Casey Schaufler
    Cc: James Morris
    Signed-off-by: James Morris

    Tetsuo Handa
     

06 Mar, 2017

2 commits

  • Mark all of the registration hooks as __ro_after_init (via the
    __lsm_ro_after_init macro).

    Signed-off-by: James Morris
    Acked-by: Stephen Smalley
    Acked-by: Kees Cook

    James Morris
     
  • When SELinux was first added to the kernel, a process could only get
    and set its own resource limits via getrlimit(2) and setrlimit(2), so no
    MAC checks were required for those operations, and thus no security hooks
    were defined for them. Later, SELinux introduced a hook for setlimit(2)
    with a check if the hard limit was being changed in order to be able to
    rely on the hard limit value as a safe reset point upon context
    transitions.

    Later on, when prlimit(2) was added to the kernel with the ability to get
    or set resource limits (hard or soft) of another process, LSM/SELinux was
    not updated other than to pass the target process to the setrlimit hook.
    This resulted in incomplete control over both getting and setting the
    resource limits of another process.

    Add a new security_task_prlimit() hook to the check_prlimit_permission()
    function to provide complete mediation. The hook is only called when
    acting on another task, and only if the existing DAC/capability checks
    would allow access. Pass flags down to the hook to indicate whether the
    prlimit(2) call will read, write, or both read and write the resource
    limits of the target process.

    The existing security_task_setrlimit() hook is left alone; it continues
    to serve a purpose in supporting the ability to make decisions based on
    the old and/or new resource limit values when setting limits. This
    is consistent with the DAC/capability logic, where
    check_prlimit_permission() performs generic DAC/capability checks for
    acting on another task, while do_prlimit() performs a capability check
    based on a comparison of the old and new resource limits. Fix the
    inline documentation for the hook to match the code.

    Implement the new hook for SELinux. For setting resource limits, we
    reuse the existing setrlimit permission. Note that this does overload
    the setrlimit permission to mean the ability to set the resource limit
    (soft or hard) of another process or the ability to change one's own
    hard limit. For getting resource limits, a new getrlimit permission
    is defined. This was not originally defined since getrlimit(2) could
    only be used to obtain a process' own limits.

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

    Stephen Smalley