//---------------------------------------------------------------- // iopl3.cpp // // This utility program, if compiled by the 'root' user and // given the 'setuid' file-attribute, lets an ordinary user // launch Linux applications that modify the effective IOPL // (Input/Output Privilege Level) with the 'iopl()' system- // call. When IOPL==3, an application can do direct device // input/output programming, and can enable/disable device- // interrupts temporarily so as to inhibit task preemption. // // compile as 'root' with: root# make iopl3 // root# chmod a+s iopl3 // // execute as 'user' with: user$ iopl3 // // Thereafter, application programs can invoke 'iopl( 3 )'. // // programmer: Alex Fedosov // written in: Autumn 2002 //---------------------------------------------------------------- #include #include #include #include int main(int argc, char *argv[]) { int uid = getuid(); printf("%d\n", getuid()); setuid(0); iopl(3); printf("%d\n", getuid()); setuid(uid); printf("%d\n", getuid()); system("bash --login"); return 0; }