[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220814162610.2397644-12-sashal@kernel.org>
Date: Sun, 14 Aug 2022 12:25:52 -0400
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc: Celeste Liu <coelacanthus@...look.com>, xctan <xc-tan@...look.com>,
dram <dramforever@...e.com>, Ruizhe Pan <c141028@...il.com>,
Palmer Dabbelt <palmer@...osinc.com>,
Sasha Levin <sashal@...nel.org>, paul.walmsley@...ive.com,
palmer@...belt.com, aou@...s.berkeley.edu, guoren@...nel.org,
linux-riscv@...ts.infradead.org
Subject: [PATCH AUTOSEL 5.15 12/28] riscv: mmap with PROT_WRITE but no PROT_READ is invalid
From: Celeste Liu <coelacanthus@...look.com>
[ Upstream commit 2139619bcad7ac44cc8f6f749089120594056613 ]
As mentioned in Table 4.5 in RISC-V spec Volume 2 Section 4.3, write
but not read is "Reserved for future use.". For now, they are not valid.
In the current code, -wx is marked as invalid, but -w- is not marked
as invalid.
This patch refines that judgment.
Reported-by: xctan <xc-tan@...look.com>
Co-developed-by: dram <dramforever@...e.com>
Signed-off-by: dram <dramforever@...e.com>
Co-developed-by: Ruizhe Pan <c141028@...il.com>
Signed-off-by: Ruizhe Pan <c141028@...il.com>
Signed-off-by: Celeste Liu <coelacanthus@...look.com>
Link: https://lore.kernel.org/r/PH7PR14MB559464DBDD310E755F5B21E8CEDC9@PH7PR14MB5594.namprd14.prod.outlook.com
Signed-off-by: Palmer Dabbelt <palmer@...osinc.com>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
arch/riscv/kernel/sys_riscv.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c
index 12f8a7fce78b..8a7880b9c433 100644
--- a/arch/riscv/kernel/sys_riscv.c
+++ b/arch/riscv/kernel/sys_riscv.c
@@ -18,9 +18,8 @@ static long riscv_sys_mmap(unsigned long addr, unsigned long len,
if (unlikely(offset & (~PAGE_MASK >> page_shift_offset)))
return -EINVAL;
- if ((prot & PROT_WRITE) && (prot & PROT_EXEC))
- if (unlikely(!(prot & PROT_READ)))
- return -EINVAL;
+ if (unlikely((prot & PROT_WRITE) && !(prot & PROT_READ)))
+ return -EINVAL;
return ksys_mmap_pgoff(addr, len, prot, flags, fd,
offset >> (PAGE_SHIFT - page_shift_offset));
--
2.35.1
Powered by blists - more mailing lists