* [PATCH] slub: slub_def.h: needs additional check for "index"
@ 2011-05-06 18:28 ` Maxin John
0 siblings, 0 replies; 6+ messages in thread
From: Maxin John @ 2011-05-06 18:28 UTC (permalink / raw)
To: Christoph Lameter; +Cc: Pekka Enberg, Matt Mackall, linux-mm, linux-kernel
In slub_def.h file, the kmalloc_index() may return -1 for some special cases.
If that negative return value gets assigned to "index", it might lead to issues
later as the variable "index" is used as index to array "kmalloc_caches" in :
return kmalloc_caches[index];
Please let me know your comments.
Signed-off-by: Maxin B. John <maxin.john@gmail.com>
---
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 45ca123..3db4b33 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -211,7 +211,7 @@ static __always_inline struct kmem_cache
*kmalloc_slab(size_t size)
{
int index = kmalloc_index(size);
- if (index == 0)
+ if (index <= 0)
return NULL;
return kmalloc_caches[index];
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] slub: slub_def.h: needs additional check for "index"
@ 2011-05-06 18:28 ` Maxin John
0 siblings, 0 replies; 6+ messages in thread
From: Maxin John @ 2011-05-06 18:28 UTC (permalink / raw)
To: Christoph Lameter; +Cc: Pekka Enberg, Matt Mackall, linux-mm, linux-kernel
In slub_def.h file, the kmalloc_index() may return -1 for some special cases.
If that negative return value gets assigned to "index", it might lead to issues
later as the variable "index" is used as index to array "kmalloc_caches" in :
return kmalloc_caches[index];
Please let me know your comments.
Signed-off-by: Maxin B. John <maxin.john@gmail.com>
---
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 45ca123..3db4b33 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -211,7 +211,7 @@ static __always_inline struct kmem_cache
*kmalloc_slab(size_t size)
{
int index = kmalloc_index(size);
- if (index == 0)
+ if (index <= 0)
return NULL;
return kmalloc_caches[index];
--
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>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] slub: slub_def.h: needs additional check for "index"
2011-05-06 18:28 ` Maxin John
@ 2011-05-06 18:56 ` Christoph Lameter
-1 siblings, 0 replies; 6+ messages in thread
From: Christoph Lameter @ 2011-05-06 18:56 UTC (permalink / raw)
To: Maxin John; +Cc: Pekka Enberg, Matt Mackall, linux-mm, linux-kernel
On Fri, 6 May 2011, Maxin John wrote:
> In slub_def.h file, the kmalloc_index() may return -1 for some special cases.
> If that negative return value gets assigned to "index", it might lead to issues
> later as the variable "index" is used as index to array "kmalloc_caches" in :
The value passed to kmalloc_slab is tested before the result is used.
kmalloc_slab() only returns -1 for values > 4MB.
The size of the object is checked against SLUB_MAX size which is
significantly smaller than 4MB. 8kb by default.
So kmalloc_slab() cannot return -1 if the parameter is checked first.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] slub: slub_def.h: needs additional check for "index"
@ 2011-05-06 18:56 ` Christoph Lameter
0 siblings, 0 replies; 6+ messages in thread
From: Christoph Lameter @ 2011-05-06 18:56 UTC (permalink / raw)
To: Maxin John; +Cc: Pekka Enberg, Matt Mackall, linux-mm, linux-kernel
On Fri, 6 May 2011, Maxin John wrote:
> In slub_def.h file, the kmalloc_index() may return -1 for some special cases.
> If that negative return value gets assigned to "index", it might lead to issues
> later as the variable "index" is used as index to array "kmalloc_caches" in :
The value passed to kmalloc_slab is tested before the result is used.
kmalloc_slab() only returns -1 for values > 4MB.
The size of the object is checked against SLUB_MAX size which is
significantly smaller than 4MB. 8kb by default.
So kmalloc_slab() cannot return -1 if the parameter is checked first.
--
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>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] slub: slub_def.h: needs additional check for "index"
2011-05-06 18:56 ` Christoph Lameter
@ 2011-05-07 0:03 ` Maxin John
-1 siblings, 0 replies; 6+ messages in thread
From: Maxin John @ 2011-05-07 0:03 UTC (permalink / raw)
To: Christoph Lameter; +Cc: Pekka Enberg, Matt Mackall, linux-mm, linux-kernel
Hi,
On Fri, May 6, 2011 at 9:56 PM, Christoph Lameter <cl@linux.com> wrote:
> The value passed to kmalloc_slab is tested before the result is used.
> kmalloc_slab() only returns -1 for values > 4MB.
>
> The size of the object is checked against SLUB_MAX size which is
> significantly smaller than 4MB. 8kb by default.
>
> So kmalloc_slab() cannot return -1 if the parameter is checked first.
Thank you very much for pointing it out. I think it's a lot more clear
for me now.
Best Regards,
Maxin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] slub: slub_def.h: needs additional check for "index"
@ 2011-05-07 0:03 ` Maxin John
0 siblings, 0 replies; 6+ messages in thread
From: Maxin John @ 2011-05-07 0:03 UTC (permalink / raw)
To: Christoph Lameter; +Cc: Pekka Enberg, Matt Mackall, linux-mm, linux-kernel
Hi,
On Fri, May 6, 2011 at 9:56 PM, Christoph Lameter <cl@linux.com> wrote:
> The value passed to kmalloc_slab is tested before the result is used.
> kmalloc_slab() only returns -1 for values > 4MB.
>
> The size of the object is checked against SLUB_MAX size which is
> significantly smaller than 4MB. 8kb by default.
>
> So kmalloc_slab() cannot return -1 if the parameter is checked first.
Thank you very much for pointing it out. I think it's a lot more clear
for me now.
Best Regards,
Maxin
--
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>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-05-07 0:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-06 18:28 [PATCH] slub: slub_def.h: needs additional check for "index" Maxin John
2011-05-06 18:28 ` Maxin John
2011-05-06 18:56 ` Christoph Lameter
2011-05-06 18:56 ` Christoph Lameter
2011-05-07 0:03 ` Maxin John
2011-05-07 0:03 ` Maxin John
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.