From: Patrick Callaghan <patrickc@linux.vnet.ibm.com>
To: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>,
Mimi Zohar <zohar@linux.ibm.com>,
Patrick Callaghan <patrickc@linux.ibm.com>,
linux-integrity@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Sascha Hauer <s.hauer@pengutronix.de>
Subject: Re: [PATCH] ima: avoid appraise error for hash calc interrupt
Date: Fri, 15 Nov 2019 10:25:57 -0500 [thread overview]
Message-ID: <ffb1ec9d8cf12f6366fb4eb022a5442a8edae53c.camel@linux.vnet.ibm.com> (raw)
In-Reply-To: <4e1c0c6b-a5e1-a95a-8a0b-c5a7f0a253cf@linux.microsoft.com>
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.
next prev parent reply other threads:[~2019-11-15 15:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-11 19:23 Patrick Callaghan
2019-11-11 22:29 ` Lakshmi Ramasubramanian
2019-11-12 17:14 ` Mimi Zohar
2019-11-12 17:33 ` Lakshmi Ramasubramanian
2019-11-12 18:12 ` Mimi Zohar
2019-11-14 13:55 ` Patrick Callaghan
2019-11-14 18:45 ` Lakshmi Ramasubramanian
2019-11-15 15:25 ` Patrick Callaghan [this message]
2019-11-15 20:34 ` Lakshmi Ramasubramanian
2019-11-13 7:52 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ffb1ec9d8cf12f6366fb4eb022a5442a8edae53c.camel@linux.vnet.ibm.com \
--to=patrickc@linux.vnet.ibm.com \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nramas@linux.microsoft.com \
--cc=patrickc@linux.ibm.com \
--cc=s.hauer@pengutronix.de \
--cc=zohar@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome