MIPS: kernel: Fix random segmentation faults
Thomas Bogendoerfer
maintainerPATCH v2 1/1 MIPS: kernel: Fix random segmentation faults
Commit 69896119dc9d ("MIPS: vdso: Switch to generic storage implementation") switches to a generic vdso storage, which increases the number of data pages from 1 to 4. But there is only one page reserved, which causes segementation faults depending where the VDSO area is randomized to. To fix this use the same size of reservation and allocation of the VDSO data pages.
---
v2: Don't reserve additionnal VDSO_NR_PAGES, but reserve VDSO_NR_PAGES
instead of the one page before.
Reworked description
v1: https://lore.kernel.org/all/[email protected]/
arch/mips/kernel/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/process.c +1 -1
@@ -692,7 +692,7 @@ unsigned long mips_stack_top(void)/* Space for the VDSO, data page & GIC user page */ if (current->thread.abi) { top -=PAGE_ALIGN (current->thread.abi->vdso->size); - top -=PAGE_SIZE ; + top -=VDSO_NR_PAGES *PAGE_SIZE ; top -=mips_gic_present () ?PAGE_SIZE :0 ;/* Space to randomize the VDSO base */
Signature · 1 line
2.43.0
Quoted 8 lines · Thomas Bogendoerfer
Commit
69896119dc9d("MIPS: vdso: Switch to generic storage implementation") switches to a generic vdso storage, which increases the number of data pages from 1 to 4. But there is only one page reserved, which causes segementation faults depending where the VDSO area is randomized to. To fix this use the same size of reservation and allocation of the VDSO data pages.Fixes 69896119dc9d ("MIPS: vdso: Switch to generic storage implementation")
Thanks!
Quoted 26 lines
Signed-off-by Thomas Bogendoerfer <[email protected]>---
v2: Don't reserve additionnalVDSO_NR_PAGES, but reserveVDSO_NR_PAGES
instead of the one page before.
Reworked description
v1: https://lore.kernel.org/all/[email protected]/arch/mips/kernel/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/kernel/process.c +1
-1@@ -692,7 +692,7 @@ unsigned long mips_stack_top(void)/* Space for the VDSO, data page & GIC user page */ if (current->thread.abi) { top -=PAGE_ALIGN (current->thread.abi->vdso->size); - top -=PAGE_SIZE ; + top -=VDSO_NR_PAGES *PAGE_SIZE ; top -=mips_gic_present () ?PAGE_SIZE :0 ;/* Space to randomize the VDSO base */ Signature · 1 line
2.43.0
Huacai Chen
Reviewed-byQuoted 9 lines · Thomas Weißschuh
Quoted 7 lines · Thomas Bogendoerfer
Commit
69896119dc9d("MIPS: vdso: Switch to generic storage implementation") switches to a generic vdso storage, which increases the number of data pages from 1 to 4. But there is only one page reserved, which causes segementation faults depending where the VDSO area is randomized to. To fix this use the same size of reservation and allocation of the VDSO data pages.
Quoted 5 lines
Quoted 1 line
Fixes 69896119dc9d ("MIPS: vdso: Switch to generic storage implementation")Thanks!
Reviewed-by Thomas Weißschuh <[email protected]>
Quoted 28 lines
Quoted 27 lines
Signed-off-by Thomas Bogendoerfer <[email protected]>---
v2: Don't reserve additionnalVDSO_NR_PAGES, but reserveVDSO_NR_PAGES
instead of the one page before.
Reworked description
v1: https://lore.kernel.org/all/[email protected]/arch/mips/kernel/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/kernel/process.c +1
-2@@ -692,7 +692,7 @@ unsigned long mips_stack_top(void)/* Space for the VDSO, data page & GIC user page */ if (current->thread.abi) { top -=PAGE_ALIGN (current->thread.abi->vdso->size); - top -=PAGE_SIZE ; + top -=VDSO_NR_PAGES *PAGE_SIZE ; top -=mips_gic_present () ?PAGE_SIZE :0 ;/* Space to randomize the VDSO base */ --2.43.0
Quoted 9 lines · Thomas Bogendoerfer
Commit
69896119dc9d("MIPS: vdso: Switch to generic storage implementation") switches to a generic vdso storage, which increases the number of data pages from 1 to 4. But there is only one page reserved, which causes segementation faults depending where the VDSO area is randomized to. To fix this use the same size of reservation and allocation of the VDSO data pages.Fixes 69896119dc9d ("MIPS: vdso: Switch to generic storage implementation")Signed-off-by Thomas Bogendoerfer <[email protected]>
I assume this goes through the MIPS tree to Linus.
Quoted 33 lines · Thomas Bogendoerfer
Commit
69896119dc9d("MIPS: vdso: Switch to generic storage implementation") switches to a generic vdso storage, which increases the number of data pages from 1 to 4. But there is only one page reserved, which causes segementation faults depending where the VDSO area is randomized to. To fix this use the same size of reservation and allocation of the VDSO data pages.Fixes 69896119dc9d ("MIPS: vdso: Switch to generic storage implementation")Signed-off-by Thomas Bogendoerfer <[email protected]>---
v2: Don't reserve additionnalVDSO_NR_PAGES, but reserveVDSO_NR_PAGES
instead of the one page before.
Reworked description
v1: https://lore.kernel.org/all/[email protected]/arch/mips/kernel/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/kernel/process.c +1
-1@@ -692,7 +692,7 @@ unsigned long mips_stack_top(void)/* Space for the VDSO, data page & GIC user page */ if (current->thread.abi) { top -=PAGE_ALIGN (current->thread.abi->vdso->size); - top -=PAGE_SIZE ; + top -=VDSO_NR_PAGES *PAGE_SIZE ; top -=mips_gic_present () ?PAGE_SIZE :0 ;/* Space to randomize the VDSO base */ Signature · 1 line
2.43.0
applied to mips-fixes.
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]