| 12 Nov 2025 |
Mic92 | Is riscv 4k page aligned. Usually the first page should not be mapped in userspace | 06:06:27 |
Tristan Ross | When I updated bootstrap-tools on my clone, I got awk to work and it works with this:
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x0000000000000040 0x0000000000000040
0x00000000000002a0 0x00000000000002a0 R 0x8
RISCV_ATTRIBUT 0x00000000000b1022 0x0000000000000000 0x0000000000000000
0x000000000000006a 0x0000000000000000 R 0x1
LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x00000000000ab84c 0x00000000000ab84c R E 0x1000
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 0x10
GNU_EH_FRAME 0x0000000000098fc8 0x0000000000098fc8 0x0000000000098fc8
0x00000000000017a4 0x00000000000017a4 R 0x4
NOTE 0x00000000000ab82c 0x00000000000ab82c 0x00000000000ab82c
0x0000000000000020 0x0000000000000020 R 0x4
LOAD 0x00000000000ac848 0x00000000000ac848 0x00000000000ac848
0x00000000000047c8 0x000000000000c818 RW 0x1000
GNU_RELRO 0x00000000000ac848 0x00000000000ac848 0x00000000000ac848
0x00000000000037b8 0x00000000000037b8 R 0x1
DYNAMIC 0x00000000000af2d0 0x00000000000af2d0 0x00000000000af2d0
0x0000000000000230 0x0000000000000230 RW 0x8
INTERP 0x00000000000b2000 0x00000000000ba000 0x00000000000ba000
0x000000000000005c 0x000000000000005c R 0x1
[Requesting program interpreter: /nix/store/95y6xmfgcvgxjmba9xm6ccxxnf6i61pw-bootstrap-tools/lib/ld-linux-riscv64-lp64d.so.1]
LOAD 0x00000000000b2000 0x00000000000ba000 0x00000000000ba000
0x0000000000000060 0x0000000000000060 RW 0x1000
LOAD 0x00000000000b3000 0x00000000000bb000 0x00000000000bb000
0x00000000000019d0 0x00000000000019d0 RW 0x1000
So maybe the virt addr PHDR isn't as important
| 06:06:33 |
Mic92 | * Is riscv 4k page aligned? Usually the first page should not be mapped in userspace | 06:06:36 |
Mic92 | Not sure if this is your thing, but llms are pretty good at having read all of the cpu architecture specs and have found in the past for me pretty quickly oddities in readelf. | 06:09:20 |
Tristan Ross | I've been rubber ducking ChatGPT since Sunday with this problem | 06:09:44 |
Tristan Ross | It believe AppArmor is the problem, despite me disabling it thinking that was the problem | 06:10:10 |
Mic92 | Feels unlikely. | 06:10:53 |
Mic92 | You would see the audit log in dmesg | 06:11:16 |
Tristan Ross | Yeah, which I don't but ChatGPT is just confident it's AppArmor lol | 06:11:33 |
Mic92 | It's definitely the mmap syscall requesting that returns eperm | 06:12:33 |
Mic92 | You could even ask it to write an mmap call on these parameters to reproduce it | 06:13:30 |
Mic92 | I just don't know which load segment is off. My brain cannot parse these unaligned columns from the phone | 06:14:34 |
Tristan Ross | $ zcat /proc/config.gz | grep CONFIG_STRICT_KERNEL_RWX
CONFIG_STRICT_KERNEL_RWX=y
Could this be a problem?
| 06:14:54 |
Tristan Ross | ChatGPT says it could be lol | 06:15:06 |
Mic92 | No we don't map as executable here if i interpret correctly | 06:16:06 |
Mic92 |
mmap(0xf000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0) = -1 EPERM (Operation not permitted) | 06:16:19 |
Mic92 | Only read/write | 06:16:32 |
Mic92 | Figure out what 3 is here | 06:16:59 |
Mic92 | Run strace with -yy | 06:17:15 |
dramforever | 0xf000 is sus | 06:17:29 |
Mic92 | This gives you file descriptors | 06:17:33 |
dramforever | is it below the minimum address limit | 06:17:38 |
Mic92 | In reply to @dramforever:matrix.org 0xf000 is sus I agree | 06:17:47 |
Mic92 | What's allowed on RISC-V? | 06:18:05 |
Tristan Ross | I set sudo sysctl -w vm.mmap_min_addr=4096 and GCC works | 06:18:15 |
dramforever | the other thing is it may be relevant to us enabling PIE recently | 06:18:41 |
dramforever | ish | 06:18:45 |
dramforever | recent-ish | 06:18:49 |
dramforever | i'm starting to think maybe you shouldn't be on 6.6 | 06:19:14 |
Tristan Ross | The bootstrap-tools GCC is from last year, I thought PIE was within the last couple months | 06:19:14 |