Re: [PATCH] ima: avoid appraise error for hash calc interrupt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/14/19 5:55 AM, Patrick Callaghan wrote:

Hi Patrick,

Hello Laks,
You suggested that the if statement of the patch change to the
following:

if ((rbuf_len == 0) || (offset + rbuf_len >= i_size)) {

Unless the file size changed between the time that i_size was set in
ima_calc_file_hash_tfm() and an i_size_read() call was subsequently
issued in a function downstream of the integrity_kernel_read() call,
the rbuf_len returned on the integrity_kernel_read() call will not be
more than i_size - offset. I do not think that it is possible for the
file size to change during this window but nonetheless, if it can, this
would be a different problem and I would not want to include this in my
patch. That said, I do appreciate you taking time to review this patch.

You are right - unless the file size changes between the calls this problem would not occur. I agree - that issue, even if it can occur, should be addressed separately.

Another one (again - am not saying this needs to be addressed in this patch, but just wanted to point out)

	rbuf = kzalloc(PAGE_SIZE, GFP_KERNEL);
	...
	rbuf_len = integrity_kernel_read(file, offset, rbuf, PAGE_SIZE);
	...
	rc = crypto_shash_update(shash, rbuf, rbuf_len);

rbuf is of size PAGE_SIZE, but rbuf_len, returned by integrity_kernel_read() is passed as buffer size to crypto_shash_update() without any validation (rbuf_len <= PAGE_SIZE)

It is assumed here that integrity_kernel_read() would not return a length greater than rbuf size and hence crypto_shash_update() would never access beyond the given buffer.

thanks,
 -lakshmi





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux Kernel Hardening]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux