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]
Message-ID: <abdf66fb39d4c8ee08e0b52c34fb81b93bd33006.camel@linux.vnet.ibm.com>
Date:   Thu, 14 Nov 2019 08:55:34 -0500
From:   Patrick Callaghan <patrickc@...ux.vnet.ibm.com>
To:     Mimi Zohar <zohar@...ux.ibm.com>,
        Lakshmi Ramasubramanian <nramas@...ux.microsoft.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 Tue, 2019-11-12 at 13:12 -0500, Mimi Zohar wrote:
> On Tue, 2019-11-12 at 09:33 -0800, Lakshmi Ramasubramanian wrote:
> > On 11/12/2019 9:14 AM, Mimi Zohar wrote:
> > 
> > > On Mon, 2019-11-11 at 14:29 -0800, Lakshmi Ramasubramanian wrote:
> > > > On 11/11/19 11:23 AM, Patrick Callaghan wrote:
> > > > 
> > > > > -		if (rbuf_len == 0)
> > > > > +		if (rbuf_len == 0) {	/* unexpected EOF */
> > > > > +			rc = -EINVAL;
> > > > >    			break;
> > > > > +		}
> > > > >    		offset += rbuf_len;
> > > > 
> > > > Should there be an additional check to validate that (offset +
> > > > rbuf_len)
> > > > is less than i_size before calling cypto_shash_update (since
> > > > rbuf_len is
> > > > one of the parameters for this call)?
> > > 
> > > The "while" statement enforces that.
> > > 
> > > Mimi
> > 
> > Yes - but that check happens after the call to
> > crypto_shash_update().
> > 
> > Perhaps integrity_kernel_read() will never return (rbuf_len) that
> > will
> >   => violate the check in the "while" statement.
> >   => number of bytes read that is greater than the memory allocated
> > for 
> > rbuf even in error conditions.
> > 
> > Just making sure.
> 
> integrity_kernel_read() returns an error (< 0) or the number of bytes
> read.  The while statement ensures that there is more data to read,
> so
> returning 0 is always an error.
> 
> Mimi
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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ