10 Aug, 2010

1 commit

  • The comments in the code indicate that file_info should be released if the
    function fails. This releasing is done at the label out_free, not out.

    The semantic match that finds this problem is as follows:
    (http://www.emn.fr/x-info/coccinelle/)

    //
    @r exists@
    local idexpression x;
    statement S;
    expression E;
    identifier f,f1,l;
    position p1,p2;
    expression *ptr != NULL;
    @@

    x@p1 = kmem_cache_zalloc(...);
    ...
    if (x == NULL) S
    }
    (
    x->f1 = E
    |
    (x->f1 == NULL || ...)
    |
    f(...,x->f1,...)
    )
    ...>
    (
    return ;
    |
    return@p2 ...;
    )

    @script:python@
    p1 << r.p1;
    p2 << r.p2;
    @@

    print "* file: %s kmem_cache_zalloc %s" % (p1[0].file,p1[0].line)
    //

    Signed-off-by: Julia Lawall
    Cc: stable@kernel.org
    Signed-off-by: Tyler Hicks

    Julia Lawall
     

09 Aug, 2010

1 commit

  • Lower filesystems that only implemented unlocked_ioctl weren't being
    passed ioctl calls because eCryptfs only checked for
    lower_file->f_op->ioctl and returned -ENOTTY if it was NULL.

    eCryptfs shouldn't implement ioctl(), since it doesn't require the BKL.
    This patch introduces ecryptfs_unlocked_ioctl() and
    ecryptfs_compat_ioctl(), which passes the calls on to the lower file
    system.

    https://bugs.launchpad.net/ecryptfs/+bug/469664

    Reported-by: James Dupin
    Cc: stable@kernel.org
    Signed-off-by: Tyler Hicks

    Tyler Hicks
     

28 May, 2010

1 commit


22 May, 2010

1 commit

  • Now that the last user passing a NULL file pointer is gone we can remove
    the redundant dentry argument and associated hacks inside vfs_fsynmc_range.

    The next step will be removig the dentry argument from ->fsync, but given
    the luck with the last round of method prototype changes I'd rather
    defer this until after the main merge window.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Al Viro

    Christoph Hellwig
     

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

3 commits

  • The variable lower_dentry is initialized twice to the same (side effect-free)
    expression. Drop one initialization.

    A simplified version of the semantic match that finds this problem is:
    (http://coccinelle.lip6.fr/)

    //
    @forall@
    idexpression *x;
    identifier f!=ERR_PTR;
    @@

    x = f(...)
    ... when != x
    (
    x = f(...,,...)
    |
    * x = f(...)
    )
    //

    Signed-off-by: Julia Lawall
    Signed-off-by: Tyler Hicks

    Julia Lawall
     
  • Ecryptfs_open dereferences a pointer to the private lower file (the one
    stored in the ecryptfs inode), without checking if the pointer is NULL.
    Right afterward, it initializes that pointer if it is NULL. Swap order of
    statements to first initialize. Bug discovered by Duckjin Kang.

    Signed-off-by: Duckjin Kang
    Signed-off-by: Erez Zadok
    Cc: Dustin Kirkland
    Cc: Al Viro
    Cc:
    Signed-off-by: Tyler Hicks

    Erez Zadok
     
  • Adrian reported that mkfontscale didn't work inside of eCryptfs mounts.
    Strace revealed the following:

    open("./", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
    fcntl64(3, F_GETFD) = 0x1 (flags FD_CLOEXEC)
    open("./fonts.scale", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
    getdents(3, /* 80 entries */, 32768) = 2304
    open("./.", O_RDONLY) = 5
    fcntl64(5, F_SETFD, FD_CLOEXEC) = 0
    fstat64(5, {st_mode=S_IFDIR|0755, st_size=16384, ...}) = 0
    mmap2(NULL, 16384, PROT_READ, MAP_PRIVATE, 5, 0) = 0xb7fcf000
    close(5) = 0
    --- SIGBUS (Bus error) @ 0 (0) ---
    +++ killed by SIGBUS +++

    The mmap2() on a directory was successful, resulting in a SIGBUS
    signal later. This patch removes mmap() from the list of possible
    ecryptfs_dir_fops so that mmap() isn't possible on eCryptfs directory
    files.

    https://bugs.launchpad.net/ecryptfs/+bug/400443

    Reported-by: Adrian C.
    Signed-off-by: Tyler Hicks

    Tyler Hicks
     

07 Jan, 2009

2 commits

  • Correct several format string data type specifiers. Correct filename size
    data types; they should be size_t rather than int when passed as
    parameters to some other functions (although note that the filenames will
    never be larger than int).

    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
     
  • Make the requisite modifications to ecryptfs_filldir(), ecryptfs_lookup(),
    and ecryptfs_readlink() to call out to filename encryption functions.
    Propagate filename encryption policy flags from mount-wide crypt_stat to
    inode crypt_stat.

    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
     

06 Jan, 2009

1 commit

  • 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: Christoph Hellwig
    Signed-off-by: Al Viro

    Christoph Hellwig
     

17 Oct, 2008

1 commit

  • The retry block in ecryptfs_readdir() has been in the eCryptfs code base
    for a while, apparently for no good reason. This loop could potentially
    run without terminating. This patch removes the loop, instead erroring
    out if vfs_readdir() on the lower file fails.

    Signed-off-by: Michael Halcrow
    Reported-by: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Halcrow
     

25 Jul, 2008

3 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
     
  • 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
     

03 Jul, 2008

1 commit


29 Apr, 2008

1 commit


07 Feb, 2008

1 commit


17 Oct, 2007

5 commits

  • The switch to read_write.c routines and the persistent file make a number of
    functions unnecessary. This patch removes them.

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

    Michael Halcrow
     
  • Rather than open a new lower file for every eCryptfs file that is opened,
    truncated, or setattr'd, instead use the existing lower persistent file for
    the eCryptfs inode. Change truncate to use read_write.c functions. Change
    ecryptfs_getxattr() to use the common ecryptfs_getxattr_lower() function.

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

    Michael Halcrow
     
  • Update the metadata read/write functions and grow_file() to use the
    read_write.c routines. Do not open another lower file; use the persistent
    lower file instead. Provide a separate function for
    crypto.c::ecryptfs_read_xattr_region() to get to the lower xattr without
    having to go through the eCryptfs getxattr.

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

    Michael Halcrow
     
  • Remove assignments in if-statements.

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

    Michael Halcrow
     
  • eCryptfs is currently just passing through splice reads to the lower
    filesystem. This is obviously incorrect behavior; the decrypted data is
    what needs to be read, not the lower encrypted data. I cannot think of any
    good reason for eCryptfs to implement splice_read, so this patch points the
    eCryptfs fops splice_read to use generic_file_splice_read.

    Signed-off-by: Michael Halcrow
    Reviewed-by: Jens Axboe
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Halcrow
     

10 Jul, 2007

1 commit


24 May, 2007

1 commit

  • Delay writing 0's out in eCryptfs after a seek past the end of the file
    until data is actually written.

    http://www.opengroup.org/onlinepubs/009695399/functions/lseek.html

    ``The lseek() function shall not, by itself, extend the size of a
    file.''

    Without this fix, applications that lseek() past the end of the file without
    writing will experience unexpected behavior.

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

    Michael Halcrow
     

09 May, 2007

1 commit


02 Mar, 2007

1 commit


13 Feb, 2007

3 commits

  • Open-code flag checking and manipulation.

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

    Michael Halcrow
     
  • Provide an option to provide a view of the encrypted files such that the
    metadata is always in the header of the files, regardless of whether the
    metadata is actually in the header or in the extended attribute. This mode of
    operation is useful for applications like incremental backup utilities that do
    not preserve the extended attributes when directly accessing the lower files.

    With this option enabled, the files under the eCryptfs mount point will be
    read-only.

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

    Michael Halcrow
     
  • Generalize the metadata reading and writing mechanisms, with two targets for
    now: metadata in file header and metadata in the user.ecryptfs xattr of the
    lower file.

    [akpm@osdl.org: printk warning fix]
    [bunk@stusta.de: make some needlessly global code static]
    Signed-off-by: Michael Halcrow
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Halcrow
     

12 Feb, 2007

1 commit

  • Replace appropriate pairs of "kmem_cache_alloc()" + "memset(0)" with the
    corresponding "kmem_cache_zalloc()" call.

    Signed-off-by: Robert P. J. Day
    Cc: "Luck, Tony"
    Cc: Andi Kleen
    Cc: Roland McGrath
    Cc: James Bottomley
    Cc: Greg KH
    Acked-by: Joel Becker
    Cc: Steven Whitehouse
    Cc: Jan Kara
    Cc: Michael Halcrow
    Cc: "David S. Miller"
    Cc: Stephen Smalley
    Cc: James Morris
    Cc: Chris Wright
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Robert P. J. Day
     

09 Dec, 2006

2 commits


08 Dec, 2006

1 commit


01 Nov, 2006

1 commit

  • Opens on lower dentry objects happen in several places in eCryptfs, and they
    all involve the same steps (dget, mntget, dentry_open). This patch
    consolidates the lower open events into a single function call.

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

    Michael Halcrow
     

04 Oct, 2006

1 commit

  • eCryptfs is a stacked cryptographic filesystem for Linux. It is derived from
    Erez Zadok's Cryptfs, implemented through the FiST framework for generating
    stacked filesystems. eCryptfs extends Cryptfs to provide advanced key
    management and policy features. eCryptfs stores cryptographic metadata in the
    header of each file written, so that encrypted files can be copied between
    hosts; the file will be decryptable with the proper key, and there is no need
    to keep track of any additional information aside from what is already in the
    encrypted file itself.

    [akpm@osdl.org: updates for ongoing API changes]
    [bunk@stusta.de: cleanups]
    [akpm@osdl.org: alpha build fix]
    [akpm@osdl.org: cleanups]
    [tytso@mit.edu: inode-diet updates]
    [pbadari@us.ibm.com: generic_file_*_read/write() interface updates]
    [rdunlap@xenotime.net: printk format fixes]
    [akpm@osdl.org: make slab creation and teardown table-driven]
    Signed-off-by: Phillip Hellewell
    Signed-off-by: Michael Halcrow
    Signed-off-by: Erez Zadok
    Signed-off-by: Adrian Bunk
    Signed-off-by: Stephan Mueller
    Signed-off-by: "Theodore Ts'o"
    Signed-off-by: Badari Pulavarty
    Signed-off-by: Randy Dunlap
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Halcrow