1. 22 4月, 2009 5 次提交
    • T
      eCryptfs: Remove ecryptfs_unlink_sigs warnings · e77cc8d2
      Tyler Hicks 提交于
      A feature was added to the eCryptfs umount helper to automatically
      unlink the keys used for an eCryptfs mount from the kernel keyring upon
      umount.  This patch keeps the unrecognized mount option warnings for
      ecryptfs_unlink_sigs out of the logs.
      Signed-off-by: NTyler Hicks <tyhicks@linux.vnet.ibm.com>
      e77cc8d2
    • T
      eCryptfs: Fix data corruption when using ecryptfs_passthrough · 13a791b4
      Tyler Hicks 提交于
      ecryptfs_passthrough is a mount option that allows eCryptfs to allow
      data to be written to non-eCryptfs files in the lower filesystem.  The
      passthrough option was causing data corruption due to it not always
      being treated as a non-eCryptfs file.
      
      The first 8 bytes of an eCryptfs file contains the decrypted file size.
      This value was being written to the non-eCryptfs files, too.  Also,
      extra 0x00 characters were being written to make the file size a
      multiple of PAGE_CACHE_SIZE.
      Signed-off-by: NTyler Hicks <tyhicks@linux.vnet.ibm.com>
      13a791b4
    • T
      eCryptfs: Print FNEK sig properly in /proc/mounts · 3a5203ab
      Tyler Hicks 提交于
      The filename encryption key signature is not properly displayed in
      /proc/mounts.  The "ecryptfs_sig=" mount option name is displayed for
      all global authentication tokens, included those for filename keys.
      
      This patch checks the global authentication token flags to determine if
      the key is a FEKEK or FNEK and prints the appropriate mount option name
      before the signature.
      Signed-off-by: NTyler Hicks <tyhicks@linux.vnet.ibm.com>
      3a5203ab
    • T
      eCryptfs: NULL pointer dereference in ecryptfs_send_miscdev() · 57ea34d1
      Tyler Hicks 提交于
      If data is NULL, msg_ctx->msg is set to NULL and then dereferenced
      afterwards.  ecryptfs_send_raw_message() is the only place that
      ecryptfs_send_miscdev() is called with data being NULL, but the only
      caller of that function (ecryptfs_process_helo()) is never called.  In
      short, there is currently no way to trigger the NULL pointer
      dereference.
      
      This patch removes the two unused functions and modifies
      ecryptfs_send_miscdev() to remove the NULL dereferences.
      Signed-off-by: NTyler Hicks <tyhicks@linux.vnet.ibm.com>
      57ea34d1
    • T
      eCryptfs: Copy lower inode attrs before dentry instantiation · ae6e8459
      Tyler Hicks 提交于
      Copies the lower inode attributes to the upper inode before passing the
      upper inode to d_instantiate().  This is important for
      security_d_instantiate().
      
      The problem was discovered by a user seeing SELinux denials like so:
      
      type=AVC msg=audit(1236812817.898:47): avc:  denied  { 0x100000 } for
      pid=3584 comm="httpd" name="testdir" dev=ecryptfs ino=943872
      scontext=root:system_r:httpd_t:s0
      tcontext=root:object_r:httpd_sys_content_t:s0 tclass=file
      
      Notice target class is file while testdir is really a directory,
      confusing the permission translation (0x100000) due to the wrong i_mode.
      Signed-off-by: NTyler Hicks <tyhicks@linux.vnet.ibm.com>
      ae6e8459
  2. 21 4月, 2009 1 次提交
  3. 01 4月, 2009 1 次提交
  4. 28 3月, 2009 1 次提交
  5. 23 3月, 2009 2 次提交
    • T
      eCryptfs: NULL crypt_stat dereference during lookup · 2aac0cf8
      Tyler Hicks 提交于
      If ecryptfs_encrypted_view or ecryptfs_xattr_metadata were being
      specified as mount options, a NULL pointer dereference of crypt_stat
      was possible during lookup.
      
      This patch moves the crypt_stat assignment into
      ecryptfs_lookup_and_interpose_lower(), ensuring that crypt_stat
      will not be NULL before we attempt to dereference it.
      
      Thanks to Dan Carpenter and his static analysis tool, smatch, for
      finding this bug.
      Signed-off-by: NTyler Hicks <tyhicks@linux.vnet.ibm.com>
      Acked-by: NDustin Kirkland <kirkland@canonical.com>
      Cc: Dan Carpenter <error27@gmail.com>
      Cc: Serge Hallyn <serue@us.ibm.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2aac0cf8
    • T
      eCryptfs: Allocate a variable number of pages for file headers · 8faece5f
      Tyler Hicks 提交于
      When allocating the memory used to store the eCryptfs header contents, a
      single, zeroed page was being allocated with get_zeroed_page().
      However, the size of an eCryptfs header is either PAGE_CACHE_SIZE or
      ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE (8192), whichever is larger, and is
      stored in the file's private_data->crypt_stat->num_header_bytes_at_front
      field.
      
      ecryptfs_write_metadata_to_contents() was using
      num_header_bytes_at_front to decide how many bytes should be written to
      the lower filesystem for the file header.  Unfortunately, at least 8K
      was being written from the page, despite the chance of the single,
      zeroed page being smaller than 8K.  This resulted in random areas of
      kernel memory being written between the 0x1000 and 0x1FFF bytes offsets
      in the eCryptfs file headers if PAGE_SIZE was 4K.
      
      This patch allocates a variable number of pages, calculated with
      num_header_bytes_at_front, and passes the number of allocated pages
      along to ecryptfs_write_metadata_to_contents().
      
      Thanks to Florian Streibelt for reporting the data leak and working with
      me to find the problem.  2.6.28 is the only kernel release with this
      vulnerability.  Corresponds to CVE-2009-0787
      Signed-off-by: NTyler Hicks <tyhicks@linux.vnet.ibm.com>
      Acked-by: NDustin Kirkland <kirkland@canonical.com>
      Reviewed-by: NEric Sandeen <sandeen@redhat.com>
      Reviewed-by: NEugene Teo <eugeneteo@kernel.sg>
      Cc: Greg KH <greg@kroah.com>
      Cc: dann frazier <dannf@dannf.org>
      Cc: Serge E. Hallyn <serue@us.ibm.com>
      Cc: Florian Streibelt <florian@f-streibelt.de>
      Cc: stable@kernel.org
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8faece5f
  6. 15 3月, 2009 1 次提交
  7. 07 2月, 2009 1 次提交
  8. 22 1月, 2009 1 次提交
  9. 07 1月, 2009 10 次提交
  10. 06 1月, 2009 2 次提交
    • C
      add a vfs_fsync helper · 4c728ef5
      Christoph Hellwig 提交于
      Fsync currently has a fdatawrite/fdatawait pair around the method call,
      and a mutex_lock/unlock of the inode mutex.  All callers of fsync have
      to duplicate this, but we have a few and most of them don't quite get
      it right.  This patch adds a new vfs_fsync that takes care of this.
      It's a little more complicated as usual as ->fsync might get a NULL file
      pointer and just a dentry from nfsd, but otherwise gets afile and we
      want to take the mapping and file operations from it when it is there.
      
      Notes on the fsync callers:
      
       - ecryptfs wasn't calling filemap_fdatawrite / filemap_fdatawait on the
         	lower file
       - coda wasn't calling filemap_fdatawrite / filemap_fdatawait on the host
      	file, and returning 0 when ->fsync was missing
       - shm wasn't calling either filemap_fdatawrite / filemap_fdatawait nor
         taking i_mutex.  Now given that shared memory doesn't have disk
         backing not doing anything in fsync seems fine and I left it out of
         the vfs_fsync conversion for now, but in that case we might just
         not pass it through to the lower file at all but just call the no-op
         simple_sync_file directly.
      
      [and now actually export vfs_fsync]
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      4c728ef5
    • A
      inode->i_op is never NULL · acfa4380
      Al Viro 提交于
      We used to have rather schizophrenic set of checks for NULL ->i_op even
      though it had been eliminated years ago.  You'd need to go out of your
      way to set it to NULL explicitly _and_ a bunch of code would die on
      such inodes anyway.  After killing two remaining places that still
      did that bogosity, all that crap can go away.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      acfa4380
  11. 05 1月, 2009 1 次提交
    • N
      fs: symlink write_begin allocation context fix · 54566b2c
      Nick Piggin 提交于
      With the write_begin/write_end aops, page_symlink was broken because it
      could no longer pass a GFP_NOFS type mask into the point where the
      allocations happened.  They are done in write_begin, which would always
      assume that the filesystem can be entered from reclaim.  This bug could
      cause filesystem deadlocks.
      
      The funny thing with having a gfp_t mask there is that it doesn't really
      allow the caller to arbitrarily tinker with the context in which it can be
      called.  It couldn't ever be GFP_ATOMIC, for example, because it needs to
      take the page lock.  The only thing any callers care about is __GFP_FS
      anyway, so turn that into a single flag.
      
      Add a new flag for write_begin, AOP_FLAG_NOFS.  Filesystems can now act on
      this flag in their write_begin function.  Change __grab_cache_page to
      accept a nofs argument as well, to honour that flag (while we're there,
      change the name to grab_cache_page_write_begin which is more instructive
      and does away with random leading underscores).
      
      This is really a more flexible way to go in the end anyway -- if a
      filesystem happens to want any extra allocations aside from the pagecache
      ones in ints write_begin function, it may now use GFP_KERNEL (rather than
      GFP_NOFS) for common case allocations (eg.  ocfs2_alloc_write_ctxt, for a
      random example).
      
      [kosaki.motohiro@jp.fujitsu.com: fix ubifs]
      [kosaki.motohiro@jp.fujitsu.com: fix fuse]
      Signed-off-by: NNick Piggin <npiggin@suse.de>
      Reviewed-by: NKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Cc: <stable@kernel.org>		[2.6.28.x]
      Signed-off-by: NKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      [ Cleaned up the calling convention: just pass in the AOP flags
        untouched to the grab_cache_page_write_begin() function.  That
        just simplifies everybody, and may even allow future expansion of the
        logic.   - Linus ]
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      54566b2c
  12. 01 1月, 2009 1 次提交
  13. 25 11月, 2008 1 次提交
    • S
      User namespaces: set of cleanups (v2) · 18b6e041
      Serge Hallyn 提交于
      The user_ns is moved from nsproxy to user_struct, so that a struct
      cred by itself is sufficient to determine access (which it otherwise
      would not be).  Corresponding ecryptfs fixes (by David Howells) are
      here as well.
      
      Fix refcounting.  The following rules now apply:
              1. The task pins the user struct.
              2. The user struct pins its user namespace.
              3. The user namespace pins the struct user which created it.
      
      User namespaces are cloned during copy_creds().  Unsharing a new user_ns
      is no longer possible.  (We could re-add that, but it'll cause code
      duplication and doesn't seem useful if PAM doesn't need to clone user
      namespaces).
      
      When a user namespace is created, its first user (uid 0) gets empty
      keyrings and a clean group_info.
      
      This incorporates a previous patch by David Howells.  Here
      is his original patch description:
      
      >I suggest adding the attached incremental patch.  It makes the following
      >changes:
      >
      > (1) Provides a current_user_ns() macro to wrap accesses to current's user
      >     namespace.
      >
      > (2) Fixes eCryptFS.
      >
      > (3) Renames create_new_userns() to create_user_ns() to be more consistent
      >     with the other associated functions and because the 'new' in the name is
      >     superfluous.
      >
      > (4) Moves the argument and permission checks made for CLONE_NEWUSER to the
      >     beginning of do_fork() so that they're done prior to making any attempts
      >     at allocation.
      >
      > (5) Calls create_user_ns() after prepare_creds(), and gives it the new creds
      >     to fill in rather than have it return the new root user.  I don't imagine
      >     the new root user being used for anything other than filling in a cred
      >     struct.
      >
      >     This also permits me to get rid of a get_uid() and a free_uid(), as the
      >     reference the creds were holding on the old user_struct can just be
      >     transferred to the new namespace's creator pointer.
      >
      > (6) Makes create_user_ns() reset the UIDs and GIDs of the creds under
      >     preparation rather than doing it in copy_creds().
      >
      >David
      
      >Signed-off-by: David Howells <dhowells@redhat.com>
      
      Changelog:
      	Oct 20: integrate dhowells comments
      		1. leave thread_keyring alone
      		2. use current_user_ns() in set_user()
      Signed-off-by: NSerge Hallyn <serue@us.ibm.com>
      18b6e041
  14. 20 11月, 2008 1 次提交
    • M
      eCryptfs: Allocate up to two scatterlists for crypto ops on keys · ac97b9f9
      Michael Halcrow 提交于
      I have received some reports of out-of-memory errors on some older AMD
      architectures.  These errors are what I would expect to see if
      crypt_stat->key were split between two separate pages.  eCryptfs should
      not assume that any of the memory sent through virt_to_scatterlist() is
      all contained in a single page, and so this patch allocates two
      scatterlist structs instead of one when processing keys.  I have received
      confirmation from one person affected by this bug that this patch resolves
      the issue for him, and so I am submitting it for inclusion in a future
      stable release.
      
      Note that virt_to_scatterlist() runs sg_init_table() on the scatterlist
      structs passed to it, so the calls to sg_init_table() in
      decrypt_passphrase_encrypted_session_key() are redundant.
      Signed-off-by: NMichael Halcrow <mhalcrow@us.ibm.com>
      Reported-by: NPaulo J. S. Silva <pjssilva@ime.usp.br>
      Cc: "Leon Woestenberg" <leon.woestenberg@gmail.com>
      Cc: Tim Gardner <tim.gardner@canonical.com>
      Cc: <stable@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ac97b9f9
  15. 14 11月, 2008 2 次提交
  16. 31 10月, 2008 1 次提交
    • E
      ecryptfs: fix memory corruption when storing crypto info in xattrs · 87b811c3
      Eric Sandeen 提交于
      When ecryptfs allocates space to write crypto headers into, before copying
      it out to file headers or to xattrs, it looks at the value of
      crypt_stat->num_header_bytes_at_front to determine how much space it
      needs.  This is also used as the file offset to the actual encrypted data,
      so for xattr-stored crypto info, the value was zero.
      
      So, we kzalloc'd 0 bytes, and then ran off to write to that memory.
      (Which returned as ZERO_SIZE_PTR, so we explode quickly).
      
      The right answer is to always allocate a page to write into; the current
      code won't ever write more than that (this is enforced by the
      (PAGE_CACHE_SIZE - offset) length in the call to
      ecryptfs_generate_key_packet_set).  To be explicit about this, we now send
      in a "max" parameter, rather than magically using PAGE_CACHE_SIZE there.
      
      Also, since the pointer we pass down the callchain eventually gets the
      virt_to_page() treatment, we should be using a alloc_page variant, not
      kzalloc (see also 7fcba054)
      Signed-off-by: NEric Sandeen <sandeen@redhat.com>
      Acked-by: NMichael Halcrow <mhalcrow@us.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      87b811c3
  17. 23 10月, 2008 1 次提交
  18. 17 10月, 2008 3 次提交
  19. 14 10月, 2008 1 次提交
  20. 29 7月, 2008 1 次提交
  21. 27 7月, 2008 2 次提交