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

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

 



On Thu, 2019-11-14 at 10:45 -0800, Lakshmi Ramasubramanian wrote:
> 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
> 
> 
Hello Laks,
Agreed. The assumption is that integrity_kernel_read() function does
not return a value greater than the fourth parameter passed to it (i.e.
does not read more bytes from the file than the size of the buffer
passed to it). I tried to validate that this assumption was true by
following the code but felt I could not prove it with my current
knowledge of the code. If this assumption is not true then I believe
that any code change for this problem should go into a different
patch. 

Thank you.




[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