diff mbox series

[KINETIC] UBUNTU: SAUCE: Revert "riscv: mmap with PROT_WRITE but no PROT_READ is invalid"

Message ID 20221011170005.96692-1-dimitri.ledkov@canonical.com
State New
Headers show
Series [KINETIC] UBUNTU: SAUCE: Revert "riscv: mmap with PROT_WRITE but no PROT_READ is invalid" | expand

Commit Message

Dimitri John Ledkov Oct. 11, 2022, 5 p.m. UTC
This reverts commit 9795ca67b5d3eeeb4b602cbc34f72f41af6df142.

Upstream reported riscv regression of userspace (OpenJDK).

BugLink: https://bugs.launchpad.net/bugs/1992484
Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
---
 arch/riscv/kernel/sys_riscv.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Cory Todd Oct. 11, 2022, 5:14 p.m. UTC | #1
Acked-by: Cory Todd <cory.todd@canonical.com>

On Tue, Oct 11, 2022 at 06:00:05PM +0100, Dimitri John Ledkov wrote:
> This reverts commit 9795ca67b5d3eeeb4b602cbc34f72f41af6df142.
> 
> Upstream reported riscv regression of userspace (OpenJDK).
> 
> BugLink: https://bugs.launchpad.net/bugs/1992484
> Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
> ---
>  arch/riscv/kernel/sys_riscv.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c
> index 571556bb92..9c0194f176 100644
> --- a/arch/riscv/kernel/sys_riscv.c
> +++ b/arch/riscv/kernel/sys_riscv.c
> @@ -18,8 +18,9 @@ static long riscv_sys_mmap(unsigned long addr, unsigned long len,
>  	if (unlikely(offset & (~PAGE_MASK >> page_shift_offset)))
>  		return -EINVAL;
>  
> -	if (unlikely((prot & PROT_WRITE) && !(prot & PROT_READ)))
> -		return -EINVAL;
> +	if ((prot & PROT_WRITE) && (prot & PROT_EXEC))
> +		if (unlikely(!(prot & PROT_READ)))
> +			return -EINVAL;
>  
>  	return ksys_mmap_pgoff(addr, len, prot, flags, fd,
>  			       offset >> (PAGE_SHIFT - page_shift_offset));
> -- 
> 2.34.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
Thadeu Lima de Souza Cascardo Oct. 11, 2022, 5:22 p.m. UTC | #2
On Tue, Oct 11, 2022 at 06:00:05PM +0100, Dimitri John Ledkov wrote:
> This reverts commit 9795ca67b5d3eeeb4b602cbc34f72f41af6df142.
, which is commit 2139619bcad7ac44cc8f6f749089120594056613 upstream.

Just usual to mention what upstream commit is being reverted.

Acked-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>

The ACK is also valid to apply it on top of linux-riscv derivative directly.

> 
> Upstream reported riscv regression of userspace (OpenJDK).
> 
> BugLink: https://bugs.launchpad.net/bugs/1992484
> Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
> ---
>  arch/riscv/kernel/sys_riscv.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c
> index 571556bb92..9c0194f176 100644
> --- a/arch/riscv/kernel/sys_riscv.c
> +++ b/arch/riscv/kernel/sys_riscv.c
> @@ -18,8 +18,9 @@ static long riscv_sys_mmap(unsigned long addr, unsigned long len,
>  	if (unlikely(offset & (~PAGE_MASK >> page_shift_offset)))
>  		return -EINVAL;
>  
> -	if (unlikely((prot & PROT_WRITE) && !(prot & PROT_READ)))
> -		return -EINVAL;
> +	if ((prot & PROT_WRITE) && (prot & PROT_EXEC))
> +		if (unlikely(!(prot & PROT_READ)))
> +			return -EINVAL;
>  
>  	return ksys_mmap_pgoff(addr, len, prot, flags, fd,
>  			       offset >> (PAGE_SHIFT - page_shift_offset));
> -- 
> 2.34.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
Dimitri John Ledkov Oct. 11, 2022, 5:41 p.m. UTC | #3
Applied to kinetic next branches in generic; and riscv kernels (thus
any next cranks for risc kernels will pick up this patch either as a
direct build, or as part of rebase).

On Tue, 11 Oct 2022 at 18:22, Thadeu Lima de Souza Cascardo
<cascardo@canonical.com> wrote:
>
> On Tue, Oct 11, 2022 at 06:00:05PM +0100, Dimitri John Ledkov wrote:
> > This reverts commit 9795ca67b5d3eeeb4b602cbc34f72f41af6df142.
> , which is commit 2139619bcad7ac44cc8f6f749089120594056613 upstream.
>
> Just usual to mention what upstream commit is being reverted.
>

Ack, updated to just the upstream commit id, but yes, mentioning both
ids is probably the best.

> Acked-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
>
> The ACK is also valid to apply it on top of linux-riscv derivative directly.
>
> >
> > Upstream reported riscv regression of userspace (OpenJDK).
> >
> > BugLink: https://bugs.launchpad.net/bugs/1992484
> > Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
> > ---
> >  arch/riscv/kernel/sys_riscv.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c
> > index 571556bb92..9c0194f176 100644
> > --- a/arch/riscv/kernel/sys_riscv.c
> > +++ b/arch/riscv/kernel/sys_riscv.c
> > @@ -18,8 +18,9 @@ static long riscv_sys_mmap(unsigned long addr, unsigned long len,
> >       if (unlikely(offset & (~PAGE_MASK >> page_shift_offset)))
> >               return -EINVAL;
> >
> > -     if (unlikely((prot & PROT_WRITE) && !(prot & PROT_READ)))
> > -             return -EINVAL;
> > +     if ((prot & PROT_WRITE) && (prot & PROT_EXEC))
> > +             if (unlikely(!(prot & PROT_READ)))
> > +                     return -EINVAL;
> >
> >       return ksys_mmap_pgoff(addr, len, prot, flags, fd,
> >                              offset >> (PAGE_SHIFT - page_shift_offset));
> > --
> > 2.34.1
> >
> >
> > --
> > kernel-team mailing list
> > kernel-team@lists.ubuntu.com
> > https://lists.ubuntu.com/mailman/listinfo/kernel-team
diff mbox series

Patch

diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c
index 571556bb92..9c0194f176 100644
--- a/arch/riscv/kernel/sys_riscv.c
+++ b/arch/riscv/kernel/sys_riscv.c
@@ -18,8 +18,9 @@  static long riscv_sys_mmap(unsigned long addr, unsigned long len,
 	if (unlikely(offset & (~PAGE_MASK >> page_shift_offset)))
 		return -EINVAL;
 
-	if (unlikely((prot & PROT_WRITE) && !(prot & PROT_READ)))
-		return -EINVAL;
+	if ((prot & PROT_WRITE) && (prot & PROT_EXEC))
+		if (unlikely(!(prot & PROT_READ)))
+			return -EINVAL;
 
 	return ksys_mmap_pgoff(addr, len, prot, flags, fd,
 			       offset >> (PAGE_SHIFT - page_shift_offset));