Skip to contentSkip to conversation

kaslr should avoid setup_data region

DISCUSSION Dave Young 3 participants 10 messages Apr 24, 2014 – May 9, 2014

lore
Share & tools
lore

Dave Young

author
#0 lore raw

Hello Kees

I'm worrying that setup_data regions could be overwitten by randomize kernel base. Would you like to fix it in kaslr code?

One problem is there could be a lot of setup_data regions but current mem_avoid is an fixed array.

Thanks
Dave

#1 lore raw
Quoted 7 lines · Dave Young

Hello Kees

I'm worrying that setup_data regions could be overwitten by randomize kernel base. Would you like to fix it in kaslr code?

One problem is there could be a lot of setup_data regions but current mem_avoid is an fixed array.

Sure, can you give me some examples? Seems like it shouldn't be too hard to have the mem_avoid logic walk additional areas.

-Kees

Signature · 2 lines
Kees Cook
Chrome OS Security
author
#2 lore raw
Quoted 11 lines · Kees Cook
Quoted 7 lines · Dave Young

Hello Kees

I'm worrying that setup_data regions could be overwitten by randomize kernel base. Would you like to fix it in kaslr code?

One problem is there could be a lot of setup_data regions but current mem_avoid is an fixed array.

Sure, can you give me some examples? Seems like it shouldn't be too hard to have the mem_avoid logic walk additional areas.

Great, To walk through the list just like the function parse_setup_data in arch/x86/kernel/setup.c

Thanks
Dave

#3 lore raw

Ah, it sounds like boot_params.hdr.setup_data contains a series of e820-like entries chained together as a linked list? Which loaders currently populate that? Looks like EFI? Seems like arch/x86/boot/compressed/eboot.c works on setup_data at least.

I won't be in a position to test EFI booting for a while. If someone else took this, that would make it get fixed much faster.

Do you have examples where this is actually causing failures?

-Kees

Quoted 18 lines · Dave Young
Quoted 11 lines · Kees Cook
Quoted 7 lines · Dave Young

Hello Kees

I'm worrying that setup_data regions could be overwitten by randomize kernel base. Would you like to fix it in kaslr code?

One problem is there could be a lot of setup_data regions but current mem_avoid is an fixed array.

Sure, can you give me some examples? Seems like it shouldn't be too hard to have the mem_avoid logic walk additional areas.

Great, To walk through the list just like the function parse_setup_data in arch/x86/kernel/setup.c

Thanks
Dave

Signature · 2 lines
Kees Cook
Chrome OS Security
#4 lore raw
Quoted 11 lines · Kees Cook

Ah, it sounds like boot_params.hdr.setup_data contains a series of e820-like entries chained together as a linked list? Which loaders currently populate that? Looks like EFI? Seems like arch/x86/boot/compressed/eboot.c works on setup_data at least.

I won't be in a position to test EFI booting for a while. If someone else took this, that would make it get fixed much faster.

Do you have examples where this is actually causing failures?

-Kees

Syslinux can populate it with arbitrary data; in particular Syslinux uses it to pass FDT information if requested.

-hpa

author
#5 lore raw
In reply to Kees Cook
Quoted 4 lines · Kees Cook

Ah, it sounds like boot_params.hdr.setup_data contains a series of e820-like entries chained together as a linked list? Which loaders currently populate that? Looks like EFI? Seems like arch/x86/boot/compressed/eboot.c works on setup_data at least.

AFAIK efi stub, kexec, also as HPA mentioned syslinux use it as well.

kexec use setup_data for passing e820 ext ranges, also use it for efi boot.

Quoted 3 lines

I won't be in a position to test EFI booting for a while. If someone else took this, that would make it get fixed much faster.

Because kaslr is randomizing the base, it's hard to produce the failure.

Quoted 1 line

From the code itself, maybe just iterate the setup_data regions and add them

to avoid list, not necessary to care about the setup_data type..

Quoted 2 lines

Do you have examples where this is actually causing failures?

As mentioned above I have no idea how to test. Probably need manually hack the code to create a failure?

Quoted 28 lines

-Kees

Quoted 18 lines · Dave Young
Quoted 11 lines · Kees Cook
Quoted 7 lines · Dave Young

Hello Kees

I'm worrying that setup_data regions could be overwitten by randomize kernel base. Would you like to fix it in kaslr code?

One problem is there could be a lot of setup_data regions but current mem_avoid is an fixed array.

Sure, can you give me some examples? Seems like it shouldn't be too hard to have the mem_avoid logic walk additional areas.

Great, To walk through the list just like the function parse_setup_data in arch/x86/kernel/setup.c

Thanks
Dave

Signature · 2 lines
Kees Cook
Chrome OS Security
author
#6 lore raw
In reply to Kees Cook
Quoted 2 lines

I won't be in a position to test EFI booting for a while. If someone else took this, that would make it get fixed much faster.

I will hopefully look into it next week. But as I said I can only test with a hacked kernel which set the randomized addr to the setup_data region.

Thanks
Dave

author
#7 lore raw
In reply to Kees Cook
Quoted 5 lines · Kees Cook

Ah, it sounds like boot_params.hdr.setup_data contains a series of e820-like entries chained together as a linked list? Which loaders currently populate that? Looks like EFI? Seems like arch/x86/boot/compressed/eboot.c works on setup_data at least.

Quoted 23 lines

I won't be in a position to test EFI booting for a while. If someone else took this, that would make it get fixed much faster.

Do you have examples where this is actually causing failures?

-Kees

Quoted 15 lines · Dave Young
Quoted 11 lines · Kees Cook
Quoted 7 lines · Dave Young

Hello Kees

I'm worrying that setup_data regions could be overwitten by randomize kernel base. Would you like to fix it in kaslr code?

One problem is there could be a lot of setup_data regions but current mem_avoid is an fixed array.

Sure, can you give me some examples? Seems like it shouldn't be too hard to have the mem_avoid logic walk additional areas.

Great, To walk through the list just like the function parse_setup_data in arch/x86/kernel/setup.c

One problem for me is that I am not sure how to read the setup_data memory and iterate it, I think early_ioremap is not available that early. BTW the setup_data region could be above 4G.

Appreciate for any hints.

Thanks
Dave

#8 lore raw
Quoted 15 lines · Dave Young
Quoted 14 lines · Kees Cook
Quoted 13 lines · Dave Young
Quoted 11 lines · Kees Cook
Quoted 7 lines · Dave Young

Hello Kees

I'm worrying that setup_data regions could be overwitten by randomize kernel base. Would you like to fix it in kaslr code?

One problem is there could be a lot of setup_data regions but current mem_avoid is an fixed array.

Sure, can you give me some examples? Seems like it shouldn't be too hard to have the mem_avoid logic walk additional areas.

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

Great, To walk through the list just like the function parse_setup_data in arch/x86/kernel/setup.c

One problem for me is that I am not sure how to read the setup_data memory and iterate it, I think early_ioremap is not available that early. BTW the setup_data region could be above 4G.

Appreciate for any hints.

Hm, I'm not sure. The kASLR code only deals with memory that has been set up during the physical/virtual identity mapping.

-Kees

Signature · 2 lines
Kees Cook
Chrome OS Security
author
#9 lore raw
Quoted 19 lines · Kees Cook
Quoted 18 lines · Dave Young
Quoted 16 lines · Kees Cook
Quoted 15 lines · Dave Young
Quoted 11 lines · Kees Cook
Quoted 7 lines · Dave Young

Hello Kees

I'm worrying that setup_data regions could be overwitten by randomize kernel base. Would you like to fix it in kaslr code?

One problem is there could be a lot of setup_data regions but current mem_avoid is an fixed array.

Sure, can you give me some examples? Seems like it shouldn't be too hard to have the mem_avoid logic walk additional areas.

Great, To walk through the list just like the function parse_setup_data in arch/x86/kernel/setup.c

Quoted 9 lines
Quoted 5 lines

One problem for me is that I am not sure how to read the setup_data memory and iterate it, I think early_ioremap is not available that early. BTW the setup_data region could be above 4G.

Appreciate for any hints.

Hm, I'm not sure. The kASLR code only deals with memory that has been set up during the physical/virtual identity mapping.

So will dereference them directly and ignore setup_data which is above 4G.

Thanks
Dave