Merge git://git.kernel.org/pub/scm/linux/kernel/git/agk/linux-2.6-dm
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 26 Mar 2011 03:51:44 +0000 (20:51 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 26 Mar 2011 03:51:44 +0000 (20:51 -0700)
* git://git.kernel.org/pub/scm/linux/kernel/git/agk/linux-2.6-dm:
  dm stripe: implement merge method
  dm mpath: allow table load with no priority groups
  dm mpath: fail message ioctl if specified path is not valid
  dm ioctl: add flag to wipe buffers for secure data
  dm ioctl: prepare for crypt key wiping
  dm crypt: wipe keys string immediately after key is set
  dm: add flakey target
  dm: fix opening log and cow devices for read only tables

1  2 
drivers/md/dm-crypt.c
drivers/md/dm-log.c

diff --combined drivers/md/dm-crypt.c
@@@ -991,6 -991,11 +991,6 @@@ static void clone_init(struct dm_crypt_
        clone->bi_destructor = dm_crypt_bio_destructor;
  }
  
 -static void kcryptd_unplug(struct crypt_config *cc)
 -{
 -      blk_unplug(bdev_get_queue(cc->dev->bdev));
 -}
 -
  static int kcryptd_io_read(struct dm_crypt_io *io, gfp_t gfp)
  {
        struct crypt_config *cc = io->target->private;
         * one in order to decrypt the whole bio data *afterwards*.
         */
        clone = bio_alloc_bioset(gfp, bio_segments(base_bio), cc->bs);
 -      if (!clone) {
 -              kcryptd_unplug(cc);
 +      if (!clone)
                return 1;
 -      }
  
        crypt_inc_pending(io);
  
@@@ -1324,20 -1331,29 +1324,29 @@@ static int crypt_setkey_allcpus(struct 
  
  static int crypt_set_key(struct crypt_config *cc, char *key)
  {
+       int r = -EINVAL;
+       int key_string_len = strlen(key);
        /* The key size may not be changed. */
-       if (cc->key_size != (strlen(key) >> 1))
-               return -EINVAL;
+       if (cc->key_size != (key_string_len >> 1))
+               goto out;
  
        /* Hyphen (which gives a key_size of zero) means there is no key. */
        if (!cc->key_size && strcmp(key, "-"))
-               return -EINVAL;
+               goto out;
  
        if (cc->key_size && crypt_decode_key(cc->key, key, cc->key_size) < 0)
-               return -EINVAL;
+               goto out;
  
        set_bit(DM_CRYPT_KEY_VALID, &cc->flags);
  
-       return crypt_setkey_allcpus(cc);
+       r = crypt_setkey_allcpus(cc);
+ out:
+       /* Hex key string not needed after here, so wipe it. */
+       memset(key, '0', key_string_len);
+       return r;
  }
  
  static int crypt_wipe_key(struct crypt_config *cc)
diff --combined drivers/md/dm-log.c
@@@ -251,20 -251,20 +251,20 @@@ struct log_c 
   */
  static inline int log_test_bit(uint32_t *bs, unsigned bit)
  {
 -      return ext2_test_bit(bit, (unsigned long *) bs) ? 1 : 0;
 +      return test_bit_le(bit, (unsigned long *) bs) ? 1 : 0;
  }
  
  static inline void log_set_bit(struct log_c *l,
                               uint32_t *bs, unsigned bit)
  {
 -      ext2_set_bit(bit, (unsigned long *) bs);
 +      __test_and_set_bit_le(bit, (unsigned long *) bs);
        l->touched_cleaned = 1;
  }
  
  static inline void log_clear_bit(struct log_c *l,
                                 uint32_t *bs, unsigned bit)
  {
 -      ext2_clear_bit(bit, (unsigned long *) bs);
 +      __test_and_clear_bit_le(bit, (unsigned long *) bs);
        l->touched_dirtied = 1;
  }
  
@@@ -543,7 -543,7 +543,7 @@@ static int disk_ctr(struct dm_dirty_lo
                return -EINVAL;
        }
  
-       r = dm_get_device(ti, argv[0], FMODE_READ | FMODE_WRITE, &dev);
+       r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &dev);
        if (r)
                return r;
  
@@@ -740,7 -740,7 +740,7 @@@ static int core_get_resync_work(struct 
                return 0;
  
        do {
 -              *region = ext2_find_next_zero_bit(
 +              *region = find_next_zero_bit_le(
                                             (unsigned long *) lc->sync_bits,
                                             lc->region_count,
                                             lc->sync_search);