02 Aug, 2014

1 commit


01 Aug, 2014

3 commits

  • Historically the NetLabel LSM secattr catmap functions and data
    structures have had very long names which makes a mess of the NetLabel
    code and anyone who uses NetLabel. This patch renames the catmap
    functions and structures from "*_secattr_catmap_*" to just "*_catmap_*"
    which improves things greatly.

    There are no substantial code or logic changes in this patch.

    Signed-off-by: Paul Moore
    Tested-by: Casey Schaufler

    Paul Moore
     
  • The NetLabel secattr catmap functions, and the SELinux import/export
    glue routines, were broken in many horrible ways and the SELinux glue
    code fiddled with the NetLabel catmap structures in ways that we
    probably shouldn't allow. At some point this "worked", but that was
    likely due to a bit of dumb luck and sub-par testing (both inflicted
    by yours truly). This patch corrects these problems by basically
    gutting the code in favor of something less obtuse and restoring the
    NetLabel abstractions in the SELinux catmap glue code.

    Everything is working now, and if it decides to break itself in the
    future this code will be much easier to debug than the code it
    replaces.

    One noteworthy side effect of the changes is that it is no longer
    necessary to allocate a NetLabel catmap before calling one of the
    NetLabel APIs to set a bit in the catmap. NetLabel will automatically
    allocate the catmap nodes when needed, resulting in less allocations
    when the lowest bit is greater than 255 and less code in the LSMs.

    Cc: stable@vger.kernel.org
    Reported-by: Christian Evans
    Signed-off-by: Paul Moore
    Tested-by: Casey Schaufler

    Paul Moore
     
  • The NetLabel category (catmap) functions have a problem in that they
    assume categories will be set in an increasing manner, e.g. the next
    category set will always be larger than the last. Unfortunately, this
    is not a valid assumption and could result in problems when attempting
    to set categories less than the startbit in the lowest catmap node.
    In some cases kernel panics and other nasties can result.

    This patch corrects the problem by checking for this and allocating a
    new catmap node instance and placing it at the front of the list.

    Cc: stable@vger.kernel.org
    Reported-by: Christian Evans
    Signed-off-by: Paul Moore
    Tested-by: Casey Schaufler

    Paul Moore
     

20 May, 2014

1 commit


07 May, 2014

1 commit


01 May, 2014

1 commit

  • The cgroup filesystem isn't ready for an LSM to
    properly use extented attributes. This patch makes
    files created in the cgroup filesystem usable by
    a system running Smack and systemd.

    Targeted for git://git.gitorious.org/smack-next/kernel.git

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

23 Apr, 2014

1 commit

  • Smack believes that many of the operatons that can
    be performed on an open file descriptor are read operations.
    The fstat and lseek system calls are examples.
    An implication of this is that files shouldn't be open
    if the task doesn't have read access even if it has
    write access and the file is being opened write only.

    Targeted for git://git.gitorious.org/smack-next/kernel.git

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

12 Apr, 2014

8 commits

  • Smack IPC policy requires that the sender have write access
    to the receiver. UDS streams don't do per-packet checks. The
    only check is done at connect time. The existing code checks
    if the connecting process can write to the other, but not the
    other way around. This change adds a check that the other end
    can write to the connecting process.

    Targeted for git://git.gitorious.org/smack-next/kernel.git

    Signed-off-by: Casey Schuafler

    Casey Schaufler
     
  • Sam Henderson points out that removing the SMACK64TRANSMUTE
    attribute from a directory does not result in the directory
    transmuting. This is because the inode flag indicating that
    the directory is transmuting isn't cleared. The fix is a tad
    less than trivial because smk_task and smk_mmap should have
    been broken out, too.

    Targeted for git://git.gitorious.org/smack-next/kernel.git

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     
  • The function `smack_inode_post_setxattr` is called each
    time that a setxattr is done, for any value of name.
    The kernel allow to put value==NULL when size==0
    to set an empty attribute value. The systematic
    call to smk_import_entry was causing the dereference
    of a NULL pointer hence a KERNEL PANIC!

    The problem can be produced easily by issuing the
    command `setfattr -n user.data file` under bash prompt
    when SMACK is active.

    Moving the call to smk_import_entry as proposed by this
    patch is correcting the behaviour because the function
    smack_inode_post_setxattr is called for the SMACK's
    attributes only if the function smack_inode_setxattr validated
    the value and its size (what will not be the case when size==0).

    It also has a benefical effect to not fill the smack hash
    with garbage values coming from any extended attribute
    write.

    Change-Id: Iaf0039c2be9bccb6cee11c24a3b44d209101fe47
    Signed-off-by: José Bollo

    José Bollo
     
  • 1. In order to remove any SMACK extended attribute from a file, a user
    should have CAP_MAC_ADMIN capability. But user without having this
    capability is able to remove SMACK64MMAP security attribute.

    2. While validating size and value of smack extended attribute in
    smack_inode_setsecurity hook, wrong error code is returned.

    Signed-off-by: Pankaj Kumar
    Signed-off-by: Himanshu Shukla

    Pankaj Kumar
     
  • This allows to limit ptrace beyond the regular smack access rules.
    It adds a smackfs/ptrace interface that allows smack to be configured
    to require equal smack labels for PTRACE_MODE_ATTACH access.
    See the changes in Documentation/security/Smack.txt below for details.

    Signed-off-by: Lukasz Pawelczyk
    Signed-off-by: Rafal Krypa

    Lukasz Pawelczyk
     
  • The decision whether we can trace a process is made in the following
    functions:
    smack_ptrace_traceme()
    smack_ptrace_access_check()
    smack_bprm_set_creds() (in case the proces is traced)

    This patch unifies all those decisions by introducing one function that
    checks whether ptrace is allowed: smk_ptrace_rule_check().

    This makes possible to actually trace with TRACEME where first the
    TRACEME itself must be allowed and then exec() on a traced process.

    Additional bugs fixed:
    - The decision is made according to the mode parameter that is now correctly
    translated from PTRACE_MODE_* to MAY_* instead of being treated 1:1.
    PTRACE_MODE_READ requires MAY_READ.
    PTRACE_MODE_ATTACH requires MAY_READWRITE.
    - Add a smack audit log in case of exec() refused by bprm_set_creds().
    - Honor the PTRACE_MODE_NOAUDIT flag and don't put smack audit info
    in case this flag is set.

    Signed-off-by: Lukasz Pawelczyk
    Signed-off-by: Rafal Krypa

    Lukasz Pawelczyk
     
  • The order of subject/object is currently reversed in
    smack_ptrace_traceme(). It is currently checked if the tracee has a
    capability to trace tracer and according to this rule a decision is made
    whether the tracer will be allowed to trace tracee.

    Signed-off-by: Lukasz Pawelczyk
    Signed-off-by: Rafal Krypa

    Lukasz Pawelczyk
     
  • Fix a possible memory access fault when transmute is true and isp is NULL.

    Signed-off-by: José Bollo

    José Bollo
     

15 Mar, 2014

2 commits

  • For any keyring access type SMACK always used MAY_READWRITE access check.
    It prevents reading the key with label "_", which should be allowed for anyone.

    This patch changes default access check to MAY_READ and use MAY_READWRITE in only
    appropriate cases.

    Signed-off-by: Dmitry Kasatkin
    Signed-off-by: David Howells
    Acked-by: Casey Schaufler

    Dmitry Kasatkin
     
  • Move the flags representing required permission to linux/key.h as the perm
    parameter of security_key_permission() is in terms of them - and not the
    permissions mask flags used in key->perm.

    Whilst we're at it:

    (1) Rename them to be KEY_NEED_xxx rather than KEY_xxx to avoid collisions
    with symbols in uapi/linux/input.h.

    (2) Don't use key_perm_t for a mask of required permissions, but rather limit
    it to the permissions mask attached to the key and arguments related
    directly to that.

    Signed-off-by: David Howells
    Tested-by: Dmitry Kasatkin

    David Howells
     

24 Jan, 2014

1 commit

  • Pull audit update from Eric Paris:
    "Again we stayed pretty well contained inside the audit system.
    Venturing out was fixing a couple of function prototypes which were
    inconsistent (didn't hurt anything, but we used the same value as an
    int, uint, u32, and I think even a long in a couple of places).

    We also made a couple of minor changes to when a couple of LSMs called
    the audit system. We hoped to add aarch64 audit support this go
    round, but it wasn't ready.

    I'm disappearing on vacation on Thursday. I should have internet
    access, but it'll be spotty. If anything goes wrong please be sure to
    cc rgb@redhat.com. He'll make fixing things his top priority"

    * git://git.infradead.org/users/eparis/audit: (50 commits)
    audit: whitespace fix in kernel-parameters.txt
    audit: fix location of __net_initdata for audit_net_ops
    audit: remove pr_info for every network namespace
    audit: Modify a set of system calls in audit class definitions
    audit: Convert int limit uses to u32
    audit: Use more current logging style
    audit: Use hex_byte_pack_upper
    audit: correct a type mismatch in audit_syscall_exit()
    audit: reorder AUDIT_TTY_SET arguments
    audit: rework AUDIT_TTY_SET to only grab spin_lock once
    audit: remove needless switch in AUDIT_SET
    audit: use define's for audit version
    audit: documentation of audit= kernel parameter
    audit: wait_for_auditd rework for readability
    audit: update MAINTAINERS
    audit: log task info on feature change
    audit: fix incorrect set of audit_sock
    audit: print error message when fail to create audit socket
    audit: fix dangling keywords in audit_log_set_loginuid() output
    audit: log on errors from filter user rules
    ...

    Linus Torvalds
     

14 Jan, 2014

1 commit


01 Jan, 2014

2 commits

  • Eric Paris politely points out:

    Inside smack_file_receive() it seems like you are initting the audit
    field with LSM_AUDIT_DATA_TASK. And then use
    smk_ad_setfield_u_fs_path().

    Seems like LSM_AUDIT_DATA_PATH would make more sense. (and depending
    on how it's used fix a crash...)

    He is correct. This puts things in order.

    Targeted for git://git.gitorious.org/smack-next/kernel.git

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     
  • The mount restrictions imposed by Smack rely heavily on the
    use of the filesystem "floor", which is the label that all
    processes writing to the filesystem must have access to. It
    turns out that while the "floor" notion is sound, it has yet
    to be fully implemented and has never been used.

    The sb_mount and sb_umount hooks only make sense if the
    filesystem floor is used actively, and it isn't. They can
    be reintroduced if a rational restriction comes up. Until
    then, they get removed.

    The sb_kern_mount hook is required for the option processing.
    It is too permissive in the case of unprivileged mounts,
    effectively bypassing the CAP_MAC_ADMIN restrictions if
    any of the smack options are specified. Unprivileged mounts
    are no longer allowed to set Smack filesystem options.
    Additionally, the root and default values are set to the
    label of the caller, in keeping with the policy that objects
    get the label of their creator.

    Targeted for git://git.gitorious.org/smack-next/kernel.git

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

24 Dec, 2013

2 commits

  • smk_write_change_rule() is calling capable rather than
    the more correct smack_privileged(). This allows for setting
    rules in violation of the onlycap facility. This is the
    simple repair.

    Targeted for git://git.gitorious.org/smack-next/kernel.git

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     
  • The syslog control requires that the calling proccess
    have the floor ("_") Smack label. Tizen does not run any
    processes except for kernel helpers with the floor label.
    This changes allows the admin to configure a specific
    label for syslog. The default value is the star ("*")
    label, effectively removing the restriction. The value
    can be set using smackfs/syslog for anyone who wants
    a more restrictive behavior.

    Targeted for git://git.gitorious.org/smack-next/kernel.git

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

20 Dec, 2013

1 commit

  • Smack prohibits processes from using the star ("*") and web ("@") labels
    because we don't want files with those labels getting created implicitly.
    All setting of those labels should be done explicitly. The trouble is that
    there is no check for these labels in the processing of SMACK64EXEC. That
    is repaired.

    Targeted for git://git.gitorious.org/smack-next/kernel.git

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

12 Dec, 2013

1 commit


29 Oct, 2013

1 commit

  • When the ptrace security hooks were split the addition of
    a mode parameter was not taken advantage of in the Smack
    ptrace access check. This changes the access check from
    always looking for read and write access to using the
    passed mode. This will make use of /proc much happier.

    Targeted for git://git.gitorious.org/smack-next/kernel.git

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

19 Oct, 2013

1 commit

  • Linux file locking does not follow the same rules
    as other mechanisms. Even though it is a write operation
    a process can set a read lock on files which it has open
    only for read access. Two programs with read access to
    a file can use read locks to communicate.

    This is not acceptable in a Mandatory Access Control
    environment. Smack treats setting a read lock as the
    write operation that it is. Unfortunately, many programs
    assume that setting a read lock is a read operation.
    These programs are unhappy in the Smack environment.

    This patch introduces a new access mode (lock) to address
    this problem. A process with lock access to a file can
    set a read lock. A process with write access to a file can
    set a read lock or a write lock. This prevents a situation
    where processes are granted write access just so they can
    set read locks.

    Targeted for git://git.gitorious.org/smack-next/kernel.git

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

08 Sep, 2013

1 commit

  • Pull security subsystem updates from James Morris:
    "Nothing major for this kernel, just maintenance updates"

    * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (21 commits)
    apparmor: add the ability to report a sha1 hash of loaded policy
    apparmor: export set of capabilities supported by the apparmor module
    apparmor: add the profile introspection file to interface
    apparmor: add an optional profile attachment string for profiles
    apparmor: add interface files for profiles and namespaces
    apparmor: allow setting any profile into the unconfined state
    apparmor: make free_profile available outside of policy.c
    apparmor: rework namespace free path
    apparmor: update how unconfined is handled
    apparmor: change how profile replacement update is done
    apparmor: convert profile lists to RCU based locking
    apparmor: provide base for multiple profiles to be replaced at once
    apparmor: add a features/policy dir to interface
    apparmor: enable users to query whether apparmor is enabled
    apparmor: remove minimum size check for vmalloc()
    Smack: parse multiple rules per write to load2, up to PAGE_SIZE-1 bytes
    Smack: network label match fix
    security: smack: add a hash table to quicken smk_find_entry()
    security: smack: fix memleak in smk_write_rules_list()
    xattr: Constify ->name member of "struct xattr".
    ...

    Linus Torvalds
     

23 Aug, 2013

1 commit


13 Aug, 2013

1 commit

  • Smack interface for loading rules has always parsed only single rule from
    data written to it. This requires user program to call one write() per
    each rule it wants to load.
    This change makes it possible to write multiple rules, separated by new
    line character. Smack will load at most PAGE_SIZE-1 characters and properly
    return number of processed bytes. In case when user buffer is larger, it
    will be additionally truncated. All characters after last \n will not get
    parsed to avoid partial rule near input buffer boundary.

    Signed-off-by: Rafal Krypa

    Rafal Krypa
     

06 Aug, 2013

1 commit

  • The original implementation of the Smack IPv6 port based
    local controls works most of the time using a sockaddr as
    a temporary variable, but not always as it overflows in
    some circumstances. The correct data is a sockaddr_in6.
    A struct sockaddr isn't as large as a struct sockaddr_in6.
    There would need to be casting one way or the other. This
    patch gets it the right way.

    Signed-off-by: Casey Schaufler
    Signed-off-by: James Morris

    Casey Schaufler
     

02 Aug, 2013

3 commits

  • The Smack code that matches incoming CIPSO tags with Smack labels
    reaches through the NetLabel interfaces and compares the network
    data with the CIPSO header associated with a Smack label. This was
    done in a ill advised attempt to optimize performance. It works
    so long as the categories fit in a single capset, but this isn't
    always the case.

    This patch changes the Smack code to use the appropriate NetLabel
    interfaces to compare the incoming CIPSO header with the CIPSO
    header associated with a label. It will always match the CIPSO
    headers correctly.

    Targeted for git://git.gitorious.org/smack-next/kernel.git

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     
  • Accepted for the smack-next tree after changing the number of
    slots from 128 to 16.

    This patch adds a hash table to quicken searching of a smack label by its name.

    Basically, the patch improves performance of SMACK initialization. Parsing of
    rules involves translation from a string to a smack_known (aka label) entity
    which is done in smk_find_entry().

    The current implementation of the function iterates over a global list of
    smack_known resulting in O(N) complexity for smk_find_entry(). The total
    complexity of SMACK initialization becomes O(rules * labels). Therefore it
    scales quadratically with a complexity of a system.

    Applying the patch reduced the complexity of smk_find_entry() to O(1) as long
    as number of label is in hundreds. If the number of labels is increased please
    update SMACK_HASH_SLOTS constant defined in security/smack/smack.h. Introducing
    the configuration of this constant with Kconfig or cmdline might be a good
    idea.

    The size of the hash table was adjusted experimentally. The rule set used by
    TIZEN contains circa 17K rules for 500 labels. The table above contains
    results of SMACK initialization using 'time smackctl apply' bash command.
    The 'Ref' is a kernel without this patch applied. The consecutive values
    refers to value of SMACK_HASH_SLOTS. Every measurement was repeated three
    times to reduce noise.

    | Ref | 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 256 | 512
    --------------------------------------------------------------------------------------------
    Run1 | 1.156 | 1.096 | 0.883 | 0.764 | 0.692 | 0.667 | 0.649 | 0.633 | 0.634 | 0.629 | 0.620
    Run2 | 1.156 | 1.111 | 0.885 | 0.764 | 0.694 | 0.661 | 0.649 | 0.651 | 0.634 | 0.638 | 0.623
    Run3 | 1.160 | 1.107 | 0.886 | 0.764 | 0.694 | 0.671 | 0.661 | 0.638 | 0.631 | 0.624 | 0.638
    AVG | 1.157 | 1.105 | 0.885 | 0.764 | 0.693 | 0.666 | 0.653 | 0.641 | 0.633 | 0.630 | 0.627

    Surprisingly, a single hlist is slightly faster than a double-linked list.
    The speed-up saturates near 64 slots. Therefore I chose value 128 to provide
    some margin if more labels were used.
    It looks that IO becomes a new bottleneck.

    Signed-off-by: Tomasz Stanislawski

    Tomasz Stanislawski
     
  • The smack_parsed_rule structure is allocated. If a rule is successfully
    installed then the last reference to the object is lost. This patch fixes this
    leak. Moreover smack_parsed_rule is allocated on stack because it no longer
    needed ofter smk_write_rules_list() is finished.

    Signed-off-by: Tomasz Stanislawski

    Tomasz Stanislawski
     

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
     

10 Jul, 2013

1 commit

  • Pull NFS client updates from Trond Myklebust:
    "Feature highlights include:
    - Add basic client support for NFSv4.2
    - Add basic client support for Labeled NFS (selinux for NFSv4.2)
    - Fix the use of credentials in NFSv4.1 stateful operations, and add
    support for NFSv4.1 state protection.

    Bugfix highlights:
    - Fix another NFSv4 open state recovery race
    - Fix an NFSv4.1 back channel session regression
    - Various rpc_pipefs races
    - Fix another issue with NFSv3 auth negotiation

    Please note that Labeled NFS does require some additional support from
    the security subsystem. The relevant changesets have all been
    reviewed and acked by James Morris."

    * tag 'nfs-for-3.11-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: (54 commits)
    NFS: Set NFS_CS_MIGRATION for NFSv4 mounts
    NFSv4.1 Refactor nfs4_init_session and nfs4_init_channel_attrs
    nfs: have NFSv3 try server-specified auth flavors in turn
    nfs: have nfs_mount fake up a auth_flavs list when the server didn't provide it
    nfs: move server_authlist into nfs_try_mount_request
    nfs: refactor "need_mount" code out of nfs_try_mount
    SUNRPC: PipeFS MOUNT notification optimization for dying clients
    SUNRPC: split client creation routine into setup and registration
    SUNRPC: fix races on PipeFS UMOUNT notifications
    SUNRPC: fix races on PipeFS MOUNT notifications
    NFSv4.1 use pnfs_device maxcount for the objectlayout gdia_maxcount
    NFSv4.1 use pnfs_device maxcount for the blocklayout gdia_maxcount
    NFSv4.1 Fix gdia_maxcount calculation to fit in ca_maxresponsesize
    NFS: Improve legacy idmapping fallback
    NFSv4.1 end back channel session draining
    NFS: Apply v4.1 capabilities to v4.2
    NFSv4.1: Clean up layout segment comparison helper names
    NFSv4.1: layout segment comparison helpers should take 'const' parameters
    NFSv4: Move the DNS resolver into the NFSv4 module
    rpc_pipefs: only set rpc_dentry_ops if d_op isn't already set
    ...

    Linus Torvalds
     

09 Jun, 2013

1 commit

  • 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
     

04 Jun, 2013

1 commit


29 May, 2013

1 commit