lkml.org 
[lkml]   [2012]   [Jul]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
Subjectiopl not preserved across execve on x64
Dear Linux kernel developers,

I have a question about how iopl works with execve. Essentially, I
want to set iopl to 3 with one program, then call execve to change to
another program that writes to the system speaker. This works fine on
x86 kernels, but segfaults on x64 kernels. Why is this?

-Alex

---iopl3.c---
#include <stdio.h>
#include <unistd.h>

int main(int argc, char* argv[])
{
if (iopl(3) == -1)
{
perror("iopl");
return 1;
}

if (execvp(argv[1], &argv[1]) == -1)
{
perror("execvp");
return 1;
}

return 0;
}

---beep.c---
#include <stdio.h>

int main()
{
__asm__("movb $0xB6, %al\n"
"outb %al, $0x43\n"
"inb $0x61, %al\n"
"orb $0x03, %al\n"
"outb %al, $0x61\n"
"movb $0x64, %al\n"
"outb %al, $0x42\n"
"movb $0x01, %al\n"
"outb %al, $0x42\n");
sleep(1);
__asm__("inb $0x61, %al\n"
"andb $0xFC, %al\n"
"outb %al, $0x61\n");
return 0;
}

---test.sh---
gcc iopl3.c -o iopl3
gcc beep.c -o beep
sudo setcap cap_sys_rawio+eip ./iopl3
./iopl3 ./beep


\
 
 \ /
  Last update: 2012-07-03 00:41    [W:0.036 / U:0.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site