From: <Conor.Dooley@microchip.com>
To: <abrestic@rivosinc.com>, <palmer@dabbelt.com>
Cc: <paul.walmsley@sifive.com>, <coelacanthus@outlook.com>,
<dramforever@live.com>, <c141028@gmail.com>,
<linux-riscv@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
<atishp@rivosinc.com>
Subject: Re: [PATCH v3 2/2] riscv: Allow PROT_WRITE-only mmap()
Date: Thu, 15 Sep 2022 16:56:36 +0000 [thread overview]
Message-ID: <d46d6340-b985-49b2-babb-0082f1759c7b@microchip.com> (raw)
In-Reply-To: <20220909212731.1373355-2-abrestic@rivosinc.com>
On 09/09/2022 22:27, Andrew Bresticker wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> Commit 2139619bcad7 ("riscv: mmap with PROT_WRITE but no PROT_READ is
> invalid") made mmap() return EINVAL if PROT_WRITE was set wihtout
> PROT_READ with the justification that a write-only PTE is considered a
> reserved PTE permission bit pattern in the privileged spec. This check
> is unnecessary since we let VM_WRITE imply VM_READ on RISC-V, and it is
> inconsistent with other architectures that don't support write-only PTEs,
> creating a potential software portability issue. Just remove the check
> altogether and let PROT_WRITE imply PROT_READ as is the case on other
> architectures.
>
> Note that this also allows PROT_WRITE|PROT_EXEC mappings which were
> disallowed prior to the aforementioned commit; PROT_READ is implied in
> such mappings as well.
>
> Fixes: 2139619bcad7 ("riscv: mmap with PROT_WRITE but no PROT_READ is invalid")
For the naive members of the audience such as myself, this patch
came after a non-fixes patch in the series. What is the dependence
of this patch on the other one (if any)?
Thanks,
Conor.
> Reviewed-by: Atish Patra <atishp@rivosinc.com>
> Signed-off-by: Andrew Bresticker <abrestic@rivosinc.com>
> ---
> v1 -> v2: Update access_error() to account for write-implies-read
> v2 -> v3: Separate into two commits
> ---
> arch/riscv/kernel/sys_riscv.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c
> index 571556bb9261..5d3f2fbeb33c 100644
> --- a/arch/riscv/kernel/sys_riscv.c
> +++ b/arch/riscv/kernel/sys_riscv.c
> @@ -18,9 +18,6 @@ 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;
> -
> return ksys_mmap_pgoff(addr, len, prot, flags, fd,
> offset >> (PAGE_SHIFT - page_shift_offset));
> }
> --
> 2.25.1
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2022-09-15 16:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-09 21:27 [PATCH v3 1/2] riscv: Make VM_WRITE imply VM_READ Andrew Bresticker
2022-09-09 21:27 ` [PATCH v3 2/2] riscv: Allow PROT_WRITE-only mmap() Andrew Bresticker
2022-09-15 16:56 ` Conor.Dooley [this message]
2022-09-15 17:27 ` Andrew Bresticker
2022-09-15 17:40 ` Conor.Dooley
2022-09-15 17:51 ` Vivian Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d46d6340-b985-49b2-babb-0082f1759c7b@microchip.com \
--to=conor.dooley@microchip.com \
--cc=abrestic@rivosinc.com \
--cc=atishp@rivosinc.com \
--cc=c141028@gmail.com \
--cc=coelacanthus@outlook.com \
--cc=dramforever@live.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®