Last active
September 26, 2016 12:40
-
-
Save digetx/7551a25761cac1268f7e35e123b2d125 to your computer and use it in GitHub Desktop.
BUG: Bad page state in process
This file contains 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
/* | |
* gcc bug.c -I/usr/include/libdrm -ldrm | |
* | |
*/ | |
#include <assert.h> | |
#include <errno.h> | |
#include <fcntl.h> | |
#include <stdio.h> | |
#include <sys/mman.h> | |
#include <xf86drm.h> | |
#include <libdrm/tegra_drm.h> | |
void main(void) | |
{ | |
struct drm_tegra_gem_create cargs = { .size = 4096 }; | |
struct drm_tegra_gem_mmap margs = {}; | |
int err, fd; | |
void *map; | |
fd = open("/dev/dri/card0", O_RDWR, 0); | |
assert(fd >= 0); | |
err = drmCommandWriteRead(fd, DRM_TEGRA_GEM_CREATE, &cargs, sizeof(cargs)); | |
assert(err == 0); | |
margs.handle = cargs.handle; | |
err = drmCommandWriteRead(fd, DRM_TEGRA_GEM_MMAP, &margs, sizeof(margs)); | |
assert(err == 0); | |
map = mmap(0, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, margs.offset); | |
assert(errno == 0); | |
sprintf(map, "crash it"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment