14 Jul, 2008

2 commits

  • The register security hook is no longer required, as the capability
    module is always registered. LSMs wishing to stack capability as
    a secondary module should do so explicitly.

    Signed-off-by: James Morris
    Acked-by: Stephen Smalley
    Acked-by: Greg Kroah-Hartman

    James Morris
     
  • Enable security modules to distinguish reading of process state via
    proc from full ptrace access by renaming ptrace_may_attach to
    ptrace_may_access and adding a mode argument indicating whether only
    read access or full attach access is requested. This allows security
    modules to permit access to reading process state without granting
    full ptrace access. The base DAC/capability checking remains unchanged.

    Read access to /proc/pid/mem continues to apply a full ptrace attach
    check since check_mem_permission() already requires the current task
    to already be ptracing the target. The other ptrace checks within
    proc for elements like environ, maps, and fds are changed to pass the
    read mode instead of attach.

    In the SELinux case, we model such reading of process state as a
    reading of a proc file labeled with the target process' label. This
    enables SELinux policy to permit such reading of process state without
    permitting control or manipulation of the target process, as there are
    a number of cases where programs probe for such information via proc
    but do not need to be able to control the target (e.g. procps,
    lsof, PolicyKit, ConsoleKit). At present we have to choose between
    allowing full ptrace in policy (more permissive than required/desired)
    or breaking functionality (or in some cases just silencing the denials
    via dontaudit rules but this can hide genuine attacks).

    This version of the patch incorporates comments from Casey Schaufler
    (change/replace existing ptrace_may_attach interface, pass access
    mode), and Chris Wright (provide greater consistency in the checking).

    Note that like their predecessors __ptrace_may_attach and
    ptrace_may_attach, the __ptrace_may_access and ptrace_may_access
    interfaces use different return value conventions from each other (0
    or -errno vs. 1 or 0). I retained this difference to avoid any
    changes to the caller logic but made the difference clearer by
    changing the latter interface to return a bool rather than an int and
    by adding a comment about it to ptrace.h for any future callers.

    Signed-off-by: Stephen Smalley
    Acked-by: Chris Wright
    Signed-off-by: James Morris

    Stephen Smalley
     

04 Jun, 2008

1 commit

  • The d_instantiate hook for Smack can hang on the root inode of a
    filesystem if the file system code has not really done all the set-up.
    Fuse is known to encounter this problem.

    This change detects an attempt to instantiate a root inode and addresses
    it early in the processing, before any attempt is made to do something
    that might hang.

    Signed-off-by: Casey Schaufler
    Tested-by: Luiz Fernando N. Capitulino
    Signed-off-by: Linus Torvalds

    Casey Schaufler
     

30 Apr, 2008

4 commits

  • Every implementation of ->task_kill() does nothing when the signal comes from
    the kernel. This is correct, but means that check_kill_permission() should
    call security_task_kill() only for SI_FROMUSER() case, and we can remove the
    same check from ->task_kill() implementations.

    (sadly, check_kill_permission() is the last user of signal->session/__session
    but we can't s/task_session_nr/task_session/ here).

    NOTE: Eric W. Biederman pointed out cap_task_kill() should die, and I think
    he is very right.

    Signed-off-by: Oleg Nesterov
    Cc: "Eric W. Biederman"
    Cc: Serge Hallyn
    Cc: Roland McGrath
    Cc: Casey Schaufler
    Cc: David Quigley
    Cc: Eric Paris
    Cc: Harald Welte
    Cc: Pavel Emelyanov
    Cc: Stephen Smalley
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • Setup the new Audit hooks for Smack. SELinux Audit rule fields are recycled
    to avoid `auditd' userspace modifications. Currently only equality testing
    is supported on labels acting as a subject (AUDIT_SUBJ_USER) or as an object
    (AUDIT_OBJ_USER).

    Signed-off-by: Ahmed S. Darwish
    Acked-by: Casey Schaufler

    Ahmed S. Darwish
     
  • Make secctx_to_secid() take constant secdata.

    Signed-off-by: David Howells
    Acked-by: Casey Schaufler
    Signed-off-by: James Morris

    David Howells
     
  • * 'audit.b50' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit-current:
    [PATCH] new predicate - AUDIT_FILETYPE
    [patch 2/2] Use find_task_by_vpid in audit code
    [patch 1/2] audit: let userspace fully control TTY input auditing
    [PATCH 2/2] audit: fix sparse shadowed variable warnings
    [PATCH 1/2] audit: move extern declarations to audit.h
    Audit: MAINTAINERS update
    Audit: increase the maximum length of the key field
    Audit: standardize string audit interfaces
    Audit: stop deadlock from signals under load
    Audit: save audit_backlog_limit audit messages in case auditd comes back
    Audit: collect sessionid in netlink messages
    Audit: end printk with newline

    Linus Torvalds
     

29 Apr, 2008

1 commit


28 Apr, 2008

4 commits


22 Apr, 2008

1 commit


19 Apr, 2008

2 commits

  • …s/security-testing-2.6

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6:
    security: fix up documentation for security_module_enable
    Security: Introduce security= boot parameter
    Audit: Final renamings and cleanup
    SELinux: use new audit hooks, remove redundant exports
    Audit: internally use the new LSM audit hooks
    LSM/Audit: Introduce generic Audit LSM hooks
    SELinux: remove redundant exports
    Netlink: Use generic LSM hook
    Audit: use new LSM hooks instead of SELinux exports
    SELinux: setup new inode/ipc getsecid hooks
    LSM: Introduce inode_getsecid and ipc_getsecid hooks

    Linus Torvalds
     
  • Add the security= boot parameter. This is done to avoid LSM
    registration clashes in case of more than one bult-in module.

    User can choose a security module to enable at boot. If no
    security= boot parameter is specified, only the first LSM
    asking for registration will be loaded. An invalid security
    module name will be treated as if no module has been chosen.

    LSM modules must check now if they are allowed to register
    by calling security_module_enable(ops) first. Modify SELinux
    and SMACK to do so.

    Do not let SMACK register smackfs if it was not chosen on
    boot. Smackfs assumes that smack hooks are registered and
    the initial task security setup (swapper->security) is done.

    Signed-off-by: Ahmed S. Darwish
    Acked-by: James Morris

    Ahmed S. Darwish
     

13 Apr, 2008

1 commit

  • Smack doesn't have the need to create a private copy of the LSM "domain" when
    setting NetLabel security attributes like SELinux, however, the current
    NetLabel code requires a private copy of the LSM "domain". This patches fixes
    that by letting the LSM determine how it wants to pass the domain value.

    * NETLBL_SECATTR_DOMAIN_CPY
    The current behavior, NetLabel assumes that the domain value is a copy and
    frees it when done

    * NETLBL_SECATTR_DOMAIN
    New, Smack-friendly behavior, NetLabel assumes that the domain value is a
    reference to a string managed by the LSM and does not free it when done

    Signed-off-by: Paul Moore
    Acked-by: James Morris
    Signed-off-by: David S. Miller

    Paul Moore
     

25 Mar, 2008

1 commit

  • Older smackfs was parsing MAC rules by characters, thus a need of locking
    write sessions on open() was needed. This lock is no longer useful now since
    each rule is handled by a single write() call.

    This is also a bugfix since seq_open() was not called if an open() O_RDWR flag
    was given, leading to a seq_read() without an initialized seq_file, thus an
    Oops.

    Signed-off-by: Ahmed S. Darwish
    Reported-by: Jonathan Corbet
    Acked-by: Casey Schaufler
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ahmed S. Darwish
     

21 Mar, 2008

1 commit

  • The original justification for cap_task_kill() was as follows:

    check_kill_permission() does appropriate uid equivalence checks.
    However with file capabilities it becomes possible for an
    unprivileged user to execute a file with file capabilities
    resulting in a more privileged task with the same uid.

    However now that cap_task_kill() always returns 0 (permission
    granted) when p->uid==current->uid, the whole hook is worthless,
    and only likely to create more subtle problems in the corner cases
    where it might still be called but return -EPERM. Those cases
    are basically when uids are different but euid/suid is equivalent
    as per the check in check_kill_permission().

    One example of a still-broken application is 'at' for non-root users.

    This patch removes cap_task_kill().

    Signed-off-by: Serge Hallyn
    Acked-by: Andrew G. Morgan
    Earlier-version-tested-by: Luiz Fernando N. Capitulino
    Acked-by: Casey Schaufler
    Signed-off-by: Linus Torvalds

    Serge Hallyn
     

20 Mar, 2008

1 commit

  • In the SYSV ipc msgctl(),semctl(),shmctl() family, if the user passed *_INFO
    as the desired operation, no specific object is meant to be controlled and
    only system-wide information is returned. This leads to a NULL IPC object in
    the LSM hooks if the _INFO flag is given.

    Avoid dereferencing this NULL pointer in Smack ipc *ctl() methods.

    Signed-off-by: Ahmed S. Darwish
    Acked-by: Casey Schaufler
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ahmed S. Darwish
     

14 Mar, 2008

1 commit

  • Smackfs write() implementation does not put a higher bound on the number of
    bytes to copy from user-space. This may lead to a DOS attack if a malicious
    `count' field is given.

    Assure that given `count' is exactly the length needed for a /smack/load rule.
    In case of /smack/cipso where the length is relative, assure that `count'
    does not exceed the size needed for a buffer representing maximum possible
    number of CIPSO 2.2 categories.

    Signed-off-by: Ahmed S. Darwish
    Acked-by: Casey Schaufler
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ahmed S. Darwish
     

06 Mar, 2008

1 commit

  • Introduce new LSM interfaces to allow an FS to deal with their own mount
    options. This includes a new string parsing function exported from the
    LSM that an FS can use to get a security data blob and a new security
    data blob. This is particularly useful for an FS which uses binary
    mount data, like NFS, which does not pass strings into the vfs to be
    handled by the loaded LSM. Also fix a BUG() in both SELinux and SMACK
    when dealing with binary mount data. If the binary mount data is less
    than one page the copy_page() in security_sb_copy_data() can cause an
    illegal page fault and boom. Remove all NFSisms from the SELinux code
    since they were broken by past NFS changes.

    Signed-off-by: Eric Paris
    Acked-by: Stephen Smalley
    Acked-by: Casey Schaufler
    Signed-off-by: James Morris

    Eric Paris
     

24 Feb, 2008

1 commit

  • Update the Smack LSM to allow the registration of the capability "module"
    as a secondary LSM. Integrate the new hooks required for file based
    capabilities.

    Signed-off-by: Casey Schaufler
    Cc: Serge Hallyn
    Cc: Stephen Smalley
    Cc: Paul Moore
    Cc: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Casey Schaufler
     

19 Feb, 2008

1 commit

  • Smack uses CIPSO labeling, but allows for unlabeled packets by
    specifying an "ambient" label that is applied to incoming unlabeled
    packets.

    Because the other end of the connection may dislike IP options, and ssh
    is one know application that behaves thus, it is prudent to respond in
    kind.

    This patch changes the network labeling behavior such that an outgoing
    packet that would be given a CIPSO label that matches the ambient label
    is left unlabeled. An "unlbl" domain is added and the netlabel
    defaulting mechanism invoked rather than assuming that everything is
    CIPSO. Locking has been added around changes to the ambient label as
    the mechanisms used to do so are more involved.

    Signed-off-by: Casey Schaufler
    Acked-by: Paul Moore
    Signed-off-by: Linus Torvalds

    Casey Schaufler
     

15 Feb, 2008

1 commit

  • This is the central patch of a cleanup series. In most cases there is no good
    reason why someone would want to use a dentry for itself. This series reflects
    that fact and embeds a struct path into nameidata.

    Together with the other patches of this series
    - it enforced the correct order of getting/releasing the reference count on
    pairs
    - it prepares the VFS for stacking support since it is essential to have a
    struct path in every place where the stack can be traversed
    - it reduces the overall code size:

    without patch series:
    text data bss dec hex filename
    5321639 858418 715768 6895825 6938d1 vmlinux

    with patch series:
    text data bss dec hex filename
    5320026 858418 715768 6894212 693284 vmlinux

    This patch:

    Switch from nd->{dentry,mnt} to nd->path.{dentry,mnt} everywhere.

    [akpm@linux-foundation.org: coding-style fixes]
    [akpm@linux-foundation.org: fix cifs]
    [akpm@linux-foundation.org: fix smack]
    Signed-off-by: Jan Blunck
    Signed-off-by: Andreas Gruenbacher
    Acked-by: Christoph Hellwig
    Cc: Al Viro
    Cc: Casey Schaufler
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Blunck
     

14 Feb, 2008

1 commit

  • There's a small problem with smack and NFS. A similar report was also
    sent here: http://lkml.org/lkml/2007/10/27/85

    I've also added similar checks in inode_{get/set}security(). Cheating from
    SELinux post_create_socket(), it does the same.

    [akpm@linux-foundation.org: remove uneeded BUG_ON()]
    Signed-off-by: Ahmed S. Darwish
    Acked-by: Casey Schaufler
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ahmed S. Darwish
     

06 Feb, 2008

1 commit

  • Smack is the Simplified Mandatory Access Control Kernel.

    Smack implements mandatory access control (MAC) using labels
    attached to tasks and data containers, including files, SVIPC,
    and other tasks. Smack is a kernel based scheme that requires
    an absolute minimum of application support and a very small
    amount of configuration data.

    Smack uses extended attributes and
    provides a set of general mount options, borrowing technics used
    elsewhere. Smack uses netlabel for CIPSO labeling. Smack provides
    a pseudo-filesystem smackfs that is used for manipulation of
    system Smack attributes.

    The patch, patches for ls and sshd, a README, a startup script,
    and x86 binaries for ls and sshd are also available on

    http://www.schaufler-ca.com

    Development has been done using Fedora Core 7 in a virtual machine
    environment and on an old Sony laptop.

    Smack provides mandatory access controls based on the label attached
    to a task and the label attached to the object it is attempting to
    access. Smack labels are deliberately short (1-23 characters) text
    strings. Single character labels using special characters are reserved
    for system use. The only operation applied to Smack labels is equality
    comparison. No wildcards or expressions, regular or otherwise, are
    used. Smack labels are composed of printable characters and may not
    include "/".

    A file always gets the Smack label of the task that created it.

    Smack defines and uses these labels:

    "*" - pronounced "star"
    "_" - pronounced "floor"
    "^" - pronounced "hat"
    "?" - pronounced "huh"

    The access rules enforced by Smack are, in order:

    1. Any access requested by a task labeled "*" is denied.
    2. A read or execute access requested by a task labeled "^"
    is permitted.
    3. A read or execute access requested on an object labeled "_"
    is permitted.
    4. Any access requested on an object labeled "*" is permitted.
    5. Any access requested by a task on an object with the same
    label is permitted.
    6. Any access requested that is explicitly defined in the loaded
    rule set is permitted.
    7. Any other access is denied.

    Rules may be explicitly defined by writing subject,object,access
    triples to /smack/load.

    Smack rule sets can be easily defined that describe Bell&LaPadula
    sensitivity, Biba integrity, and a variety of interesting
    configurations. Smack rule sets can be modified on the fly to
    accommodate changes in the operating environment or even the time
    of day.

    Some practical use cases:

    Hierarchical levels. The less common of the two usual uses
    for MLS systems is to define hierarchical levels, often
    unclassified, confidential, secret, and so on. To set up smack
    to support this, these rules could be defined:

    C Unclass rx
    S C rx
    S Unclass rx
    TS S rx
    TS C rx
    TS Unclass rx

    A TS process can read S, C, and Unclass data, but cannot write it.
    An S process can read C and Unclass. Note that specifying that
    TS can read S and S can read C does not imply TS can read C, it
    has to be explicitly stated.

    Non-hierarchical categories. This is the more common of the
    usual uses for an MLS system. Since the default rule is that a
    subject cannot access an object with a different label no
    access rules are required to implement compartmentalization.

    A case that the Bell & LaPadula policy does not allow is demonstrated
    with this Smack access rule:

    A case that Bell&LaPadula does not allow that Smack does:

    ESPN ABC r
    ABC ESPN r

    On my portable video device I have two applications, one that
    shows ABC programming and the other ESPN programming. ESPN wants
    to show me sport stories that show up as news, and ABC will
    only provide minimal information about a sports story if ESPN
    is covering it. Each side can look at the other's info, neither
    can change the other. Neither can see what FOX is up to, which
    is just as well all things considered.

    Another case that I especially like:

    SatData Guard w
    Guard Publish w

    A program running with the Guard label opens a UDP socket and
    accepts messages sent by a program running with a SatData label.
    The Guard program inspects the message to ensure it is wholesome
    and if it is sends it to a program running with the Publish label.
    This program then puts the information passed in an appropriate
    place. Note that the Guard program cannot write to a Publish
    file system object because file system semanitic require read as
    well as write.

    The four cases (categories, levels, mutual read, guardbox) here
    are all quite real, and problems I've been asked to solve over
    the years. The first two are easy to do with traditonal MLS systems
    while the last two you can't without invoking privilege, at least
    for a while.

    Signed-off-by: Casey Schaufler
    Cc: Joshua Brindle
    Cc: Paul Moore
    Cc: Stephen Smalley
    Cc: Chris Wright
    Cc: James Morris
    Cc: "Ahmed S. Darwish"
    Cc: Andrew G. Morgan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Casey Schaufler