* Re: [patch 3/3] IA64: virt_to_page() can be called with NULL arg
2006-12-19 21:04 [patch 3/3] IA64: virt_to_page() can be called with NULL arg akpm
@ 2006-12-20 9:31 ` Jes Sorensen
2006-12-20 9:48 ` Jes Sorensen
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jes Sorensen @ 2006-12-20 9:31 UTC (permalink / raw)
To: linux-ia64
>>>>> "akpm" = akpm <akpm@osdl.org> writes:
akpm> From: Kirill Korotaev <dev@openvz.org> It does not return NULL
akpm> when arg is NULL.
Shouldn't the real fix be to track down who calls virt_to_page() with
a NULL pointer? IMHO it is bogus to do so.
Cheers,
Jes
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [patch 3/3] IA64: virt_to_page() can be called with NULL arg
2006-12-19 21:04 [patch 3/3] IA64: virt_to_page() can be called with NULL arg akpm
2006-12-20 9:31 ` Jes Sorensen
@ 2006-12-20 9:48 ` Jes Sorensen
2006-12-20 9:52 ` Kirill Korotaev
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jes Sorensen @ 2006-12-20 9:48 UTC (permalink / raw)
To: linux-ia64
Kirill Korotaev wrote:
>>>>>>> "akpm" = akpm <akpm@osdl.org> writes:
>>
>> akpm> From: Kirill Korotaev <dev@openvz.org> It does not return NULL
>> akpm> when arg is NULL.
>>
>> Shouldn't the real fix be to track down who calls virt_to_page() with
>> a NULL pointer? IMHO it is bogus to do so.
> what do you propose? to insert BUG_ON(!kaddr) into virt_to_page()?
> in this case caller in question should be still fixed.
If you hit this, yes I'd insert the BUG_ON in your test kernel and fix
the code. Maybe add the BUG_ON in upstream for CONFIG_DEBUG or
something.
Which callers did you see cause this? If it was a common problem I would
expect a lot of data corruption or crashes on ia64 systems which I
haven't heard of.
Cheers,
Jes
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [patch 3/3] IA64: virt_to_page() can be called with NULL arg
2006-12-19 21:04 [patch 3/3] IA64: virt_to_page() can be called with NULL arg akpm
2006-12-20 9:31 ` Jes Sorensen
2006-12-20 9:48 ` Jes Sorensen
@ 2006-12-20 9:52 ` Kirill Korotaev
2006-12-20 10:14 ` Jes Sorensen
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Kirill Korotaev @ 2006-12-20 9:52 UTC (permalink / raw)
To: linux-ia64
>>>>>>"akpm" = akpm <akpm@osdl.org> writes:
>
>
> akpm> From: Kirill Korotaev <dev@openvz.org> It does not return NULL
> akpm> when arg is NULL.
>
> Shouldn't the real fix be to track down who calls virt_to_page() with
> a NULL pointer? IMHO it is bogus to do so.
what do you propose? to insert BUG_ON(!kaddr) into virt_to_page()?
in this case caller in question should be still fixed.
Thanks,
Kirill
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [patch 3/3] IA64: virt_to_page() can be called with NULL arg
2006-12-19 21:04 [patch 3/3] IA64: virt_to_page() can be called with NULL arg akpm
` (2 preceding siblings ...)
2006-12-20 9:52 ` Kirill Korotaev
@ 2006-12-20 10:14 ` Jes Sorensen
2006-12-20 10:19 ` Kirill Korotaev
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jes Sorensen @ 2006-12-20 10:14 UTC (permalink / raw)
To: linux-ia64
Kirill Korotaev wrote:
> Jes Sorensen wrote:
>> If you hit this, yes I'd insert the BUG_ON in your test kernel and fix
>> the code. Maybe add the BUG_ON in upstream for CONFIG_DEBUG or
>> something.
> I guess then all the platforms should be analyzed/patched carefully
> or all the callers of virt_to_page().
> Care to create debug patch?
Well you suggested a patch which just hides the problem. I suggest you
change it to have the BUG_ON().
>> Which callers did you see cause this? If it was a common problem I would
>> expect a lot of data corruption or crashes on ia64 systems which I
>> haven't heard of.
> from the patch:
> pte_alloc_one() calls pgtable_quicklist_alloc() which can return NULL in
> case of allocation failure.
>
> It was hit on OpenVZ where kernel memory is accounted and limited on
> per-container basis (it is possible to DoS using page tables allocations).
> In mainstream the bug can be hit if OOM killer
> kills the process and __get_free_page() returns NULL which is rare, but still possible.
I see, since you have it tracked down, it would be good to fix it
and push a patch upstream. Unless of course Andrew or Linus thinks this
is the wrong approach.
Cheers,
Jes
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [patch 3/3] IA64: virt_to_page() can be called with NULL arg
2006-12-19 21:04 [patch 3/3] IA64: virt_to_page() can be called with NULL arg akpm
` (3 preceding siblings ...)
2006-12-20 10:14 ` Jes Sorensen
@ 2006-12-20 10:19 ` Kirill Korotaev
2006-12-20 10:47 ` Andrew Morton
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Kirill Korotaev @ 2006-12-20 10:19 UTC (permalink / raw)
To: linux-ia64
Jes Sorensen wrote:
> Kirill Korotaev wrote:
>
>>>>>>>>"akpm" = akpm <akpm@osdl.org> writes:
>>>
>>>akpm> From: Kirill Korotaev <dev@openvz.org> It does not return NULL
>>>akpm> when arg is NULL.
>>>
>>>Shouldn't the real fix be to track down who calls virt_to_page() with
>>>a NULL pointer? IMHO it is bogus to do so.
>>
>>what do you propose? to insert BUG_ON(!kaddr) into virt_to_page()?
>>in this case caller in question should be still fixed.
>
>
> If you hit this, yes I'd insert the BUG_ON in your test kernel and fix
> the code. Maybe add the BUG_ON in upstream for CONFIG_DEBUG or
> something.
I guess then all the platforms should be analyzed/patched carefully
or all the callers of virt_to_page().
Care to create debug patch?
> Which callers did you see cause this? If it was a common problem I would
> expect a lot of data corruption or crashes on ia64 systems which I
> haven't heard of.
from the patch:
pte_alloc_one() calls pgtable_quicklist_alloc() which can return NULL in
case of allocation failure.
It was hit on OpenVZ where kernel memory is accounted and limited on
per-container basis (it is possible to DoS using page tables allocations).
In mainstream the bug can be hit if OOM killer
kills the process and __get_free_page() returns NULL which is rare, but still possible.
Thanks,
Kirill
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [patch 3/3] IA64: virt_to_page() can be called with NULL arg
2006-12-19 21:04 [patch 3/3] IA64: virt_to_page() can be called with NULL arg akpm
` (4 preceding siblings ...)
2006-12-20 10:19 ` Kirill Korotaev
@ 2006-12-20 10:47 ` Andrew Morton
2006-12-20 10:54 ` Jes Sorensen
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Andrew Morton @ 2006-12-20 10:47 UTC (permalink / raw)
To: linux-ia64
On Wed, 20 Dec 2006 11:14:53 +0100
Jes Sorensen <jes@sgi.com> wrote:
> Kirill Korotaev wrote:
> > Jes Sorensen wrote:
> >> If you hit this, yes I'd insert the BUG_ON in your test kernel and fix
> >> the code. Maybe add the BUG_ON in upstream for CONFIG_DEBUG or
> >> something.
> > I guess then all the platforms should be analyzed/patched carefully
> > or all the callers of virt_to_page().
> > Care to create debug patch?
>
> Well you suggested a patch which just hides the problem. I suggest you
> change it to have the BUG_ON().
>
The patch doesn't hide any problems:
--- a/include/asm-ia64/pgalloc.h~ia64-virt_to_page-can-be-called-with-null-arg
+++ a/include/asm-ia64/pgalloc.h
@@ -137,7 +137,8 @@ pmd_populate_kernel(struct mm_struct *mm
static inline struct page *pte_alloc_one(struct mm_struct *mm,
unsigned long addr)
{
- return virt_to_page(pgtable_quicklist_alloc());
+ void *pg = pgtable_quicklist_alloc();
+ return pg ? virt_to_page(pg) : NULL;
}
if the memory allocation function fails, we propagate that failure back to
callers. All very good.
From a quick look it seems that the pte_alloc() callers are all nicely
handling the failures.
The patch looks good to me?
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [patch 3/3] IA64: virt_to_page() can be called with NULL arg
2006-12-19 21:04 [patch 3/3] IA64: virt_to_page() can be called with NULL arg akpm
` (5 preceding siblings ...)
2006-12-20 10:47 ` Andrew Morton
@ 2006-12-20 10:54 ` Jes Sorensen
2006-12-20 10:57 ` Kirill Korotaev
2006-12-20 10:59 ` Jes Sorensen
8 siblings, 0 replies; 10+ messages in thread
From: Jes Sorensen @ 2006-12-20 10:54 UTC (permalink / raw)
To: linux-ia64
Andrew Morton wrote:
> The patch doesn't hide any problems:
[snip]
> if the memory allocation function fails, we propagate that failure back to
> callers. All very good.
ARGH!
I somehow put it in my head that the patch was modifying virt_to_page()
rather than the pte function.
My apologies, this was written by a stupid person who can't read :-(
Cheers,
Jes
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [patch 3/3] IA64: virt_to_page() can be called with NULL arg
2006-12-19 21:04 [patch 3/3] IA64: virt_to_page() can be called with NULL arg akpm
` (6 preceding siblings ...)
2006-12-20 10:54 ` Jes Sorensen
@ 2006-12-20 10:57 ` Kirill Korotaev
2006-12-20 10:59 ` Jes Sorensen
8 siblings, 0 replies; 10+ messages in thread
From: Kirill Korotaev @ 2006-12-20 10:57 UTC (permalink / raw)
To: linux-ia64
Jes,
> Well you suggested a patch which just hides the problem. I suggest you
> change it to have the BUG_ON().
IMHO you are wrong.
the suggested patch *fixes* one particular place, which can be triggered on
mainstream IA64 by a standard user and is actually a *SECURITY* bug which
can be potentially exploited (when OOM killer is enabled).
It doesn't hide anything, It just doesn't help to catch other places.
>>>Which callers did you see cause this? If it was a common problem I would
>>>expect a lot of data corruption or crashes on ia64 systems which I
>>>haven't heard of.
>>
>>from the patch:
>>pte_alloc_one() calls pgtable_quicklist_alloc() which can return NULL in
>>case of allocation failure.
>>
>>It was hit on OpenVZ where kernel memory is accounted and limited on
>>per-container basis (it is possible to DoS using page tables allocations).
>>In mainstream the bug can be hit if OOM killer
>>kills the process and __get_free_page() returns NULL which is rare, but still possible.
>
>
> I see, since you have it tracked down, it would be good to fix it
> and push a patch upstream. Unless of course Andrew or Linus thinks this
> is the wrong approach.
Maybe the fact that I came without an exploit to crash IA64
makes you think it should not be commited, ok, you can leave it as is then.
NOTE: I don't mind against the debug you proposed. It is quite a good idea.
Thanks,
Kirill
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [patch 3/3] IA64: virt_to_page() can be called with NULL arg
2006-12-19 21:04 [patch 3/3] IA64: virt_to_page() can be called with NULL arg akpm
` (7 preceding siblings ...)
2006-12-20 10:57 ` Kirill Korotaev
@ 2006-12-20 10:59 ` Jes Sorensen
8 siblings, 0 replies; 10+ messages in thread
From: Jes Sorensen @ 2006-12-20 10:59 UTC (permalink / raw)
To: linux-ia64
Kirill Korotaev wrote:
> Jes,
>
>> Well you suggested a patch which just hides the problem. I suggest you
>> change it to have the BUG_ON().
> IMHO you are wrong.
> the suggested patch *fixes* one particular place, which can be triggered on
> mainstream IA64 by a standard user and is actually a *SECURITY* bug which
> can be potentially exploited (when OOM killer is enabled).
> It doesn't hide anything, It just doesn't help to catch other places.
Hi Kirill,
See my response to Andrew, you are indeed right.
I'll go back and hide in my corner in shame :-(
Cheers,
Jes
^ permalink raw reply [flat|nested] 10+ messages in thread