Re: [PATCH] tpm: fix buffer overflow in /dev/tpm0
From: Jason Gunthorpe
Date: Mon Sep 12 2016 - 00:06:03 EST
On Sun, Sep 11, 2016 at 03:19:00PM +0300, Jarkko Sakkinen wrote:
> tpm_write() does not check whether the buffer has at least enough space
> for the header before passing it to tpm_transmit() so an overflow can
> happen.
Eh?
tpm_write uses a hard wired buffer size of TPM_BUFSIZE when working
with tpm_transmit.
in_size is never used except for the copy. We should probably fix that
to sanity check the header length vs in_size.
That doesn't seem to be a security issue however because the header
length is propery limited to TPM_BUFSIZE and the data buffer is
allocated specifically for that process using kzalloc.
Jason