On Sat, May 30, 2026 at 8:02 AM Andreas Schwab <[email protected]> wrote: > > On Nov 12 2025, Deepak Gupta via B4 Relay wrote: > > > From: Deepak Gupta <[email protected]> > > > > `arch_calc_vm_prot_bits` is implemented on risc-v to return VM_READ | > > VM_WRITE if PROT_WRITE is specified. Similarly `riscv_sys_mmap` is > > updated to convert all incoming PROT_WRITE to (PROT_WRITE | PROT_READ). > > This is to make sure that any existing apps using PROT_WRITE still work. > > > > Earlier `protection_map[VM_WRITE]` used to pick read-write PTE encodings. > > Now `protection_map[VM_WRITE]` will always pick PAGE_SHADOWSTACK PTE > > encodings for shadow stack. Above changes ensure that existing apps > > continue to work because underneath kernel will be picking > > `protection_map[VM_WRITE|VM_READ]` PTE encodings. > > This breaks LTP mmap04: > > $ ./mmap04 > tst_test.c:2042: TINFO: LTP version: 20260529.5ccf816f > tst_test.c:2045: TINFO: Tested kernel: 7.0.10-5-default #1 SMP > PREEMPT_DYNAMIC Sat May 23 12:09:09 UTC 2026 (bb95589) riscv64 > tst_kconfig.c:90: TINFO: Parsing kernel config '/proc/config.gz' > tst_kconfig.c:753: TINFO: CONFIG_FAULT_INJECTION kernel option detected which > might slow the execution > tst_test.c:1870: TINFO: Overall timeout per run is 0h 04m 00s > mmap04.c:66: TPASS: mapping permissions in /proc matched: ---p > mmap04.c:66: TPASS: mapping permissions in /proc matched: ---s > mmap04.c:66: TPASS: mapping permissions in /proc matched: r--p > mmap04.c:66: TPASS: mapping permissions in /proc matched: r--s > mmap04.c:68: TFAIL: mapping permissions in /proc mismatched, expected: -w-p, > found: rw-p > mmap04.c:68: TFAIL: mapping permissions in /proc mismatched, expected: -w-s, > found: rw-s > mmap04.c:66: TPASS: mapping permissions in /proc matched: rw-p > mmap04.c:66: TPASS: mapping permissions in /proc matched: rw-s > mmap04.c:66: TPASS: mapping permissions in /proc matched: r-xp > mmap04.c:66: TPASS: mapping permissions in /proc matched: r-xs > mmap04.c:68: TFAIL: mapping permissions in /proc mismatched, expected: -wxp, > found: rwxp > mmap04.c:68: TFAIL: mapping permissions in /proc mismatched, expected: -wxs, > found: rwxs > mmap04.c:66: TPASS: mapping permissions in /proc matched: rwxp > mmap04.c:66: TPASS: mapping permissions in /proc matched: rwxs
But what does a writable only mapping even mean? It can always be read. I see two ways forward: - It can be done in generic way where incoming PROT_WRITE means PROT_READ | PROT_WRITE irrespective of RISC-V. Although others (x86, arm, etc) would have to weigh in. OR - mmap04 LTP test can be updated to expect either of "rw-p" or "-w-p" whenever only PROT_WRITE was specified. I think latter (updating mmap04 test) is the easier path. > > Summary: > passed 10 > failed 4 > broken 0 > skipped 0 > warnings 0 > > -- > Andreas Schwab, [email protected] > GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 > "And now for something completely different."

