From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5273C1758B for ; Thu, 4 Dec 2025 12:46:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764852381; cv=none; b=l/ua/JUdoIJPkEJit4I48HeXNPhEK08SSiisv8Z2rLunnpUcO1fAvi3PY2bxV74KoftAglBisUf+XxfrGuB+jycjkRfIu5oHypm3961wlPr0ykWGOXkQWVOw3BB1xWlCAQnnZ9OlvgjQqhg7gHWKAXjnGbXS+4NqphGdgfkJnoA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764852381; c=relaxed/simple; bh=k2d6AKIbxjDNvI+iSHhx9EKEQwXZyEmjVW0faFK8DDo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ppJOUYSVfTh6vzypfCrkE89Gljy8MokXpy/8nFhBEtQuPcSzB74yXgQu/fETrhG9j5EoxVTqGwuRimEnvd9Blendol092HjQ3hVOwhjzyWHhKrkOT7r+YKn7oNR0xlW1VApOdZdVK0jnk6iYpY0uepMC/dxoVC9Npe4bPO3LHKQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=IZ/g4Ssz; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=YL1MzLfn; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IZ/g4Ssz"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="YL1MzLfn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764852378; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=CeTXlItwEjkfILL3F/GDxGRgx6cCYk34DZi75wL0heE=; b=IZ/g4SszzFtqXNFSm5mgbhUgHMHjVP3fGXMxG8oKKQo5vjJqaloIzzutiLr3ZO2mtKM00U t//Skkr4ENRfybB9iKp8pHxVyAL9mmZwC0GnJvV7Zg3c8Gw9P+jWD5vie2jG6hmj1uey8p oOBU2T6v6mcOw38ZPTOCZ26F5GDxRZg= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-578-ok-9wyreMC2dKPvFC7KSCw-1; Thu, 04 Dec 2025 07:46:17 -0500 X-MC-Unique: ok-9wyreMC2dKPvFC7KSCw-1 X-Mimecast-MFC-AGG-ID: ok-9wyreMC2dKPvFC7KSCw_1764852376 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-477cf25ceccso6482105e9.0 for ; Thu, 04 Dec 2025 04:46:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1764852376; x=1765457176; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=CeTXlItwEjkfILL3F/GDxGRgx6cCYk34DZi75wL0heE=; b=YL1MzLfnmPZ9uTUbvuKBKfO8RaFFN7MqaDW2GMogIhzls6ATNU8su2EypyZ3Jph7po 1rwjMeKgWBngJxJYqLhmEBTO5uRyKG9/IpRVQXRBBnZIM3oxMqG6SmHg/wSu9ixep+d+ CfBSOryYiL2pUbSmy3NtXh0oMTI69IHQMkxas69DceLUVYqWecpKCRcyjGWAutsATd7s /tcQ6KKSWteE4VFCRhXvH+9k9OCNvhjTCkSy6rSiPZPaFRReyYzgbnt9wrzrTMpo6lL5 gPhZBKPH6IntStV0R+Oyga2FyXRSCF7HFXMnf3rUJDiswm8vqno+YC/DFM1OqdJmA0/2 Re8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764852376; x=1765457176; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CeTXlItwEjkfILL3F/GDxGRgx6cCYk34DZi75wL0heE=; b=moT51qGRawoOoj1caE2lVEOmLjMlsr04+WbUOlAWAmrA7uKMzkMZy0/7J+xDvt750j VIwgI6Lnkjx3Use6AqcACF8lNC+vQgF8dMu/ocXrmQ8XsMgs22nHW8YniCukStjwcuwX 5TeeSqkqdfK4HYW7DTZ9wb+B9Y2uIwNy27CcW9CHCJs4qawuuvLAuIxxz2LbPYkj2Ca5 1Z1HnlyEWiNC9JLnQRHtD6uKOLi30m306lWX9VFngscen3XlLIzLA5yxQinJSFpCxG8L ZteohSgbAYHGBHJlyNxqJhHlOhU14Ybhk3I/fN6MZekijlyC/FHpad4xhROB2d3IA3Pw WfcQ== X-Forwarded-Encrypted: i=1; AJvYcCW7n3B/Qc1z6zirP6hC5uSxGKBD8+XlVZuhckuxwBnHCPXaODVHrW+99HB4d81fCfJ41urAXn2qxskFJ2E=@vger.kernel.org X-Gm-Message-State: AOJu0YwkRZ3HTRpkjw94ZvlBbYWJ/n10MYv+oOJEBexbKwzmjPL3Xurl iQ7BvRN/TDw/xr9zohC7y9lOWzPI2DR/+BK1QAFIjdzN5i29YVCJDcb/sMyp2UUcQCnO8D5ULgo 1llCOFWK5VERnHh+Rxrm0AWoTGgNUJRi8pv9GAi6b0KEyUPgP0IIz81AEA3tj4U/O93FonrBx+g == X-Gm-Gg: ASbGncskXHE7jgVa+CEKzmyMTEIA3nyYwbU4HwP2XK1RiKhuwyGQX2LfbDLSm7dlf9h PkhBFvGafNqG8NiIAWUE3i854Bm/6wWvCKXYyNo3zXGGdJuUjfVrew/dkfkiNF2wsZkNDot5Qdj dIUzGuxghc8TNC6CAk+bq6bjrqd0taVccNCqPSDO7vrUSsrKCXg0r6bqtJWdKOstNlAjyiV0HfJ 646BmAveqGjdC043TWAdE3vjjxcSokThQM1kSeh+Ycd7B+LJdF3gQKXE+f4Fkqmnp/UOUwYv1pj obpNCQJOIj+DtpEEE3cpUizOdwpxhkSt2bbO2QC2AAVoaDYADUwZdJC6sXaoOZZxFjKN9KT9B4y YlCvH89bSO1uz5u0dx3wXofOSqPm034KpYQ== X-Received: by 2002:a05:600c:548a:b0:45d:d1a3:ba6a with SMTP id 5b1f17b1804b1-4792f39cb06mr27308915e9.33.1764852375511; Thu, 04 Dec 2025 04:46:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IEeqahDkXcX70vDduTq7HLlftnPzdScbCOHAGJylBXRuVjbzCCIVcrHwCKumENhm/jymdPb+A== X-Received: by 2002:a05:600c:548a:b0:45d:d1a3:ba6a with SMTP id 5b1f17b1804b1-4792f39cb06mr27308625e9.33.1764852375047; Thu, 04 Dec 2025 04:46:15 -0800 (PST) Received: from redhat.com (IGLD-80-230-38-228.inter.net.il. [80.230.38.228]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4792b1522e6sm37484525e9.13.2025.12.04.04.46.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Dec 2025 04:46:14 -0800 (PST) Date: Thu, 4 Dec 2025 07:46:11 -0500 From: "Michael S. Tsirkin" To: Bibo Mao Cc: Gonglei , Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Herbert Xu , "David S. Miller" , virtualization@lists.linux.dev, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 6/9] crypto: virtio: Add req_data with structure virtio_crypto_sym_request Message-ID: <20251204074310-mutt-send-email-mst@kernel.org> References: <20251204112227.2659404-1-maobibo@loongson.cn> <20251204112227.2659404-7-maobibo@loongson.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251204112227.2659404-7-maobibo@loongson.cn> On Thu, Dec 04, 2025 at 07:22:23PM +0800, Bibo Mao wrote: > With normal encrypt/decrypt workflow, req_data with struct type > virtio_crypto_op_data_req will be allocated. Here put req_data in > virtio_crypto_sym_request, it is pre-allocated when encrypt/decrypt > interface is called. > > Signed-off-by: Bibo Mao > --- > drivers/crypto/virtio/virtio_crypto_core.c | 3 ++- > drivers/crypto/virtio/virtio_crypto_skcipher_algs.c | 12 +++--------- > 2 files changed, 5 insertions(+), 10 deletions(-) > > diff --git a/drivers/crypto/virtio/virtio_crypto_core.c b/drivers/crypto/virtio/virtio_crypto_core.c > index ccc6b5c1b24b..e60ad1d94e7f 100644 > --- a/drivers/crypto/virtio/virtio_crypto_core.c > +++ b/drivers/crypto/virtio/virtio_crypto_core.c > @@ -17,7 +17,8 @@ void > virtcrypto_clear_request(struct virtio_crypto_request *vc_req) > { > if (vc_req) { > - kfree_sensitive(vc_req->req_data); > + if (vc_req->req_data) > + kfree_sensitive(vc_req->req_data); kfree of NULL is a nop, why make this change? > kfree(vc_req->sgs); > } > } > diff --git a/drivers/crypto/virtio/virtio_crypto_skcipher_algs.c b/drivers/crypto/virtio/virtio_crypto_skcipher_algs.c > index 7b3f21a40d78..a7c7c726e6d9 100644 > --- a/drivers/crypto/virtio/virtio_crypto_skcipher_algs.c > +++ b/drivers/crypto/virtio/virtio_crypto_skcipher_algs.c > @@ -26,6 +26,7 @@ struct virtio_crypto_skcipher_ctx { > > struct virtio_crypto_sym_request { > struct virtio_crypto_request base; > + struct virtio_crypto_op_data_req req_data; > > /* Cipher or aead */ > uint32_t type; > @@ -350,14 +351,8 @@ __virtio_crypto_skcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req, > if (!sgs) > return -ENOMEM; > > - req_data = kzalloc_node(sizeof(*req_data), GFP_KERNEL, > - dev_to_node(&vcrypto->vdev->dev)); > - if (!req_data) { > - kfree(sgs); > - return -ENOMEM; > - } > - > - vc_req->req_data = req_data; > + req_data = &vc_sym_req->req_data; > + vc_req->req_data = NULL; > vc_sym_req->type = VIRTIO_CRYPTO_SYM_OP_CIPHER; > /* Head of operation */ > if (vc_sym_req->encrypt) { > @@ -450,7 +445,6 @@ __virtio_crypto_skcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req, > free_iv: > kfree_sensitive(iv); > free: > - kfree_sensitive(req_data); So the request is no longer erased with memset on error. Is that not a problem? > kfree(sgs); > return err; > } > -- > 2.39.3