]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: virtio - Erase some sensitive memory when it is freed
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Mon, 3 Mar 2025 19:08:04 +0000 (20:08 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 15 Mar 2025 07:08:54 +0000 (15:08 +0800)
virtcrypto_clear_request() does the same as the code here, but uses
kfree_sensitive() for one of the free operation.

So, better safe than sorry, use virtcrypto_clear_request() directly to
save a few lines of code and cleanly free the memory.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Tested-by: Lei Yang <leiyang@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/virtio/virtio_crypto_core.c

index d0278eb568b9675bd7c074dbc4b865fece8d7131..0d522049f595bca7793d6ff352dc7156f609575f 100644 (file)
@@ -480,10 +480,8 @@ static void virtcrypto_free_unused_reqs(struct virtio_crypto *vcrypto)
 
        for (i = 0; i < vcrypto->max_data_queues; i++) {
                vq = vcrypto->data_vq[i].vq;
-               while ((vc_req = virtqueue_detach_unused_buf(vq)) != NULL) {
-                       kfree(vc_req->req_data);
-                       kfree(vc_req->sgs);
-               }
+               while ((vc_req = virtqueue_detach_unused_buf(vq)) != NULL)
+                       virtcrypto_clear_request(vc_req);
                cond_resched();
        }
 }