Skip to content

Commit

Permalink
CIFS: Fix BUG() in calc_seckey()
Browse files Browse the repository at this point in the history
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: Sachin Prabhu <sprabhu@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
  • Loading branch information
Sachin Prabhu authored and Steve French committed Nov 29, 2016
1 parent 88abd82 commit 5f4b556
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions fs/cifs/cifsencrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,15 +808,19 @@ calc_seckey(struct cifs_ses *ses)
struct crypto_skcipher *tfm_arc4;
struct scatterlist sgin, sgout;
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);

tfm_arc4 = crypto_alloc_skcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(tfm_arc4)) {
rc = PTR_ERR(tfm_arc4);
cifs_dbg(VFS, "could not allocate crypto API arc4\n");
return rc;
goto out;
}

rc = crypto_skcipher_setkey(tfm_arc4, ses->auth_key.response,
Expand Down Expand Up @@ -854,7 +858,8 @@ calc_seckey(struct cifs_ses *ses)

out_free_cipher:
crypto_free_skcipher(tfm_arc4);

out:
kfree(sec_key);
return rc;
}

Expand Down

0 comments on commit 5f4b556

Please sign in to comment.