All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Sachin Prabhu <sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	linux-cifs <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] Fix BUG() in calc_seckey()
Date: Tue, 18 Oct 2016 09:57:28 -0400	[thread overview]
Message-ID: <1476799048.8356.2.camel@redhat.com> (raw)
In-Reply-To: <1476736822-30098-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

On Mon, 2016-10-17 at 16:40 -0400, Sachin Prabhu wrote:
> 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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
>  fs/cifs/cifsencrypt.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
> index 8347c90..5eb0412 100644
> --- a/fs/cifs/cifsencrypt.c
> +++ b/fs/cifs/cifsencrypt.c
> @@ -808,7 +808,11 @@ 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);
>  
> @@ -816,7 +820,7 @@ calc_seckey(struct cifs_ses *ses)
>  	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,
> @@ -854,7 +858,8 @@ calc_seckey(struct cifs_ses *ses)
>  
>  out_free_cipher:
>  	crypto_free_skcipher(tfm_arc4);
> -
> +out:
> +	kfree(sec_key);
>  	return rc;
>  }
>  

Reviewed-by: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

      parent reply	other threads:[~2016-10-18 13:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-17 20:40 [PATCH] Fix BUG() in calc_seckey() Sachin Prabhu
     [not found] ` <1476736822-30098-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-10-18 12:46   ` Sachin Prabhu
2016-10-18 13:57   ` Jeff Layton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1476799048.8356.2.camel@redhat.com \
    --to=jlayton-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.