1. 30 8月, 2014 2 次提交
  2. 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
  3. 26 8月, 2014 1 次提交
  4. 09 8月, 2014 3 次提交
    • K
      Smack: remove unneeded NULL-termination from securtity label · da1b6356
      Konstantin Khlebnikov 提交于
      Values of extended attributes are stored as binary blobs. NULL-termination
      of them isn't required. It just wastes disk space and confuses command-line
      tools like getfattr because they have to print that zero byte at the end.
      
      This patch removes terminating zero byte from initial security label in
      smack_inode_init_security and cuts it out in function smack_inode_getsecurity
      which is used by syscall getxattr. This change seems completely safe, because
      function smk_parse_smack ignores everything after first zero byte.
      Signed-off-by: NKonstantin Khlebnikov <k.khlebnikov@samsung.com>
      da1b6356
    • 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
    • K
      Smack: fix behavior of smack_inode_listsecurity · fd5c9d23
      Konstantin Khlebnikov 提交于
      Security operation ->inode_listsecurity is used for generating list of
      available extended attributes for syscall listxattr. Currently it's used
      only in nfs4 or if filesystem doesn't provide i_op->listxattr.
      
      The list is the set of NULL-terminated names, one after the other.
      This method must include zero byte at the and into result.
      
      Also this function must return length even if string does not fit into
      output buffer or it is NULL, see similar method in selinux and man listxattr.
      Signed-off-by: NKonstantin Khlebnikov <k.khlebnikov@samsung.com>
      fd5c9d23
  5. 01 8月, 2014 1 次提交
  6. 01 5月, 2014 1 次提交
  7. 23 4月, 2014 1 次提交
  8. 12 4月, 2014 8 次提交
  9. 15 3月, 2014 2 次提交
  10. 14 1月, 2014 1 次提交
  11. 01 1月, 2014 2 次提交
    • C
      Smack: File receive audit correction · 4482a44f
      Casey Schaufler 提交于
      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.gitSigned-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      4482a44f
    • C
      Smack: Rationalize mount restrictions · 24ea1b6e
      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.gitSigned-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      24ea1b6e
  12. 24 12月, 2013 1 次提交
  13. 20 12月, 2013 1 次提交
  14. 29 10月, 2013 1 次提交
  15. 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
  16. 06 8月, 2013 1 次提交
  17. 02 8月, 2013 2 次提交
    • C
      Smack: network label match fix · 677264e8
      Casey Schaufler 提交于
      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.gitSigned-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      677264e8
    • T
      security: smack: add a hash table to quicken smk_find_entry() · 4d7cf4a1
      Tomasz Stanislawski 提交于
      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: NTomasz Stanislawski <t.stanislaws@samsung.com>
      4d7cf4a1
  18. 25 7月, 2013 1 次提交
  19. 09 6月, 2013 1 次提交
  20. 29 5月, 2013 3 次提交
  21. 20 3月, 2013 1 次提交
    • I
      Fix NULL pointer dereference in smack_inode_unlink() and smack_inode_rmdir() · cdb56b60
      Igor Zhbanov 提交于
      This patch fixes kernel Oops because of wrong common_audit_data type
      in smack_inode_unlink() and smack_inode_rmdir().
      
      When SMACK security module is enabled and SMACK logging is on (/smack/logging
      is not zero) and you try to delete the file which
      1) you cannot delete due to SMACK rules and logging of failures is on
      or
      2) you can delete and logging of success is on,
      
      you will see following:
      
      	Unable to handle kernel NULL pointer dereference at virtual address 000002d7
      
      	[<...>] (strlen+0x0/0x28)
      	[<...>] (audit_log_untrustedstring+0x14/0x28)
      	[<...>] (common_lsm_audit+0x108/0x6ac)
      	[<...>] (smack_log+0xc4/0xe4)
      	[<...>] (smk_curacc+0x80/0x10c)
      	[<...>] (smack_inode_unlink+0x74/0x80)
      	[<...>] (security_inode_unlink+0x2c/0x30)
      	[<...>] (vfs_unlink+0x7c/0x100)
      	[<...>] (do_unlinkat+0x144/0x16c)
      
      The function smack_inode_unlink() (and smack_inode_rmdir()) need
      to log two structures of different types. First of all it does:
      
      	smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
      	smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
      
      This will set common audit data type to LSM_AUDIT_DATA_DENTRY
      and store dentry for auditing (by function smk_curacc(), which in turn calls
      dump_common_audit_data(), which is actually uses provided data and logs it).
      
      	/*
      	 * You need write access to the thing you're unlinking
      	 */
      	rc = smk_curacc(smk_of_inode(ip), MAY_WRITE, &ad);
      	if (rc == 0) {
      		/*
      		 * You also need write access to the containing directory
      		 */
      
      Then this function wants to log anoter data:
      
      		smk_ad_setfield_u_fs_path_dentry(&ad, NULL);
      		smk_ad_setfield_u_fs_inode(&ad, dir);
      
      The function sets inode field, but don't change common_audit_data type.
      
      		rc = smk_curacc(smk_of_inode(dir), MAY_WRITE, &ad);
      	}
      
      So the dump_common_audit() function incorrectly interprets inode structure
      as dentry, and Oops will happen.
      
      This patch reinitializes common_audit_data structures with correct type.
      Also I removed unneeded
      	smk_ad_setfield_u_fs_path_dentry(&ad, NULL);
      initialization, because both dentry and inode pointers are stored
      in the same union.
      Signed-off-by: NIgor Zhbanov <i.zhbanov@samsung.com>
      Signed-off-by: NKyungmin Park <kyungmin.park@samsung.com>
      cdb56b60
  22. 23 2月, 2013 1 次提交
  23. 12 10月, 2012 1 次提交
  24. 19 9月, 2012 2 次提交
    • C
      Smack: setprocattr memory leak fix · 46a2f3b9
      Casey Schaufler 提交于
      The data structure allocations being done in prepare_creds
      are duplicated in smack_setprocattr. This results in the
      structure allocated in prepare_creds being orphaned and
      never freed. The duplicate code is removed from
      smack_setprocattr.
      
      Targeted for git://git.gitorious.org/smack-next/kernel.gitSigned-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      46a2f3b9
    • C
      Smack: remove task_wait() hook. · c00bedb3
      Casey Schaufler 提交于
      On 12/20/2011 11:20 PM, Jarkko Sakkinen wrote:
      > Allow SIGCHLD to be passed to child process without
      > explicit policy. This will help to keep the access
      > control policy simple and easily maintainable with
      > complex applications that require use of multiple
      > security contexts. It will also help to keep them
      > as isolated as possible.
      >
      > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@intel.com>
      
      I have a slightly different version that applies to the
      current smack-next tree.
      
      Allow SIGCHLD to be passed to child process without
      explicit policy. This will help to keep the access
      control policy simple and easily maintainable with
      complex applications that require use of multiple
      security contexts. It will also help to keep them
      as isolated as possible.
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      
       security/smack/smack_lsm.c |   37 ++++++++-----------------------------
       1 files changed, 8 insertions(+), 29 deletions(-)
      c00bedb3