diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-02-05 19:19:01 -0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-02-22 16:07:23 -0800 |
commit | 66aa3e1274fcf887e9d6501a68163270fc7718e7 (patch) | |
tree | 16e1eceb2697c666961be51bf341dc55e3037367 /fs/f2fs/crypto_key.c | |
parent | 8ef2af45ae20f6348eeb3d0156f3eeddac2289e1 (diff) | |
download | op-kernel-dev-66aa3e1274fcf887e9d6501a68163270fc7718e7.zip op-kernel-dev-66aa3e1274fcf887e9d6501a68163270fc7718e7.tar.gz |
f2fs crypto: replace some BUG_ON()'s with error checks
This patch adopts:
ext4 crypto: replace some BUG_ON()'s with error checks
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/crypto_key.c')
-rw-r--r-- | fs/f2fs/crypto_key.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/fs/f2fs/crypto_key.c b/fs/f2fs/crypto_key.c index 5de2d86..fc0e3cc 100644 --- a/fs/f2fs/crypto_key.c +++ b/fs/f2fs/crypto_key.c @@ -75,7 +75,6 @@ static int f2fs_derive_key_aes(char deriving_key[F2FS_AES_128_ECB_KEY_SIZE], F2FS_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; } @@ -198,7 +197,11 @@ 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 "f2fs: key type must be logon\n"); + res = -ENOKEY; + goto out; + } ukp = user_key_payload(keyring_key); if (ukp->datalen != sizeof(struct f2fs_encryption_key)) { res = -EINVAL; @@ -207,7 +210,13 @@ retry: master_key = (struct f2fs_encryption_key *)ukp->data; BUILD_BUG_ON(F2FS_AES_128_ECB_KEY_SIZE != F2FS_KEY_DERIVATION_NONCE_SIZE); - BUG_ON(master_key->size != F2FS_AES_256_XTS_KEY_SIZE); + if (master_key->size != F2FS_AES_256_XTS_KEY_SIZE) { + printk_once(KERN_WARNING + "f2fs: key size incorrect: %d\n", + master_key->size); + res = -ENOKEY; + goto out; + } res = f2fs_derive_key_aes(ctx.nonce, master_key->raw, raw_key); if (res) |