Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4602054iob; Sun, 8 May 2022 18:51:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhw/dQ8hOTh/IINuysoVFC5Ul4MHVVHPWyFghlUT8irwfmbt3bSupW2FuHkSqLEb9bXncf X-Received: by 2002:aa7:9085:0:b0:50d:35ae:271 with SMTP id i5-20020aa79085000000b0050d35ae0271mr13591630pfa.42.1652061118150; Sun, 08 May 2022 18:51:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652061118; cv=none; d=google.com; s=arc-20160816; b=zWZhPMeC8axlCU8oj1/74eQedxSD23iBb4DPCFABbvYFyXkuGUmsVeoFFFYAGAxokZ fs7HOEzPL7PwAPUyjLsDSuzraLmW2TxCOfp1OCMcOjerBvhr2iibSOvnRO9kZR9JeI8j jVhDlq8P1U1WqD7EDwbYR2ZwIzs1ETenf7QB8OTNz3W9rX1zdm0Y75EdBgoY95Kqqa6V kXNsCqG47+NbpfoUue8HzsNfDdB4T0JXl3Sf/FYyEDfi2H+SovvhJGoHd8hJjP2fP1z9 XdUHCKhfH97WdtFlBXOKF0wmp2Q0uAtvsLi0jOi+hVJITui5+/3voS/OEjuruH4ggiXy pV3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=cIrrx6mRSwo60pX89eo2eRfInBTN0/BTTHo6lzKsSCA=; b=lFdXkcGlNIBOB3L62Rr3Xomz4iPKZd8UF8adYhWjojyH8eT0xcCqarc7XaVbunTFfQ ENn6Z4iC5bREKoDINNg10ohtP4mm0wUGupSZZmdGhtW0AWkLvlrjGT97Xr3J4bMmMFql HAUMsQzX3UrbBX4ubSFfClqxICwbAWBlPzRdmS+5VXsWZBKyoISEPyGZo/1gAO/P/qn1 qWKjWC17yUtAjzDHKRUDSm6Zqota9u4GoONBO89/EEVT+45cwnB8SFjO13j4c4/TdX4c XJ1gNHuWf4o65CbsLac7Z/ttoQ7sslUyOYlx2/4dtxWXRZHPIcu+ydM7F3z4urt3dZxQ lcQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 127-20020a630185000000b003c65a5b6b46si9816466pgb.528.2022.05.08.18.51.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 18:51:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AFFA341FBA; Sun, 8 May 2022 18:50:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390503AbiEFJbs convert rfc822-to-8bit (ORCPT + 99 others); Fri, 6 May 2022 05:31:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1390489AbiEFJbr (ORCPT ); Fri, 6 May 2022 05:31:47 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C5CD64BC4; Fri, 6 May 2022 02:28:04 -0700 (PDT) Received: from kwepemi500011.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4KvlZS3bvfz1JBmX; Fri, 6 May 2022 17:26:56 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by kwepemi500011.china.huawei.com (7.221.188.124) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 6 May 2022 17:28:01 +0800 Received: from dggpemm500006.china.huawei.com ([7.185.36.236]) by dggpemm500006.china.huawei.com ([7.185.36.236]) with mapi id 15.01.2375.024; Fri, 6 May 2022 17:28:01 +0800 From: "Gonglei (Arei)" To: zhenwei pi , "mst@redhat.com" CC: "jasowang@redhat.com" , "herbert@gondor.apana.org.au" , "linux-kernel@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "linux-crypto@vger.kernel.org" , "helei.sig11@bytedance.com" , "davem@davemloft.net" Subject: RE: [PATCH v5 4/5] virtio-crypto: adjust dst_len at ops callback Thread-Topic: [PATCH v5 4/5] virtio-crypto: adjust dst_len at ops callback Thread-Index: AQHYYGJ6/Z4WULmv0kCZX8LJqZ7zXa0Rlkkg Date: Fri, 6 May 2022 09:28:01 +0000 Message-ID: References: <20220505092408.53692-1-pizhenwei@bytedance.com> <20220505092408.53692-5-pizhenwei@bytedance.com> In-Reply-To: <20220505092408.53692-5-pizhenwei@bytedance.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.149.11] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: zhenwei pi [mailto:pizhenwei@bytedance.com] > Sent: Thursday, May 5, 2022 5:24 PM > To: Gonglei (Arei) ; mst@redhat.com > Cc: jasowang@redhat.com; herbert@gondor.apana.org.au; > linux-kernel@vger.kernel.org; virtualization@lists.linux-foundation.org; > linux-crypto@vger.kernel.org; helei.sig11@bytedance.com; > pizhenwei@bytedance.com; davem@davemloft.net > Subject: [PATCH v5 4/5] virtio-crypto: adjust dst_len at ops callback > > From: lei he > > For some akcipher operations(eg, decryption of pkcs1pad(rsa)), the length of > returned result maybe less than akcipher_req->dst_len, we need to recalculate > the actual dst_len through the virt-queue protocol. > > Cc: Michael S. Tsirkin > Cc: Jason Wang > Cc: Gonglei > Signed-off-by: lei he > Signed-off-by: zhenwei pi > --- > drivers/crypto/virtio/virtio_crypto_akcipher_algs.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > Reviewed-by: Gonglei Regards, -Gonglei > diff --git a/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c > b/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c > index 382ccec9ab12..2a60d0525cde 100644 > --- a/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c > +++ b/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c > @@ -90,9 +90,12 @@ static void > virtio_crypto_dataq_akcipher_callback(struct virtio_crypto_request * > } > > akcipher_req = vc_akcipher_req->akcipher_req; > - if (vc_akcipher_req->opcode != VIRTIO_CRYPTO_AKCIPHER_VERIFY) > + if (vc_akcipher_req->opcode != VIRTIO_CRYPTO_AKCIPHER_VERIFY) { > + /* actuall length maybe less than dst buffer */ > + akcipher_req->dst_len = len - sizeof(vc_req->status); > sg_copy_from_buffer(akcipher_req->dst, > sg_nents(akcipher_req->dst), > vc_akcipher_req->dst_buf, akcipher_req->dst_len); > + } > virtio_crypto_akcipher_finalize_req(vc_akcipher_req, akcipher_req, > error); } > > -- > 2.20.1