21 Nov, 2016

1 commit

  • At present, one can write any signed integer value to
    /sys/fs/selinux/enforce and it will be stored,
    e.g. echo -1 > /sys/fs/selinux/enforce or echo 2 >
    /sys/fs/selinux/enforce. This makes no real difference
    to the kernel, since it only ever cares if it is zero or non-zero,
    but some userspace code compares it with 1 to decide if SELinux
    is enforcing, and this could confuse it. Only a process that is
    already root and is allowed the setenforce permission in SELinux
    policy can write to /sys/fs/selinux/enforce, so this is not considered
    to be a security issue, but it should be fixed.

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

    Stephen Smalley
     

15 Nov, 2016

1 commit

  • Fix the comment for function __inode_security_revalidate, which returns
    an integer.

    Use the LABEL_* constants consistently for isec->initialized.

    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Paul Moore

    Andreas Gruenbacher
     

28 Sep, 2016

1 commit

  • CURRENT_TIME macro is not appropriate for filesystems as it
    doesn't use the right granularity for filesystem timestamps.
    Use current_time() instead.

    CURRENT_TIME is also not y2038 safe.

    This is also in preparation for the patch that transitions
    vfs timestamps to use 64 bit time and hence make them
    y2038 safe. As part of the effort current_time() will be
    extended to do range checks. Hence, it is necessary for all
    file system timestamps to use current_time(). Also,
    current_time() will be transitioned along with vfs to be
    y2038 safe.

    Note that whenever a single call to current_time() is used
    to change timestamps in different inodes, it is because they
    share the same time granularity.

    Signed-off-by: Deepa Dinamani
    Reviewed-by: Arnd Bergmann
    Acked-by: Felipe Balbi
    Acked-by: Steven Whitehouse
    Acked-by: Ryusuke Konishi
    Acked-by: David Sterba
    Signed-off-by: Al Viro

    Deepa Dinamani
     

16 Jun, 2016

1 commit

  • avc_cache_threshold is of type unsigned int. Do not use a signed
    new_value in sscanf(page, "%u", &new_value).

    Signed-off-by: Heinrich Schuchardt
    [PM: subject prefix fix, description cleanup]
    Signed-off-by: Paul Moore

    Heinrich Schuchardt
     

23 Jan, 2016

1 commit

  • parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested},
    inode_foo(inode) being mutex_foo(&inode->i_mutex).

    Please, use those for access to ->i_mutex; over the coming cycle
    ->i_mutex will become rwsem, with ->lookup() done with it held
    only shared.

    Signed-off-by: Al Viro

    Al Viro
     

18 Jan, 2016

1 commit

  • Pull security subsystem updates from James Morris:

    - EVM gains support for loading an x509 cert from the kernel
    (EVM_LOAD_X509), into the EVM trusted kernel keyring.

    - Smack implements 'file receive' process-based permission checking for
    sockets, rather than just depending on inode checks.

    - Misc enhancments for TPM & TPM2.

    - Cleanups and bugfixes for SELinux, Keys, and IMA.

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (41 commits)
    selinux: Inode label revalidation performance fix
    KEYS: refcount bug fix
    ima: ima_write_policy() limit locking
    IMA: policy can be updated zero times
    selinux: rate-limit netlink message warnings in selinux_nlmsg_perm()
    selinux: export validatetrans decisions
    gfs2: Invalid security labels of inodes when they go invalid
    selinux: Revalidate invalid inode security labels
    security: Add hook to invalidate inode security labels
    selinux: Add accessor functions for inode->i_security
    security: Make inode argument of inode_getsecid non-const
    security: Make inode argument of inode_getsecurity non-const
    selinux: Remove unused variable in selinux_inode_init_security
    keys, trusted: seal with a TPM2 authorization policy
    keys, trusted: select hash algorithm for TPM2 chips
    keys, trusted: fix: *do not* allow duplicate key options
    tpm_ibmvtpm: properly handle interrupted packet receptions
    tpm_tis: Tighten IRQ auto-probing
    tpm_tis: Refactor the interrupt setup
    tpm_tis: Get rid of the duplicate IRQ probing code
    ...

    Linus Torvalds
     

04 Jan, 2016

1 commit

  • Nothing in there gives a damn about the buffer alignment - it
    just parses its contents. So the use of get_zeroed_page()
    doesn't buy us anything - might as well had been kmalloc(),
    which makes that code equivalent to open-coded memdup_user_nul()

    Signed-off-by: Al Viro

    Al Viro
     

25 Dec, 2015

1 commit

  • Make validatetrans decisions available through selinuxfs.
    "/validatetrans" is added to selinuxfs for this purpose.
    This functionality is needed by file system servers
    implemented in userspace or kernelspace without the VFS
    layer.

    Writing "$oldcontext $newcontext $tclass $taskcontext"
    to /validatetrans is expected to return 0 if the transition
    is allowed and -EPERM otherwise.

    Signed-off-by: Andrew Perepechko
    CC: andrew.perepechko@seagate.com
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Andrew Perepechko
     

22 Oct, 2015

1 commit

  • There seems to be a little confusion as to whether the scontext_len
    parameter of security_context_to_sid() includes the nul-byte or
    not. Reading security_context_to_sid_core(), it seems that the
    expectation is that it does not (both the string copying and the test
    for scontext_len being zero hint at that).

    Introduce the helper security_context_str_to_sid() to do the strlen()
    call and fix all callers.

    Signed-off-by: Rasmus Villemoes
    Acked-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Rasmus Villemoes
     

11 Sep, 2015

1 commit

  • With two exceptions (drm/qxl and drm/radeon) all vm_operations_struct
    structs should be constant.

    Signed-off-by: Kirill A. Shutemov
    Reviewed-by: Oleg Nesterov
    Cc: "H. Peter Anvin"
    Cc: Andy Lutomirski
    Cc: Dave Hansen
    Cc: Ingo Molnar
    Cc: Minchan Kim
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kirill A. Shutemov
     

01 Jul, 2015

1 commit

  • This allows for better documentation in the code and
    it allows for a simpler and fully correct version of
    fs_fully_visible to be written.

    The mount points converted and their filesystems are:
    /sys/hypervisor/s390/ s390_hypfs
    /sys/kernel/config/ configfs
    /sys/kernel/debug/ debugfs
    /sys/firmware/efi/efivars/ efivarfs
    /sys/fs/fuse/connections/ fusectl
    /sys/fs/pstore/ pstore
    /sys/kernel/tracing/ tracefs
    /sys/fs/cgroup/ cgroup
    /sys/kernel/security/ securityfs
    /sys/fs/selinux/ selinuxfs
    /sys/fs/smackfs/ smackfs

    Cc: stable@vger.kernel.org
    Acked-by: Greg Kroah-Hartman
    Signed-off-by: "Eric W. Biederman"

    Eric W. Biederman
     

16 Apr, 2015

1 commit


27 Mar, 2015

1 commit


26 Mar, 2015

1 commit


26 Jan, 2015

1 commit


04 Nov, 2014

1 commit


04 Apr, 2014

1 commit

  • Pull security subsystem updates from James Morris:
    "Apart from reordering the SELinux mmap code to ensure DAC is called
    before MAC, these are minor maintenance updates"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (23 commits)
    selinux: correctly label /proc inodes in use before the policy is loaded
    selinux: put the mmap() DAC controls before the MAC controls
    selinux: fix the output of ./scripts/get_maintainer.pl for SELinux
    evm: enable key retention service automatically
    ima: skip memory allocation for empty files
    evm: EVM does not use MD5
    ima: return d_name.name if d_path fails
    integrity: fix checkpatch errors
    ima: fix erroneous removal of security.ima xattr
    security: integrity: Use a more current logging style
    MAINTAINERS: email updates and other misc. changes
    ima: reduce memory usage when a template containing the n field is used
    ima: restore the original behavior for sending data with ima template
    Integrity: Pass commname via get_task_comm()
    fs: move i_readcount
    ima: use static const char array definitions
    security: have cap_dentry_init_security return error
    ima: new helper: file_inode(file)
    kernel: Mark function as static in kernel/seccomp.c
    capability: Use current logging styles
    ...

    Linus Torvalds
     

10 Mar, 2014

1 commit

  • security_xfrm_policy_alloc can be called in atomic context so the
    allocation should be done with GFP_ATOMIC. Add an argument to let the
    callers choose the appropriate way. In order to do so a gfp argument
    needs to be added to the method xfrm_policy_alloc_security in struct
    security_operations and to the internal function
    selinux_xfrm_alloc_user. After that switch to GFP_ATOMIC in the atomic
    callers and leave GFP_KERNEL as before for the rest.
    The path that needed the gfp argument addition is:
    security_xfrm_policy_alloc -> security_ops.xfrm_policy_alloc_security ->
    all users of xfrm_policy_alloc_security (e.g. selinux_xfrm_policy_alloc) ->
    selinux_xfrm_alloc_user (here the allocation used to be GFP_KERNEL only)

    Now adding a gfp argument to selinux_xfrm_alloc_user requires us to also
    add it to security_context_to_sid which is used inside and prior to this
    patch did only GFP_KERNEL allocation. So add gfp argument to
    security_context_to_sid and adjust all of its callers as well.

    CC: Paul Moore
    CC: Dave Jones
    CC: Steffen Klassert
    CC: Fan Du
    CC: David S. Miller
    CC: LSM list
    CC: SELinux list

    Signed-off-by: Nikolay Aleksandrov
    Acked-by: Paul Moore
    Signed-off-by: Steffen Klassert

    Nikolay Aleksandrov
     

06 Feb, 2014

1 commit


26 Jul, 2013

1 commit

  • Currently the packet class in SELinux is not checked if there are no
    SECMARK rules in the security or mangle netfilter tables. Some systems
    prefer that packets are always checked, for example, to protect the system
    should the netfilter rules fail to load or if the nefilter rules
    were maliciously flushed.

    Add the always_check_network policy capability which, when enabled, treats
    SECMARK as enabled, even if there are no netfilter SECMARK rules and
    treats peer labeling as enabled, even if there is no Netlabel or
    labeled IPSEC configuration.

    Includes definition of "redhat1" SELinux policy capability, which
    exists in the SELinux userpace library, to keep ordering correct.

    The SELinux userpace portion of this was merged last year, but this kernel
    change fell on the floor.

    Signed-off-by: Chris PeBenito
    Signed-off-by: Eric Paris

    Chris PeBenito
     

23 Feb, 2013

1 commit


09 Oct, 2012

1 commit

  • A long time ago, in v2.4, VM_RESERVED kept swapout process off VMA,
    currently it lost original meaning but still has some effects:

    | effect | alternative flags
    -+------------------------+---------------------------------------------
    1| account as reserved_vm | VM_IO
    2| skip in core dump | VM_IO, VM_DONTDUMP
    3| do not merge or expand | VM_IO, VM_DONTEXPAND, VM_HUGETLB, VM_PFNMAP
    4| do not mlock | VM_IO, VM_DONTEXPAND, VM_HUGETLB, VM_PFNMAP

    This patch removes reserved_vm counter from mm_struct. Seems like nobody
    cares about it, it does not exported into userspace directly, it only
    reduces total_vm showed in proc.

    Thus VM_RESERVED can be replaced with VM_IO or pair VM_DONTEXPAND | VM_DONTDUMP.

    remap_pfn_range() and io_remap_pfn_range() set VM_IO|VM_DONTEXPAND|VM_DONTDUMP.
    remap_vmalloc_range() set VM_DONTEXPAND | VM_DONTDUMP.

    [akpm@linux-foundation.org: drivers/vfio/pci/vfio_pci.c fixup]
    Signed-off-by: Konstantin Khlebnikov
    Cc: Alexander Viro
    Cc: Carsten Otte
    Cc: Chris Metcalf
    Cc: Cyrill Gorcunov
    Cc: Eric Paris
    Cc: H. Peter Anvin
    Cc: Hugh Dickins
    Cc: Ingo Molnar
    Cc: James Morris
    Cc: Jason Baron
    Cc: Kentaro Takeda
    Cc: Matt Helsley
    Cc: Nick Piggin
    Cc: Oleg Nesterov
    Cc: Peter Zijlstra
    Cc: Robert Richter
    Cc: Suresh Siddha
    Cc: Tetsuo Handa
    Cc: Venkatesh Pallipadi
    Acked-by: Linus Torvalds
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Konstantin Khlebnikov
     

21 Sep, 2012

1 commit


23 Jul, 2012

1 commit


30 May, 2012

1 commit


10 Apr, 2012

4 commits

  • We reset the bool names and values array to NULL, but do not reset the
    number of entries in these arrays to 0. If we error out and then get back
    into this function we will walk these NULL pointers based on the belief
    that they are non-zero length.

    Signed-off-by: Eric Paris
    cc: stable@kernel.org

    Eric Paris
     
  • I'm not really sure what the idea behind the sel_div function is, but it's
    useless. Since a and b are both unsigned, it's impossible for a % b < 0.
    That means that part of the function never does anything. Thus it's just a
    normal /. Just do that instead. I don't even understand what that operation
    was supposed to mean in the signed case however....

    If it was signed:
    sel_div(-2, 4) == ((-2 / 4) - ((-2 % 4) < 0))
    ((0) - ((-2) < 0))
    ((0) - (1))
    (-1)

    What actually happens:
    sel_div(-2, 4) == ((18446744073709551614 / 4) - ((18446744073709551614 % 4) < 0))
    ((4611686018427387903) - ((2 < 0))
    (4611686018427387903 - 0)
    ((unsigned int)4611686018427387903)
    (4294967295)

    Neither makes a whole ton of sense to me. So I'm getting rid of the
    function entirely.

    Signed-off-by: Eric Paris

    Eric Paris
     
  • There is no reason the DAC perms on reading the policy file need to be root
    only. There are selinux checks which should control this access.

    Signed-off-by: Eric Paris

    Eric Paris
     
  • sesearch uses:
    lseek(3, 0, SEEK_SET) = -1 ESPIPE (Illegal seek)

    Make that work.

    Signed-off-by: Eric Paris

    Eric Paris
     

01 Apr, 2012

1 commit


16 Nov, 2011

1 commit


10 Sep, 2011

3 commits


02 Aug, 2011

1 commit


24 Jul, 2011

1 commit

  • For a number of file systems that don't have a mount point (e.g. sockfs
    and pipefs), they are not marked as long term. Therefore in
    mntput_no_expire, all locks in vfs_mount lock are taken instead of just
    local cpu's lock to aggregate reference counts when we release
    reference to file objects. In fact, only local lock need to have been
    taken to update ref counts as these file systems are in no danger of
    going away until we are ready to unregister them.

    The attached patch marks file systems using kern_mount without
    mount point as long term. The contentions of vfs_mount lock
    is now eliminated. Before un-registering such file system,
    kern_unmount should be called to remove the long term flag and
    make the mount point ready to be freed.

    Signed-off-by: Tim Chen
    Signed-off-by: Al Viro

    Tim Chen
     

15 Jun, 2011

1 commit


27 May, 2011

1 commit

  • I submit the patch again, according to patch submission convension.

    This patch enables to accept percent-encoded object names as forth
    argument of /selinux/create interface to avoid possible bugs when we
    give an object name including whitespace or multibutes.

    E.g) if and when a userspace object manager tries to create a new object
    named as "resolve.conf but fake", it shall give this name as the forth
    argument of the /selinux/create. But sscanf() logic in kernel space
    fetches only the part earlier than the first whitespace.
    In this case, selinux may unexpectedly answer a default security context
    configured to "resolve.conf", but it is bug.

    Although I could not test this patch on named TYPE_TRANSITION rules
    actually, But debug printk() message seems to me the logic works
    correctly.
    I assume the libselinux provides an interface to apply this logic
    transparently, so nothing shall not be changed from the viewpoint of
    application.

    Signed-off-by: KaiGai Kohei
    Signed-off-by: Eric Paris

    Kohei Kaigai
     

24 May, 2011

2 commits

  • Conflicts:
    lib/flex_array.c
    security/selinux/avc.c
    security/selinux/hooks.c
    security/selinux/ss/policydb.c
    security/smack/smack_lsm.c

    Manually resolve conflicts.

    Signed-off-by: James Morris

    James Morris
     
  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (39 commits)
    b43: fix comment typo reqest -> request
    Haavard Skinnemoen has left Atmel
    cris: typo in mach-fs Makefile
    Kconfig: fix copy/paste-ism for dell-wmi-aio driver
    doc: timers-howto: fix a typo ("unsgined")
    perf: Only include annotate.h once in tools/perf/util/ui/browsers/annotate.c
    md, raid5: Fix spelling error in comment ('Ofcourse' --> 'Of course').
    treewide: fix a few typos in comments
    regulator: change debug statement be consistent with the style of the rest
    Revert "arm: mach-u300/gpio: Fix mem_region resource size miscalculations"
    audit: acquire creds selectively to reduce atomic op overhead
    rtlwifi: don't touch with treewide double semicolon removal
    treewide: cleanup continuations and remove logging message whitespace
    ath9k_hw: don't touch with treewide double semicolon removal
    include/linux/leds-regulator.h: fix syntax in example code
    tty: fix typo in descripton of tty_termios_encode_baud_rate
    xtensa: remove obsolete BKL kernel option from defconfig
    m68k: fix comment typo 'occcured'
    arch:Kconfig.locks Remove unused config option.
    treewide: remove extra semicolons
    ...

    Linus Torvalds