1. 10 4月, 2013 1 次提交
  2. 04 3月, 2013 2 次提交
    • K
      eCryptfs: allow userspace messaging to be disabled · 290502be
      Kees Cook 提交于
      When the userspace messaging (for the less common case of userspace key
      wrap/unwrap via ecryptfsd) is not needed, allow eCryptfs to build with
      it removed. This saves on kernel code size and reduces potential attack
      surface by removing the /dev/ecryptfs node.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NTyler Hicks <tyhicks@canonical.com>
      290502be
    • E
      fs: Limit sys_mount to only request filesystem modules. · 7f78e035
      Eric W. Biederman 提交于
      Modify the request_module to prefix the file system type with "fs-"
      and add aliases to all of the filesystems that can be built as modules
      to match.
      
      A common practice is to build all of the kernel code and leave code
      that is not commonly needed as modules, with the result that many
      users are exposed to any bug anywhere in the kernel.
      
      Looking for filesystems with a fs- prefix limits the pool of possible
      modules that can be loaded by mount to just filesystems trivially
      making things safer with no real cost.
      
      Using aliases means user space can control the policy of which
      filesystem modules are auto-loaded by editing /etc/modprobe.d/*.conf
      with blacklist and alias directives.  Allowing simple, safe,
      well understood work-arounds to known problematic software.
      
      This also addresses a rare but unfortunate problem where the filesystem
      name is not the same as it's module name and module auto-loading
      would not work.  While writing this patch I saw a handful of such
      cases.  The most significant being autofs that lives in the module
      autofs4.
      
      This is relevant to user namespaces because we can reach the request
      module in get_fs_type() without having any special permissions, and
      people get uncomfortable when a user specified string (in this case
      the filesystem type) goes all of the way to request_module.
      
      After having looked at this issue I don't think there is any
      particular reason to perform any filtering or permission checks beyond
      making it clear in the module request that we want a filesystem
      module.  The common pattern in the kernel is to call request_module()
      without regards to the users permissions.  In general all a filesystem
      module does once loaded is call register_filesystem() and go to sleep.
      Which means there is not much attack surface exposed by loading a
      filesytem module unless the filesystem is mounted.  In a user
      namespace filesystems are not mounted unless .fs_flags = FS_USERNS_MOUNT,
      which most filesystems do not set today.
      Acked-by: NSerge Hallyn <serge.hallyn@canonical.com>
      Acked-by: NKees Cook <keescook@chromium.org>
      Reported-by: NKees Cook <keescook@google.com>
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      7f78e035
  3. 28 2月, 2013 2 次提交
    • S
      hlist: drop the node parameter from iterators · b67bfe0d
      Sasha Levin 提交于
      I'm not sure why, but the hlist for each entry iterators were conceived
      
              list_for_each_entry(pos, head, member)
      
      The hlist ones were greedy and wanted an extra parameter:
      
              hlist_for_each_entry(tpos, pos, head, member)
      
      Why did they need an extra pos parameter? I'm not quite sure. Not only
      they don't really need it, it also prevents the iterator from looking
      exactly like the list iterator, which is unfortunate.
      
      Besides the semantic patch, there was some manual work required:
      
       - Fix up the actual hlist iterators in linux/list.h
       - Fix up the declaration of other iterators based on the hlist ones.
       - A very small amount of places were using the 'node' parameter, this
       was modified to use 'obj->member' instead.
       - Coccinelle didn't handle the hlist_for_each_entry_safe iterator
       properly, so those had to be fixed up manually.
      
      The semantic patch which is mostly the work of Peter Senna Tschudin is here:
      
      @@
      iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
      
      type T;
      expression a,c,d,e;
      identifier b;
      statement S;
      @@
      
      -T b;
          <+... when != b
      (
      hlist_for_each_entry(a,
      - b,
      c, d) S
      |
      hlist_for_each_entry_continue(a,
      - b,
      c) S
      |
      hlist_for_each_entry_from(a,
      - b,
      c) S
      |
      hlist_for_each_entry_rcu(a,
      - b,
      c, d) S
      |
      hlist_for_each_entry_rcu_bh(a,
      - b,
      c, d) S
      |
      hlist_for_each_entry_continue_rcu_bh(a,
      - b,
      c) S
      |
      for_each_busy_worker(a, c,
      - b,
      d) S
      |
      ax25_uid_for_each(a,
      - b,
      c) S
      |
      ax25_for_each(a,
      - b,
      c) S
      |
      inet_bind_bucket_for_each(a,
      - b,
      c) S
      |
      sctp_for_each_hentry(a,
      - b,
      c) S
      |
      sk_for_each(a,
      - b,
      c) S
      |
      sk_for_each_rcu(a,
      - b,
      c) S
      |
      sk_for_each_from
      -(a, b)
      +(a)
      S
      + sk_for_each_from(a) S
      |
      sk_for_each_safe(a,
      - b,
      c, d) S
      |
      sk_for_each_bound(a,
      - b,
      c) S
      |
      hlist_for_each_entry_safe(a,
      - b,
      c, d, e) S
      |
      hlist_for_each_entry_continue_rcu(a,
      - b,
      c) S
      |
      nr_neigh_for_each(a,
      - b,
      c) S
      |
      nr_neigh_for_each_safe(a,
      - b,
      c, d) S
      |
      nr_node_for_each(a,
      - b,
      c) S
      |
      nr_node_for_each_safe(a,
      - b,
      c, d) S
      |
      - for_each_gfn_sp(a, c, d, b) S
      + for_each_gfn_sp(a, c, d) S
      |
      - for_each_gfn_indirect_valid_sp(a, c, d, b) S
      + for_each_gfn_indirect_valid_sp(a, c, d) S
      |
      for_each_host(a,
      - b,
      c) S
      |
      for_each_host_safe(a,
      - b,
      c, d) S
      |
      for_each_mesh_entry(a,
      - b,
      c, d) S
      )
          ...+>
      
      [akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
      [akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
      [akpm@linux-foundation.org: checkpatch fixes]
      [akpm@linux-foundation.org: fix warnings]
      [akpm@linux-foudnation.org: redo intrusive kvm changes]
      Tested-by: NPeter Senna Tschudin <peter.senna@gmail.com>
      Acked-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Signed-off-by: NSasha Levin <sasha.levin@oracle.com>
      Cc: Wu Fengguang <fengguang.wu@intel.com>
      Cc: Marcelo Tosatti <mtosatti@redhat.com>
      Cc: Gleb Natapov <gleb@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b67bfe0d
    • T
      eCryptfs: Fix redundant error check on ecryptfs_find_daemon_by_euid() · 1111eae9
      Tyler Hicks 提交于
      It is sufficient to check the return code of
      ecryptfs_find_daemon_by_euid(). If it returns 0, it always sets the
      daemon pointer to point to a valid ecryptfs_daemon.
      Signed-off-by: NTyler Hicks <tyhicks@canonical.com>
      Reported-by: NKees Cook <keescook@chromium.org>
      1111eae9
  4. 26 2月, 2013 2 次提交
  5. 23 2月, 2013 1 次提交
  6. 13 2月, 2013 2 次提交
  7. 29 1月, 2013 1 次提交
  8. 18 1月, 2013 3 次提交
  9. 12 1月, 2013 1 次提交
  10. 19 12月, 2012 2 次提交
  11. 08 11月, 2012 1 次提交
    • L
      eCryptfs: Avoid unnecessary disk read and data decryption during writing · e4bc6522
      Li Wang 提交于
      ecryptfs_write_begin grabs a page from page cache for writing.
      If the page contains invalid data, or data older than the
      counterpart on the disk, eCryptfs will read out the
      corresponing data from the disk into the page, decrypt them,
      then perform writing. However, for this page, if the length
      of the data to be written into is equal to page size,
      that means the whole page of data will be overwritten,
      in which case, it does not matter whatever the data were before,
      it is beneficial to perform writing directly rather than bothering
      to read and decrypt first.
      
      With this optimization, according to our test on a machine with
      Intel Core 2 Duo processor, iozone 'write' operation on an existing
      file with write size being multiple of page size will enjoy a steady
      3x speedup.
      Signed-off-by: NLi Wang <wangli@kylinos.com.cn>
      Signed-off-by: NYunchuan Wen <wenyunchuan@kylinos.com.cn>
      Signed-off-by: NTyler Hicks <tyhicks@canonical.com>
      e4bc6522
  12. 03 10月, 2012 1 次提交
  13. 21 9月, 2012 1 次提交
  14. 15 9月, 2012 3 次提交
    • T
      eCryptfs: Copy up attributes of the lower target inode after rename · 8335eafc
      Tyler Hicks 提交于
      After calling into the lower filesystem to do a rename, the lower target
      inode's attributes were not copied up to the eCryptfs target inode. This
      resulted in the eCryptfs target inode staying around, rather than being
      evicted, because i_nlink was not updated for the eCryptfs inode. This
      also meant that eCryptfs didn't do the final iput() on the lower target
      inode so it stayed around, as well. This would result in a failure to
      free up space occupied by the target file in the rename() operation.
      Both target inodes would eventually be evicted when the eCryptfs
      filesystem was unmounted.
      
      This patch calls fsstack_copy_attr_all() after the lower filesystem
      does its ->rename() so that important inode attributes, such as i_nlink,
      are updated at the eCryptfs layer. ecryptfs_evict_inode() is now called
      and eCryptfs can drop its final reference on the lower inode.
      
      http://launchpad.net/bugs/561129Signed-off-by: NTyler Hicks <tyhicks@canonical.com>
      Tested-by: NColin Ian King <colin.king@canonical.com>
      Cc: <stable@vger.kernel.org> [2.6.39+]
      8335eafc
    • T
      eCryptfs: Call lower ->flush() from ecryptfs_flush() · 64e6651d
      Tyler Hicks 提交于
      Since eCryptfs only calls fput() on the lower file in
      ecryptfs_release(), eCryptfs should call the lower filesystem's
      ->flush() from ecryptfs_flush().
      
      If the lower filesystem implements ->flush(), then eCryptfs should try
      to flush out any dirty pages prior to calling the lower ->flush(). If
      the lower filesystem does not implement ->flush(), then eCryptfs has no
      need to do anything in ecryptfs_flush() since dirty pages are now
      written out to the lower filesystem in ecryptfs_release().
      Signed-off-by: NTyler Hicks <tyhicks@canonical.com>
      64e6651d
    • T
      eCryptfs: Write out all dirty pages just before releasing the lower file · 7149f255
      Tyler Hicks 提交于
      Fixes a regression caused by:
      
      821f7494 eCryptfs: Revert to a writethrough cache model
      
      That patch reverted some code (specifically, 32001d6f) that was
      necessary to properly handle open() -> mmap() -> close() -> dirty pages
      -> munmap(), because the lower file could be closed before the dirty
      pages are written out.
      
      Rather than reapplying 32001d6f, this approach is a better way of
      ensuring that the lower file is still open in order to handle writing
      out the dirty pages. It is called from ecryptfs_release(), while we have
      a lock on the lower file pointer, just before the lower file gets the
      final fput() and we overwrite the pointer.
      
      https://launchpad.net/bugs/1047261Signed-off-by: NTyler Hicks <tyhicks@canonical.com>
      Reported-by: NArtemy Tregubenko <me@arty.name>
      Tested-by: NArtemy Tregubenko <me@arty.name>
      Tested-by: NColin Ian King <colin.king@canonical.com>
      7149f255
  15. 30 7月, 2012 2 次提交
  16. 23 7月, 2012 3 次提交
  17. 14 7月, 2012 7 次提交
  18. 09 7月, 2012 5 次提交
    • T
      eCryptfs: Initialize empty lower files when opening them · e3ccaa97
      Tyler Hicks 提交于
      Historically, eCryptfs has only initialized lower files in the
      ecryptfs_create() path. Lower file initialization is the act of writing
      the cryptographic metadata from the inode's crypt_stat to the header of
      the file. The ecryptfs_open() path already expects that metadata to be
      in the header of the file.
      
      A number of users have reported empty lower files in beneath their
      eCryptfs mounts. Most of the causes for those empty files being left
      around have been addressed, but the presence of empty files causes
      problems due to the lack of proper cryptographic metadata.
      
      To transparently solve this problem, this patch initializes empty lower
      files in the ecryptfs_open() error path. If the metadata is unreadable
      due to the lower inode size being 0, plaintext passthrough support is
      not in use, and the metadata is stored in the header of the file (as
      opposed to the user.ecryptfs extended attribute), the lower file will be
      initialized.
      
      The number of nested conditionals in ecryptfs_open() was getting out of
      hand, so a helper function was created. To avoid the same nested
      conditional problem, the conditional logic was reversed inside of the
      helper function.
      
      https://launchpad.net/bugs/911507Signed-off-by: NTyler Hicks <tyhicks@canonical.com>
      Cc: John Johansen <john.johansen@canonical.com>
      Cc: Colin Ian King <colin.king@canonical.com>
      e3ccaa97
    • T
      eCryptfs: Unlink lower inode when ecryptfs_create() fails · 8bc2d3cf
      Tyler Hicks 提交于
      ecryptfs_create() creates a lower inode, allocates an eCryptfs inode,
      initializes the eCryptfs inode and cryptographic metadata attached to
      the inode, and then writes the metadata to the header of the file.
      
      If an error was to occur after the lower inode was created, an empty
      lower file would be left in the lower filesystem. This is a problem
      because ecryptfs_open() refuses to open any lower files which do not
      have the appropriate metadata in the file header.
      
      This patch properly unlinks the lower inode when an error occurs in the
      later stages of ecryptfs_create(), reducing the chance that an empty
      lower file will be left in the lower filesystem.
      
      https://launchpad.net/bugs/872905Signed-off-by: NTyler Hicks <tyhicks@canonical.com>
      Cc: John Johansen <john.johansen@canonical.com>
      Cc: Colin Ian King <colin.king@canonical.com>
      8bc2d3cf
    • T
      eCryptfs: Make all miscdev functions use daemon ptr in file private_data · 2ecaf55d
      Tyler Hicks 提交于
      Now that a pointer to a valid struct ecryptfs_daemon is stored in the
      private_data of an opened /dev/ecryptfs file, the remaining miscdev
      functions can utilize the pointer rather than looking up the
      ecryptfs_daemon at the beginning of each operation.
      
      The security model of /dev/ecryptfs is simplified a little bit with this
      patch. Upon opening /dev/ecryptfs, a per-user ecryptfs_daemon is
      registered. Another daemon cannot be registered for that user until the
      last file reference is released. During the lifetime of the
      ecryptfs_daemon, access checks are not performed on the /dev/ecryptfs
      operations because it is assumed that the application securely handles
      the opened file descriptor and does not unintentionally leak it to
      processes that are not trusted.
      Signed-off-by: NTyler Hicks <tyhicks@canonical.com>
      Cc: Sasha Levin <levinsasha928@gmail.com>
      2ecaf55d
    • T
      eCryptfs: Remove unused messaging declarations and function · 56696886
      Tyler Hicks 提交于
      These are no longer needed.
      Signed-off-by: NTyler Hicks <tyhicks@canonical.com>
      Cc: Sasha Levin <levinsasha928@gmail.com>
      56696886
    • T
      eCryptfs: Copy up POSIX ACL and read-only flags from lower mount · 069ddcda
      Tyler Hicks 提交于
      When the eCryptfs mount options do not include '-o acl', but the lower
      filesystem's mount options do include 'acl', the MS_POSIXACL flag is not
      flipped on in the eCryptfs super block flags. This flag is what the VFS
      checks in do_last() when deciding if the current umask should be applied
      to a newly created inode's mode or not. When a default POSIX ACL mask is
      set on a directory, the current umask is incorrectly applied to new
      inodes created in the directory. This patch ignores the MS_POSIXACL flag
      passed into ecryptfs_mount() and sets the flag on the eCryptfs super
      block depending on the flag's presence on the lower super block.
      
      Additionally, it is incorrect to allow a writeable eCryptfs mount on top
      of a read-only lower mount. This missing check did not allow writes to
      the read-only lower mount because permissions checks are still performed
      on the lower filesystem's objects but it is best to simply not allow a
      rw mount on top of ro mount. However, a ro eCryptfs mount on top of a rw
      mount is valid and still allowed.
      
      https://launchpad.net/bugs/1009207Signed-off-by: NTyler Hicks <tyhicks@canonical.com>
      Reported-by: NStefan Beller <stefanbeller@googlemail.com>
      Cc: John Johansen <john.johansen@canonical.com>
      069ddcda