drm security
play

DRM Security David Herrmann <dh.herrmann@gmail.com> DRM - PowerPoint PPT Presentation

DRM Security David Herrmann <dh.herrmann@gmail.com> DRM rendering mode-setting open(/dev/dri/card0, ...) (Dumb) Buffer Allocation ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &creq) mreq.handle = creq.handle; ioctl(fd,


  1. DRM Security David Herrmann <dh.herrmann@gmail.com>

  2. DRM rendering mode-setting

  3. open(“/dev/dri/card0”, ...)

  4. (Dumb) Buffer Allocation ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &creq) mreq.handle = creq.handle; ioctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &mreq) mmap(fd, size, …, MAP_SHARED, …, mreq.offset)

  5. mmap-offsets are globally accessible

  6. for (i = 0; i < 0xffffffff; ++i) { void *p = mmap(fd, …, i); if (p != MAP_FAILED) break; }

  7. for (i = 0; i < 0xffffffff; ++i) { D void *p = mmap(fd, …, i); E X I F if (p != MAP_FAILED) break; }

  8. ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &creq) mreq.handle = creq.handle; ioctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &mreq) mmap(fd, size, …, MAP_SHARED, …, mreq.offset)

  9. Buffer Passing lreq.handle = mreq.handle; ioctl(fd, DRM_IOCTL_GEM_FLINK , &lreq); send(somewhere, lreq.name, sizeof(lreq.name)); recv(somewhere, &oreq.name, sizeof(oreq.name)); ioctl(fd, DRM_IOCTL_GEM_OPEN , &oreq);

  10. for (i = 1; i < 0xffffffff; ++i) { req.name = i; r = ioctl(fd, DRM_IOCTL_GEM_OPEN, &req); if (!r) break; }

  11. D for (i = 1; i < 0xffffffff; ++i) { E T A req.name = i; C E R r = ioctl(fd, DRM_IOCTL_GEM_OPEN, &req); P E if (!r) D break; }

  12. dma-buf

  13. req.handle = mreq.handle; ioctl(fd, DRM_IOCTL_PRIME_HANDLE_TO_FD , &req); send_unix_fd(somewhere, req.fd); recv_unix_fd(somewhere, &req.fd); ioctl(fd, DRM_IOCTL_PRIME_FD_TO_HANDLE , &req);

  14. DRM Authentication open(“/dev/dri/card0”, …);

  15. ioctl(fd, DRM_IOCTL_GET_MAGIC , &magic); send(somewhere, &magic, sizeof(magic)); recv(somewhere, &magic, sizeof(magic)); ioctl(fd, DRM_IOCTL_AUTH_MAGIC , &magic);

  16. ioctl(fd, DRM_IOCTL_GET_MAGIC , &magic); send(somewhere, &magic, sizeof(magic)); E T E L O S B O recv(somewhere, &magic, sizeof(magic)); ioctl(fd, DRM_IOCTL_AUTH_MAGIC , &magic);

  17. Access-Management is done via file-system modes!

  18. There is a reason FD-passing is call SCM_RIGHTS

  19. open(“/dev/dri/renderD128”, …);

  20. Render Nodes ● No GEM_FLINK ● No DRM AUTH/MAGIC ● No Mode-setting ● No global resources ● No legacy DRM API ● No DRM-Master

  21. OpenGL with Render-Nodes fd = open (“/dev/dri/renderD128”, …); dev = gbm_create_device (fd); disp = eglGetDisplay (dev); eglInitialize(disp, major, minor); eglBindAPI(EGL_OPENGL_API); eglChooseConfig(disp, …, &conf); ctx = eglCreateContext (disp, conf, 0, &attrs); eglMakeCurrent (disp, 0, 0, ctx);

  22. surf = gbm_surface_create(dev, … attrs ...); wnd = eglCreateWindowSurface(disp, conf, surf, …); eglMakeCurrent(disp, wnd, wnd, ctx);

  23. DRM Master

  24. ● acquire DRM-Master: – open() or – drmSetMaster() ● drop DRM-Master – close() or – drmDropMaster()

  25. ● acquire DRM-Master: – open() or Y L N – drmSetMaster() O T O O R ● drop DRM-Master – close() or Y L N – drmDropMaster() O T O O R

Recommend


More recommend