30 Dec, 2020

1 commit

  • [ Upstream commit 942cb357ae7d9249088e3687ee6a00ed2745a0c7 ]

    Smack assumes that kernel threads are privileged for smackfs
    operations. This was necessary because the credential of the
    kernel thread was not related to a user operation. With io_uring
    the credential does reflect a user's rights and can be used.

    Suggested-by: Jens Axboe
    Acked-by: Jens Axboe
    Acked-by: Eric W. Biederman
    Signed-off-by: Casey Schaufler
    Signed-off-by: Sasha Levin

    Casey Schaufler
     

12 Sep, 2020

1 commit


05 Sep, 2019

1 commit

  • inode_smack::smk_lock is taken during smack_d_instantiate(), which is
    called during a filesystem transaction when creating a file on ext4.
    Therefore to avoid a deadlock, all code that takes this lock must use
    GFP_NOFS, to prevent memory reclaim from waiting for the filesystem
    transaction to complete.

    Reported-by: syzbot+0eefc1e06a77d327a056@syzkaller.appspotmail.com
    Cc: stable@vger.kernel.org
    Signed-off-by: Eric Biggers
    Signed-off-by: Casey Schaufler

    Eric Biggers
     

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
     

11 Jan, 2019

1 commit

  • This patch provides a general mechanism for passing flags to the
    security_capable LSM hook. It replaces the specific 'audit' flag that is
    used to tell security_capable whether it should log an audit message for
    the given capability check. The reason for generalizing this flag
    passing is so we can add an additional flag that signifies whether
    security_capable is being called by a setid syscall (which is needed by
    the proposed SafeSetID LSM).

    Signed-off-by: Micah Morton
    Reviewed-by: Kees Cook
    Signed-off-by: James Morris

    Micah Morton
     

09 Jan, 2019

1 commit


11 Jan, 2018

1 commit

  • Smack: Privilege check on key operations

    Operations on key objects are subjected to Smack policy
    even if the process is privileged. This is inconsistent
    with the general behavior of Smack and may cause issues
    with authentication by privileged daemons. This patch
    allows processes with CAP_MAC_OVERRIDE to access keys
    even if the Smack rules indicate otherwise.

    Reported-by: Jose Bollo
    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

02 Jun, 2017

1 commit

  • Use cap_capable() rather than capable() in the Smack privilege
    check as the former does not invoke other security module
    privilege check, while the later does. This becomes important
    when stacking. It may be a problem even with minor modules.

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

05 Apr, 2017

1 commit

  • Since all callers of smk_netlbl_mls() are GFP_KERNEL context
    (smk_set_cipso() calls memdup_user_nul(), init_smk_fs() calls
    __kernfs_new_node(), smk_import_entry() calls kzalloc(GFP_KERNEL)),
    it is safe to use GFP_KERNEL from netlbl_catmap_setbit().

    Signed-off-by: Tetsuo Handa
    Signed-off-by: Casey Schaufler

    Tetsuo Handa
     

16 Nov, 2016

1 commit

  • The invalid Smack label ("") and the Huh ("?") Smack label
    serve the same purpose and having both is unnecessary.
    While pulling out the invalid label it became clear that
    the use of smack_from_secid() was inconsistent, so that
    is repaired. The setting of inode labels to the invalid
    label could never happen in a functional system, has
    never been observed in the wild and is not what you'd
    really want for a failure behavior in any case. That is
    removed.

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

11 Jun, 2016

1 commit

  • We always mixed in the parent pointer into the dentry name hash, but we
    did it late at lookup time. It turns out that we can simplify that
    lookup-time action by salting the hash with the parent pointer early
    instead of late.

    A few other users of our string hashes also wanted to mix in their own
    pointers into the hash, and those are updated to use the same mechanism.

    Hash users that don't have any particular initial salt can just use the
    NULL pointer as a no-salt.

    Cc: Vegard Nossum
    Cc: George Spelvin
    Cc: Al Viro
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

20 Oct, 2015

1 commit

  • This feature introduces new kernel interface:

    - /relabel-self - for setting transition labels list

    This list is used to control smack label transition mechanism.
    List is set by, and per process. Process can transit to new label only if
    label is on the list. Only process with CAP_MAC_ADMIN capability can add
    labels to this list. With this list, process can change it's label without
    CAP_MAC_ADMIN but only once. After label changing, list is unset.

    Changes in v2:
    * use list_for_each_entry instead of _rcu during label write
    * added missing description in security/Smack.txt

    Changes in v3:
    * squashed into one commit

    Changes in v4:
    * switch from global list to per-task list
    * since the per-task list is accessed only by the task itself
    there is no need to use synchronization mechanisms on it

    Changes in v5:
    * change smackfs interface of relabel-self to the one used for onlycap
    multiple labels are accepted, separated by space, which
    replace the previous list upon write

    Signed-off-by: Zbigniew Jasinski
    Signed-off-by: Rafal Krypa
    Acked-by: Casey Schaufler

    Zbigniew Jasinski
     

11 Aug, 2015

1 commit

  • Adds an ignore case for kernel tasks,
    so that they can access all resources.

    Since kernel worker threads are spawned with
    floor label, they are severely restricted by
    Smack policy. It is not an issue without onlycap,
    as these processes also run with root,
    so CAP_MAC_OVERRIDE kicks in. But with onlycap
    turned on, there is no way to change the label
    for these processes.

    Signed-off-by: Roman Kubiak
    Acked-by: Casey Schaufler

    Roman Kubiak
     

03 Jun, 2015

1 commit

  • Smack onlycap allows limiting of CAP_MAC_ADMIN and CAP_MAC_OVERRIDE to
    processes running with the configured label. But having single privileged
    label is not enough in some real use cases. On a complex system like Tizen,
    there maybe few programs that need to configure Smack policy in run-time
    and running them all with a single label is not always practical.
    This patch extends onlycap feature for multiple labels. They are configured
    in the same smackfs "onlycap" interface, separated by spaces.

    Signed-off-by: Rafal Krypa

    Rafal Krypa
     

15 May, 2015

1 commit

  • This patch makes the following functions to use ERR_PTR() and related
    macros to pass the appropriate error code through returned pointers:

    smk_parse_smack()
    smk_import_entry()
    smk_fetch()

    It also makes all the other functions that use them to handle the
    error cases properly. This ways correct error codes from places
    where they happened can be propagated to the user space if necessary.

    Doing this it fixes a bug in onlycap and unconfined files
    handling. Previously their content was cleared on any error from
    smk_import_entry/smk_parse_smack, be it EINVAL (as originally intended)
    or ENOMEM. Right now it only reacts on EINVAL passing other codes
    properly to userspace.

    Comments have been updated accordingly.

    Signed-off-by: Lukasz Pawelczyk

    Lukasz Pawelczyk
     

24 Mar, 2015

1 commit

  • I have vehemently opposed adding a "permissive" mode to Smack
    for the simple reasons that it would be subject to massive abuse
    and that developers refuse to turn it off come product release.
    I still believe that this is true, and still refuse to add a
    general "permissive mode". So don't ask again.

    Bumjin Im suggested an approach that addresses most of the concerns,
    and I have implemented it here. I still believe that we'd be better
    off without this sort of thing, but it looks like this minimizes the
    abuse potential.

    Firstly, you have to configure Smack Bringup Mode. That allows
    for "release" software to be ammune from abuse. Second, only one
    label gets to be "permissive" at a time. You can use it for
    debugging, but that's about it.

    A label written to smackfs/unconfined is treated specially.
    If either the subject or object label of an access check
    matches the "unconfined" label, and the access would not
    have been allowed otherwise an audit record and a console
    message are generated. The audit record "request" string is
    marked with either "(US)" or "(UO)", to indicate that the
    request was granted because of an unconfined label. The
    fact that an inode was accessed by an unconfined label is
    remembered, and subsequent accesses to that "impure"
    object are noted in the log. The impurity is not stored in
    the filesystem, so a file mislabled as a side effect of
    using an unconfined label may still cause concern after
    a reboot.

    So, it's there, it's dangerous, but so many application
    developers seem incapable of living without it I have
    given in. I've tried to make it as safe as I can, but
    in the end it's still a chain saw.

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

22 Nov, 2014

1 commit

  • Setting smack label on file (e.g. 'attr -S -s SMACK64 -V "test" test')
    triggered following spew on the kernel with KASan applied:
    ==================================================================
    BUG: AddressSanitizer: out of bounds access in strncpy+0x28/0x60 at addr ffff8800059ad064
    =============================================================================
    BUG kmalloc-8 (Not tainted): kasan error
    -----------------------------------------------------------------------------

    Disabling lock debugging due to kernel taint
    INFO: Slab 0xffffea0000166b40 objects=128 used=7 fp=0xffff8800059ad080 flags=0x4000000000000080
    INFO: Object 0xffff8800059ad060 @offset=96 fp=0xffff8800059ad080

    Bytes b4 ffff8800059ad050: a0 df 9a 05 00 88 ff ff 5a 5a 5a 5a 5a 5a 5a 5a ........ZZZZZZZZ
    Object ffff8800059ad060: 74 65 73 74 6b 6b 6b a5 testkkk.
    Redzone ffff8800059ad068: cc cc cc cc cc cc cc cc ........
    Padding ffff8800059ad078: 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ
    CPU: 0 PID: 528 Comm: attr Tainted: G B 3.18.0-rc1-mm1+ #5
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
    0000000000000000 ffff8800059ad064 ffffffff81534cf2 ffff880005a5bc40
    ffffffff8112fe1a 0000000100800006 0000000f059ad060 ffff880006000f90
    0000000000000296 ffffea0000166b40 ffffffff8107ca97 ffff880005891060
    Call Trace:
    ? dump_stack (lib/dump_stack.c:52)
    ? kasan_report_error (mm/kasan/report.c:102 mm/kasan/report.c:178)
    ? preempt_count_sub (kernel/sched/core.c:2651)
    ? __asan_load1 (mm/kasan/kasan.h:50 mm/kasan/kasan.c:248 mm/kasan/kasan.c:358)
    ? strncpy (lib/string.c:121)
    ? strncpy (lib/string.c:121)
    ? smk_parse_smack (security/smack/smack_access.c:457)
    ? setxattr (fs/xattr.c:343)
    ? smk_import_entry (security/smack/smack_access.c:514)
    ? smack_inode_setxattr (security/smack/smack_lsm.c:1093 (discriminator 1))
    ? security_inode_setxattr (security/security.c:602)
    ? vfs_setxattr (fs/xattr.c:134)
    ? setxattr (fs/xattr.c:343)
    ? setxattr (fs/xattr.c:360)
    ? get_parent_ip (kernel/sched/core.c:2606)
    ? preempt_count_sub (kernel/sched/core.c:2651)
    ? __percpu_counter_add (arch/x86/include/asm/preempt.h:98 lib/percpu_counter.c:90)
    ? get_parent_ip (kernel/sched/core.c:2606)
    ? preempt_count_sub (kernel/sched/core.c:2651)
    ? __mnt_want_write (arch/x86/include/asm/preempt.h:98 fs/namespace.c:359)
    ? path_setxattr (fs/xattr.c:380)
    ? SyS_lsetxattr (fs/xattr.c:397)
    ? system_call_fastpath (arch/x86/kernel/entry_64.S:423)
    Read of size 1 by task attr:
    Memory state around the buggy address:
    ffff8800059ace80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    ffff8800059acf00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    ffff8800059acf80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    >ffff8800059ad000: 00 fc fc fc 00 fc fc fc 05 fc fc fc 04 fc fc fc
    ^
    ffff8800059ad080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    ffff8800059ad100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    ffff8800059ad180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    ==================================================================

    strncpy() copies one byte more than the source string has.
    Fix this by passing the correct length to strncpy().

    Now we can remove initialization of the last byte in 'smack' string
    because kzalloc() already did this for us.

    Signed-off-by: Andrey Ryabinin

    Andrey Ryabinin
     

28 Oct, 2014

1 commit

  • The lock access mode allows setting a read lock on a file
    for with the process has only read access. The floor label is
    defined to make it easy to have the basic system installed such
    that everyone can read it. Once there's a desire to read lock
    (rationally or otherwise) a floor file a rule needs to get set.
    This happens all the time, so make the floor label a little bit
    more special and allow everyone lock access, too. By implication,
    give processes with the hat label (hat can read everything)
    lock access as well. This reduces clutter in the Smack rule set.

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

30 Aug, 2014

1 commit


29 Aug, 2014

1 commit

  • People keep asking me for permissive mode, and I keep saying "no".

    Permissive mode is wrong for more reasons than I can enumerate,
    but the compelling one is that it's once on, never off.

    Nonetheless, there is an argument to be made for running a
    process with lots of permissions, logging which are required,
    and then locking the process down. There wasn't a way to do
    that with Smack, but this provides it.

    The notion is that you start out by giving the process an
    appropriate Smack label, such as "ATBirds". You create rules
    with a wide range of access and the "b" mode. On Tizen it
    might be:

    ATBirds System rwxalb
    ATBirds User rwxalb
    ATBirds _ rwxalb
    User ATBirds wb
    System ATBirds wb

    Accesses that fail will generate audit records. Accesses
    that succeed because of rules marked with a "b" generate
    log messages identifying the rule, the program and as much
    object information as is convenient.

    When the system is properly configured and the programs
    brought in line with the labeling scheme the "b" mode can
    be removed from the rules. When the system is ready for
    production the facility can be configured out.

    This provides the developer the convenience of permissive
    mode without creating a system that looks like it is
    enforcing a policy while it is not.

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

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
     

12 Apr, 2014

2 commits

  • 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 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
     

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
     

02 Aug, 2013

1 commit

  • 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
     

29 May, 2013

2 commits

  • netlbl_secattr_catmap_alloc(GFP_ATOMIC) can return NULL.

    Signed-off-by: Tetsuo Handa

    Tetsuo Handa
     
  • Each Smack label that the kernel has seen is added to a
    list of labels. The list of access rules for a given subject
    label hangs off of the label list entry for the label.
    This patch changes the structures that contain subject
    labels to point at the label list entry rather that the
    label itself. Doing so removes a label list lookup in
    smk_access() that was accounting for the largest single
    chunk of Smack overhead.

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

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

20 Mar, 2013

1 commit


14 Jul, 2012

1 commit

  • Smack is integrated with the POSIX capabilities scheme,
    using the capabilities CAP_MAC_OVERRIDE and CAP_MAC_ADMIN to
    determine if a process is allowed to ignore Smack checks or
    change Smack related data respectively. Smack provides an
    additional restriction that if an onlycap value is set
    by writing to /smack/onlycap only tasks with that Smack
    label are allowed to use CAP_MAC_OVERRIDE.

    This change adds CAP_MAC_ADMIN as a capability that is affected
    by the onlycap mechanism.

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

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

15 May, 2012

1 commit

  • V4 updated to current linux-security#next
    Targeted for git://gitorious.org/smack-next/kernel.git

    Modern application runtime environments like to use
    naming schemes that are structured and generated without
    human intervention. Even though the Smack limit of 23
    characters for a label name is perfectly rational for
    human use there have been complaints that the limit is
    a problem in environments where names are composed from
    a set or sources, including vendor, author, distribution
    channel and application name. Names like

    softwarehouse-pgwodehouse-coolappstore-mellowmuskrats

    are becoming harder to avoid. This patch introduces long
    label support in Smack. Labels are now limited to 255
    characters instead of the old 23.

    The primary reason for limiting the labels to 23 characters
    was so they could be directly contained in CIPSO category sets.
    This is still done were possible, but for labels that are too
    large a mapping is required. This is perfectly safe for communication
    that stays "on the box" and doesn't require much coordination
    between boxes beyond what would have been required to keep label
    names consistent.

    The bulk of this patch is in smackfs, adding and updating
    administrative interfaces. Because existing APIs can't be
    changed new ones that do much the same things as old ones
    have been introduced.

    The Smack specific CIPSO data representation has been removed
    and replaced with the data format used by netlabel. The CIPSO
    header is now computed when a label is imported rather than
    on use. This results in improved IP performance. The smack
    label is now allocated separately from the containing structure,
    allowing for larger strings.

    Four new /smack interfaces have been introduced as four
    of the old interfaces strictly required labels be specified
    in fixed length arrays.

    The access interface is supplemented with the check interface:
    access "Subject Object rwxat"
    access2 "Subject Object rwaxt"

    The load interface is supplemented with the rules interface:
    load "Subject Object rwxat"
    load2 "Subject Object rwaxt"

    The load-self interface is supplemented with the self-rules interface:
    load-self "Subject Object rwxat"
    load-self2 "Subject Object rwaxt"

    The cipso interface is supplemented with the wire interface:
    cipso "Subject lvl cnt c1 c2 ..."
    cipso2 "Subject lvl cnt c1 c2 ..."

    The old interfaces are maintained for compatibility.

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

04 Apr, 2012

2 commits

  • It just bloats the audit data structure for no good reason, since the
    only time those fields are filled are just before calling the
    common_lsm_audit() function, which is also the only user of those
    fields.

    So just make them be the arguments to common_lsm_audit(), rather than
    bloating that structure that is passed around everywhere, and is
    initialized in hot paths.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • Linus found that the gigantic size of the common audit data caused a big
    perf hit on something as simple as running stat() in a loop. This patch
    requires LSMs to declare the LSM specific portion separately rather than
    doing it in a union. Thus each LSM can be responsible for shrinking their
    portion and don't have to pay a penalty just because other LSMs have a
    bigger space requirement.

    Signed-off-by: Eric Paris
    Signed-off-by: Linus Torvalds

    Eric Paris
     

21 Oct, 2011

1 commit


13 Oct, 2011

1 commit

  • This patch is targeted for the smack-next tree.

    Smack access checks suffer from two significant performance
    issues. In cases where there are large numbers of rules the
    search of the single list of rules is wasteful. Comparing the
    string values of the smack labels is less efficient than a
    numeric comparison would.

    These changes take advantage of the Smack label list, which
    maintains the mapping of Smack labels to secids and optional
    CIPSO labels. Because the labels are kept perpetually, an
    access check can be done strictly based on the address of the
    label in the list without ever looking at the label itself.
    Rather than keeping one global list of rules the rules with
    a particular subject label can be based off of that label
    list entry. The access check need never look at entries that
    do not use the current subject label.

    This requires that packets coming off the network with
    CIPSO direct Smack labels that have never been seen before
    be treated carefully. The only case where they could be
    delivered is where the receiving socket has an IPIN star
    label, so that case is explicitly addressed.

    On a system with 39,800 rules (200 labels in all permutations)
    a system with this patch runs an access speed test in 5% of
    the time of the old version. That should be a best case
    improvement. If all of the rules are associated with the
    same subject label and all of the accesses are for processes
    with that label (unlikely) the improvement is about 30%.

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

31 Mar, 2011

1 commit


18 Jan, 2011

1 commit

  • In the embedded world there are often situations
    where libraries are updated from a variety of sources,
    for a variety of reasons, and with any number of
    security characteristics. These differences
    might include privilege required for a given library
    provided interface to function properly, as occurs
    from time to time in graphics libraries. There are
    also cases where it is important to limit use of
    libraries based on the provider of the library and
    the security aware application may make choices
    based on that criteria.

    These issues are addressed by providing an additional
    Smack label that may optionally be assigned to an object,
    the SMACK64MMAP attribute. An mmap operation is allowed
    if there is no such attribute.

    If there is a SMACK64MMAP attribute the mmap is permitted
    only if a subject with that label has all of the access
    permitted a subject with the current task label.

    Security aware applications may from time to time
    wish to reduce their "privilege" to avoid accidental use
    of privilege. One case where this arises is the
    environment in which multiple sources provide libraries
    to perform the same functions. An application may know
    that it should eschew services made available from a
    particular vendor, or of a particular version.

    In support of this a secondary list of Smack rules has
    been added that is local to the task. This list is
    consulted only in the case where the global list has
    approved access. It can only further restrict access.
    Unlike the global last, if no entry is found on the
    local list access is granted. An application can add
    entries to its own list by writing to /smack/load-self.

    The changes appear large as they involve refactoring
    the list handling to accomodate there being more
    than one rule list.

    Signed-off-by: Casey Schaufler

    Casey Schaufler
     

08 Dec, 2010

1 commit

  • In a situation where Smack access rules allow processes
    with multiple labels to write to a directory it is easy
    to get into a situation where the directory gets cluttered
    with files that the owner can't deal with because while
    they could be written to the directory a process at the
    label of the directory can't write them. This is generally
    the desired behavior, but when it isn't it is a real
    issue.

    This patch introduces a new attribute SMACK64TRANSMUTE that
    instructs Smack to create the file with the label of the directory
    under certain circumstances.

    A new access mode, "t" for transmute, is made available to
    Smack access rules, which are expanded from "rwxa" to "rwxat".
    If a file is created in a directory marked as transmutable
    and if access was granted to perform the operation by a rule
    that included the transmute mode, then the file gets the
    Smack label of the directory instead of the Smack label of the
    creating process.

    Note that this is equivalent to creating an empty file at the
    label of the directory and then having the other process write
    to it. The transmute scheme requires that both the access rule
    allows transmutation and that the directory be explicitly marked.

    Signed-off-by: Jarkko Sakkinen
    Signed-off-by: Casey Schaufler

    Jarkko Sakkinen