mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-14 17:18:09 +00:00
Trap SIGBUS to handle truncated shared memory segments
If a client passes a section of memory via file descriptor and then subsequently truncates that file, the underlying pages will be freed and the addresses invalidated. Subsequent accesses to the page will fail with a SIGBUS error. Trap that SIGBUS, figure out which segment was causing the error and then allocate new pages to fill in for that region. Mark the offending shared segment as invalid and free the resource ID so that the client will be able to tell when subsequently attempting to use the segment. Signed-off-by: Keith Packard <keithp@keithp.com> v2: Use MAP_FIXED to simplify the recovery logic (Mark Kettenis) v3: Also catch errors in ShmCreateSegment Conflicts: include/dix-config.h.in include/xorg-config.h.in
This commit is contained in:
@@ -62,6 +62,10 @@ typedef struct _ShmFuncs {
|
||||
#define SHM_FD_PASSING 1
|
||||
#endif
|
||||
|
||||
#ifdef SHM_FD_PASSING
|
||||
#include "busfault.h"
|
||||
#endif
|
||||
|
||||
typedef struct _ShmDesc {
|
||||
struct _ShmDesc *next;
|
||||
int shmid;
|
||||
@@ -71,6 +75,7 @@ typedef struct _ShmDesc {
|
||||
unsigned long size;
|
||||
#ifdef SHM_FD_PASSING
|
||||
Bool is_fd;
|
||||
struct busfault *busfault;
|
||||
XID resource;
|
||||
#endif
|
||||
} ShmDescRec, *ShmDescPtr;
|
||||
|
||||
Reference in New Issue
Block a user