diff mbox series

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

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

Commit Message

Dimitri John Ledkov Oct. 11, 2022, 5:02 p.m. UTC
This reverts commit 4fc4fa4f729dccbc36467bae17c3a037d59b95a4.

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:19 p.m. UTC | #1
On Tue, Oct 11, 2022 at 06:02:27PM +0100, Dimitri John Ledkov wrote:
> This reverts commit 4fc4fa4f729dccbc36467bae17c3a037d59b95a4.
> 
> 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 8a7880b9c4..12f8a7fce7 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

Acked-by: Cory Todd <cory.todd@canonical.com>
Thadeu Lima de Souza Cascardo Oct. 11, 2022, 5:22 p.m. UTC | #2
On Tue, Oct 11, 2022 at 06:02:27PM +0100, Dimitri John Ledkov wrote:
> This reverts commit 4fc4fa4f729dccbc36467bae17c3a037d59b95a4.
, 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 8a7880b9c4..12f8a7fce7 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
Stefan Bader Oct. 19, 2022, 9:55 a.m. UTC | #3
On 11.10.22 19:02, Dimitri John Ledkov wrote:
> This reverts commit 4fc4fa4f729dccbc36467bae17c3a037d59b95a4.
> 
> Upstream reported riscv regression of userspace (OpenJDK).
> 
> BugLink: https://bugs.launchpad.net/bugs/1992484
> Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
> ---

Applied to jammy:linux/master-next. Thanks.

-Stefan

>   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 8a7880b9c4..12f8a7fce7 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));
diff mbox series

Patch

diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c
index 8a7880b9c4..12f8a7fce7 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));