I am triaging a bug in Unix-like OS, and i hit GP fault in that kernel, and system reset.
I don't know what should Linux do in this case, I want to have a try.
So, in X86 Linux, how can I trigger a GP fault?
Many thanks,
-Tao
How can I trigger a general protection fault in X86 Linux?
Re: How can I trigger a general protection fault in X86 Linu
This should be sufficient
FWIW, what it does for me when run is
and in the kernel log:
Basically, a "standard" UNIX-like OS should probably catch the GPF interrupt, decide that it happened because a userspace program is being naughty and not due to a kernel bug, and kill the offending process with as much/little logging as needed
Code: Select all
section .text
global _start
_start: lgdt [0x0]
Code: Select all
$ ./file
Segmentation fault (core dumped)
Code: Select all
[10832.987652] traps: file[32233] general protection ip:8048060 sp:ffdcd2a0 error:0 in file[8048000+1000]
Re: How can I trigger a general protection fault in X86 Linu
By reading the Wiki for general protection, i can trigger the GP fault in Linux by setting a reserved bit in CR4.
The kernel will panic, then reboot.
Thanks,
-Tao
The kernel will panic, then reboot.
Thanks,
-Tao
- lkurusa
- Member
- Posts: 42
- Joined: Wed Aug 08, 2012 6:39 am
- Libera.chat IRC: Levex
- Location: New York, NY
- Contact:
Re: How can I trigger a general protection fault in X86 Linu
Are you setting that bit in a kernel module or are you doing that in userspace? If the latter, that's a serious security issue.
Cheers,
Lev
Lev
- Schol-R-LEA
- Member
- Posts: 1925
- Joined: Fri Oct 27, 2006 9:42 am
- Location: Athens, GA, USA
Re: How can I trigger a general protection fault in X86 Linu
Could you please give us more information about the cause of the problem? Under what circumstances does it happen, and what are trying to do to triage it (by which I assume you mean track it down so you can fix it, rather than trying to decide the priority with which it should be treated )?wangt13 wrote:I am triaging a bug in Unix-like OS, and i hit GP fault in that kernel, and system reset.
I don't know what should Linux do in this case, I want to have a try.
Also, why are you then trying to create an analogous situation in Linux? Are you certain that the specific cause of the fault can occur in Linux at all? Are you trying to find out how Linux handles it, so you can apply the same approach (which may or may not be a good idea, depending on the details of your own OS and how it differs from Linux)?
I have a sense that there might be an XY Problem in this post - that what you are asking for isn't necessarily what you need, and that you are presupposing the answer in a way that excludes a better one. If X is 'find and fix the fault in my OS', then asking for Y ('how do I replicate the error in a related but significantly different OS?') is shifting the problem in a way that may not really solve X.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.