22 May, 2010

3 commits

  • This is a seriously simplified patch from Eric Sandeen; copy of
    rationale follows:
    ===
    mounting stacked ecryptfs on ecryptfs has been shown to lead to bugs
    in testing. For crypto info in xattr, there is no mechanism for handling
    this at all, and for normal file headers, we run into other trouble:

    BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
    IP: [] ecryptfs_d_revalidate+0x43/0xa0 [ecryptfs]
    ...

    There doesn't seem to be any good usecase for this, so I'd suggest just
    disallowing the configuration.

    Based on a patch originally, I believe, from Mike Halcrow.
    ===

    Signed-off-by: Al Viro

    Al Viro
     
  • Signed-off-by: Al Viro

    Al Viro
     
  • First of all, get_sb_nodev() grabs anon dev minor and we
    never free it in ecryptfs ->kill_sb(). Moreover, on one
    of the failure exits in ecryptfs_get_sb() we leak things -
    it happens before we set ->s_root and ->put_super() won't
    be called in that case. Solution: kill ->put_super(), do
    all that stuff in ->kill_sb(). And use kill_anon_sb() instead
    of generic_shutdown_super() to deal with anon dev leak.

    Signed-off-by: Al Viro

    Al Viro
     

22 Apr, 2010

1 commit


30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

20 Jan, 2010

1 commit


17 Dec, 2009

2 commits


09 Oct, 2009

1 commit

  • The unencrypted files are being measured. Update the counters to get
    rid of the ecryptfs imbalance message. (http://bugzilla.redhat.com/519737)

    Reported-by: Sachin Garg
    Cc: Eric Paris
    Cc: Dustin Kirkland
    Cc: James Morris
    Cc: David Safford
    Cc: stable@kernel.org
    Signed-off-by: Mimi Zohar
    Signed-off-by: Tyler Hicks

    Mimi Zohar
     

23 Sep, 2009

1 commit

  • If the lower inode is read-only, don't attempt to open the lower file
    read/write and don't hand off the open request to the privileged
    eCryptfs kthread for opening it read/write. Instead, only try an
    unprivileged, read-only open of the file and give up if that fails.
    This patch fixes an oops when eCryptfs is mounted on top of a read-only
    mount.

    Acked-by: Serge Hallyn
    Cc: Eric Sandeen
    Cc: Dave Kleikamp
    Cc: ecryptfs-devel@lists.launchpad.net
    Cc: stable
    Signed-off-by: Tyler Hicks

    Tyler Hicks
     

09 May, 2009

1 commit


22 Apr, 2009

2 commits

  • 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: Tyler Hicks

    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: Tyler Hicks

    Tyler Hicks
     

15 Mar, 2009

1 commit

  • eCryptfs has file encryption keys (FEK), file encryption key encryption
    keys (FEKEK), and filename encryption keys (FNEK). The per-file FEK is
    encrypted with one or more FEKEKs and stored in the header of the
    encrypted file. I noticed that the FEK is also being encrypted by the
    FNEK. This is a problem if a user wants to use a different FNEK than
    their FEKEK, as their file contents will still be accessible with the
    FNEK.

    This is a minimalistic patch which prevents the FNEKs signatures from
    being copied to the inode signatures list. Ultimately, it keeps the FEK
    from being encrypted with a FNEK.

    Signed-off-by: Tyler Hicks
    Cc: Serge Hallyn
    Acked-by: Dustin Kirkland
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tyler Hicks
     

07 Jan, 2009

1 commit

  • Enable mount-wide filename encryption by providing the Filename Encryption
    Key (FNEK) signature as a mount option. Note that the ecryptfs-utils
    userspace package versions 61 or later support this option.

    When mounting with ecryptfs-utils version 61 or later, the mount helper
    will detect the availability of the passphrase-based filename encryption
    in the kernel (via the eCryptfs sysfs handle) and query the user
    interactively as to whether or not he wants to enable the feature for the
    mount. If the user enables filename encryption, the mount helper will
    then prompt for the FNEK signature that the user wishes to use, suggesting
    by default the signature for the mount passphrase that the user has
    already entered for encrypting the file contents.

    When not using the mount helper, the user can specify the signature for
    the passphrase key with the ecryptfs_fnek_sig= mount option. This key
    must be available in the user's keyring. The mount helper usually takes
    care of this step. If, however, the user is not mounting with the mount
    helper, then he will need to enter the passphrase key into his keyring
    with some other utility prior to mounting, such as ecryptfs-manager.

    Signed-off-by: Michael Halcrow
    Cc: Dustin Kirkland
    Cc: Eric Sandeen
    Cc: Tyler Hicks
    Cc: David Kleikamp
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Halcrow
     

14 Nov, 2008

1 commit

  • Pass credentials through dentry_open() so that the COW creds patch can have
    SELinux's flush_unauthorized_files() pass the appropriate creds back to itself
    when it opens its null chardev.

    The security_dentry_open() call also now takes a creds pointer, as does the
    dentry_open hook in struct security_operations.

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

    David Howells
     

23 Oct, 2008

1 commit


17 Oct, 2008

1 commit

  • The netlink transport code has not worked for a while and the miscdev
    transport is a simpler solution. This patch removes the netlink code and
    makes the miscdev transport the only eCryptfs kernel to userspace
    transport.

    Signed-off-by: Tyler Hicks
    Cc: Michael Halcrow
    Cc: Dustin Kirkland
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tyler Hicks
     

14 Oct, 2008

1 commit

  • This is a much better version of a previous patch to make the parser
    tables constant. Rather than changing the typedef, we put the "const" in
    all the various places where its required, allowing the __initconst
    exception for nfsroot which was the cause of the previous trouble.

    This was posted for review some time ago and I believe its been in -mm
    since then.

    Signed-off-by: Steven Whitehouse
    Cc: Alexander Viro
    Signed-off-by: Linus Torvalds

    Steven Whitehouse
     

27 Jul, 2008

1 commit

  • Kmem cache passed to constructor is only needed for constructors that are
    themselves multiplexeres. Nobody uses this "feature", nor does anybody uses
    passed kmem cache in non-trivial way, so pass only pointer to object.

    Non-trivial places are:
    arch/powerpc/mm/init_64.c
    arch/powerpc/mm/hugetlbpage.c

    This is flag day, yes.

    Signed-off-by: Alexey Dobriyan
    Acked-by: Pekka Enberg
    Acked-by: Christoph Lameter
    Cc: Jon Tollefson
    Cc: Nick Piggin
    Cc: Matt Mackall
    [akpm@linux-foundation.org: fix arch/powerpc/mm/hugetlbpage.c]
    [akpm@linux-foundation.org: fix mm/slab.c]
    [akpm@linux-foundation.org: fix ubifs]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

25 Jul, 2008

5 commits

  • There is no good reason to immediately open the lower file, and that can
    cause problems with files that the user does not intend to immediately
    open, such as device nodes.

    This patch removes the persistent file open from the interpose step and
    pushes that to the locations where eCryptfs really does need the lower
    persistent file, such as just before reading or writing the metadata
    stored in the lower file header.

    Two functions are jumping to out_dput when they should just be jumping to
    out on error paths. This patch also fixes these.

    Signed-off-by: Michael Halcrow
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Halcrow
     
  • When creating device nodes, eCryptfs needs to delay actually opening the lower
    persistent file until an application tries to open. Device handles may not be
    backed by anything when they first come into existence.

    [Valdis.Kletnieks@vt.edu: build fix]
    Signed-off-by: Michael Halcrow
    Cc:
    Signed-off-by: Linus Torvalds

    Michael Halcrow
     
  • Clean up overcomplicated string copy, which also gets rid of this
    bogus warning:

    fs/ecryptfs/main.c: In function 'ecryptfs_parse_options':
    include/asm/arch/string_32.h:75: warning: array subscript is above array bounds

    Signed-off-by: Miklos Szeredi
    Cc: Michael Halcrow
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Miklos Szeredi
     
  • Mounting with invalid key signatures should probably fail, if they were
    specifically requested but not available.

    Also fix case checks in process_request_key_err() for the right sign of
    the errnos, as spotted by Jan Tluka.

    Signed-off-by: Eric Sandeen
    Reviewed-by: Jan Tluka
    Acked-by: Michael Halcrow
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Sandeen
     
  • eCryptfs would really like to have read-write access to all files in the
    lower filesystem. Right now, the persistent lower file may be opened
    read-only if the attempt to open it read-write fails. One way to keep
    from having to do that is to have a privileged kthread that can open the
    lower persistent file on behalf of the user opening the eCryptfs file;
    this patch implements this functionality.

    This patch will properly allow a less-privileged user to open the eCryptfs
    file, followed by a more-privileged user opening the eCryptfs file, with
    the first user only being able to read and the second user being able to
    both read and write. eCryptfs currently does this wrong; it will wind up
    calling vfs_write() on a file that was opened read-only. This is fixed in
    this patch.

    Signed-off-by: Michael Halcrow
    Cc: Dave Kleikamp
    Cc: Serge Hallyn
    Cc: Eric Sandeen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Halcrow
     

29 Apr, 2008

1 commit


15 Feb, 2008

2 commits

  • * Add path_put() functions for releasing a reference to the dentry and
    vfsmount of a struct path in the right order

    * Switch from path_release(nd) to path_put(&nd->path)

    * Rename dput_path() to path_put_conditional()

    [akpm@linux-foundation.org: fix cifs]
    Signed-off-by: Jan Blunck
    Signed-off-by: Andreas Gruenbacher
    Acked-by: Christoph Hellwig
    Cc:
    Cc: Al Viro
    Cc: Steven French
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Blunck
     
  • 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
     

07 Feb, 2008

4 commits

  • Jeff Moyer pointed out that a mount; umount loop of ecryptfs, with the same
    cipher & other mount options, created a new ecryptfs_key_tfm_cache item
    each time, and the cache could grow quite large this way.

    Looking at this with mhalcrow, we saw that ecryptfs_parse_options()
    unconditionally called ecryptfs_add_new_key_tfm(), which is what was adding
    these items.

    Refactor ecryptfs_get_tfm_and_mutex_for_cipher_name() to create a new
    helper function, ecryptfs_tfm_exists(), which checks for the cipher on the
    cached key_tfm_list, and sets a pointer to it if it exists. This can then
    be called from ecryptfs_parse_options(), and new key_tfm's can be added
    only when a cached one is not found.

    With list locking changes suggested by akpm.

    Signed-off-by: Eric Sandeen
    Cc: Michael Halcrow
    Cc: Jeff Moyer
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Sandeen
     
  • ecryptfs_debug really should not be a mount option; it is not per-mount,
    but rather sets a global "ecryptfs_verbosity" variable which affects all
    mounted filesysytems. It's already settable as a module load option,
    I think we can leave it at that.

    Also, if set, since secret values come out in debug messages, kick
    things off with a stern warning.

    Signed-off-by: Eric Sandeen
    Acked-by: Mike Halcrow
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Sandeen
     
  • Remove internal references to header extents; just keep track of header bytes
    instead. Headers can easily span multiple pages with the recent persistent
    file changes.

    Signed-off-by: Michael Halcrow
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Halcrow
     
  • - make the following needlessly global code static:
    - crypto.c:ecryptfs_lower_offset_for_extent()
    - crypto.c:key_tfm_list
    - crypto.c:key_tfm_list_mutex
    - inode.c:ecryptfs_getxattr()
    - main.c:ecryptfs_init_persistent_file()

    - remove the no longer used mmap.c:ecryptfs_lower_page_cache

    - #if 0 the unused read_write.c:ecryptfs_read()

    Signed-off-by: Adrian Bunk
    Cc: Michael Halcrow
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Adrian Bunk
     

25 Jan, 2008

8 commits