All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gonglei (Arei)" <arei.gonglei@huawei.com>
To: longpeng <longpeng2@huawei.com>,
	"berrange@redhat.com" <berrange@redhat.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] crypto: afalg: fix a NULL pointer dereference
Date: Mon, 6 Nov 2017 10:21:47 +0000	[thread overview]
Message-ID: <33183CC9F5247A488A2544077AF19020DA461521@DGGEMA505-MBS.china.huawei.com> (raw)
In-Reply-To: <1509949271-36280-1-git-send-email-longpeng2@huawei.com>


> -----Original Message-----
> From: longpeng
> Sent: Monday, November 06, 2017 2:21 PM
> To: berrange@redhat.com; pbonzini@redhat.com; Gonglei (Arei)
> Cc: longpeng; qemu-devel@nongnu.org
> Subject: [PATCH] crypto: afalg: fix a NULL pointer dereference
> 
> Test-crypto-hash calls qcrypto_hash_bytesv/digest/base64 with
> errp=NULL, this will cause a NULL poniter deference if afalg_driver
> doesn't support requested algos:
>     ret = qcrypto_hash_afalg_driver.hash_bytesv(alg, iov, niov,
>                                                 result, resultlen,
>                                                 errp);
>     if (ret == 0) {
>         return ret;
>     }
> 
>     error_free(*errp);  // <--- here
> 
> So we must check 'errp & *errp' before dereference.
> 
> Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com>
> ---

Reported-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>

Thanks,
-Gonglei

>  crypto/hash.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/crypto/hash.c b/crypto/hash.c
> index ac59c63..c464c78 100644
> --- a/crypto/hash.c
> +++ b/crypto/hash.c
> @@ -60,7 +60,9 @@ int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg,
>       * TODO:
>       * Maybe we should treat some afalg errors as fatal
>       */
> -    error_free(*errp);
> +    if (errp && *errp) {
> +        error_free(*errp);
> +    }
>  #endif
> 
>      return qcrypto_hash_lib_driver.hash_bytesv(alg, iov, niov,
> --
> 1.8.3.1
> 

  reply	other threads:[~2017-11-06 10:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-06  6:21 [Qemu-devel] [PATCH] crypto: afalg: fix a NULL pointer dereference Longpeng(Mike)
2017-11-06 10:21 ` Gonglei (Arei) [this message]
2017-11-06 17:00 ` Eric Blake
2017-11-07  2:27   ` Longpeng (Mike)
2017-11-07  9:16     ` Daniel P. Berrange
2017-11-07  9:32       ` Longpeng (Mike)
2017-11-06 17:18 ` Stefan Hajnoczi
2017-11-07  1:13   ` Longpeng (Mike)

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=33183CC9F5247A488A2544077AF19020DA461521@DGGEMA505-MBS.china.huawei.com \
    --to=arei.gonglei@huawei.com \
    --cc=berrange@redhat.com \
    --cc=longpeng2@huawei.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.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.