public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Longpeng (Mike, Cloud Infrastructure Service Product Dept.)"  <longpeng2@huawei.com>
To: Markus Elfring <Markus.Elfring@web.de>,
	<linux-crypto@vger.kernel.org>,
	<virtualization@lists.linux-foundation.org>
Cc: Corentin Labbe <clabbe@baylibre.com>,
	Gonglei <arei.gonglei@huawei.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] crypto: virtio: Fix use-after-free in virtio_crypto_skcipher_finalize_req()
Date: Tue, 26 May 2020 15:38:52 +0800	[thread overview]
Message-ID: <03d3387f-c886-4fb9-e6f2-9ff8dc6bb80a@huawei.com> (raw)
In-Reply-To: <0248e0f6-7648-f08d-afa2-170ad2e724b7@web.de>

Hi Markus,

On 2020/5/26 15:19, Markus Elfring wrote:
>> The system'll crash when the users insmod crypto/tcrypto.ko with mode=155
>> ( testing "authenc(hmac(sha1),cbc(aes))" ). It's caused by reuse the memory
>> of request structure.
> 
> Wording adjustments:
> * … system will crash …
> * … It is caused by reusing the …
> 
> 
>> when these memory will be used again.
> 
> when this memory …
> 
OK.

> 
>> … Thus release specific resources before
> 
> Is there a need to improve also this information another bit?
> 
You mean the last two paragraph is redundant ?
'''
When the virtio_crypto driver finish skcipher req, it'll call ->complete
callback(in crypto_finalize_skcipher_request) and then free its
resources whose pointers are recorded in 'skcipher parts'.

However, the ->complete is 'crypto_authenc_encrypt_done' in this case,
it will use the 'ahash part' of the request and change its content,
so virtio_crypto driver will get the wrong pointer after ->complete
finish and mistakenly free some other's memory. So the system will crash
when these memory will be used again.

The resources which need to be cleaned up are not used any more. But the
pointers of these resources may be changed in the function
"crypto_finalize_skcipher_request". Thus release specific resources before
calling this function.
'''

How about:
'''
When the virtio_crypto driver finish the skcipher request, it will call the
function "crypto_finalize_skcipher_request()" and then free the resources whose
pointers are stored in the 'skcipher parts', but the pointers of these resources
 may be changed in that function. Thus fix it by releasing these resources
befored calling the function "crypto_finalize_skcipher_request()".
'''


> Regards,
> Markus
> 
---
Regards,
Longpeng(Mike)

  reply	other threads:[~2020-05-26  7:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26  3:19 [PATCH v2 0/2] crypto: virtio: Fix two crash issue Longpeng(Mike)
2020-05-26  3:19 ` [PATCH v2 1/2] crypto: virtio: Fix src/dst scatterlist calculation in __virtio_crypto_skcipher_do_req() Longpeng(Mike)
2020-05-26  7:03   ` Markus Elfring
2020-05-26  7:21     ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2020-05-26  8:25       ` [v2 " Markus Elfring
2020-05-26 14:11   ` [PATCH v2 " Sasha Levin
2020-05-26  3:19 ` [PATCH v2 2/2] crypto: virtio: Fix use-after-free in virtio_crypto_skcipher_finalize_req() Longpeng(Mike)
2020-05-26  7:19   ` Markus Elfring
2020-05-26  7:38     ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.) [this message]
2020-05-26  9:01       ` [v2 " Markus Elfring
2020-05-26  9:24         ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2020-05-26  9:30           ` Markus Elfring
2020-05-26 10:16           ` Greg KH
2020-05-26 12:00   ` [PATCH v2 " Gonglei (Arei)
2020-05-26 14:11   ` Sasha Levin
2020-05-31  9:21     ` Michael S. Tsirkin
2020-06-02  3:54       ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)

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=03d3387f-c886-4fb9-e6f2-9ff8dc6bb80a@huawei.com \
    --to=longpeng2@huawei.com \
    --cc=Markus.Elfring@web.de \
    --cc=arei.gonglei@huawei.com \
    --cc=clabbe@baylibre.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=jasowang@redhat.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox