Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3214145rwb; Thu, 29 Sep 2022 23:40:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5y7z+t0aXQLrL1YRJXFrMw8yJPZjpmxMBXtexz3UMC/ZESQn9DqLeKWXeFn5qJol+MmQvF X-Received: by 2002:a05:6402:2994:b0:453:4c5c:d31c with SMTP id eq20-20020a056402299400b004534c5cd31cmr6734464edb.412.1664520041853; Thu, 29 Sep 2022 23:40:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664520041; cv=none; d=google.com; s=arc-20160816; b=iJw7/vSdF36JxbYmXAB8OpKRS3UlIJ69ZEGoAQz0qYU+d3pAFLgjM2ELpgh3GXIdGB uMt7zbvD7F8Fde+7SIuRlJ03eiS0bDjsIl9OxBz+eetEzOhcJvTki1gH+x1Niue6hfm5 bmPwKtndvNlkWdA7wUPz8/ISMzU+CmKOu5ecmgK5WQbG3YYVZ1WlR5ddrMDomCMnpO6S zyiB7QcTV/aYQK2+QsHDafm3+VgifDbIWr22lRv1JwhgT6y0cSyBUXisDe+hW5nBGddJ VtB3foIsygIWdngQCUpm8QqT41Ezd+ESYca7/XrJWt8mONH+XeBcAG/dD1Fw957Qxq+8 iNOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=3/r9sEUFsrXGDfR2A939Zx+57F6Hk0ETCIfd1KtmpRg=; b=qEQmoXJRCYD/Nvy0mZ2IjYG4X/1tkYmxx428+EO1lAlwtHyIuHzOvwGxb77bzko3bp TxsenxvSd8V3n1mWEHAQ0umb5+s+BOrrKqRZXsbi6ETg6VzgBRoA/c/tVEOZT0q55QXJ zSaIDqH0ieHZGaMqNusN38RLHyNnYcBsNVU3s2mmE9zvN6dtPHAOqYhrjduMr/pEajHI cKR4LXgZ7kdr23KSrj/2L8HCWMZWfYGamJ/uf8f0Dbx+D2orFLNn5678QKQmJZm5PZJx fDfyf811RgbWTlVXWtDkJfPpTGPBC/IFgAjhNDxLuAZSTucYQUFr0aQBOv1lHcZuLjPL iSfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=rmmTyeDl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he30-20020a1709073d9e00b0077fc66b581esi1401567ejc.688.2022.09.29.23.40.16; Thu, 29 Sep 2022 23:40:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=rmmTyeDl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230319AbiI3Gcp (ORCPT + 99 others); Fri, 30 Sep 2022 02:32:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230079AbiI3Gcm (ORCPT ); Fri, 30 Sep 2022 02:32:42 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0FFA1F7EF0 for ; Thu, 29 Sep 2022 23:32:38 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id bh13so3379273pgb.4 for ; Thu, 29 Sep 2022 23:32:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date; bh=3/r9sEUFsrXGDfR2A939Zx+57F6Hk0ETCIfd1KtmpRg=; b=rmmTyeDlrcMvucl2X8jk6lyNFKDDEWmaR1R4JCIcG898/vY5v/QeVWWbr7ND97HZXm jjLvF6wZNjMY29QFrhV+SvySRh5+x87c6qfpna+BvQkNsSVfc+gMOpL896GSnQCdD+ek ARz9Ah2SCAXym3K6YdRXhYuMFrEfU0d7HWvRmgxLanc/WwRPzE8JZrTMyiaczojlMQMA t6jsQAtYH2Prs8btPOienzHK6sKYqrnzWmlj0K9klmUYm/TYAkUf9tYEFlH5ZGQdTiaJ NxTnaNZBMdy5cNDXoo3fYw5Pt6JDEOD6oyf9mAVaQX/yGNdxADrTvLNSZoABBhn0aVwj EjmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=3/r9sEUFsrXGDfR2A939Zx+57F6Hk0ETCIfd1KtmpRg=; b=dgE3PNBSlRHgH2lNH5XIjhF1yq8VdlKfjzz6L7gzu/K+VJoqyt3qs+0oGnRMULyKE2 JDh8xmgM8SUYpUAZjy6M+fq0i2mA66JEgZXtDXMsWDLX2OFtd1jSyFcpoSMA3lZJAWQN UKBkujyh7TQRkL2XzTXIWbeqxJAQwUXIyGrxIUq5vXrgbMYg9fu+rA/F7+5IqK1uI020 QaIbLkswJhYamUKsAhzTnD4dN+GpfXaPntiBqZ1xosLK8NjIvOyeSRYYoQHRT1hvYKLT 1h9LxDwkSg23Des8uPeLgwm1/qeZusv0BX1EhNu/hgsViSf7QhPBsmRxTXE4hqeyH3zM IzaQ== X-Gm-Message-State: ACrzQf1nqpv3XQ5jnR3ZjePk1kqEAuGLtXK9z9nVpYJ/W0Xbv9dFwp7w L7rundlTPwjRLGqs6h6+GShhq1yPn1Dow4O7 X-Received: by 2002:a63:f014:0:b0:43c:2ad9:ae9 with SMTP id k20-20020a63f014000000b0043c2ad90ae9mr6385345pgh.8.1664519556735; Thu, 29 Sep 2022 23:32:36 -0700 (PDT) Received: from [10.76.53.66] ([61.120.150.74]) by smtp.gmail.com with ESMTPSA id o1-20020a17090ab88100b00203059fc75bsm865642pjr.5.2022.09.29.23.32.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Sep 2022 23:32:36 -0700 (PDT) Message-ID: Date: Fri, 30 Sep 2022 14:31:28 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: Re: [PATCH v2 RESEND] virtio-crypto: fix memory-leak Content-Language: en-US To: Herbert Xu Cc: mst@redhat.com, arei.gonglei@huawei.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220919075158.3625-1-helei.sig11@bytedance.com> From: zhenwei pi In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On 9/30/22 14:14, Herbert Xu wrote: > On Mon, Sep 19, 2022 at 03:51:58PM +0800, Lei He wrote: >> From: lei he >> >> Fix memory-leak for virtio-crypto akcipher request, this problem is >> introduced by 59ca6c93387d3(virtio-crypto: implement RSA algorithm). >> The leak can be reproduced and tested with the following script >> inside virtual machine: >> >> #!/bin/bash >> >> LOOP_TIMES=10000 >> >> # required module: pkcs8_key_parser, virtio_crypto >> modprobe pkcs8_key_parser # if CONFIG_PKCS8_PRIVATE_KEY_PARSER=m >> modprobe virtio_crypto # if CONFIG_CRYPTO_DEV_VIRTIO=m >> rm -rf /tmp/data >> dd if=/dev/random of=/tmp/data count=1 bs=230 >> >> # generate private key and self-signed cert >> openssl req -nodes -x509 -newkey rsa:2048 -keyout key.pem \ >> -outform der -out cert.der \ >> -subj "/C=CN/ST=GD/L=SZ/O=vihoo/OU=dev/CN=always.com/emailAddress=yy@always.com" >> # convert private key from pem to der >> openssl pkcs8 -in key.pem -topk8 -nocrypt -outform DER -out key.der >> >> # add key >> PRIV_KEY_ID=`cat key.der | keyctl padd asymmetric test_priv_key @s` >> echo "priv key id = "$PRIV_KEY_ID >> PUB_KEY_ID=`cat cert.der | keyctl padd asymmetric test_pub_key @s` >> echo "pub key id = "$PUB_KEY_ID >> >> # query key >> keyctl pkey_query $PRIV_KEY_ID 0 >> keyctl pkey_query $PUB_KEY_ID 0 >> >> # here we only run pkey_encrypt becasuse it is the fastest interface >> function bench_pub() { >> keyctl pkey_encrypt $PUB_KEY_ID 0 /tmp/data enc=pkcs1 >/tmp/enc.pub >> } >> >> # do bench_pub in loop to obtain the memory leak >> for (( i = 0; i < ${LOOP_TIMES}; ++i )); do >> bench_pub >> done >> >> Signed-off-by: lei he >> Acked-by: Michael S. Tsirkin >> Reviewed-by: Gonglei >> --- >> drivers/crypto/virtio/virtio_crypto_akcipher_algs.c | 4 ++++ >> 1 file changed, 4 insertions(+) > > Patch applied. Thanks. Hi, I noticed that MST has already applied on vhost branch. https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git/commit/?h=vhost&id=1bedcf22c081a6e9943f09937b2da8d3ef52d20d Thanks. -- zhenwei pi