mirror of https://lore.kernel.org/lkml/
 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>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	Gonglei <arei.gonglei@huawei.com>, <linux-kernel@vger.kernel.org>,
	<stable@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] crypto: virtio: Fix src/dst scatterlist calculation in __virtio_crypto_skcipher_do_req()
Date: Tue, 26 May 2020 15:21:05 +0800	[thread overview]
Message-ID: <e1864c6d-6380-831f-9c2f-85611a78779b@huawei.com> (raw)
In-Reply-To: <d58a046a-e559-55be-16ba-64db43a06568@web.de>

Hi Markus,

On 2020/5/26 15:03, Markus Elfring wrote:
>> Fix it by sg_next() on calculation of src/dst scatterlist.
> 
> Wording adjustment:
> … by calling the function “sg_next” …
> 
OK, thanks.

> 
> …
>> +++ b/drivers/crypto/virtio/virtio_crypto_algs.c
>> @@ -350,13 +350,18 @@ __virtio_crypto_skcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req,
> …
>>  	src_nents = sg_nents_for_len(req->src, req->cryptlen);
>> +	if (src_nents < 0) {
>> +		pr_err("Invalid number of src SG.\n");
>> +		return src_nents;
>> +	}
>> +
>>  	dst_nents = sg_nents(req->dst);
> …
> 
> I suggest to move the addition of such input parameter validation
> to a separate update step.
> 
Um...The 'src_nents' will be used as a loop condition, so validate it here is
needed ?

'''
 	/* Source data */
-	for (i = 0; i < src_nents; i++)
-		sgs[num_out++] = &req->src[i];
+	for (sg = req->src; src_nents; sg = sg_next(sg), src_nents--)
+		sgs[num_out++] = sg;
'''

> Regards,
> Markus
> 

-- 
---
Regards,
Longpeng(Mike)

  reply	other threads:[~2020-05-26  7:21 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.) [this message]
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.)
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=e1864c6d-6380-831f-9c2f-85611a78779b@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

all inboxes | Powered by JetHome®