Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 7 Nov 2015 00:23:27 +0000 (16:23 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 7 Nov 2015 00:23:27 +0000 (16:23 -0800)
Pull ext4 updates from Ted Ts'o:
 "Add support for the CSUM_SEED feature which will allow future
  userspace utilities to change the file system's UUID without rewriting
  all of the file system metadata.

  A number of miscellaneous fixes, the most significant of which are in
  the ext4 encryption support.  Anyone wishing to use the encryption
  feature should backport all of the ext4 crypto patches up to 4.4 to
  get fixes to a memory leak and file system corruption bug.

  There are also cleanups in ext4's feature test macros and in ext4's
  sysfs support code"

* tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (26 commits)
  fs/ext4: remove unnecessary new_valid_dev check
  ext4: fix abs() usage in ext4_mb_check_group_pa
  ext4: do not allow journal_opts for fs w/o journal
  ext4: explicit mount options parsing cleanup
  ext4, jbd2: ensure entering into panic after recording an error in superblock
  [PATCH] fix calculation of meta_bg descriptor backups
  ext4: fix potential use after free in __ext4_journal_stop
  jbd2: fix checkpoint list cleanup
  ext4: fix xfstest generic/269 double revoked buffer bug with bigalloc
  ext4: make the bitmap read routines return real error codes
  jbd2: clean up feature test macros with predicate functions
  ext4: clean up feature test macros with predicate functions
  ext4: call out CRC and corruption errors with specific error codes
  ext4: store checksum seed in superblock
  ext4: reserve code points for the project quota feature
  ext4: promote ext4 over ext2 in the default probe order
  jbd2: gate checksum calculations on crc driver presence, not sb flags
  ext4: use private version of page_zero_new_buffers() for data=journal mode
  ext4 crypto: fix bugs in ext4_encrypted_zeroout()
  ext4 crypto: replace some BUG_ON()'s with error checks
  ...

1  2 
fs/ext4/crypto_key.c
fs/ext4/readpage.c

diff --combined fs/ext4/crypto_key.c
index 5c52c79dea4625c4a73d7d6195da9c1e39d6f02b,f9270ec2a1325cce3ae87ab69dc36481fef2ca5c..c5882b36e5582d0005582d0fe3ac86cab70d9c9c
@@@ -71,7 -71,6 +71,6 @@@ static int ext4_derive_key_aes(char der
                                     EXT4_AES_256_XTS_KEY_SIZE, NULL);
        res = crypto_ablkcipher_encrypt(req);
        if (res == -EINPROGRESS || res == -EBUSY) {
-               BUG_ON(req->base.data != &ecr);
                wait_for_completion(&ecr.completion);
                res = ecr.res;
        }
@@@ -121,7 -120,7 +120,7 @@@ int _ext4_get_encryption_info(struct in
        struct key *keyring_key = NULL;
        struct ext4_encryption_key *master_key;
        struct ext4_encryption_context ctx;
 -      struct user_key_payload *ukp;
 +      const struct user_key_payload *ukp;
        struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
        struct crypto_ablkcipher *ctfm;
        const char *cipher_str;
@@@ -208,8 -207,13 +207,13 @@@ retry
                goto out;
        }
        crypt_info->ci_keyring_key = keyring_key;
-       BUG_ON(keyring_key->type != &key_type_logon);
+       if (keyring_key->type != &key_type_logon) {
+               printk_once(KERN_WARNING
+                           "ext4: key type must be logon\n");
+               res = -ENOKEY;
+               goto out;
+       }
 -      ukp = ((struct user_key_payload *)keyring_key->payload.data);
 +      ukp = user_key_payload(keyring_key);
        if (ukp->datalen != sizeof(struct ext4_encryption_key)) {
                res = -EINVAL;
                goto out;
        master_key = (struct ext4_encryption_key *)ukp->data;
        BUILD_BUG_ON(EXT4_AES_128_ECB_KEY_SIZE !=
                     EXT4_KEY_DERIVATION_NONCE_SIZE);
-       BUG_ON(master_key->size != EXT4_AES_256_XTS_KEY_SIZE);
+       if (master_key->size != EXT4_AES_256_XTS_KEY_SIZE) {
+               printk_once(KERN_WARNING
+                           "ext4: key size incorrect: %d\n",
+                           master_key->size);
+               res = -ENOKEY;
+               goto out;
+       }
        res = ext4_derive_key_aes(ctx.nonce, master_key->raw,
                                  raw_key);
        if (res)
diff --combined fs/ext4/readpage.c
index 560af043770462df6170acd4d523f9d0385884a3,a91e4bf6ebc454802812907d261674c9254b6afe..d94af71a4e7fcabd1783f28cccb86363473fe3ae
@@@ -62,7 -62,7 +62,7 @@@ static void completion_pages(struct wor
        bio_for_each_segment_all(bv, bio, i) {
                struct page *page = bv->bv_page;
  
-               int ret = ext4_decrypt(ctx, page);
+               int ret = ext4_decrypt(page);
                if (ret) {
                        WARN_ON_ONCE(1);
                        SetPageError(page);
@@@ -165,8 -165,8 +165,8 @@@ int ext4_mpage_readpages(struct address
                if (pages) {
                        page = list_entry(pages->prev, struct page, lru);
                        list_del(&page->lru);
 -                      if (add_to_page_cache_lru(page, mapping,
 -                                                page->index, GFP_KERNEL))
 +                      if (add_to_page_cache_lru(page, mapping, page->index,
 +                                      GFP_KERNEL & mapping_gfp_mask(mapping)))
                                goto next_page;
                }