20 Nov, 2008

1 commit

  • 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: Michael Halcrow
    Reported-by: Paulo J. S. Silva
    Cc: "Leon Woestenberg"
    Cc: Tim Gardner
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Halcrow
     

31 Oct, 2008

1 commit

  • 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 7fcba054373d5dfc43d26e243a5c9b92069972ee)

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

    Eric Sandeen
     

23 Oct, 2008

1 commit


17 Oct, 2008

3 commits

  • 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
     
  • Convert ecryptfs to use write_begin/write_end

    Signed-off-by: Nick Piggin
    Signed-off-by: Badari Pulavarty
    Acked-by: Michael Halcrow
    Cc: Dave Kleikamp
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Badari Pulavarty
     
  • 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
     

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
     

29 Jul, 2008

1 commit

  • With SLUB debugging turned on in 2.6.26, I was getting memory corruption
    when testing eCryptfs. The root cause turned out to be that eCryptfs was
    doing kmalloc(PAGE_CACHE_SIZE); virt_to_page() and treating that as a nice
    page-aligned chunk of memory. But at least with SLUB debugging on, this
    is not always true, and the page we get from virt_to_page does not
    necessarily match the PAGE_CACHE_SIZE worth of memory we got from kmalloc.

    My simple testcase was 2 loops doing "rm -f fileX; cp /tmp/fileX ." for 2
    different multi-megabyte files. With this change I no longer see the
    corruption.

    Signed-off-by: Eric Sandeen
    Acked-by: Michael Halcrow
    Acked-by: Rik van Riel
    Cc: [2.6.25.x, 2.6.26.x]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Sandeen
     

27 Jul, 2008

4 commits

  • Incidentally, the name that gives hundreds of false positives on grep
    is not a good idea...

    Signed-off-by: Al Viro

    Al Viro
     
  • Remove the unused mode parameter from vfs_symlink and callers.

    Thanks to Tetsuo Handa for noticing.

    CC: Tetsuo Handa
    Signed-off-by: Miklos Szeredi

    Miklos Szeredi
     
  • * kill nameidata * argument; map the 3 bits in ->flags anybody cares
    about to new MAY_... ones and pass with the mask.
    * kill redundant gfs2_iop_permission()
    * sanitize ecryptfs_permission()
    * fix remaining places where ->permission() instances might barf on new
    MAY_... found in mask.

    The obvious next target in that direction is permission(9)

    folded fix for nfs_permission() breakage from Miklos Szeredi

    Signed-off-by: Al Viro

    Al Viro
     
  • 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

8 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
     
  • Fixe sparse warnings:
    fs/ecryptfs/inode.c:368:15: warning: cast to restricted __be64
    fs/ecryptfs/mmap.c:385:12: warning: incorrect type in assignment (different base types)
    fs/ecryptfs/mmap.c:385:12: expected unsigned long long [unsigned] [assigned] [usertype] file_size
    fs/ecryptfs/mmap.c:385:12: got restricted __be64 [usertype]
    fs/ecryptfs/mmap.c:428:12: warning: incorrect type in assignment (different base types)
    fs/ecryptfs/mmap.c:428:12: expected unsigned long long [unsigned] [assigned] [usertype] file_size
    fs/ecryptfs/mmap.c:428:12: got restricted __be64 [usertype]

    Signed-off-by: Harvey Harrison
    Cc: Michael Halcrow
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Harvey Harrison
     
  • Fixes the following sparse warnings:
    fs/ecryptfs/crypto.c:1036:8: warning: cast to restricted __be32
    fs/ecryptfs/crypto.c:1038:8: warning: cast to restricted __be32
    fs/ecryptfs/crypto.c:1077:10: warning: cast to restricted __be32
    fs/ecryptfs/crypto.c:1103:6: warning: incorrect type in assignment (different base types)
    fs/ecryptfs/crypto.c:1105:6: warning: incorrect type in assignment (different base types)
    fs/ecryptfs/crypto.c:1124:8: warning: incorrect type in assignment (different base types)
    fs/ecryptfs/crypto.c:1241:21: warning: incorrect type in assignment (different base types)
    fs/ecryptfs/crypto.c:1244:30: warning: incorrect type in assignment (different base types)
    fs/ecryptfs/crypto.c:1414:23: warning: cast to restricted __be32
    fs/ecryptfs/crypto.c:1417:32: warning: cast to restricted __be16

    Signed-off-by: Harvey Harrison
    Cc: Michael Halcrow
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Harvey Harrison
     
  • 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
     
  • The userspace eCryptfs daemon sends HELO and QUIT messages to the kernel
    for per-user daemon (un)registration. These messages are required when
    netlink is used as the transport, but (un)registration is handled by
    opening and closing the device file when miscdev is the transport. These
    messages should be discarded in the miscdev transport so that a daemon
    isn't registered twice.

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

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

15 Jul, 2008

1 commit


05 Jul, 2008

1 commit


03 Jul, 2008

1 commit


07 Jun, 2008

1 commit

  • The page decrypt calls in ecryptfs_write() are both pointless and buggy.
    Pointless because ecryptfs_get_locked_page() has already brought the page
    up to date, and buggy because prior mmap writes will just be blown away by
    the decrypt call.

    This patch also removes the declaration of a now-nonexistent function
    ecryptfs_write_zeros().

    Thanks to Eric Sandeen and David Kleikamp for helping to track this
    down.

    Eric said:

    fsx w/ mmap dies quickly ( < 100 ops) without this, and survives
    nicely (to millions of ops+) with it in place.

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

    Michael Halcrow
     

25 May, 2008

1 commit


22 May, 2008

1 commit


13 May, 2008

2 commits

  • Fix imbalanced calls for mutex lock/unlock on ecryptfs_daemon_hash_mux
    Revealed by Ingo Molnar: http://lkml.org/lkml/2008/5/7/260

    Signed-off-by: Cyrill Gorcunov
    Cc: Michael Halcrow
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Cyrill Gorcunov
     
  • dget(dentry->d_parent) --> dget_parent(dentry)

    unlock_parent() is racy and unnecessary. Replace single caller with
    unlock_dir().

    There are several other suspect uses of ->d_parent in ecryptfs...

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

    Miklos Szeredi
     

29 Apr, 2008

8 commits

  • Some drivers have duplicated unlikely() macros. IS_ERR() already has
    unlikely() in itself.

    This patch cleans up such pointless code.

    Signed-off-by: Hirofumi Nakagawa
    Acked-by: David S. Miller
    Acked-by: Jeff Garzik
    Cc: Paul Clements
    Cc: Richard Purdie
    Cc: Alessandro Zummo
    Cc: David Brownell
    Cc: James Bottomley
    Cc: Michael Halcrow
    Cc: Anton Altaparmakov
    Cc: Al Viro
    Cc: Carsten Otte
    Cc: Patrick McHardy
    Cc: Paul Mundt
    Cc: Jaroslav Kysela
    Cc: Takashi Iwai
    Acked-by: Mike Frysinger
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Hirofumi Nakagawa
     
  • Make sure crypt_stat->flags is protected with a lock in ecryptfs_open().

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

    Michael Halcrow
     
  • Make eCryptfs key module subsystem respect namespaces.

    Since I will be removing the netlink interface in a future patch, I just made
    changes to the netlink.c code so that it will not break the build. With my
    recent patches, the kernel module currently defaults to the device handle
    interface rather than the netlink interface.

    [akpm@linux-foundation.org: export free_user_ns()]
    Signed-off-by: Michael Halcrow
    Acked-by: Serge Hallyn
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Halcrow
     
  • Update the versioning information. Make the message types generic. Add an
    outgoing message queue to the daemon struct. Make the functions to parse
    and write the packet lengths available to the rest of the module. Add
    functions to create and destroy the daemon structs. Clean up some of the
    comments and make the code a little more consistent with itself.

    [akpm@linux-foundation.org: printk fixes]
    Signed-off-by: Michael Halcrow
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Halcrow
     
  • A regular device file was my real preference from the get-go, but I went with
    netlink at the time because I thought it would be less complex for managing
    send queues (i.e., just do a unicast and move on). It turns out that we do
    not really get that much complexity reduction with netlink, and netlink is
    more heavyweight than a device handle.

    In addition, the netlink interface to eCryptfs has been broken since 2.6.24.
    I am assuming this is a bug in how eCryptfs uses netlink, since the other
    in-kernel users of netlink do not seem to be having any problems. I have had
    one report of a user successfully using eCryptfs with netlink on 2.6.24, but
    for my own systems, when starting the userspace daemon, the initial helo
    message sent to the eCryptfs kernel module results in an oops right off the
    bat. I spent some time looking at it, but I have not yet found the cause.
    The netlink interface breaking gave me the motivation to just finish my patch
    to migrate to a regular device handle. If I cannot find out soon why the
    netlink interface in eCryptfs broke, I am likely to just send a patch to
    disable it in 2.6.24 and 2.6.25. I would like the device handle to be the
    preferred means of communicating with the userspace daemon from 2.6.26 on
    forward.

    This patch:

    Functions to facilitate reading and writing to the eCryptfs miscellaneous
    device handle. This will replace the netlink interface as the preferred
    mechanism for communicating with the userspace eCryptfs daemon.

    Each user has his own daemon, which registers itself by opening the eCryptfs
    device handle. Only one daemon per euid may be registered at any given time.
    The eCryptfs module sends a message to a daemon by adding its message to the
    daemon's outgoing message queue. The daemon reads the device handle to get
    the oldest message off the queue.

    Incoming messages from the userspace daemon are immediately handled. If the
    message is a response, then the corresponding process that is blocked waiting
    for the response is awakened.

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

    Michael Halcrow
     
  • Callers of notify_change() need to hold i_mutex.

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

    Miklos Szeredi
     
  • __FUNCTION__ is gcc-specific, use __func__

    Signed-off-by: Harvey Harrison
    Cc: Michael Halcrow
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Harvey Harrison
     
  • Remove the no longer used ecryptfs_header_cache_0.

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

    Adrian Bunk
     

20 Mar, 2008

1 commit

  • ecryptfs_d_release() is doing a mntput before doing the dput. This patch
    moves the dput before the mntput.

    Thanks to Rajouri Jammu for reporting this.

    Signed-off-by: Michael Halcrow
    Cc: Rajouri Jammu
    Cc: Eric Sandeen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Halcrow
     

05 Mar, 2008

1 commit

  • When the page is not up to date, ecryptfs_prepare_write() should be
    acting much like ecryptfs_readpage(). This includes the painfully
    obvious step of actually decrypting the page contents read from the
    lower encrypted file.

    Note that this patch resolves a bug in eCryptfs in 2.6.24 that one can
    produce with these steps:

    # mount -t ecryptfs /secret /secret
    # echo "abc" > /secret/file.txt
    # umount /secret
    # mount -t ecryptfs /secret /secret
    # echo "def" >> /secret/file.txt
    # cat /secret/file.txt

    Without this patch, the resulting data returned from cat is likely to
    be something other than "abc\ndef\n".

    (Thanks to Benedikt Driessen for reporting this.)

    Signed-off-by: Michael Halcrow
    Cc: Benedikt Driessen
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Halcrow
     

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