05 Jun, 2018

1 commit

  • commit efe3de79e0b52ca281ef6691480c8c68c82a4657 upstream.

    Call trace:
    [] dump_backtrace+0x0/0x428
    [] show_stack+0x28/0x38
    [] dump_stack+0xd4/0x124
    [] print_address_description+0x68/0x258
    [] kasan_report.part.2+0x228/0x2f0
    [] kasan_report+0x5c/0x70
    [] check_memory_region+0x12c/0x1c0
    [] memcpy+0x34/0x68
    [] xattr_getsecurity+0xe0/0x160
    [] vfs_getxattr+0xc8/0x120
    [] getxattr+0x100/0x2c8
    [] SyS_fgetxattr+0x64/0xa0
    [] el0_svc_naked+0x24/0x28

    If user get root access and calls security.selinux setxattr() with an
    embedded NUL on a file and then if some process performs a getxattr()
    on that file with a length greater than the actual length of the string,
    it would result in a panic.

    To fix this, add the actual length of the string to the security context
    instead of the length passed by the userspace process.

    Signed-off-by: Sachin Grover
    Cc: stable@vger.kernel.org
    Signed-off-by: Paul Moore
    Signed-off-by: Greg Kroah-Hartman

    Sachin Grover
     

25 Feb, 2018

2 commits

  • commit 4b14752ec4e0d87126e636384cf37c8dd9df157c upstream.

    We can't do anything reasonable in security_bounded_transition() if we
    don't have a policy loaded, and in fact we could run into problems
    with some of the code inside expecting a policy. Fix these problems
    like we do many others in security/selinux/ss/services.c by checking
    to see if the policy is loaded (ss_initialized) and returning quickly
    if it isn't.

    Reported-by: syzbot
    Signed-off-by: Paul Moore
    Acked-by: Stephen Smalley
    Reviewed-by: James Morris
    Signed-off-by: Greg Kroah-Hartman

    Paul Moore
     
  • commit ef28df55ac27e1e5cd122e19fa311d886d47a756 upstream.

    The syzbot/syzkaller automated tests found a problem in
    security_context_to_sid_core() during early boot (before we load the
    SELinux policy) where we could potentially feed context strings without
    NUL terminators into the strcmp() function.

    We already guard against this during normal operation (after the SELinux
    policy has been loaded) by making a copy of the context strings and
    explicitly adding a NUL terminator to the end. The patch extends this
    protection to the early boot case (no loaded policy) by moving the context
    copy earlier in security_context_to_sid_core().

    Reported-by: syzbot
    Signed-off-by: Paul Moore
    Reviewed-By: William Roberts
    Signed-off-by: Greg Kroah-Hartman

    Paul Moore
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

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
     

08 Sep, 2017

2 commits

  • Pull audit updates from Paul Moore:
    "A small pull request for audit this time, only four patches and only
    two with any real code changes.

    Those two changes are the removal of a pointless SELinux AVC
    initialization audit event and a fix to improve the audit timestamp
    overhead.

    The other two patches are comment cleanup and administrative updates,
    nothing very exciting.

    Everything passes our tests"

    * tag 'audit-pr-20170907' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit:
    audit: update the function comments
    selinux: remove AVC init audit log message
    audit: update the audit info in MAINTAINERS
    audit: Reduce overhead using a coarse clock

    Linus Torvalds
     
  • Pull secureexec update from Kees Cook:
    "This series has the ultimate goal of providing a sane stack rlimit
    when running set*id processes.

    To do this, the bprm_secureexec LSM hook is collapsed into the
    bprm_set_creds hook so the secureexec-ness of an exec can be
    determined early enough to make decisions about rlimits and the
    resulting memory layouts. Other logic acting on the secureexec-ness of
    an exec is similarly consolidated. Capabilities needed some special
    handling, but the refactoring removed other special handling, so that
    was a wash"

    * tag 'secureexec-v4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
    exec: Consolidate pdeath_signal clearing
    exec: Use sane stack rlimit under secureexec
    exec: Consolidate dumpability logic
    smack: Remove redundant pdeath_signal clearing
    exec: Use secureexec for clearing pdeath_signal
    exec: Use secureexec for setting dumpability
    LSM: drop bprm_secureexec hook
    commoncap: Move cap_elevated calculation into bprm_set_creds
    commoncap: Refactor to remove bprm_secureexec hook
    smack: Refactor to remove bprm_secureexec hook
    selinux: Refactor to remove bprm_secureexec hook
    apparmor: Refactor to remove bprm_secureexec hook
    binfmt: Introduce secureexec flag
    exec: Correct comments about "point of no return"
    exec: Rename bprm->cred_prepared to called_set_creds

    Linus Torvalds
     

05 Sep, 2017

1 commit

  • In the process of normalizing audit log messages, it was noticed that the AVC
    initialization code registered an audit log KERNEL record that didn't fit the
    standard format. In the process of attempting to normalize it it was
    determined that this record was not even necessary. Remove it.

    Ref: http://marc.info/?l=selinux&m=149614868525826&w=2
    See: https://github.com/linux-audit/audit-kernel/issues/48
    Signed-off-by: Richard Guy Briggs
    Acked-by: Stephen Smalley
    Acked-by: Steve Grubb
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

29 Aug, 2017

1 commit

  • nf_hook_ops are not supposed to change at runtime. nf_register_net_hooks
    and nf_unregister_net_hooks are working with const nf_hook_ops.
    So mark the non-const nf_hook_ops structs as const.

    Signed-off-by: Arvind Yadav
    Signed-off-by: Paul Moore

    Arvind Yadav
     

23 Aug, 2017

1 commit


18 Aug, 2017

1 commit


08 Aug, 2017

1 commit

  • There is a strange __GFP_NOMEMALLOC usage pattern in SELinux,
    specifically GFP_ATOMIC | __GFP_NOMEMALLOC which doesn't make much
    sense. GFP_ATOMIC on its own allows to access memory reserves while
    __GFP_NOMEMALLOC dictates we cannot use memory reserves. Replace this
    with the much more sane GFP_NOWAIT in the AVC code as we can tolerate
    memory allocation failures in that code.

    Signed-off-by: Michal Hocko
    Acked-by: Mel Gorman
    Signed-off-by: Paul Moore

    Michal Hocko
     

03 Aug, 2017

1 commit

  • As systemd ramps up enabling NNP (NoNewPrivileges) for system services,
    it is increasingly breaking SELinux domain transitions for those services
    and their descendants. systemd enables NNP not only for services whose
    unit files explicitly specify NoNewPrivileges=yes but also for services
    whose unit files specify any of the following options in combination with
    running without CAP_SYS_ADMIN (e.g. specifying User= or a
    CapabilityBoundingSet= without CAP_SYS_ADMIN): SystemCallFilter=,
    SystemCallArchitectures=, RestrictAddressFamilies=, RestrictNamespaces=,
    PrivateDevices=, ProtectKernelTunables=, ProtectKernelModules=,
    MemoryDenyWriteExecute=, or RestrictRealtime= as per the systemd.exec(5)
    man page.

    The end result is bad for the security of both SELinux-disabled and
    SELinux-enabled systems. Packagers have to turn off these
    options in the unit files to preserve SELinux domain transitions. For
    users who choose to disable SELinux, this means that they miss out on
    at least having the systemd-supported protections. For users who keep
    SELinux enabled, they may still be missing out on some protections
    because it isn't necessarily guaranteed that the SELinux policy for
    that service provides the same protections in all cases.

    commit 7b0d0b40cd78 ("selinux: Permit bounded transitions under
    NO_NEW_PRIVS or NOSUID.") allowed bounded transitions under NNP in
    order to support limited usage for sandboxing programs. However,
    defining typebounds for all of the affected service domains
    is impractical to implement in policy, since typebounds requires us
    to ensure that each domain is allowed everything all of its descendant
    domains are allowed, and this has to be repeated for the entire chain
    of domain transitions. There is no way to clone all allow rules from
    descendants to their ancestors in policy currently, and doing so would
    be undesirable even if it were practical, as it requires leaking
    permissions to objects and operations into ancestor domains that could
    weaken their own security in order to allow them to the descendants
    (e.g. if a descendant requires execmem permission, then so do all of
    its ancestors; if a descendant requires execute permission to a file,
    then so do all of its ancestors; if a descendant requires read to a
    symbolic link or temporary file, then so do all of its ancestors...).
    SELinux domains are intentionally not hierarchical / bounded in this
    manner normally, and making them so would undermine their protections
    and least privilege.

    We have long had a similar tension with SELinux transitions and nosuid
    mounts, albeit not as severe. Users often have had to choose between
    retaining nosuid on a mount and allowing SELinux domain transitions on
    files within those mounts. This likewise leads to unfortunate tradeoffs
    in security.

    Decouple NNP/nosuid from SELinux transitions, so that we don't have to
    make a choice between them. Introduce a nnp_nosuid_transition policy
    capability that enables transitions under NNP/nosuid to be based on
    a permission (nnp_transition for NNP; nosuid_transition for nosuid)
    between the old and new contexts in addition to the current support
    for bounded transitions. Domain transitions can then be allowed in
    policy without requiring the parent to be a strict superset of all of
    its children.

    With this change, systemd unit files can be left unmodified from upstream.
    SELinux-disabled and SELinux-enabled users will benefit from retaining any
    of the systemd-provided protections. SELinux policy will only need to
    be adapted to enable the new policy capability and to allow the
    new permissions between domain pairs as appropriate.

    NB: Allowing nnp_transition between two contexts opens up the potential
    for the old context to subvert the new context by installing seccomp
    filters before the execve. Allowing nosuid_transition between two contexts
    opens up the potential for a context transition to occur on a file from
    an untrusted filesystem (e.g. removable media or remote filesystem). Use
    with care.

    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley
     

02 Aug, 2017

2 commits

  • The SELinux bprm_secureexec hook can be merged with the bprm_set_creds
    hook since it's dealing with the same information, and all of the details
    are finalized during the first call to the bprm_set_creds hook via
    prepare_binprm() (subsequent calls due to binfmt_script, etc, are ignored
    via bprm->called_set_creds).

    Here, the test can just happen at the end of the bprm_set_creds hook,
    and the bprm_secureexec hook can be dropped.

    Cc: Stephen Smalley
    Signed-off-by: Kees Cook
    Acked-by: Paul Moore
    Tested-by: Paul Moore
    Acked-by: Serge Hallyn
    Reviewed-by: James Morris
    Reviewed-by: Andy Lutomirski

    Kees Cook
     
  • The cred_prepared bprm flag has a misleading name. It has nothing to do
    with the bprm_prepare_cred hook, and actually tracks if bprm_set_creds has
    been called. Rename this flag and improve its comment.

    Cc: David Howells
    Cc: Stephen Smalley
    Cc: Casey Schaufler
    Signed-off-by: Kees Cook
    Acked-by: John Johansen
    Acked-by: James Morris
    Acked-by: Paul Moore
    Acked-by: Serge Hallyn

    Kees Cook
     

01 Aug, 2017

1 commit


26 Jul, 2017

1 commit


19 Jul, 2017

1 commit

  • After rcu conversions performance degradation in forward tests isn't that
    noticeable anymore.

    See next patch for some numbers.

    A followup patcg could then also remove genid from the policies
    as we do not cache bundles anymore.

    Signed-off-by: Florian Westphal
    Signed-off-by: David S. Miller

    Florian Westphal
     

06 Jul, 2017

3 commits

  • Pull memdup_user() conversions from Al Viro:
    "A fairly self-contained series - hunting down open-coded memdup_user()
    and memdup_user_nul() instances"

    * 'work.memdup_user' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    bpf: don't open-code memdup_user()
    kimage_file_prepare_segments(): don't open-code memdup_user()
    ethtool: don't open-code memdup_user()
    do_ip_setsockopt(): don't open-code memdup_user()
    do_ipv6_setsockopt(): don't open-code memdup_user()
    irda: don't open-code memdup_user()
    xfrm_user_policy(): don't open-code memdup_user()
    ima_write_policy(): don't open-code memdup_user_nul()
    sel_write_validatetrans(): don't open-code memdup_user_nul()

    Linus Torvalds
     
  • Pull networking updates from David Miller:
    "Reasonably busy this cycle, but perhaps not as busy as in the 4.12
    merge window:

    1) Several optimizations for UDP processing under high load from
    Paolo Abeni.

    2) Support pacing internally in TCP when using the sch_fq packet
    scheduler for this is not practical. From Eric Dumazet.

    3) Support mutliple filter chains per qdisc, from Jiri Pirko.

    4) Move to 1ms TCP timestamp clock, from Eric Dumazet.

    5) Add batch dequeueing to vhost_net, from Jason Wang.

    6) Flesh out more completely SCTP checksum offload support, from
    Davide Caratti.

    7) More plumbing of extended netlink ACKs, from David Ahern, Pablo
    Neira Ayuso, and Matthias Schiffer.

    8) Add devlink support to nfp driver, from Simon Horman.

    9) Add RTM_F_FIB_MATCH flag to RTM_GETROUTE queries, from Roopa
    Prabhu.

    10) Add stack depth tracking to BPF verifier and use this information
    in the various eBPF JITs. From Alexei Starovoitov.

    11) Support XDP on qed device VFs, from Yuval Mintz.

    12) Introduce BPF PROG ID for better introspection of installed BPF
    programs. From Martin KaFai Lau.

    13) Add bpf_set_hash helper for TC bpf programs, from Daniel Borkmann.

    14) For loads, allow narrower accesses in bpf verifier checking, from
    Yonghong Song.

    15) Support MIPS in the BPF selftests and samples infrastructure, the
    MIPS eBPF JIT will be merged in via the MIPS GIT tree. From David
    Daney.

    16) Support kernel based TLS, from Dave Watson and others.

    17) Remove completely DST garbage collection, from Wei Wang.

    18) Allow installing TCP MD5 rules using prefixes, from Ivan
    Delalande.

    19) Add XDP support to Intel i40e driver, from Björn Töpel

    20) Add support for TC flower offload in nfp driver, from Simon
    Horman, Pieter Jansen van Vuuren, Benjamin LaHaise, Jakub
    Kicinski, and Bert van Leeuwen.

    21) IPSEC offloading support in mlx5, from Ilan Tayari.

    22) Add HW PTP support to macb driver, from Rafal Ozieblo.

    23) Networking refcount_t conversions, From Elena Reshetova.

    24) Add sock_ops support to BPF, from Lawrence Brako. This is useful
    for tuning the TCP sockopt settings of a group of applications,
    currently via CGROUPs"

    * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1899 commits)
    net: phy: dp83867: add workaround for incorrect RX_CTRL pin strap
    dt-bindings: phy: dp83867: provide a workaround for incorrect RX_CTRL pin strap
    cxgb4: Support for get_ts_info ethtool method
    cxgb4: Add PTP Hardware Clock (PHC) support
    cxgb4: time stamping interface for PTP
    nfp: default to chained metadata prepend format
    nfp: remove legacy MAC address lookup
    nfp: improve order of interfaces in breakout mode
    net: macb: remove extraneous return when MACB_EXT_DESC is defined
    bpf: add missing break in for the TCP_BPF_SNDCWND_CLAMP case
    bpf: fix return in load_bpf_file
    mpls: fix rtm policy in mpls_getroute
    net, ax25: convert ax25_cb.refcount from atomic_t to refcount_t
    net, ax25: convert ax25_route.refcount from atomic_t to refcount_t
    net, ax25: convert ax25_uid_assoc.refcount from atomic_t to refcount_t
    net, sctp: convert sctp_ep_common.refcnt from atomic_t to refcount_t
    net, sctp: convert sctp_transport.refcnt from atomic_t to refcount_t
    net, sctp: convert sctp_chunk.refcnt from atomic_t to refcount_t
    net, sctp: convert sctp_datamsg.refcnt from atomic_t to refcount_t
    net, sctp: convert sctp_auth_bytes.refcnt from atomic_t to refcount_t
    ...

    Linus Torvalds
     
  • Pull security layer updates from James Morris:

    - a major update for AppArmor. From JJ:

    * several bug fixes and cleanups

    * the patch to add symlink support to securityfs that was floated
    on the list earlier and the apparmorfs changes that make use of
    securityfs symlinks

    * it introduces the domain labeling base code that Ubuntu has been
    carrying for several years, with several cleanups applied. And it
    converts the current mediation over to using the domain labeling
    base, which brings domain stacking support with it. This finally
    will bring the base upstream code in line with Ubuntu and provide
    a base to upstream the new feature work that Ubuntu carries.

    * This does _not_ contain any of the newer apparmor mediation
    features/controls (mount, signals, network, keys, ...) that
    Ubuntu is currently carrying, all of which will be RFC'd on top
    of this.

    - Notable also is the Infiniband work in SELinux, and the new file:map
    permission. From Paul:

    "While we're down to 21 patches for v4.13 (it was 31 for v4.12),
    the diffstat jumps up tremendously with over 2k of line changes.

    Almost all of these changes are the SELinux/IB work done by
    Daniel Jurgens; some other noteworthy changes include a NFS v4.2
    labeling fix, a new file:map permission, and reporting of policy
    capabilities on policy load"

    There's also now genfscon labeling support for tracefs, which was
    lost in v4.1 with the separation from debugfs.

    - Smack incorporates a safer socket check in file_receive, and adds a
    cap_capable call in privilege check.

    - TPM as usual has a bunch of fixes and enhancements.

    - Multiple calls to security_add_hooks() can now be made for the same
    LSM, to allow LSMs to have hook declarations across multiple files.

    - IMA now supports different "ima_appraise=" modes (eg. log, fix) from
    the boot command line.

    * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (126 commits)
    apparmor: put back designators in struct initialisers
    seccomp: Switch from atomic_t to recount_t
    seccomp: Adjust selftests to avoid double-join
    seccomp: Clean up core dump logic
    IMA: update IMA policy documentation to include pcr= option
    ima: Log the same audit cause whenever a file has no signature
    ima: Simplify policy_func_show.
    integrity: Small code improvements
    ima: fix get_binary_runtime_size()
    ima: use ima_parse_buf() to parse template data
    ima: use ima_parse_buf() to parse measurements headers
    ima: introduce ima_parse_buf()
    ima: Add cgroups2 to the defaults list
    ima: use memdup_user_nul
    ima: fix up #endif comments
    IMA: Correct Kconfig dependencies for hash selection
    ima: define is_ima_appraise_enabled()
    ima: define Kconfig IMA_APPRAISE_BOOTPARAM option
    ima: define a set of appraisal rules requiring file signatures
    ima: extend the "ima_policy" boot command line to support multiple policies
    ...

    Linus Torvalds
     

22 Jun, 2017

1 commit


21 Jun, 2017

2 commits

  • New NEWCACHEREPORT message type to be used for cache reports sent
    via Netlink, effectively allowing splitting cache report reception from
    mroute programming.

    Suggested-by: Ryan Halbrook
    Signed-off-by: Julien Gomes
    Reviewed-by: Nikolay Aleksandrov
    Signed-off-by: David S. Miller

    Julien Gomes
     
  • In kernel version 4.1, tracefs was separated from debugfs into its
    own filesystem. Prior to this split, files in
    /sys/kernel/debug/tracing could be labeled during filesystem
    creation using genfscon or later from userspace using setxattr. This
    change re-enables support for genfscon labeling.

    Signed-off-by: Jeff Vander Stoep
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Jeff Vander Stoep
     

13 Jun, 2017

1 commit

  • This patch is based on a discussion generated by an earlier patch
    from Tetsuo Handa:

    * https://marc.info/?t=149035659300001&r=1&w=2

    The double free problem involves the mnt_opts field of the
    security_mnt_opts struct, selinux_parse_opts_str() frees the memory
    on error, but doesn't set the field to NULL so if the caller later
    attempts to call security_free_mnt_opts() we trigger the problem.

    In order to play it safe we change selinux_parse_opts_str() to call
    security_free_mnt_opts() on error instead of free'ing the memory
    directly. This should ensure that everything is handled correctly,
    regardless of what the caller may do.

    Fixes: e0007529893c1c06 ("LSM/SELinux: Interfaces to allow FS to control mount options")
    Cc: stable@vger.kernel.org
    Cc: Tetsuo Handa
    Reported-by: Dmitry Vyukov
    Signed-off-by: Paul Moore
    Signed-off-by: James Morris

    Paul Moore
     

10 Jun, 2017

2 commits

  • 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
     
  • The allocated size for each ebitmap_node is 192byte by kzalloc().
    Then, ebitmap_node size is fixed, so it's possible to use only 144byte
    for each object by kmem_cache_zalloc().
    It can reduce some dynamic allocation size.

    Signed-off-by: Junil Lee
    Signed-off-by: Paul Moore

    Junil Lee
     

02 Jun, 2017

1 commit


26 May, 2017

1 commit


24 May, 2017

6 commits

  • It is likely that the SID for the same PKey will be requested many
    times. To reduce the time to modify QPs and process MADs use a cache to
    store PKey SIDs.

    This code is heavily based on the "netif" and "netport" concept
    originally developed by James Morris and Paul Moore
    (see security/selinux/netif.c and
    security/selinux/netport.c for more information)

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

    Daniel Jurgens
     
  • Add a type for Infiniband ports and an access vector for subnet
    management packets. Implement the ib_port_smp hook to check that the
    caller has permission to send and receive SMPs on the end port specified
    by the device name and port. Add interface to query the SID for a IB
    port, which walks the IB_PORT ocontexts to find an entry for the
    given name and port.

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

    Daniel Jurgens
     
  • Add a type and access vector for PKeys. Implement the ib_pkey_access
    hook to check that the caller has permission to access the PKey on the
    given subnet prefix. Add an interface to get the PKey SID. Walk the PKey
    ocontexts to find an entry for the given subnet prefix and pkey.

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

    Daniel Jurgens
     
  • Implement and attach hooks to allocate and free Infiniband object
    security structures.

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

    Daniel Jurgens
     
  • Support for Infiniband requires the addition of two new object contexts,
    one for infiniband PKeys and another IB Ports. Added handlers to read
    and write the new ocontext types when reading or writing a binary policy
    representation.

    Signed-off-by: Daniel Jurgens
    Reviewed-by: Eli Cohen
    Reviewed-by: James Morris
    Acked-by: Doug Ledford
    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
     

23 May, 2017

5 commits

  • The check is already performed in ocontext_read() when the policy is
    loaded. Removing the array also fixes the following warning when
    building with clang:

    security/selinux/hooks.c:338:20: error: variable 'labeling_behaviors'
    is not needed and will not be emitted
    [-Werror,-Wunneeded-internal-declaration]

    Signed-off-by: Matthias Kaehlcke
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Matthias Kaehlcke
     
  • Log the state of SELinux policy capabilities when a policy is loaded.
    For each policy capability known to the kernel, log the policy capability
    name and the value set in the policy. For policy capabilities that are
    set in the loaded policy but unknown to the kernel, log the policy
    capability index, since this is the only information presently available
    in the policy.

    Sample output with a policy created with a new capability defined
    that is not known to the kernel:
    SELinux: policy capability network_peer_controls=1
    SELinux: policy capability open_perms=1
    SELinux: policy capability extended_socket_class=1
    SELinux: policy capability always_check_network=0
    SELinux: policy capability cgroup_seclabel=0
    SELinux: unknown policy capability 5

    Resolves: https://github.com/SELinuxProject/selinux-kernel/issues/32

    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley
     
  • open permission is currently only defined for files in the kernel
    (COMMON_FILE_PERMS rather than COMMON_FILE_SOCK_PERMS). Construction of
    an artificial test case that tries to open a socket via /proc/pid/fd will
    generate a recvfrom avc denial because recvfrom and open happen to map to
    the same permission bit in socket vs file classes.

    open of a socket via /proc/pid/fd is not supported by the kernel regardless
    and will ultimately return ENXIO. But we hit the permission check first and
    can thus produce these odd/misleading denials. Omit the open check when
    operating on a socket.

    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley
     
  • Add a map permission check on mmap so that we can distinguish memory mapped
    access (since it has different implications for revocation). When a file
    is opened and then read or written via syscalls like read(2)/write(2),
    we revalidate access on each read/write operation via
    selinux_file_permission() and therefore can revoke access if the
    process context, the file context, or the policy changes in such a
    manner that access is no longer allowed. When a file is opened and then
    memory mapped via mmap(2) and then subsequently read or written directly
    in memory, we presently have no way to revalidate or revoke access.
    The purpose of a separate map permission check on mmap(2) is to permit
    policy to prohibit memory mapping of specific files for which we need
    to ensure that every access is revalidated, particularly useful for
    scenarios where we expect the file to be relabeled at runtime in order
    to reflect state changes (e.g. cross-domain solution, assured pipeline
    without data copying).

    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley
     
  • SELinux uses CAP_MAC_ADMIN to control the ability to get or set a raw,
    uninterpreted security context unknown to the currently loaded security
    policy. When performing these checks, we only want to perform a base
    capabilities check and a SELinux permission check. If any other
    modules that implement a capable hook are stacked with SELinux, we do
    not want to require them to also have to authorize CAP_MAC_ADMIN,
    since it may have different implications for their security model.
    Rework the CAP_MAC_ADMIN checks within SELinux to only invoke the
    capabilities module and the SELinux permission checking.

    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley