From: J Freyensee <james_p_freyensee@linux.intel.com>
To: Christoph Lameter <cl@linux.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>,
linux-mm@kvack.org, gregkh@suse.de, hari.k.kanigeri@intel.com,
linux-arch@vger.kernel.org, Pekka Enberg <penberg@cs.helsinki.fi>
Subject: Re: [PATCH] kernel buffer overflow kmalloc_slab() fix
Date: Fri, 20 May 2011 11:02:28 -0700 [thread overview]
Message-ID: <1305914548.2400.39.camel@localhost> (raw)
In-Reply-To: <alpine.DEB.2.00.1105200941260.5610@router.home>
Thank you for the collaboration work on the fix. I like it.
Jay
On Fri, 2011-05-20 at 09:42 -0500, Christoph Lameter wrote:
> Subject: slub: Deal with hyperthetical case of PAGE_SIZE > 2M
>
> kmalloc_index() currently returns -1 if the PAGE_SIZE is larger than 2M
> which seems to cause some concern since the callers do not check for -1.
>
> Insert a BUG() and add a comment to the -1 explaining that the code
> cannot be reached.
>
> Signed-off-by: Christoph Lameter <cl@linux.com>
>
> ---
> include/linux/slub_def.h | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> Index: linux-2.6/include/linux/slub_def.h
> ===================================================================
> --- linux-2.6.orig/include/linux/slub_def.h 2011-05-20 09:37:02.000000000 -0500
> +++ linux-2.6/include/linux/slub_def.h 2011-05-20 09:39:07.000000000 -0500
> @@ -179,7 +179,8 @@ static __always_inline int kmalloc_index
> if (size <= 4 * 1024) return 12;
> /*
> * The following is only needed to support architectures with a larger page
> - * size than 4k.
> + * size than 4k. We need to support 2 * PAGE_SIZE here. So for a 64k page
> + * size we would have to go up to 128k.
> */
> if (size <= 8 * 1024) return 13;
> if (size <= 16 * 1024) return 14;
> @@ -190,7 +191,8 @@ static __always_inline int kmalloc_index
> if (size <= 512 * 1024) return 19;
> if (size <= 1024 * 1024) return 20;
> if (size <= 2 * 1024 * 1024) return 21;
> - return -1;
> + BUG();
> + return -1; /* Will never be reached */
>
> /*
> * What we really wanted to do and cannot do because of compiler issues is:
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2011-05-20 18:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-19 19:51 [PATCH] kernel buffer overflow kmalloc_slab() fix james_p_freyensee
2011-05-19 20:51 ` Christoph Lameter
2011-05-19 21:14 ` J Freyensee
2011-05-19 21:24 ` Christoph Lameter
2011-05-19 22:19 ` J Freyensee
2011-05-20 14:32 ` Christoph Lameter
2011-05-20 12:02 ` James Bottomley
2011-05-20 14:33 ` Christoph Lameter
2011-05-20 14:42 ` Christoph Lameter
2011-05-20 18:02 ` J Freyensee [this message]
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=1305914548.2400.39.camel@localhost \
--to=james_p_freyensee@linux.intel.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=cl@linux.com \
--cc=gregkh@suse.de \
--cc=hari.k.kanigeri@intel.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@cs.helsinki.fi \
/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;
as well as URLs for NNTP newsgroup(s).