* [PATCH v2] MIPS: kernel: Fix random segmentation faults
@ 2025-11-20 12:10 Thomas Bogendoerfer
2025-11-20 12:19 ` Thomas Weißschuh
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Thomas Bogendoerfer @ 2025-11-20 12:10 UTC (permalink / raw)
To: Thomas Weißschuh, Thomas Gleixner, Nam Cao, linux-mips,
linux-kernel
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 <tsbogend@alpha.franken.de>
---
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/20251117191815.69556-1-tsbogend@alpha.franken.de/
arch/mips/kernel/process.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 29191fa1801e..a3101f2268c6 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] MIPS: kernel: Fix random segmentation faults
2025-11-20 12:10 [PATCH v2] MIPS: kernel: Fix random segmentation faults Thomas Bogendoerfer
@ 2025-11-20 12:19 ` Thomas Weißschuh
2025-11-20 12:32 ` Huacai Chen
2025-11-20 15:05 ` Thomas Gleixner
2025-11-21 12:25 ` Thomas Bogendoerfer
2 siblings, 1 reply; 5+ messages in thread
From: Thomas Weißschuh @ 2025-11-20 12:19 UTC (permalink / raw)
To: Thomas Bogendoerfer; +Cc: Thomas Gleixner, Nam Cao, linux-mips, linux-kernel
On Thu, Nov 20, 2025 at 01:10:29PM +0100, Thomas Bogendoerfer wrote:
> 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!
Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> ---
> 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/20251117191815.69556-1-tsbogend@alpha.franken.de/
>
> arch/mips/kernel/process.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
> index 29191fa1801e..a3101f2268c6 100644
> --- a/arch/mips/kernel/process.c
> +++ b/arch/mips/kernel/process.c
> @@ -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
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] MIPS: kernel: Fix random segmentation faults
2025-11-20 12:19 ` Thomas Weißschuh
@ 2025-11-20 12:32 ` Huacai Chen
0 siblings, 0 replies; 5+ messages in thread
From: Huacai Chen @ 2025-11-20 12:32 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: Thomas Bogendoerfer, Thomas Gleixner, Nam Cao, linux-mips,
linux-kernel
On Thu, Nov 20, 2025 at 8:21 PM Thomas Weißschuh
<thomas.weissschuh@linutronix.de> wrote:
>
> On Thu, Nov 20, 2025 at 01:10:29PM +0100, Thomas Bogendoerfer wrote:
> > 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!
>
> Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
>
> > Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > ---
> > 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/20251117191815.69556-1-tsbogend@alpha.franken.de/
> >
> > arch/mips/kernel/process.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
> > index 29191fa1801e..a3101f2268c6 100644
> > --- a/arch/mips/kernel/process.c
> > +++ b/arch/mips/kernel/process.c
> > @@ -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
> >
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] MIPS: kernel: Fix random segmentation faults
2025-11-20 12:10 [PATCH v2] MIPS: kernel: Fix random segmentation faults Thomas Bogendoerfer
2025-11-20 12:19 ` Thomas Weißschuh
@ 2025-11-20 15:05 ` Thomas Gleixner
2025-11-21 12:25 ` Thomas Bogendoerfer
2 siblings, 0 replies; 5+ messages in thread
From: Thomas Gleixner @ 2025-11-20 15:05 UTC (permalink / raw)
To: Thomas Bogendoerfer, Thomas Weißschuh, Nam Cao, linux-mips,
linux-kernel
On Thu, Nov 20 2025 at 13:10, Thomas Bogendoerfer wrote:
> 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 <tsbogend@alpha.franken.de>
I assume this goes through the MIPS tree to Linus.
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] MIPS: kernel: Fix random segmentation faults
2025-11-20 12:10 [PATCH v2] MIPS: kernel: Fix random segmentation faults Thomas Bogendoerfer
2025-11-20 12:19 ` Thomas Weißschuh
2025-11-20 15:05 ` Thomas Gleixner
@ 2025-11-21 12:25 ` Thomas Bogendoerfer
2 siblings, 0 replies; 5+ messages in thread
From: Thomas Bogendoerfer @ 2025-11-21 12:25 UTC (permalink / raw)
To: Thomas Weißschuh, Thomas Gleixner, Nam Cao, linux-mips,
linux-kernel
On Thu, Nov 20, 2025 at 01:10:29PM +0100, Thomas Bogendoerfer wrote:
> 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 <tsbogend@alpha.franken.de>
> ---
> 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/20251117191815.69556-1-tsbogend@alpha.franken.de/
>
> arch/mips/kernel/process.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
> index 29191fa1801e..a3101f2268c6 100644
> --- a/arch/mips/kernel/process.c
> +++ b/arch/mips/kernel/process.c
> @@ -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
applied to mips-fixes.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-11-21 12:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-20 12:10 [PATCH v2] MIPS: kernel: Fix random segmentation faults Thomas Bogendoerfer
2025-11-20 12:19 ` Thomas Weißschuh
2025-11-20 12:32 ` Huacai Chen
2025-11-20 15:05 ` Thomas Gleixner
2025-11-21 12:25 ` Thomas Bogendoerfer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).