[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <mhng-56794b7f-6cd4-4eb9-a962-83ad256ed3cd@palmer-si-x1e>
Date: Tue, 07 May 2019 16:48:03 -0700 (PDT)
From: Palmer Dabbelt <palmer@...ive.com>
To: schwab@...e.de
CC: linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] riscv: fix locking violation in page fault handler
On Tue, 07 May 2019 00:36:46 PDT (-0700), schwab@...e.de wrote:
> When a user mode process accesses an address in the vmalloc area
> do_page_fault tries to unlock the mmap semaphore when it isn't locked.
>
> Signed-off-by: Andreas Schwab <schwab@...e.de>
> ---
> arch/riscv/mm/fault.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
> index 88401d5125bc..c51878e5a66a 100644
> --- a/arch/riscv/mm/fault.c
> +++ b/arch/riscv/mm/fault.c
> @@ -181,6 +181,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
> up_read(&mm->mmap_sem);
> /* User mode accesses just cause a SIGSEGV */
> if (user_mode(regs)) {
> +bad_area_do_trap:
> do_trap(regs, SIGSEGV, code, addr, tsk);
> return;
> }
> @@ -230,7 +231,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
> int index;
>
> if (user_mode(regs))
> - goto bad_area;
> + goto bad_area_do_trap;
>
> /*
> * Synchronize this task's top level page-table
I got lost with all the gotos, I think something like this is cleaner
diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
index 26293bc053a8..cec8be9e2d6a 100644
--- a/arch/riscv/mm/fault.c
+++ b/arch/riscv/mm/fault.c
@@ -229,8 +229,9 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
pte_t *pte_k;
int index;
+ /* User mode accesses just cause a SIGSEGV */
if (user_mode(regs))
- goto bad_area;
+ return do_trap(regs, SIGSEGV, code, addr, tsk);
/*
* Synchronize this task's top level page-table
Unless anyone has a better idea?
Either way:
Reviewed-by: Palmer Dabbelt <palmer@...ive.com>
LMK if you, or anyone else, has a preference. I'm assuming this will go in
through my tree, so I've picked up my version for now :)
Powered by blists - more mailing lists