[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Unprivileged double fault with GDB and simple program written in assembl
From: |
J. E. Marinheiro |
Subject: |
Unprivileged double fault with GDB and simple program written in assembly |
Date: |
Wed, 28 Aug 2024 13:01:29 +0000 |
Out of curiosity I wrote this program, which uses the syscalls of Linux and
only should work on it:
.section .text
.global _start
_start:
mov $1, %rax
mov $1, %rdi
mov $MSG_Hello, %rsi
mov $LEN_Hello, %rdx
syscall
mov $60, %rax
mov $0, %rdi
syscall
.section .data
MSG_Hello: .ascii "Hello, world!\n"
.set LEN_Hello, . - MSG_Hello
I built the program and ran it like so:
$ as -g program.S -o prorgam.o
$ ld -g program.o -o program
$ gdb program
(gdb) break start
(gdb) run
(gdb) next 5
At this point, a double fault evidently happens, Mach starts panicking, and the
registers are dumped:
* RAX=4010DE
* RBX=0
* RCX=1
* RDX=0
* RSI=0
* RDI=0
* RBP=0
* RSP=0
* R8 to R12=0
* EFLAGS=4000CE
The error message is:
`trapno 0: Divide error, error 01402ff8'
`panic ../i386/i386/trap.c:677: handle_double_fault: DOUBLE FAULT! This is
critical'
I'm using QEMU with these args:
`-M q35 -m 8G'
When not using GDB, the program is simply killed by the system and nothing bad
seems to happen. I'm guessing Linux syscalls need not be the same as Mach
syscalls, but a double fault from some faulty program shouldn't trigger a panic
without even root privileges.
* OS: Debian GNU/Hurd for x86_64, installed through the latest netinst CD
* Toolchain: GNU Binutils 2.43.1, GDB 13.2-1+hurd.3
"Kun nykyaikainen tietokone vahingossa hävittää kaiken, mitä olet kirjoittanut,
mitä teet? Sisäistät vihan. Tunget sen sisällesi. [...] Kohtelet ongelman
lähdettä kuin kuningasta." – Zach Weinersmith
- Unprivileged double fault with GDB and simple program written in assembly,
J. E. Marinheiro <=