[RFC PATCH v1] riscv: mm: Ensure prot of VM_WRITE and VM_EXEC must be readable

Conor Dooley conor.dooley at microchip.com
Tue Apr 25 03:19:14 PDT 2023


On Tue, Apr 25, 2023 at 06:10:36PM +0800, Woodrow Shen wrote:
> Hi Conor,
> 
> On Tue, Apr 25, 2023 at 2:55 PM Conor Dooley <conor.dooley at microchip.com> wrote:
> >
> > Hey Hsieh-Tseng,
> >
> > On Tue, Apr 25, 2023 at 11:44:07AM +0800, Woodrow Shen wrote:
> > > From: Hsieh-Tseng Shen <woodrow.shen at sifive.com>
> > >
> > > The commit 8aeb7b1 allows riscv to use mmap with PROT_WRITE only,
> > > and meanwhile mmap with w+x is also permitted. However, when userspace
> > > tries to access this page with PROT_WRITE|PROT_EXEC, which causes
> > > infinite loop at load page fault as well as it triggers soft lockup.
> > > According to riscv privileged spec, "Writable pages must also be marked
> > > readable". The fix to drop the `PAGE_COPY_READ_EXEC` and `PAGE_READ_EXEC`
> > > should be just used instead. This aligns the other arches (i.e arm64)
> > > for protection_map.
> > >
> > > Fixes: 8aeb7b1 ("RISC-V: Make mmap() with PROT_WRITE imply PROT_READ")
> >
> > This fixes tag should be:
> > Fixes: 8aeb7b17f04e ("RISC-V: Make mmap() with PROT_WRITE imply PROT_READ")
> > as checkpatch would have told you :/ Perhaps Palmer can fix that up on
> > application?
> >
> > > Signed-off-by: Hsieh-Tseng Shen <woodrow.shen at sifive.com>
> > > Reviewed-by: Alexandre Ghiti <alexghiti at rivosinc.com>
> > > ---
> >
> > This is not v1, it's v2 right?
> > Please include a changelog between versions.
> 
> Yes, it's v2. I copied the outdated comment as my first version was
> verified by script correctly. Will fix it in v2.
> 
> >
> > Also, what makes it an RFC, it's an actual fix that you would like
> > merged, right?
> 
> I was suggested to use "RFC" internally, so should I just re-submit v2
> with [RESEND v2]?

If you want? It's Palmer's call whether he'd be happy with fixing up the
tag or not, not mine.

If you do resend, it would just be "v2" though IMO.

Cheers,
Conor.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-riscv/attachments/20230425/5db697f1/attachment.sig>


More information about the linux-riscv mailing list