24 Jun, 2020

1 commit

  • commit 65de50969a77509452ae590e9449b70a22b923bb upstream.

    Clang's static analysis tool reports these double free memory errors.

    security/selinux/ss/services.c:2987:4: warning: Attempt to free released memory [unix.Malloc]
    kfree(bnames[i]);
    ^~~~~~~~~~~~~~~~
    security/selinux/ss/services.c:2990:2: warning: Attempt to free released memory [unix.Malloc]
    kfree(bvalues);
    ^~~~~~~~~~~~~~

    So improve the security_get_bools error handling by freeing these variables
    and setting their return pointers to NULL and the return len to 0

    Cc: stable@vger.kernel.org
    Signed-off-by: Tom Rix
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore
    Signed-off-by: Greg Kroah-Hartman

    Tom Rix
     

22 Jun, 2020

1 commit

  • [ Upstream commit 4c09f8b6913a779ca0c70ea8058bf21537eebb3b ]

    Fix to return negative error code -ENOMEM from the kvcalloc() error
    handling case instead of 0, as done elsewhere in this function.

    Fixes: acdf52d97f82 ("selinux: convert to kvmalloc")
    Signed-off-by: Wei Yongjun
    Signed-off-by: Paul Moore
    Signed-off-by: Sasha Levin

    Wei Yongjun
     

09 Oct, 2019

1 commit


04 Oct, 2019

1 commit

  • string_to_context_struct() may garble the context string, so we need to
    copy back the contents again from the old context struct to avoid
    storing the corrupted context.

    Since string_to_context_struct() tokenizes (and therefore truncates) the
    context string and we are later potentially copying it with kstrdup(),
    this may eventually cause pieces of uninitialized kernel memory to be
    disclosed to userspace (when copying to userspace based on the stored
    length and not the null character).

    How to reproduce on Fedora and similar:
    # dnf install -y memcached
    # systemctl start memcached
    # semodule -d memcached
    # load_policy
    # load_policy
    # systemctl stop memcached
    # ausearch -m AVC
    type=AVC msg=audit(1570090572.648:313): avc: denied { signal } for pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=process permissive=0 trawcon=73797374656D5F75007400000000000070BE6E847296FFFF726F6D000096FFFF76

    Cc: stable@vger.kernel.org
    Reported-by: Milos Malik
    Fixes: ee1a84fdfeed ("selinux: overhaul sidtab to fix bug and improve performance")
    Signed-off-by: Ondrej Mosnacek
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Ondrej Mosnacek
     

24 Sep, 2019

1 commit

  • Pull selinux updates from Paul Moore:

    - Add LSM hooks, and SELinux access control hooks, for dnotify,
    fanotify, and inotify watches. This has been discussed with both the
    LSM and fs/notify folks and everybody is good with these new hooks.

    - The LSM stacking changes missed a few calls to current_security() in
    the SELinux code; we fix those and remove current_security() for
    good.

    - Improve our network object labeling cache so that we always return
    the object's label, even when under memory pressure. Previously we
    would return an error if we couldn't allocate a new cache entry, now
    we always return the label even if we can't create a new cache entry
    for it.

    - Convert the sidtab atomic_t counter to a normal u32 with
    READ/WRITE_ONCE() and memory barrier protection.

    - A few patches to policydb.c to clean things up (remove forward
    declarations, long lines, bad variable names, etc)

    * tag 'selinux-pr-20190917' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
    lsm: remove current_security()
    selinux: fix residual uses of current_security() for the SELinux blob
    selinux: avoid atomic_t usage in sidtab
    fanotify, inotify, dnotify, security: add security hook for fs notifications
    selinux: always return a secid from the network caches if we find one
    selinux: policydb - rename type_val_to_struct_array
    selinux: policydb - fix some checkpatch.pl warnings
    selinux: shuffle around policydb.c to get rid of forward declarations

    Linus Torvalds
     

28 Aug, 2019

1 commit

  • As noted in Documentation/atomic_t.txt, if we don't need the RMW atomic
    operations, we should only use READ_ONCE()/WRITE_ONCE() +
    smp_rmb()/smp_wmb() where necessary (or the combined variants
    smp_load_acquire()/smp_store_release()).

    This patch converts the sidtab code to use regular u32 for the counter
    and reverse lookup cache and use the appropriate operations instead of
    atomic_get()/atomic_set(). Note that when reading/updating the reverse
    lookup cache we don't need memory barriers as it doesn't need to be
    consistent or accurate. We can now also replace some atomic ops with
    regular loads (when under spinlock) and stores (for conversion target
    fields that are always accessed under the master table's spinlock).

    We can now also bump SIDTAB_MAX to U32_MAX as we can use the full u32
    range again.

    Suggested-by: Jann Horn
    Signed-off-by: Ondrej Mosnacek
    Reviewed-by: Jann Horn
    Signed-off-by: Paul Moore

    Ondrej Mosnacek
     

06 Aug, 2019

3 commits


03 Aug, 2019

1 commit


01 Aug, 2019

1 commit

  • Since roles_init() adds some entries to the role hash table, we need to
    destroy also its keys/values on error, otherwise we get a memory leak in
    the error path.

    Cc:
    Reported-by: syzbot+fee3a14d4cdf92646287@syzkaller.appspotmail.com
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Ondrej Mosnacek
    Signed-off-by: Paul Moore

    Ondrej Mosnacek
     

27 Jul, 2019

1 commit


24 Jul, 2019

1 commit

  • We need to error out when trying to add an entry above SIDTAB_MAX in
    sidtab_reverse_lookup() to avoid overflow on the odd chance that this
    happens.

    Cc: stable@vger.kernel.org
    Fixes: ee1a84fdfeed ("selinux: overhaul sidtab to fix bug and improve performance")
    Signed-off-by: Ondrej Mosnacek
    Reviewed-by: Kees Cook
    Signed-off-by: Paul Moore

    Ondrej Mosnacek
     

09 Jul, 2019

1 commit

  • Pull selinux updates from Paul Moore:
    "Like the audit pull request this is a little early due to some
    upcoming vacation plans and uncertain network access while I'm away.
    Also like the audit PR, the list of patches here is pretty minor, the
    highlights include:

    - Explicitly use __le variables to make sure "sparse" can verify
    proper byte endian handling.

    - Remove some BUG_ON()s that are no longer needed.

    - Allow zero-byte writes to the "keycreate" procfs attribute without
    requiring key:create to make it easier for userspace to reset the
    keycreate label.

    - Consistently log the "invalid_context" field as an untrusted string
    in the AUDIT_SELINUX_ERR audit records"

    * tag 'selinux-pr-20190702' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
    selinux: format all invalid context as untrusted
    selinux: fix empty write to keycreate file
    selinux: remove some no-op BUG_ONs
    selinux: provide __le variables explicitly

    Linus Torvalds
     

02 Jul, 2019

1 commit

  • The userspace tools expect all fields of the same name to be logged
    consistently with the same encoding. Since the invalid_context fields
    contain untrusted strings in selinux_inode_setxattr()
    and selinux_setprocattr(), encode all instances of this field the same
    way as though they were untrusted even though
    compute_sid_handle_invalid_context() and security_sid_mls_copy() are
    trusted.

    Please see github issue
    https://github.com/linux-audit/audit-kernel/issues/57

    Signed-off-by: Richard Guy Briggs
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

19 Jun, 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 version 2 as
    published by the free software foundation

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation #

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

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

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Enrico Weigelt
    Reviewed-by: Kate Stewart
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

05 Jun, 2019

1 commit

  • Based on 1 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 version 2

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

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

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190531081036.435762997@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

22 May, 2019

2 commits

  • Since acdf52d97f82 ("selinux: convert to kvmalloc"), these check whether
    an address-of value is NULL, which is pointless.

    Signed-off-by: Ondrej Mosnacek
    Signed-off-by: Paul Moore

    Ondrej Mosnacek
     
  • While the endiannes is being handled properly sparse was unable to verify
    this due to type inconsistency. So introduce an additional __le32
    respectively _le64 variable to be passed to le32/64_to_cpu() to allow
    sparse to verify proper typing. Note that this patch does not change
    the generated binary on little-endian systems - on 32bit powerpc it
    does change the binary.

    Signed-off-by: Nicholas Mc Guire
    Signed-off-by: Paul Moore

    Nicholas Mc Guire
     

08 May, 2019

1 commit

  • Pull selinux updates from Paul Moore:
    "We've got a few SELinux patches for the v5.2 merge window, the
    highlights are below:

    - Add LSM hooks, and the SELinux implementation, for proper labeling
    of kernfs. While we are only including the SELinux implementation
    here, the rest of the LSM folks have given the hooks a thumbs-up.

    - Update the SELinux mdp (Make Dummy Policy) script to actually work
    on a modern system.

    - Disallow userspace to change the LSM credentials via
    /proc/self/attr when the task's credentials are already overridden.

    The change was made in procfs because all the LSM folks agreed this
    was the Right Thing To Do and duplicating it across each LSM was
    going to be annoying"

    * tag 'selinux-pr-20190507' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
    proc: prevent changes to overridden credentials
    selinux: Check address length before reading address family
    kernfs: fix xattr name handling in LSM helpers
    MAINTAINERS: update SELinux file patterns
    selinux: avoid uninitialized variable warning
    selinux: remove useless assignments
    LSM: lsm_hooks.h - fix missing colon in docstring
    selinux: Make selinux_kernfs_init_security static
    kernfs: initialize security of newly created nodes
    selinux: implement the kernfs_init_security hook
    LSM: add new hook for kernfs node initialization
    kernfs: use simple_xattrs for security attributes
    selinux: try security xattr after genfs for kernfs filesystems
    kernfs: do not alloc iattrs in kernfs_xattr_get
    kernfs: clean up struct kernfs_iattrs
    scripts/selinux: fix build
    selinux: use kernel linux/socket.h for genheaders and mdp
    scripts/selinux: modernize mdp

    Linus Torvalds
     

25 Mar, 2019

1 commit

  • The code incorrectly assigned directly to the variables instead of the
    values they point to. Since the values are already set to NULL/0 at the
    beginning of the function, we can simply remove these useless
    assignments.

    Reported-by: Hariprasad Kelam
    Fixes: fede148324c3 ("selinux: log invalid contexts in AVCs")
    Signed-off-by: Ondrej Mosnacek
    [PM: removed a bad comment that was causing compiler warnings]
    Signed-off-by: Paul Moore

    Ondrej Mosnacek
     

19 Mar, 2019

1 commit

  • The conversion to kvmalloc() forgot to account for the possibility that
    p->type_attr_map_array might be null in policydb_destroy().

    Fix this by destroying its contents only if it is not NULL.

    Also make sure ebitmap_init() is called on all entries before
    policydb_destroy() can be called. Right now this is a no-op, because
    both kvcalloc() and ebitmap_init() just zero out the whole struct, but
    let's rather not rely on a specific implementation.

    Reported-by: syzbot+a57b2aff60832666fc28@syzkaller.appspotmail.com
    Fixes: acdf52d97f82 ("selinux: convert to kvmalloc")
    Signed-off-by: Ondrej Mosnacek
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Ondrej Mosnacek
     

13 Mar, 2019

1 commit

  • The flex arrays were being used for constant sized arrays, so there's no
    benefit to using flex_arrays over something simpler.

    Link: http://lkml.kernel.org/r/20181217131929.11727-4-kent.overstreet@gmail.com
    Signed-off-by: Kent Overstreet
    Cc: Paul Moore
    Cc: Stephen Smalley
    Cc: Eric Paris
    Cc: Alexey Dobriyan
    Cc: Al Viro
    Cc: Dave Hansen
    Cc: Marcelo Ricardo Leitner
    Cc: Matthew Wilcox
    Cc: Neil Horman
    Cc: Pravin B Shelar
    Cc: Shaohua Li
    Cc: Vlad Yasevich
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kent Overstreet
     

08 Mar, 2019

2 commits

  • Pull audit updates from Paul Moore:
    "A lucky 13 audit patches for v5.1.

    Despite the rather large diffstat, most of the changes are from two
    bug fix patches that move code from one Kconfig option to another.

    Beyond that bit of churn, the remaining changes are largely cleanups
    and bug-fixes as we slowly march towards container auditing. It isn't
    all boring though, we do have a couple of new things: file
    capabilities v3 support, and expanded support for filtering on
    filesystems to solve problems with remote filesystems.

    All changes pass the audit-testsuite. Please merge for v5.1"

    * tag 'audit-pr-20190305' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit:
    audit: mark expected switch fall-through
    audit: hide auditsc_get_stamp and audit_serial prototypes
    audit: join tty records to their syscall
    audit: remove audit_context when CONFIG_ AUDIT and not AUDITSYSCALL
    audit: remove unused actx param from audit_rule_match
    audit: ignore fcaps on umount
    audit: clean up AUDITSYSCALL prototypes and stubs
    audit: more filter PATH records keyed on filesystem magic
    audit: add support for fcaps v3
    audit: move loginuid and sessionid from CONFIG_AUDITSYSCALL to CONFIG_AUDIT
    audit: add syscall information to CONFIG_CHANGE records
    audit: hand taken context to audit_kill_trees for syscall logging
    audit: give a clue what CONFIG_CHANGE op was involved

    Linus Torvalds
     
  • Pull SELinux updates from Paul Moore:
    "Nine SELinux patches for v5.1, all bug fixes.

    As far as I'm concerned, nothing really jumps out as risky or special
    to me, but each commit has a decent description so you can judge for
    yourself. As usual, everything passes the selinux-testsuite; please
    merge for v5.1"

    * tag 'selinux-pr-20190305' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
    selinux: fix avc audit messages
    selinux: replace BUG_ONs with WARN_ONs in avc.c
    selinux: log invalid contexts in AVCs
    selinux: replace some BUG_ON()s with a WARN_ON()
    selinux: inline some AVC functions used only once
    selinux: do not override context on context mounts
    selinux: never allow relabeling on context mounts
    selinux: stop passing MAY_NOT_BLOCK to the AVC upon follow_link
    selinux: avoid silent denials in permissive mode under RCU walk

    Linus Torvalds
     

01 Feb, 2019

1 commit

  • The audit_rule_match() struct audit_context *actx parameter is not used
    by any in-tree consumers (selinux, apparmour, integrity, smack).

    The audit context is an internal audit structure that should only be
    accessed by audit accessor functions.

    It was part of commit 03d37d25e0f9 ("LSM/Audit: Introduce generic
    Audit LSM hooks") but appears to have never been used.

    Remove it.

    Please see the github issue
    https://github.com/linux-audit/audit-kernel/issues/107

    Signed-off-by: Richard Guy Briggs
    [PM: fixed the referenced commit title]
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

26 Jan, 2019

1 commit

  • In case a file has an invalid context set, in an AVC record generated
    upon access to such file, the target context is always reported as
    unlabeled. This patch adds new optional fields to the AVC record
    (srawcon and trawcon) that report the actual context string if it
    differs from the one reported in scontext/tcontext. This is useful for
    diagnosing SELinux denials involving invalid contexts.

    To trigger an AVC that illustrates this situation:

    # setenforce 0
    # touch /tmp/testfile
    # setfattr -n security.selinux -v system_u:object_r:banana_t:s0 /tmp/testfile
    # runcon system_u:system_r:sshd_t:s0 cat /tmp/testfile

    AVC before:

    type=AVC msg=audit(1547801083.248:11): avc: denied { open } for pid=1149 comm="cat" path="/tmp/testfile" dev="tmpfs" ino=6608 scontext=system_u:system_r:sshd_t:s0 tcontext=system_u:object_r:unlabeled_t:s15:c0.c1023 tclass=file permissive=1

    AVC after:

    type=AVC msg=audit(1547801083.248:11): avc: denied { open } for pid=1149 comm="cat" path="/tmp/testfile" dev="tmpfs" ino=6608 scontext=system_u:system_r:sshd_t:s0 tcontext=system_u:object_r:unlabeled_t:s15:c0.c1023 tclass=file permissive=1 trawcon=system_u:object_r:banana_t:s0

    Note that it is also possible to encounter this situation with the
    'scontext' field - e.g. when a new policy is loaded while a process is
    running, whose context is not valid in the new policy.

    Link: https://bugzilla.redhat.com/show_bug.cgi?id=1135683

    Cc: Daniel Walsh
    Signed-off-by: Ondrej Mosnacek
    Reviewed-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Ondrej Mosnacek
     

23 Jan, 2019

1 commit


16 Jan, 2019

1 commit


11 Jan, 2019

1 commit

  • levdatum->level can be NULL if we encounter an error while loading
    the policy during sens_read prior to initializing it. Make sure
    sens_destroy handles that case correctly.

    Reported-by: syzbot+6664500f0f18f07a5c0e@syzkaller.appspotmail.com
    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley
     

09 Jan, 2019

1 commit


28 Dec, 2018

1 commit

  • Pull selinux patches from Paul Moore:
    "I already used my best holiday pull request lines in the audit pull
    request, so this one is going to be a bit more boring, sorry about
    that. To make up for this, we do have a birthday of sorts to
    celebrate: SELinux turns 18 years old this December. Perhaps not the
    most exciting thing in the world for most people, but I think it's
    safe to say that anyone reading this email doesn't exactly fall into
    the "most people" category.

    Back to business and the pull request itself:

    Ondrej has five patches in this pull request and I lump them into
    three categories: one patch to always allow submounts (using similar
    logic to elsewhere in the kernel), one to fix some issues with the
    SELinux policydb, and the others to cleanup and improve the SELinux
    sidtab.

    The other patches from Alexey and Petr and trivial fixes that are
    adequately described in their respective subject lines.

    With this last pull request of the year, I want to thank everyone who
    has contributed patches, testing, and reviews to the SELinux project
    this year, and the past 18 years. Like any good open source effort,
    SELinux is only as good as the community which supports it, and I'm
    very happy that we have the community we do - thank you all!"

    * tag 'selinux-pr-20181224' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
    selinux: overhaul sidtab to fix bug and improve performance
    selinux: use separate table for initial SID lookup
    selinux: make "selinux_policycap_names[]" const char *
    selinux: always allow mounting submounts
    selinux: refactor sidtab conversion
    Documentation: Update SELinux reference policy URL
    selinux: policydb - fix byte order and alignment issues

    Linus Torvalds
     

06 Dec, 2018

2 commits

  • Before this patch, during a policy reload the sidtab would become frozen
    and trying to map a new context to SID would be unable to add a new
    entry to sidtab and fail with -ENOMEM.

    Such failures are usually propagated into userspace, which has no way of
    distignuishing them from actual allocation failures and thus doesn't
    handle them gracefully. Such situation can be triggered e.g. by the
    following reproducer:

    while true; do load_policy; echo -n .; sleep 0.1; done &
    for (( i = 0; i < 1024; i++ )); do
    runcon -l s0:c$i echo -n x || break
    # or:
    # chcon -l s0:c$i || break
    done

    This patch overhauls the sidtab so it doesn't need to be frozen during
    policy reload, thus solving the above problem.

    The new SID table leverages the fact that SIDs are allocated
    sequentially and are never invalidated and stores them in linear buckets
    indexed by a tree structure. This brings several advantages:
    1. Fast SID -> context lookup - this lookup can now be done in
    logarithmic time complexity (usually in less than 4 array lookups)
    and can still be done safely without locking.
    2. No need to re-search the whole table on reverse lookup miss - after
    acquiring the spinlock only the newly added entries need to be
    searched, which means that reverse lookups that end up inserting a
    new entry are now about twice as fast.
    3. No need to freeze sidtab during policy reload - it is now possible
    to handle insertion of new entries even during sidtab conversion.

    The tree structure of the new sidtab is able to grow automatically to up
    to about 2^31 entries (at which point it should not have more than about
    4 tree levels). The old sidtab had a theoretical capacity of almost 2^32
    entries, but half of that is still more than enough since by that point
    the reverse table lookups would become unusably slow anyway...

    The number of entries per tree node is selected automatically so that
    each node fits into a single page, which should be the easiest size for
    kmalloc() to handle.

    Note that the cache for reverse lookup is preserved with equivalent
    logic. The only difference is that instead of storing pointers to the
    hash table nodes it stores just the indices of the cached entries.

    The new cache ensures that the indices are loaded/stored atomically, but
    it still has the drawback that concurrent cache updates may mess up the
    contents of the cache. Such situation however only reduces its
    effectivity, not the correctness of lookups.

    Tested by selinux-testsuite and thoroughly tortured by this simple
    stress test:
    ```
    function rand_cat() {
    echo $(( $RANDOM % 1024 ))
    }

    function do_work() {
    while true; do
    echo -n "system_u:system_r:kernel_t:s0:c$(rand_cat),c$(rand_cat)" \
    >/sys/fs/selinux/context 2>/dev/null || true
    done
    }

    do_work >/dev/null &
    do_work >/dev/null &
    do_work >/dev/null &

    while load_policy; do echo -n .; sleep 0.1; done

    kill %1
    kill %2
    kill %3
    ```

    Link: https://github.com/SELinuxProject/selinux-kernel/issues/38

    Reported-by: Orion Poplawski
    Reported-by: Li Kun
    Signed-off-by: Ondrej Mosnacek
    Reviewed-by: Stephen Smalley
    [PM: most of sidtab.c merged by hand due to conflicts]
    [PM: checkpatch fixes in mls.c, services.c, sidtab.c]
    Signed-off-by: Paul Moore

    Ondrej Mosnacek
     
  • This moves handling of initial SIDs into a separate table. Note that the
    SIDs stored in the main table are now shifted by SECINITSID_NUM and
    converted to/from the actual SIDs transparently by helper functions.

    This change doesn't make much sense on its own, but it simplifies
    further sidtab overhaul in a succeeding patch.

    Signed-off-by: Ondrej Mosnacek
    Reviewed-by: Stephen Smalley
    [PM: fixed some checkpatch warnings on line length, whitespace]
    Signed-off-by: Paul Moore

    Ondrej Mosnacek
     

27 Nov, 2018

1 commit


21 Nov, 2018

1 commit

  • This is a purely cosmetic change that encapsulates the three-step sidtab
    conversion logic (shutdown -> clone -> map) into a single function
    defined in sidtab.c (as opposed to services.c).

    Signed-off-by: Ondrej Mosnacek
    Acked-by: Stephen Smalley
    [PM: whitespaces fixes to make checkpatch happy]
    Signed-off-by: Paul Moore

    Ondrej Mosnacek
     

14 Nov, 2018

1 commit

  • Commit 95ffe194204a ("selinux: refactor mls_context_to_sid() and make
    it stricter") inadvertently changed how we handle labels that did not
    contain MLS information. This patch restores the proper behavior in
    mls_context_to_sid() and adds a comment explaining the proper
    behavior to help ensure this doesn't happen again.

    Fixes: 95ffe194204a ("selinux: refactor mls_context_to_sid() and make it stricter")
    Reported-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Paul Moore
     

06 Nov, 2018

1 commit

  • Do the LE conversions before doing the Infiniband-related range checks.
    The incorrect checks are otherwise causing a failure to load any policy
    with an ibendportcon rule on BE systems. This can be reproduced by
    running (on e.g. ppc64):

    cat >my_module.cil <
    Cc: Eli Cohen
    Cc: James Morris
    Cc: Doug Ledford
    Cc: # 4.13+
    Fixes: a806f7a1616f ("selinux: Create policydb version for Infiniband support")
    Signed-off-by: Ondrej Mosnacek
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Ondrej Mosnacek
     

14 Sep, 2018

1 commit

  • syzbot is hitting warning at str_read() [1] because len parameter can
    become larger than KMALLOC_MAX_SIZE. We don't need to emit warning for
    this case.

    [1] https://syzkaller.appspot.com/bug?id=7f2f5aad79ea8663c296a2eedb81978401a908f0

    Signed-off-by: Tetsuo Handa
    Reported-by: syzbot
    Signed-off-by: Paul Moore

    Tetsuo Handa
     

06 Sep, 2018

1 commit

  • The intended behavior change for this patch is to reject any MLS strings
    that contain (trailing) garbage if p->mls_enabled is true.

    As suggested by Paul Moore, change mls_context_to_sid() so that the two
    parts of the range are extracted before the rest of the parsing. Because
    now we don't have to scan for two different separators simultaneously
    everywhere, we can actually switch to strchr() everywhere instead of the
    open-coded loops that scan for two separators at once.

    mls_context_to_sid() used to signal how much of the input string was parsed
    by updating `*scontext`. However, there is actually no case in which
    mls_context_to_sid() only parses a subset of the input and still returns
    a success (other than the buggy case with a second '-' in which it
    incorrectly claims to have consumed the entire string). Turn `scontext`
    into a simple pointer argument and stop redundantly checking whether the
    entire input was consumed in string_to_context_struct(). This also lets us
    remove the `scontext_len` argument from `string_to_context_struct()`.

    Signed-off-by: Jann Horn
    [PM: minor merge fuzz in convert_context()]
    Signed-off-by: Paul Moore

    Jann Horn