|
|
1.1 ! root 1: #include <stdio.h> ! 2: #include <stdlib.h> ! 3: #include <errno.h> ! 4: #include <unistd.h> ! 5: ! 6: #include <sys/syscall.h> ! 7: ! 8: #ifndef SYS_set_thread_area ! 9: #define SYS_set_thread_area 243 ! 10: #endif ! 11: ! 12: int main (void) ! 13: { ! 14: unsigned long tp, old_tp; ! 15: int ret; ! 16: ! 17: asm volatile ("move $pid,%0" : "=r" (old_tp)); ! 18: old_tp &= ~0xff; ! 19: ! 20: ret = syscall (SYS_set_thread_area, 0xf0); ! 21: if (ret != -1 || errno != EINVAL) { ! 22: syscall (SYS_set_thread_area, old_tp); ! 23: perror ("Invalid thread area accepted:"); ! 24: abort(); ! 25: } ! 26: ! 27: ret = syscall (SYS_set_thread_area, 0xeddeed00); ! 28: if (ret != 0) { ! 29: perror ("Valid thread area not accepted: "); ! 30: abort (); ! 31: } ! 32: ! 33: asm volatile ("move $pid,%0" : "=r" (tp)); ! 34: tp &= ~0xff; ! 35: syscall (SYS_set_thread_area, old_tp); ! 36: ! 37: if (tp != 0xeddeed00) { ! 38: * (volatile int *) 0 = 0; ! 39: perror ("tls2"); ! 40: abort (); ! 41: } ! 42: ! 43: printf ("pass\n"); ! 44: return EXIT_SUCCESS; ! 45: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.