Created
May 31, 2013 01:10
-
-
Save ytoshima/5682393 to your computer and use it in GitHub Desktop.
A simple program to verify si_code=128 behaviour .
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Simple test program to verify si_code=SI_KERNEL(128) for address | |
* above TASK_SIZE64 or TASK_SIZE_MAX (0x800000000000 - 4096 = 0x7ffffffff000) | |
* See do_page_fault(k). | |
*/ | |
#include <stdio.h> | |
#include <sys/types.h> | |
#include <signal.h> | |
#include <string.h> | |
#include <unistd.h> | |
void action(int signo, siginfo_t *info, void *vc) | |
{ | |
printf("action sig=%d info {errno %d code %d addr %#lx} vc %#lx\n", | |
signo, | |
info->si_errno, info->si_code, info->si_addr, | |
vc); | |
exit(1); | |
} | |
void setupHandler() | |
{ | |
int r; | |
struct sigaction act; | |
memset(&act, 0, sizeof(act)); | |
act.sa_sigaction = action; | |
act.sa_flags = SA_SIGINFO; | |
r = sigaction(SIGSEGV, &act, NULL); | |
} | |
int accessMem(long addr) | |
{ | |
char *cp = (char*)addr; | |
return *cp; | |
} | |
int main(int argc, char *argv[]) | |
{ | |
int r = -1; | |
long l; | |
/* l = 0x12345678aabbccddL; */ | |
l = 0x7fffffffff002; | |
/* long l = 0xaabbccddL; */ | |
setupHandler(); | |
r = accessMem(l); | |
return r; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment