[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e1864c6d-6380-831f-9c2f-85611a78779b@huawei.com>
Date: Tue, 26 May 2020 15:21:05 +0800
From: "Longpeng (Mike, Cloud Infrastructure Service Product Dept.)"
<longpeng2@...wei.com>
To: Markus Elfring <Markus.Elfring@....de>,
<linux-crypto@...r.kernel.org>,
<virtualization@...ts.linux-foundation.org>
CC: Corentin Labbe <clabbe@...libre.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
"Michael S. Tsirkin" <mst@...hat.com>,
"Jason Wang" <jasowang@...hat.com>,
"David S. Miller" <davem@...emloft.net>,
Gonglei <arei.gonglei@...wei.com>,
<linux-kernel@...r.kernel.org>, <stable@...r.kernel.org>
Subject: Re: [PATCH v2 1/2] crypto: virtio: Fix src/dst scatterlist
calculation in __virtio_crypto_skcipher_do_req()
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)
Powered by blists - more mailing lists