]> git.baikalelectronics.ru Git - kernel.git/commit
crypto: ccp - Use kzalloc for sev ioctl interfaces to prevent kernel memory leak
authorJohn Allen <john.allen@amd.com>
Wed, 18 May 2022 15:31:26 +0000 (15:31 +0000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 10 Jun 2022 08:40:16 +0000 (16:40 +0800)
commit5b60b134455072d9fc466ee5f0911a9cdf1285ed
tree7f972fe6276e2a18cba57fc9b4eda20806e61589
parentf040cca4b0da0180bf9de9141ef5c95f60f85182
crypto: ccp - Use kzalloc for sev ioctl interfaces to prevent kernel memory leak

For some sev ioctl interfaces, input may be passed that is less than or
equal to SEV_FW_BLOB_MAX_SIZE, but larger than the data that PSP
firmware returns. In this case, kmalloc will allocate memory that is the
size of the input rather than the size of the data. Since PSP firmware
doesn't fully overwrite the buffer, the sev ioctl interfaces with the
issue may return uninitialized slab memory.

Currently, all of the ioctl interfaces in the ccp driver are safe, but
to prevent future problems, change all ioctl interfaces that allocate
memory with kmalloc to use kzalloc and memset the data buffer to zero
in sev_ioctl_do_platform_status.

Fixes: c9a292daea55 ("crypto: ccp: Use the stack and common buffer for status commands")
Fixes: 98298cc8e7162 ("crypto: ccp: Implement SEV_PEK_CSR ioctl command")
Fixes: 83c3fc3c72095 ("crypto: ccp: Implement SEV_PDH_CERT_EXPORT ioctl command")
Fixes: 7d79c4402d1d9 ("crypto: ccp - introduce SEV_GET_ID2 command")
Cc: stable@vger.kernel.org
Reported-by: Andy Nguyen <theflow@google.com>
Suggested-by: David Rientjes <rientjes@google.com>
Suggested-by: Peter Gonda <pgonda@google.com>
Signed-off-by: John Allen <john.allen@amd.com>
Reviewed-by: Peter Gonda <pgonda@google.com>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/ccp/sev-dev.c