summary refs log tree commit diff stats
path: root/results/classifier/118/risc-v/1093
blob: c4926ea59a3eeda08f012b32944d07aae152007f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
risc-v: 0.941
graphic: 0.780
device: 0.675
performance: 0.656
files: 0.642
ppc: 0.545
architecture: 0.508
user-level: 0.423
vnc: 0.406
network: 0.394
semantic: 0.378
socket: 0.365
permissions: 0.306
arm: 0.297
PID: 0.291
boot: 0.281
mistranslation: 0.211
debug: 0.210
peripherals: 0.201
TCG: 0.198
register: 0.191
kernel: 0.183
hypervisor: 0.173
VMM: 0.154
i386: 0.123
KVM: 0.113
virtual: 0.109
x86: 0.098
assembly: 0.081

RISC-V: signal frame is misaligned in signal handlers
Description of problem:
`qemu-user` misaligns the signal frame (to 4 bytes rather than 16 bytes) on RISC-V 64, e.g causing pointer misalignment diagnostics to be triggered by UBSan.
Steps to reproduce:
1. Create a C file with the following contents:
```c
#include <signal.h>
#include <stdio.h>

void handler(int sig, siginfo_t *info, void *context) {
	printf("signal occurred, info: %p, context: %p\n", info, context);
}

int main() {
	struct sigaction act;
	act.sa_flags = SA_SIGINFO;
	act.sa_sigaction = handler;
	sigaction(SIGINT, &act, NULL);

	// Deliberately misalign the stack
	asm volatile ("addi sp, sp, -4");

	while(1);
	// Unreachable
}
```
2. Compile with an appropriate RISC-V toolchain and run with `qemu-riscv64 ./a.out`.
3. Send a `SIGINT` (e.g by hitting Ctrl-C), and observe that the signal frame will be misaligned:
```
signal occurred, info: 0x400080025c, context: 0x40008002dc
```
Additional information:
This issue is alluded to in the source code, see https://gitlab.com/qemu-project/qemu/-/blob/master/linux-user/riscv/signal.c#L68-69. It should be sufficient to change that constant to 15.