lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 15 Nov 2019 10:25:57 -0500
From:   Patrick Callaghan <patrickc@...ux.vnet.ibm.com>
To:     Lakshmi Ramasubramanian <nramas@...ux.microsoft.com>,
        Mimi Zohar <zohar@...ux.ibm.com>,
        Patrick Callaghan <patrickc@...ux.ibm.com>,
        linux-integrity@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org, Sascha Hauer <s.hauer@...gutronix.de>
Subject: Re: [PATCH] ima: avoid appraise error for hash calc interrupt

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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ