01 Apr, 2014

2 commits


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
     

22 Oct, 2013

1 commit


19 Sep, 2013

1 commit

  • Conflicts:
    security/selinux/hooks.c

    Pull Eric's existing SELinux tree as there are a number of patches in
    there that are not yet upstream. There was some minor fixup needed to
    resolve a conflict in security/selinux/hooks.c:selinux_set_mnt_opts()
    between the labeled NFS patches and Eric's security_fs_use()
    simplification patch.

    Paul Moore
     

26 Jul, 2013

1 commit

  • The xfrm_state_alloc_security() LSM hook implementation is really a
    multiplexed hook with two different behaviors depending on the
    arguments passed to it by the caller. This patch splits the LSM hook
    implementation into two new hook implementations, which match the
    LSM hooks in the rest of the kernel:

    * xfrm_state_alloc
    * xfrm_state_alloc_acquire

    Also included in this patch are the necessary changes to the SELinux
    code; no other LSMs are affected.

    Signed-off-by: Paul Moore
    Signed-off-by: Eric Paris

    Paul Moore
     

25 Jul, 2013

1 commit

  • Since everybody sets kstrdup()ed constant string to "struct xattr"->name but
    nobody modifies "struct xattr"->name , we can omit kstrdup() and its failure
    checking by constifying ->name member of "struct xattr".

    Signed-off-by: Tetsuo Handa
    Reviewed-by: Joel Becker [ocfs2]
    Acked-by: Serge E. Hallyn
    Acked-by: Casey Schaufler
    Acked-by: Mimi Zohar
    Reviewed-by: Paul Moore
    Tested-by: Paul Moore
    Acked-by: Eric Paris
    Signed-off-by: James Morris

    Tetsuo Handa
     

09 Jun, 2013

4 commits

  • The existing NFSv4 xattr handlers do not accept xattr calls to the security
    namespace. This patch extends these handlers to accept xattrs from the security
    namespace in addition to the default NFSv4 ACL namespace.

    Acked-by: James Morris
    Signed-off-by: Matthew N. Dodd
    Signed-off-by: Miguel Rodel Felipe
    Signed-off-by: Phua Eu Gene
    Signed-off-by: Khin Mi Mi Aung
    Signed-off-by: Trond Myklebust

    David Quigley
     
  • There is no way to differentiate if a text mount option is passed from user
    space or the kernel. A flags field is being added to the
    security_sb_set_mnt_opts hook to allow for in kernel security flags to be sent
    to the LSM for processing in addition to the text options received from mount.
    This patch also updated existing code to fix compilation errors.

    Acked-by: Eric Paris
    Acked-by: James Morris
    Signed-off-by: David P. Quigley
    Signed-off-by: Miguel Rodel Felipe
    Signed-off-by: Phua Eu Gene
    Signed-off-by: Khin Mi Mi Aung
    Signed-off-by: Trond Myklebust

    David Quigley
     
  • The interface to request security labels from user space is the xattr
    interface. When requesting the security label from an NFS server it is
    important to make sure the requested xattr actually is a MAC label. This allows
    us to make sure that we get the desired semantics from the attribute instead of
    something else such as capabilities or a time based LSM.

    Acked-by: Eric Paris
    Acked-by: James Morris
    Signed-off-by: Matthew N. Dodd
    Signed-off-by: Miguel Rodel Felipe
    Signed-off-by: Phua Eu Gene
    Signed-off-by: Khin Mi Mi Aung
    Signed-off-by: Trond Myklebust

    David Quigley
     
  • There is a time where we need to calculate a context without the
    inode having been created yet. To do this we take the negative dentry and
    calculate a context based on the process and the parent directory contexts.

    Acked-by: Eric Paris
    Acked-by: James Morris
    Signed-off-by: Matthew N. Dodd
    Signed-off-by: Miguel Rodel Felipe
    Signed-off-by: Phua Eu Gene
    Signed-off-by: Khin Mi Mi Aung
    Signed-off-by: Steve Dickson
    Signed-off-by: Trond Myklebust

    David Quigley
     

01 May, 2013

1 commit

  • Pull security subsystem update from James Morris:
    "Just some minor updates across the subsystem"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
    ima: eliminate passing d_name.name to process_measurement()
    TPM: Retry SaveState command in suspend path
    tpm/tpm_i2c_infineon: Add small comment about return value of __i2c_transfer
    tpm/tpm_i2c_infineon.c: Add OF attributes type and name to the of_device_id table entries
    tpm_i2c_stm_st33: Remove duplicate inclusion of header files
    tpm: Add support for new Infineon I2C TPM (SLB 9645 TT 1.2 I2C)
    char/tpm: Convert struct i2c_msg initialization to C99 format
    drivers/char/tpm/tpm_ppi: use strlcpy instead of strncpy
    tpm/tpm_i2c_stm_st33: formatting and white space changes
    Smack: include magic.h in smackfs.c
    selinux: make security_sb_clone_mnt_opts return an error on context mismatch
    seccomp: allow BPF_XOR based ALU instructions.
    Fix NULL pointer dereference in smack_inode_unlink() and smack_inode_rmdir()
    Smack: add support for modification of existing rules
    smack: SMACK_MAGIC to include/uapi/linux/magic.h
    Smack: add missing support for transmute bit in smack_str_from_perm()
    Smack: prevent revoke-subject from failing when unseen label is written to it
    tomoyo: use DEFINE_SRCU() to define tomoyo_ss
    tomoyo: use DEFINE_SRCU() to define tomoyo_ss

    Linus Torvalds
     

10 Apr, 2013

1 commit

  • Commit 90ba9b1986b5ac (tcp: tcp_make_synack() can use alloc_skb())
    broke certain SELinux/NetLabel configurations by no longer correctly
    assigning the sock to the outgoing SYNACK packet.

    Cost of atomic operations on the LISTEN socket is quite big,
    and we would like it to happen only if really needed.

    This patch introduces a new security_ops->skb_owned_by() method,
    that is a void operation unless selinux is active.

    Reported-by: Miroslav Vadkerti
    Diagnosed-by: Paul Moore
    Signed-off-by: Eric Dumazet
    Cc: "David S. Miller"
    Cc: linux-security-module@vger.kernel.org
    Acked-by: James Morris
    Tested-by: Paul Moore
    Acked-by: Paul Moore
    Signed-off-by: David S. Miller

    Eric Dumazet
     

02 Apr, 2013

1 commit

  • I had the following problem reported a while back. If you mount the
    same filesystem twice using NFSv4 with different contexts, then the
    second context= option is ignored. For instance:

    # mount server:/export /mnt/test1
    # mount server:/export /mnt/test2 -o context=system_u:object_r:tmp_t:s0
    # ls -dZ /mnt/test1
    drwxrwxrwt. root root system_u:object_r:nfs_t:s0 /mnt/test1
    # ls -dZ /mnt/test2
    drwxrwxrwt. root root system_u:object_r:nfs_t:s0 /mnt/test2

    When we call into SELinux to set the context of a "cloned" superblock,
    it will currently just bail out when it notices that we're reusing an
    existing superblock. Since the existing superblock is already set up and
    presumably in use, we can't go overwriting its context with the one from
    the "original" sb. Because of this, the second context= option in this
    case cannot take effect.

    This patch fixes this by turning security_sb_clone_mnt_opts into an int
    return operation. When it finds that the "new" superblock that it has
    been handed is already set up, it checks to see whether the contexts on
    the old superblock match it. If it does, then it will just return
    success, otherwise it'll return -EBUSY and emit a printk to tell the
    admin why the second mount failed.

    Note that this patch may cause casualties. The NFSv4 code relies on
    being able to walk down to an export from the pseudoroot. If you mount
    filesystems that are nested within one another with different contexts,
    then this patch will make those mounts fail in new and "exciting" ways.

    For instance, suppose that /export is a separate filesystem on the
    server:

    # mount server:/ /mnt/test1
    # mount salusa:/export /mnt/test2 -o context=system_u:object_r:tmp_t:s0
    mount.nfs: an incorrect mount option was specified

    ...with the printk in the ring buffer. Because we *might* eventually
    walk down to /mnt/test1/export, the mount is denied due to this patch.
    The second mount needs the pseudoroot superblock, but that's already
    present with the wrong context.

    OTOH, if we mount these in the reverse order, then both mounts work,
    because the pseudoroot superblock created when mounting /export is
    discarded once that mount is done. If we then however try to walk into
    that directory, the automount fails for the similar reasons:

    # cd /mnt/test1/scratch/
    -bash: cd: /mnt/test1/scratch: Device or resource busy

    The story I've gotten from the SELinux folks that I've talked to is that
    this is desirable behavior. In SELinux-land, mounting the same data
    under different contexts is wrong -- there can be only one.

    Cc: Steve Dickson
    Cc: Stephen Smalley
    Signed-off-by: Jeff Layton
    Acked-by: Eric Paris
    Signed-off-by: James Morris

    Jeff Layton
     

15 Jan, 2013

1 commit

  • This patch corrects some problems with LSM/SELinux that were introduced
    with the multiqueue patchset. The problem stems from the fact that the
    multiqueue work changed the relationship between the tun device and its
    associated socket; before the socket persisted for the life of the
    device, however after the multiqueue changes the socket only persisted
    for the life of the userspace connection (fd open). For non-persistent
    devices this is not an issue, but for persistent devices this can cause
    the tun device to lose its SELinux label.

    We correct this problem by adding an opaque LSM security blob to the
    tun device struct which allows us to have the LSM security state, e.g.
    SELinux labeling information, persist for the lifetime of the tun
    device. In the process we tweak the LSM hooks to work with this new
    approach to TUN device/socket labeling and introduce a new LSM hook,
    security_tun_dev_attach_queue(), to approve requests to attach to a
    TUN queue via TUNSETQUEUE.

    The SELinux code has been adjusted to match the new LSM hooks, the
    other LSMs do not make use of the LSM TUN controls. This patch makes
    use of the recently added "tun_socket:attach_queue" permission to
    restrict access to the TUNSETQUEUE operation. On older SELinux
    policies which do not define the "tun_socket:attach_queue" permission
    the access control decision for TUNSETQUEUE will be handled according
    to the SELinux policy's unknown permission setting.

    Signed-off-by: Paul Moore
    Acked-by: Eric Paris
    Tested-by: Jason Wang
    Signed-off-by: David S. Miller

    Paul Moore
     

14 Dec, 2012

2 commits

  • With the addition of the new kernel module syscall, which defines two
    arguments - a file descriptor to the kernel module and a pointer to a NULL
    terminated string of module arguments - it is now possible to measure and
    appraise kernel modules like any other file on the file system.

    This patch adds support to measure and appraise kernel modules in an
    extensible and consistent manner.

    To support filesystems without extended attribute support, additional
    patches could pass the signature as the first parameter.

    Signed-off-by: Mimi Zohar
    Signed-off-by: Rusty Russell

    Mimi Zohar
     
  • Now that kernel module origins can be reasoned about, provide a hook to
    the LSMs to make policy decisions about the module file. This will let
    Chrome OS enforce that loadable kernel modules can only come from its
    read-only hash-verified root filesystem. Other LSMs can, for example,
    read extended attributes for signatures, etc.

    Signed-off-by: Kees Cook
    Acked-by: Serge E. Hallyn
    Acked-by: Eric Paris
    Acked-by: Mimi Zohar
    Acked-by: James Morris
    Signed-off-by: Rusty Russell

    Kees Cook
     

12 Oct, 2012

1 commit


03 Oct, 2012

1 commit

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

    - Integrity: add local fs integrity verification to detect offline
    attacks
    - Integrity: add digital signature verification
    - Simple stacking of Yama with other LSMs (per LSS discussions)
    - IBM vTPM support on ppc64
    - Add new driver for Infineon I2C TIS TPM
    - Smack: add rule revocation for subject labels"

    Fixed conflicts with the user namespace support in kernel/auditsc.c and
    security/integrity/ima/ima_policy.c.

    * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (39 commits)
    Documentation: Update git repository URL for Smack userland tools
    ima: change flags container data type
    Smack: setprocattr memory leak fix
    Smack: implement revoking all rules for a subject label
    Smack: remove task_wait() hook.
    ima: audit log hashes
    ima: generic IMA action flag handling
    ima: rename ima_must_appraise_or_measure
    audit: export audit_log_task_info
    tpm: fix tpm_acpi sparse warning on different address spaces
    samples/seccomp: fix 31 bit build on s390
    ima: digital signature verification support
    ima: add support for different security.ima data types
    ima: add ima_inode_setxattr/removexattr function and calls
    ima: add inode_post_setattr call
    ima: replace iint spinblock with rwlock/read_lock
    ima: allocating iint improvements
    ima: add appraise action keywords and default rules
    ima: integrity appraisal extension
    vfs: move ima_file_free before releasing the file
    ...

    Linus Torvalds
     

21 Sep, 2012

1 commit


08 Sep, 2012

1 commit

  • Based on xattr_permission comments, the restriction to modify 'security'
    xattr is left up to the underlying fs or lsm. Ensure that not just anyone
    can modify or remove 'security.ima'.

    Changelog v1:
    - Unless IMA-APPRAISE is configured, use stub ima_inode_removexattr()/setxattr()
    functions. (Moved ima_inode_removexattr()/setxattr() to ima_appraise.c)

    Changelog:
    - take i_mutex to fix locking (Dmitry Kasatkin)
    - ima_reset_appraise_flags should only be called when modifying or
    removing the 'security.ima' xattr. Requires CAP_SYS_ADMIN privilege.
    (Incorporated fix from Roberto Sassu)
    - Even if allowed to update security.ima, reset the appraisal flags,
    forcing re-appraisal.
    - Replace CAP_MAC_ADMIN with CAP_SYS_ADMIN
    - static inline ima_inode_setxattr()/ima_inode_removexattr() stubs
    - ima_protect_xattr should be static

    Signed-off-by: Mimi Zohar
    Signed-off-by: Dmitry Kasatkin

    Mimi Zohar
     

06 Sep, 2012

1 commit

  • Unconditionally call Yama when CONFIG_SECURITY_YAMA_STACKED is selected,
    no matter what LSM module is primary.

    Ubuntu and Chrome OS already carry patches to do this, and Fedora
    has voiced interest in doing this as well. Instead of having multiple
    distributions (or LSM authors) carrying these patches, just allow Yama
    to be called unconditionally when selected by the new CONFIG.

    Signed-off-by: Kees Cook
    Acked-by: Serge E. Hallyn
    Acked-by: Eric Paris
    Acked-by: John Johansen
    Signed-off-by: James Morris

    Kees Cook
     

03 Jul, 2012

1 commit

  • The security + nommu configuration presently blows up with an undefined
    reference to BDI_CAP_EXEC_MAP:

    security/security.c: In function 'mmap_prot':
    security/security.c:687:36: error: dereferencing pointer to incomplete type
    security/security.c:688:16: error: 'BDI_CAP_EXEC_MAP' undeclared (first use in this function)
    security/security.c:688:16: note: each undeclared identifier is reported only once for each function it appears in

    include backing-dev.h directly to fix it up.

    Signed-off-by: Paul Mundt
    Signed-off-by: James Morris

    Paul Mundt
     

02 Jul, 2012

1 commit

  • The security + nommu configuration presently blows up with an undefined
    reference to BDI_CAP_EXEC_MAP:

    security/security.c: In function 'mmap_prot':
    security/security.c:687:36: error: dereferencing pointer to incomplete type
    security/security.c:688:16: error: 'BDI_CAP_EXEC_MAP' undeclared (first use in this function)
    security/security.c:688:16: note: each undeclared identifier is reported only once for each function it appears in

    include backing-dev.h directly to fix it up.

    Signed-off-by: Paul Mundt
    Signed-off-by: James Morris

    Paul Mundt
     

01 Jun, 2012

3 commits


10 Apr, 2012

1 commit


14 Feb, 2012

2 commits


10 Feb, 2012

1 commit

  • The current LSM interface to cred_free is not sufficient for allowing
    an LSM to track the life and death of a task. This patch adds the
    task_free hook so that an LSM can clean up resources on task death.

    Signed-off-by: Kees Cook
    Signed-off-by: James Morris

    Kees Cook
     

15 Jan, 2012

1 commit

  • * 'for-linus' of git://selinuxproject.org/~jmorris/linux-security:
    capabilities: remove __cap_full_set definition
    security: remove the security_netlink_recv hook as it is equivalent to capable()
    ptrace: do not audit capability check when outputing /proc/pid/stat
    capabilities: remove task_ns_* functions
    capabitlies: ns_capable can use the cap helpers rather than lsm call
    capabilities: style only - move capable below ns_capable
    capabilites: introduce new has_ns_capabilities_noaudit
    capabilities: call has_ns_capability from has_capability
    capabilities: remove all _real_ interfaces
    capabilities: introduce security_capable_noaudit
    capabilities: reverse arguments to security_capable
    capabilities: remove the task from capable LSM hook entirely
    selinux: sparse fix: fix several warnings in the security server cod
    selinux: sparse fix: fix warnings in netlink code
    selinux: sparse fix: eliminate warnings for selinuxfs
    selinux: sparse fix: declare selinux_disable() in security.h
    selinux: sparse fix: move selinux_complete_init
    selinux: sparse fix: make selinux_secmark_refcount static
    SELinux: Fix RCU deref check warning in sel_netport_insert()

    Manually fix up a semantic mis-merge wrt security_netlink_recv():

    - the interface was removed in commit fd7784615248 ("security: remove
    the security_netlink_recv hook as it is equivalent to capable()")

    - a new user of it appeared in commit a38f7907b926 ("crypto: Add
    userspace configuration API")

    causing no automatic merge conflict, but Eric Paris pointed out the
    issue.

    Linus Torvalds
     

07 Jan, 2012

1 commit


06 Jan, 2012

5 commits

  • Once upon a time netlink was not sync and we had to get the effective
    capabilities from the skb that was being received. Today we instead get
    the capabilities from the current task. This has rendered the entire
    purpose of the hook moot as it is now functionally equivalent to the
    capable() call.

    Signed-off-by: Eric Paris

    Eric Paris
     
  • The name security_real_capable and security_real_capable_noaudit just don't
    make much sense to me. Convert them to use security_capable and
    security_capable_noaudit.

    Signed-off-by: Eric Paris
    Acked-by: Serge E. Hallyn

    Eric Paris
     
  • Exactly like security_capable except don't audit any denials. This is for
    places where the kernel may make decisions about what to do if a task has a
    given capability, but which failing that capability is not a sign of a
    security policy violation. An example is checking if a task has
    CAP_SYS_ADMIN to lower it's likelyhood of being killed by the oom killer.
    This check is not a security violation if it is denied.

    Signed-off-by: Eric Paris
    Acked-by: Serge E. Hallyn

    Eric Paris
     
  • security_capable takes ns, cred, cap. But the LSM capable() hook takes
    cred, ns, cap. The capability helper functions also take cred, ns, cap.
    Rather than flip argument order just to flip it back, leave them alone.
    Heck, this should be a little faster since argument will be in the right
    place!

    Signed-off-by: Eric Paris

    Eric Paris
     
  • The capabilities framework is based around credentials, not necessarily the
    current task. Yet we still passed the current task down into LSMs from the
    security_capable() LSM hook as if it was a meaningful portion of the security
    decision. This patch removes the 'generic' passing of current and instead
    forces individual LSMs to use current explicitly if they think it is
    appropriate. In our case those LSMs are SELinux and AppArmor.

    I believe the AppArmor use of current is incorrect, but that is wholely
    unrelated to this patch. This patch does not change what AppArmor does, it
    just makes it clear in the AppArmor code that it is doing it.

    The SELinux code still uses current in it's audit message, which may also be
    wrong and needs further investigation. Again this is NOT a change, it may
    have always been wrong, this patch just makes it clear what is happening.

    Signed-off-by: Eric Paris

    Eric Paris
     

04 Jan, 2012

2 commits