diff mbox

[v2,2/2] kasan: fix memory hotplug during boot

Message ID 20180522100756.18478-3-david@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Hildenbrand May 22, 2018, 10:07 a.m. UTC
Using module_init() is wrong. E.g. ACPI adds and onlines memory before
our memory notifier gets registered.

This makes sure that ACPI memory detected during boot up will not
result in a kernel crash.

Easily reproducable with QEMU, just specify a DIMM when starting up.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 mm/kasan/kasan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrey Ryabinin May 22, 2018, 4:26 p.m. UTC | #1
On 05/22/2018 01:07 PM, David Hildenbrand wrote:
> Using module_init() is wrong. E.g. ACPI adds and onlines memory before
> our memory notifier gets registered.
> 
> This makes sure that ACPI memory detected during boot up will not
> result in a kernel crash.
> 
> Easily reproducable with QEMU, just specify a DIMM when starting up.

         reproducible
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---

Fixes: fa69b5989bb0 ("mm/kasan: add support for memory hotplug")
Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: <stable@vger.kernel.org>

>  mm/kasan/kasan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
> index 53564229674b..a8b85706e2d6 100644
> --- a/mm/kasan/kasan.c
> +++ b/mm/kasan/kasan.c
> @@ -892,5 +892,5 @@ static int __init kasan_memhotplug_init(void)
>  	return 0;
>  }
>  
> -module_init(kasan_memhotplug_init);
> +core_initcall(kasan_memhotplug_init);
>  #endif
>
David Hildenbrand May 22, 2018, 4:36 p.m. UTC | #2
On 22.05.2018 18:26, Andrey Ryabinin wrote:
> 
> 
> On 05/22/2018 01:07 PM, David Hildenbrand wrote:
>> Using module_init() is wrong. E.g. ACPI adds and onlines memory before
>> our memory notifier gets registered.
>>
>> This makes sure that ACPI memory detected during boot up will not
>> result in a kernel crash.
>>
>> Easily reproducable with QEMU, just specify a DIMM when starting up.
> 
>          reproducible
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
> 
> Fixes: fa69b5989bb0 ("mm/kasan: add support for memory hotplug")
> Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> Cc: <stable@vger.kernel.org>

Think this even dates back to:

786a8959912e ("kasan: disable memory hotplug")


> 
>>  mm/kasan/kasan.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
>> index 53564229674b..a8b85706e2d6 100644
>> --- a/mm/kasan/kasan.c
>> +++ b/mm/kasan/kasan.c
>> @@ -892,5 +892,5 @@ static int __init kasan_memhotplug_init(void)
>>  	return 0;
>>  }
>>  
>> -module_init(kasan_memhotplug_init);
>> +core_initcall(kasan_memhotplug_init);
>>  #endif
>>
Andrey Ryabinin May 22, 2018, 7:50 p.m. UTC | #3
On 05/22/2018 07:36 PM, David Hildenbrand wrote:
> On 22.05.2018 18:26, Andrey Ryabinin wrote:
>>
>>
>> On 05/22/2018 01:07 PM, David Hildenbrand wrote:
>>> Using module_init() is wrong. E.g. ACPI adds and onlines memory before
>>> our memory notifier gets registered.
>>>
>>> This makes sure that ACPI memory detected during boot up will not
>>> result in a kernel crash.
>>>
>>> Easily reproducable with QEMU, just specify a DIMM when starting up.
>>
>>          reproducible
>>>
>>> Signed-off-by: David Hildenbrand <david@redhat.com>
>>> ---
>>
>> Fixes: fa69b5989bb0 ("mm/kasan: add support for memory hotplug")
>> Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
>> Cc: <stable@vger.kernel.org>
> 
> Think this even dates back to:
> 
> 786a8959912e ("kasan: disable memory hotplug")
> 

Indeed.
Andrew Morton May 22, 2018, 9:07 p.m. UTC | #4
On Tue, 22 May 2018 22:50:12 +0300 Andrey Ryabinin <aryabinin@virtuozzo.com> wrote:

> 
> 
> On 05/22/2018 07:36 PM, David Hildenbrand wrote:
> > On 22.05.2018 18:26, Andrey Ryabinin wrote:
> >>
> >>
> >> On 05/22/2018 01:07 PM, David Hildenbrand wrote:
> >>> Using module_init() is wrong. E.g. ACPI adds and onlines memory before
> >>> our memory notifier gets registered.
> >>>
> >>> This makes sure that ACPI memory detected during boot up will not
> >>> result in a kernel crash.
> >>>
> >>> Easily reproducable with QEMU, just specify a DIMM when starting up.
> >>
> >>          reproducible
> >>>
> >>> Signed-off-by: David Hildenbrand <david@redhat.com>
> >>> ---
> >>
> >> Fixes: fa69b5989bb0 ("mm/kasan: add support for memory hotplug")
> >> Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> >> Cc: <stable@vger.kernel.org>
> > 
> > Think this even dates back to:
> > 
> > 786a8959912e ("kasan: disable memory hotplug")
> > 
> 
> Indeed.

Is a backport to -stable justified for either of these patches?
Andrey Ryabinin May 23, 2018, 9:59 a.m. UTC | #5
On 05/23/2018 12:07 AM, Andrew Morton wrote:
> On Tue, 22 May 2018 22:50:12 +0300 Andrey Ryabinin <aryabinin@virtuozzo.com> wrote:
> 
>>
>>
>> On 05/22/2018 07:36 PM, David Hildenbrand wrote:
>>> On 22.05.2018 18:26, Andrey Ryabinin wrote:
>>>>
>>>>
>>>> On 05/22/2018 01:07 PM, David Hildenbrand wrote:
>>>>> Using module_init() is wrong. E.g. ACPI adds and onlines memory before
>>>>> our memory notifier gets registered.
>>>>>
>>>>> This makes sure that ACPI memory detected during boot up will not
>>>>> result in a kernel crash.
>>>>>
>>>>> Easily reproducable with QEMU, just specify a DIMM when starting up.
>>>>
>>>>          reproducible
>>>>>
>>>>> Signed-off-by: David Hildenbrand <david@redhat.com>
>>>>> ---
>>>>
>>>> Fixes: fa69b5989bb0 ("mm/kasan: add support for memory hotplug")
>>>> Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
>>>> Cc: <stable@vger.kernel.org>
>>>
>>> Think this even dates back to:
>>>
>>> 786a8959912e ("kasan: disable memory hotplug")
>>>
>>
>> Indeed.
> 
> Is a backport to -stable justified for either of these patches?
> 

I don't see any reasons to not backport these.
The first one fixes failure to online memory, why it shouldn't be fixed in -stable?
The second one is fixes boot crash, it's definitely stable material IMO.
David Hildenbrand May 23, 2018, 11:52 a.m. UTC | #6
On 23.05.2018 11:59, Andrey Ryabinin wrote:
> 
> 
> On 05/23/2018 12:07 AM, Andrew Morton wrote:
>> On Tue, 22 May 2018 22:50:12 +0300 Andrey Ryabinin <aryabinin@virtuozzo.com> wrote:
>>
>>>
>>>
>>> On 05/22/2018 07:36 PM, David Hildenbrand wrote:
>>>> On 22.05.2018 18:26, Andrey Ryabinin wrote:
>>>>>
>>>>>
>>>>> On 05/22/2018 01:07 PM, David Hildenbrand wrote:
>>>>>> Using module_init() is wrong. E.g. ACPI adds and onlines memory before
>>>>>> our memory notifier gets registered.
>>>>>>
>>>>>> This makes sure that ACPI memory detected during boot up will not
>>>>>> result in a kernel crash.
>>>>>>
>>>>>> Easily reproducable with QEMU, just specify a DIMM when starting up.
>>>>>
>>>>>          reproducible
>>>>>>
>>>>>> Signed-off-by: David Hildenbrand <david@redhat.com>
>>>>>> ---
>>>>>
>>>>> Fixes: fa69b5989bb0 ("mm/kasan: add support for memory hotplug")
>>>>> Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
>>>>> Cc: <stable@vger.kernel.org>
>>>>
>>>> Think this even dates back to:
>>>>
>>>> 786a8959912e ("kasan: disable memory hotplug")
>>>>
>>>
>>> Indeed.
>>
>> Is a backport to -stable justified for either of these patches?
>>
> 
> I don't see any reasons to not backport these.
> The first one fixes failure to online memory, why it shouldn't be fixed in -stable?
> The second one is fixes boot crash, it's definitely stable material IMO.
> 

Agreed, at least the second one should be cc stable, as I can reproduce
it with a simple QEMU command.
diff mbox

Patch

diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index 53564229674b..a8b85706e2d6 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -892,5 +892,5 @@  static int __init kasan_memhotplug_init(void)
 	return 0;
 }
 
-module_init(kasan_memhotplug_init);
+core_initcall(kasan_memhotplug_init);
 #endif