1. 15 5月, 2015 1 次提交
    • L
      smack: pass error code through pointers · e774ad68
      Lukasz Pawelczyk 提交于
      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: NLukasz Pawelczyk <l.pawelczyk@samsung.com>
      e774ad68
  2. 12 5月, 2015 1 次提交
    • C
      LSM: Switch to lists of hooks · b1d9e6b0
      Casey Schaufler 提交于
      Instead of using a vector of security operations
      with explicit, special case stacking of the capability
      and yama hooks use lists of hooks with capability and
      yama hooks included as appropriate.
      
      The security_operations structure is no longer required.
      Instead, there is a union of the function pointers that
      allows all the hooks lists to use a common mechanism for
      list management while retaining typing. Each module
      supplies an array describing the hooks it provides instead
      of a sparsely populated security_operations structure.
      The description includes the element that gets put on
      the hook list, avoiding the issues surrounding individual
      element allocation.
      
      The method for registering security modules is changed to
      reflect the information available. The method for removing
      a module, currently only used by SELinux, has also changed.
      It should be generic now, however if there are potential
      race conditions based on ordering of hook removal that needs
      to be addressed by the calling module.
      
      The security hooks are called from the lists and the first
      failure is returned.
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      Acked-by: NJohn Johansen <john.johansen@canonical.com>
      Acked-by: NKees Cook <keescook@chromium.org>
      Acked-by: NPaul Moore <paul@paul-moore.com>
      Acked-by: NStephen Smalley <sds@tycho.nsa.gov>
      Acked-by: NTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: NJames Morris <james.l.morris@oracle.com>
      b1d9e6b0
  3. 16 4月, 2015 1 次提交
  4. 24 3月, 2015 2 次提交
    • P
      smack: Fix gcc warning from unused smack_syslog_lock mutex in smackfs.c · f43b65ba
      Paul Gortmaker 提交于
      In commit 00f84f3f ("Smack: Make the
      syslog control configurable") this mutex was added, but the rest of
      the final commit never actually made use of it, resulting in:
      
       In file included from include/linux/mutex.h:29:0,
                        from include/linux/notifier.h:13,
                        from include/linux/memory_hotplug.h:6,
                        from include/linux/mmzone.h:821,
                        from include/linux/gfp.h:5,
                        from include/linux/slab.h:14,
                        from include/linux/security.h:27,
                        from security/smack/smackfs.c:21:
       security/smack/smackfs.c:63:21: warning: ‘smack_syslog_lock’ defined but not used [-Wunused-variable]
        static DEFINE_MUTEX(smack_syslog_lock);
                            ^
      
      A git grep shows no other instances/references to smack_syslog_lock.
      Delete it, assuming that the mutex addition was just a leftover from
      an earlier work in progress version of the change.
      Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      f43b65ba
    • C
      Smack: Allow an unconfined label in bringup mode · bf4b2fee
      Casey Schaufler 提交于
      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: NCasey Schaufler <casey@schaufler-ca.com>
      bf4b2fee
  5. 30 8月, 2014 1 次提交
  6. 29 8月, 2014 1 次提交
    • C
      Smack: Bring-up access mode · d166c802
      Casey Schaufler 提交于
      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: NCasey Schaufler <casey@schaufler-ca.com>
      d166c802
  7. 09 8月, 2014 1 次提交
    • K
      Smack: handle zero-length security labels without panic · b862e561
      Konstantin Khlebnikov 提交于
      Zero-length security labels are invalid but kernel should handle them.
      
      This patch fixes kernel panic after setting zero-length security labels:
      # attr -S -s "SMACK64" -V "" file
      
      And after writing zero-length string into smackfs files syslog and onlycp:
      # python -c 'import os; os.write(1, "")' > /smack/syslog
      
      The problem is caused by brain-damaged logic in function smk_parse_smack()
      which takes pointer to buffer and its length but if length below or equal zero
      it thinks that the buffer is zero-terminated. Unfortunately callers of this
      function are widely used and proper fix requires serious refactoring.
      Signed-off-by: NKonstantin Khlebnikov <k.khlebnikov@samsung.com>
      b862e561
  8. 01 8月, 2014 1 次提交
  9. 07 5月, 2014 1 次提交
  10. 12 4月, 2014 1 次提交
  11. 24 12月, 2013 2 次提交
  12. 12 12月, 2013 1 次提交
  13. 19 10月, 2013 1 次提交
    • C
      Smack: Implement lock security mode · c0ab6e56
      Casey Schaufler 提交于
      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.gitSigned-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      c0ab6e56
  14. 13 8月, 2013 1 次提交
    • R
      Smack: parse multiple rules per write to load2, up to PAGE_SIZE-1 bytes · 10289b0f
      Rafal Krypa 提交于
      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: NRafal Krypa <r.krypa@samsung.com>
      10289b0f
  15. 02 8月, 2013 2 次提交
  16. 04 6月, 2013 1 次提交
  17. 29 5月, 2013 1 次提交
  18. 03 4月, 2013 1 次提交
  19. 20 3月, 2013 2 次提交
  20. 15 12月, 2012 1 次提交
  21. 19 9月, 2012 1 次提交
  22. 30 7月, 2012 1 次提交
  23. 14 7月, 2012 4 次提交
  24. 15 5月, 2012 1 次提交
    • C
      Smack: allow for significantly longer Smack labels v4 · f7112e6c
      Casey Schaufler 提交于
      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: NCasey Schaufler <casey@schaufler-ca.com>
      f7112e6c
  25. 18 4月, 2012 1 次提交
  26. 12 11月, 2011 1 次提交
    • C
      Smack: smackfs cipso seq read repair · 40809565
      Casey Schaufler 提交于
      Commit 272cd7a8 introduced
      a change to the way rule lists are handled and reported in
      the smackfs filesystem. One of the issues addressed had to
      do with the termination of read requests on /smack/load.
      This change introduced a error in /smack/cipso, which shares
      some of the same list processing code.
      
      This patch updates all the file access list handling in
      smackfs to use the code introduced for /smack/load.
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      40809565
  27. 21 10月, 2011 1 次提交
  28. 19 10月, 2011 1 次提交
  29. 13 10月, 2011 4 次提交
    • J
      Smack: fix for /smack/access output, use string instead of byte · f8859d98
      Jarkko Sakkinen 提交于
      Small fix for the output of access SmackFS file. Use string
      is instead of byte. Makes it easier to extend API if it is
      needed.
      Signed-off-by: NJarkko Sakkinen <jarkko.sakkinen@intel.com>
      f8859d98
    • C
      Smack: Clean up comments · ce8a4321
      Casey Schaufler 提交于
      There are a number of comments in the Smack code that
      are either malformed or include code. This patch cleans
      them up.
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      ce8a4321
    • C
      Smack: Rule list lookup performance · 272cd7a8
      Casey Schaufler 提交于
      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: NCasey Schaufler <casey@schaufler-ca.com>
      272cd7a8
    • J
      Smack: check permissions from user space (v2) · 828716c2
      Jarkko Sakkinen 提交于
      Adds a new file into SmackFS called 'access'. Wanted
      Smack permission is written into /smack/access.
      After that result can be read from the opened file.
      If access applies result contains 1 and otherwise
      0. File access is protected from race conditions
      by using simple_transaction_get()/set() API.
      
      Fixes from the previous version:
      - Removed smack.h changes, refactoring left-over
      from previous version.
      - Removed #include <linux/smack.h>, refactoring
      left-over from previous version.
      Signed-off-by: NJarkko Sakkinen <jarkko.sakkinen@intel.com>
      Signed-off-by: NCasey Schaufler <cschaufler@cschaufler-intel.(none)>
      828716c2
  30. 31 3月, 2011 1 次提交