17 Oct, 2007

40 commits

  • 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
     
  • This patch sets up and destroys the persistent lower file for each eCryptfs
    inode.

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

    Michael Halcrow
     
  • Replace page encryption and decryption routines and inode size write routine
    with versions that utilize the read_write.c functions.

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

    Michael Halcrow
     
  • Add a set of functions through which all I/O to lower files is consolidated.
    This patch adds a new inode_info reference to a persistent lower file for each
    eCryptfs inode; another patch later in this series will set that up. This
    persistent lower file is what the read_write.c functions use to call
    vfs_read() and vfs_write() on the lower filesystem, so even when reads and
    writes come in through aops->readpage and aops->writepage, we can satisfy them
    without resorting to direct access to the lower inode's address space.
    Several function declarations are going to be changing with this patchset.
    For now, in order to keep from breaking the build, I am putting dummy
    parameters in for those functions.

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

    Michael Halcrow
     
  • The error paths and the module exit code need work. sysfs
    unregistration is not the right place to tear down the crypto
    subsystem, and the code to undo subsystem initializations on various
    error paths is unnecessarily duplicated. This patch addresses those
    issues.

    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
     
  • There is no point to keeping a separate header_extent_size and an extent_size.
    The total size of the header can always be represented as some multiple of
    the regular data extent size.

    [randy.dunlap@oracle.com: ecryptfs: fix printk format warning]
    Signed-off-by: Michael Halcrow
    Signed-off-by: Randy Dunlap
    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
     
  • Andrew Morton wrote:
    > Please check that all the newly-added global symbols do indeed need
    > to be global.

    Change symbols in keystore.c and crypto.o to static if they do not
    need to be global.

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

    Michael Halcrow
     
  • Andrew Morton wrote:
    > > struct mutex *tfm_mutex = NULL;
    >
    > This initialisation looks like it's here to kill bogus gcc warning
    > (if it is, it should have been commented). Please investigate
    > uninitialized_var() and __maybe_unused sometime.

    Remove some unnecessary variable initializations. There may be a few
    more such intializations remaining in the code base; a future patch
    will take care of those.

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

    Michael Halcrow
     
  • Andrew Morton wrote:
    From: mhalcrow@us.ibm.com
    > > +/**
    > > + * decrypt_passphrase_encrypted_session_key - Decrypt the session key
    > > + * with the given auth_tok.
    > > *
    > > * Returns Zero on success; non-zero error otherwise.
    > > */
    >
    > That comment purports to be a kerneldoc-style comment. But
    >
    > - kerneldoc doesn't support multiple lines on the introductory line
    > which identifies the name of the function (alas). So you'll need to
    > overflow 80 cols here.
    >
    > - the function args weren't documented
    >
    > But the return value is! People regularly forget to do that. And
    > they frequently forget to document the locking prerequisites and the
    > permissible calling contexts (process/might_sleep/hardirq, etc)
    >
    > (please check all ecryptfs kerneldoc for this stuff sometime)

    This patch cleans up some of the existing comments and makes a couple
    of line break tweaks. There is more work to do to bring eCryptfs into
    full kerneldoc-compliance.

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

    Michael Halcrow
     
  • Andrew Morton wrote:
    > > +struct ecryptfs_global_auth_tok {
    > > +#define ECRYPTFS_AUTH_TOK_INVALID 0x00000001
    > > + u32 flags;
    > > + struct list_head mount_crypt_stat_list;
    > > + struct key *global_auth_tok_key;
    > > + struct ecryptfs_auth_tok *global_auth_tok;
    > > + unsigned char sig[ECRYPTFS_SIG_SIZE_HEX + 1];
    > > +};
    > > +
    > > +struct ecryptfs_key_tfm {
    > > + struct crypto_blkcipher *key_tfm;
    > > + size_t key_size;
    > > + struct mutex key_tfm_mutex;
    > > + struct list_head key_tfm_list;
    > > + unsigned char cipher_name[ECRYPTFS_MAX_CIPHER_NAME_SIZE + 1];
    > > +};
    >
    > Please consider commenting your struct fields carefully: it's a
    > great way to help other to understand your code.

    Add some comments to the ecryptfs_global_auth_tok and ecryptfs_key_tfm
    structs to make their functions more easily ascertained.

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

    Michael Halcrow
     
  • Andrew Morton wrote:
    > > +int ecryptfs_destruct_crypto(void)
    >
    > ecryptfs_destroy_crypto would be more grammatically correct ;)

    Grammatical fix for some function names.

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

    Michael Halcrow
     
  • Andrew Morton wrote:
    > > + crypt_stat->flags |= ECRYPTFS_ENCRYPTED;
    > > + crypt_stat->flags |= ECRYPTFS_KEY_VALID;
    >
    > Maybe the compiler can optimise those two statements, but we'd
    > normally provide it with some manual help.

    This patch provides the compiler with some manual help for
    optimizing the setting of some flags.

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

    Michael Halcrow
     
  • Andrew Morton wrote:
    > > + mutex_lock(&mount_crypt_stat->global_auth_tok_list_mutex);
    > > + BUG_ON(mount_crypt_stat->num_global_auth_toks == 0);
    > > + mutex_unlock(&mount_crypt_stat->global_auth_tok_list_mutex);
    >
    > That's odd-looking. If it was a bug for num_global_auth_toks to be
    > zero, and if that mutex protects num_global_auth_toks then as soon
    > as the lock gets dropped, another thread can make
    > num_global_auth_toks zero, hence the bug is present. Perhaps?

    That was serving as an internal sanity check that should not have made
    it into the final patch set in the first place. This patch removes it.

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

    Michael Halcrow
     
  • fs/ecryptfs/keystore.c: In function 'parse_tag_1_packet':
    fs/ecryptfs/keystore.c:557: warning: format '%d' expects type 'int', but argument 2 has type 'size_t'
    fs/ecryptfs/keystore.c: In function 'parse_tag_3_packet':
    fs/ecryptfs/keystore.c:690: warning: format '%d' expects type 'int', but argument 2 has type 'size_t'
    fs/ecryptfs/keystore.c: In function 'parse_tag_11_packet':
    fs/ecryptfs/keystore.c:836: warning: format '%d' expects type 'int', but argument 2 has type 'size_t'
    fs/ecryptfs/keystore.c: In function 'write_tag_1_packet':
    fs/ecryptfs/keystore.c:1413: warning: format '%d' expects type 'int', but argument 2 has type 'size_t'
    fs/ecryptfs/keystore.c:1413: warning: format '%d' expects type 'int', but argument 3 has type 'long unsigned int'
    fs/ecryptfs/keystore.c: In function 'write_tag_11_packet':
    fs/ecryptfs/keystore.c:1472: warning: format '%d' expects type 'int', but argument 2 has type 'size_t'
    fs/ecryptfs/keystore.c: In function 'write_tag_3_packet':
    fs/ecryptfs/keystore.c:1663: warning: format '%d' expects type 'int', but argument 2 has type 'size_t'
    fs/ecryptfs/keystore.c:1663: warning: format '%d' expects type 'int', but argument 3 has type 'long unsigned int'
    fs/ecryptfs/keystore.c: In function 'ecryptfs_generate_key_packet_set':
    fs/ecryptfs/keystore.c:1778: warning: passing argument 2 of 'write_tag_11_packet' from incompatible pointer type
    fs/ecryptfs/main.c: In function 'ecryptfs_parse_options':
    fs/ecryptfs/main.c:363: warning: format '%d' expects type 'int', but argument 3 has type 'size_t'

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

    Andrew Morton
     
  • Trivial updates to comment and debug statement.

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

    Michael Halcrow
     
  • Fix up the Tag 11 writing code to handle size limits and boundaries more
    explicitly. It looks like the packet length was 1 shorter than it should have
    been, chopping off the last byte of the key identifier. This is largely
    inconsequential, since it is not much more likely that a key identifier
    collision will occur with 7 bytes rather than 8. This patch fixes the packet
    to use the full number of bytes that were originally intended to be used for
    the key identifier.

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

    Michael Halcrow
     
  • Fix up the Tag 11 parsing code to handle size limits and boundaries more
    explicitly. Pay attention to *8* bytes for the key identifier (literal data),
    no more, no less.

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

    Michael Halcrow
     
  • Fix up the Tag 3 parsing code to handle size limits and boundaries more
    explicitly.

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

    Michael Halcrow
     
  • Fix up the Tag 1 parsing code to handle size limits and boundaries more
    explicitly. Initialize the new auth_tok's flags.

    Signed-off-by: Michael Halcrow
    Cc: Josef Sipek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Halcrow
     
  • Introduce kmem_cache objects for handling multiple keys per inode. Add calls
    in the module init and exit code to call the key list
    initialization/destruction functions.

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

    Michael Halcrow
     
  • Use list_for_each_entry_safe() when wiping the authentication token list.

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

    Michael Halcrow
     
  • Add support structures for handling multiple keys. The list in crypt_stat
    contains the key identifiers for all of the keys that should be used for
    encrypting each file's File Encryption Key (FEK). For now, each inode
    inherits this list from the mount-wide crypt_stat struct, via the
    ecryptfs_copy_mount_wide_sigs_to_inode_sigs() function.

    This patch also removes the global key tfm from the mount-wide crypt_stat
    struct, instead keeping a list of tfm's meant for dealing with the various
    inode FEK's. eCryptfs will now search the user's keyring for FEK's parsed
    from the existing file metadata, so the user can make keys available at any
    time before or after mounting.

    Now that multiple FEK packets can be written to the file metadata, we need to
    be more meticulous about size limits. The updates to the code for writing out
    packets to the file metadata makes sizes and limits more explicit, uniformly
    expressed, and (hopefully) easier to follow.

    Signed-off-by: Michael Halcrow
    Cc: "Serge E. Hallyn"
    Cc: David Howells
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Halcrow
     
  • This patch makes the following needlessly global functions static:
    - exp_get_by_name()
    - exp_parent()
    - exp_find()

    Signed-off-by: Adrian Bunk
    Cc: Neil Brown
    Cc: "J. Bruce Fields"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Adrian Bunk
     
  • In drivers/isdn/capi/kcapi.c::old_capi_manufacturer(), if the call to
    get_capi_ctr_by_nr(ldef.contr); in line 823 returns NULL, then we'll be
    dereferencing a NULL pointer in the very next line.

    (Found by Coverity checker as bug #402)

    Signed-off-by: Jesper Juhl
    Acked-by: Karsten Keil
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jesper Juhl
     
  • If we fail to allocate an skb in
    drivers/isdn/capi/capidrv.c::send_message(), then we'll end up
    dereferencing a NULL pointer.
    Since out of memory conditions are not unheard of, I believe it
    is better to print a error message and just return rather than
    bring down the whole kernel.
    Sure, doing this may upset some application, but that's still
    better than crashing the whole system.

    Signed-off-by: Jesper Juhl
    Acked-by: Karsten Keil
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jesper Juhl
     
  • The ISDN subsystem common functions use a semaphore as mutex. Use the
    mutex API instead of the (binary) semaphore.

    Signed-off-by: Matthias Kaehlcke
    Acked-by: Karsten Keil
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matthias Kaehlcke
     
  • Remove pointless taking of spinlock around reading a single pointer-sized
    or smaller variable.

    Signed-off-by: Tilman Schmidt
    Acked-by: Karsten Keil
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tilman Schmidt
     
  • Introduce architecture dependent kretprobe blacklists to prohibit users
    from inserting return probes on the function in which kprobes can be
    inserted but kretprobes can not.

    This patch also removes "__kprobes" mark from "__switch_to" on x86_64 and
    registers "__switch_to" to the blacklist on x86-64, because that mark is to
    prohibit user from inserting only kretprobe.

    Signed-off-by: Masami Hiramatsu
    Cc: Prasanna S Panchamukhi
    Acked-by: Ananth N Mavinakayanahalli
    Cc: Anil S Keshavamurthy
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Masami Hiramatsu
     
  • Make the SPI framework and drivers stop using class_device. Update docs
    accordingly ... highlighting just which sysfs paths should be
    "safe"/stable.

    Signed-off-by: Tony Jones
    Signed-off-by: David Brownell
    Cc: Greg KH
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tony Jones
     
  • Constify two char pointers and a struct in Documentation/spi/spidev_test.c.

    Acked-by: David Brownell
    Cc: Anton Vorontsov
    Signed-off-by: WANG Cong
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    WANG Cong
     
  • Currently, all QE SPI controllers are almost the same comparing to
    MPC83xx's, thus let's use that driver for them.

    Tested to work on MPC85xx in loopback mode.

    Signed-off-by: Anton Vorontsov
    Acked-by: Kumar Gala
    Signed-off-by: David Brownell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Anton Vorontsov
     
  • Shrink the runtime footprint of various SPI drivers:

    - Move the probe() routine into the init section where practical,
    using platform_driver_probe() to make that safe. This often saves
    around 1KB. Using platform_driver_probe() can also be a correctness
    fix, if the probe routine is already marked __init but the driver
    struct keeps a dangling pointer to it after init section removal.

    - Likewise move remove() routines into the exit sections.

    These changes would be inappropriate iff the platform devices were
    actually hotpluggable (e.g. they're found on optional addon cards,
    or in an FPGA that's dynamically reprogrammed). In these cases,
    that's not the situation; it's an SOC controller and the only device
    is initialized before these drivers.

    Signed-off-by: David Brownell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     
  • Remove unused variable & write space

    Signed-off-by: Kyungmin Park
    Signed-off-by: David Brownell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kyungmin Park
     
  • This patch cleans up duplicate includes in
    drivers/spi/

    Signed-off-by: Jesper Juhl
    Acked-by: David Brownell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jesper Juhl
     
  • Remove the cpuset hooks that defined sched domains depending on the setting
    of the 'cpu_exclusive' flag.

    The cpu_exclusive flag can only be set on a child if it is set on the
    parent.

    This made that flag painfully unsuitable for use as a flag defining a
    partitioning of a system.

    It was entirely unobvious to a cpuset user what partitioning of sched
    domains they would be causing when they set that one cpu_exclusive bit on
    one cpuset, because it depended on what CPUs were in the remainder of that
    cpusets siblings and child cpusets, after subtracting out other
    cpu_exclusive cpusets.

    Furthermore, there was no way on production systems to query the
    result.

    Using the cpu_exclusive flag for this was simply wrong from the get go.

    Fortunately, it was sufficiently borked that so far as I know, almost no
    successful use has been made of this. One real time group did use it to
    affectively isolate CPUs from any load balancing efforts. They are willing
    to adapt to alternative mechanisms for this, such as someway to manipulate
    the list of isolated CPUs on a running system. They can do without this
    present cpu_exclusive based mechanism while we develop an alternative.

    There is a real risk, to the best of my understanding, of users
    accidentally setting up a partitioned scheduler domains, inhibiting desired
    load balancing across all their CPUs, due to the nonobvious (from the
    cpuset perspective) side affects of the cpu_exclusive flag.

    Furthermore, since there was no way on a running system to see what one was
    doing with sched domains, this change will be invisible to any using code.
    Unless they have real insight to the scheduler load balancing choices, they
    will be unable to detect that this change has been made in the kernel's
    behaviour.

    Initial discussion on lkml of this patch has generated much comment. My
    (probably controversial) take on that discussion is that it has reached a
    rough concensus that the current cpuset cpu_exclusive mechanism for
    defining sched domains is borked. There is no concensus on the
    replacement. But since we can remove this mechanism, and since its
    continued presence risks causing unwanted partitioning of the schedulers
    load balancing, we should remove it while we can, as we proceed to work the
    replacement scheduler domain mechanisms.

    Signed-off-by: Paul Jackson
    Cc: Ingo Molnar
    Cc: Nick Piggin
    Cc: Christoph Lameter
    Cc: Dinakar Guniguntala
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Paul Jackson
     
  • Add code to connect to the DCA driver and provide cpu tags for use by
    drivers that would like to use Direct Cache Access hints.

    [Adrian Bunk] Several Kconfig cleanup items
    [Andrew Morten, Chris Leech] Fix for using cpu_physical_id() even when
    built for uni-processor

    Signed-off-by: Shannon Nelson
    Acked-by: David S. Miller
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Shannon Nelson
     
  • Direct Cache Access (DCA) is a method for warming the CPU cache before data
    is used, with the intent of lessening the impact of cache misses. This
    patch adds a manager and interface for matching up client requests for DCA
    services with devices that offer DCA services.

    In order to use DCA, a module must do bus writes with the appropriate tag
    bits set to trigger a cache read for a specific CPU. However, different
    CPUs and chipsets can require different sets of tag bits, and the methods
    for determining the correct bits may be simple hardcoding or may be a
    hardware specific magic incantation. This interface is a way for DCA
    clients to find the correct tag bits for the targeted CPU without needing
    to know the specifics.

    [Dave Miller] use DEFINE_SPINLOCK()

    Signed-off-by: Shannon Nelson
    Acked-by: David S. Miller
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Shannon Nelson