public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jarod Wilson <jarod@redhat.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	Neil Horman <nhorman@tuxdriver.com>
Subject: Re: [RFC PATCH] crypto: add buffer overflow checks to testmgr
Date: Thu, 4 Jun 2009 17:59:36 -0400	[thread overview]
Message-ID: <200906041759.37762.jarod@redhat.com> (raw)
In-Reply-To: <20090529221055.GA17957@gondor.apana.org.au>

On Friday 29 May 2009 18:10:55 Herbert Xu wrote:
> On Fri, May 29, 2009 at 11:32:54AM -0400, Jarod Wilson wrote:
> > At present, its entirely possible to add a test vector to testmgr with
> > an input longer than a page in length w/o specifying a .np option, and
> > overflow the page of memory allocated to {a,}xbuf[0], silently
> > corrupting memory. I know, because I've accidentally done it. :)
> > 
> > While this doesn't currently happen in practice w/the existing code,
> > due to all !np vectors being less than a 4k page in length (and the
> > page allocation loop often returns contiguous pages anyway), explicit
> > checks or a way to remove the 4k limit would be a good idea.
> > 
> > A few ways to fix and/or work around this:
> > 
> > 1) allocate some larger guaranteed contiguous buffers using
> > __get_free_pages() or kmalloc and use them in the !np case
> > 
> > 2) catch the > PAGE_SIZE && !np case and then do things similar to how
> > they are done in the np case
> > 
> > 3) catch the > PAGE_SIZE && !np case and simply exit with an error
> > 
> > Since there currently aren't any test vectors that are actually larger
> > than a page and not tagged np, option 1 seems like a waste of memory
> > and option 2 sounds like unnecessary complexity, so I'd offer up
> > option 3 as the most viable alternative right now.
> > 
> > Signed-off-by: Jarod Wilson <jarod@redhat.com>
> 
> I just posted exactly the same thing yesterday :)

One note... This is actually causing some new compile warnings to be
spit out, varies from arch to arch, dependent on page size... ppc64
with 64k pages is the worst offender:

crypto/testmgr.c: In function 'test_nhash':
crypto/testmgr.c:194: warning: comparison is always false due to limited range of data type
crypto/testmgr.c: In function 'test_aead':
crypto/testmgr.c:374: warning: comparison is always false due to limited range of data type
crypto/testmgr.c:375: warning: comparison is always false due to limited range of data type
crypto/testmgr.c: In function 'test_cipher':
crypto/testmgr.c:676: warning: comparison is always false due to limited range of data type
crypto/testmgr.c: In function 'test_skcipher':
crypto/testmgr.c:771: warning: comparison is always false due to limited range of data type



-- 
Jarod Wilson
jarod@redhat.com

  parent reply	other threads:[~2009-06-04 22:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-29 15:32 [RFC PATCH] crypto: add buffer overflow checks to testmgr Jarod Wilson
2009-05-29 19:27 ` Neil Horman
2009-05-29 22:10 ` Herbert Xu
2009-05-30  1:12   ` Jarod Wilson
2009-06-04 21:59   ` Jarod Wilson [this message]
2009-06-05  7:02     ` Herbert Xu

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=200906041759.37762.jarod@redhat.com \
    --to=jarod@redhat.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nhorman@tuxdriver.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