Commit 5f4b5569 authored by Sachin Prabhu's avatar Sachin Prabhu Committed by Steve French

CIFS: Fix BUG() in calc_seckey()

Andy Lutromirski's new virtually mapped kernel stack allocations moves
kernel stacks the vmalloc area. This triggers the bug
 kernel BUG at ./include/linux/scatterlist.h:140!
at calc_seckey()->sg_init()
Signed-off-by: default avatarSachin Prabhu <sprabhu@redhat.com>
Signed-off-by: default avatarSteve French <smfrench@gmail.com>
Reviewed-by: default avatarJeff Layton <jlayton@redhat.com>
parent 88abd824
...@@ -808,7 +808,11 @@ calc_seckey(struct cifs_ses *ses) ...@@ -808,7 +808,11 @@ calc_seckey(struct cifs_ses *ses)
struct crypto_skcipher *tfm_arc4; struct crypto_skcipher *tfm_arc4;
struct scatterlist sgin, sgout; struct scatterlist sgin, sgout;
struct skcipher_request *req; struct skcipher_request *req;
unsigned char sec_key[CIFS_SESS_KEY_SIZE]; /* a nonce */ unsigned char *sec_key;
sec_key = kmalloc(CIFS_SESS_KEY_SIZE, GFP_KERNEL);
if (sec_key == NULL)
return -ENOMEM;
get_random_bytes(sec_key, CIFS_SESS_KEY_SIZE); get_random_bytes(sec_key, CIFS_SESS_KEY_SIZE);
...@@ -816,7 +820,7 @@ calc_seckey(struct cifs_ses *ses) ...@@ -816,7 +820,7 @@ calc_seckey(struct cifs_ses *ses)
if (IS_ERR(tfm_arc4)) { if (IS_ERR(tfm_arc4)) {
rc = PTR_ERR(tfm_arc4); rc = PTR_ERR(tfm_arc4);
cifs_dbg(VFS, "could not allocate crypto API arc4\n"); cifs_dbg(VFS, "could not allocate crypto API arc4\n");
return rc; goto out;
} }
rc = crypto_skcipher_setkey(tfm_arc4, ses->auth_key.response, rc = crypto_skcipher_setkey(tfm_arc4, ses->auth_key.response,
...@@ -854,7 +858,8 @@ calc_seckey(struct cifs_ses *ses) ...@@ -854,7 +858,8 @@ calc_seckey(struct cifs_ses *ses)
out_free_cipher: out_free_cipher:
crypto_free_skcipher(tfm_arc4); crypto_free_skcipher(tfm_arc4);
out:
kfree(sec_key);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment