Compare commits

..

1 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult d93c87f71a miext: damage: protect against NULL screen priv or funcs
Protect against SEGFAULT in cases where per-screen damage private
hasn't been initialized yet or already destroyed, or function pointers
not implemented.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-07-02 11:20:53 +02:00
45 changed files with 98 additions and 156 deletions

View File

@ -58,13 +58,13 @@ if build_xv
hdrs_xext += ['xvdix.h', 'xvmcext.h']
endif
libxserver_xext = static_library('xserver_xext',
libxserver_xext = static_library('libxserver_xext',
srcs_xext,
include_directories: inc,
dependencies: common_dep,
)
libxserver_xext_vidmode = static_library('xserver_xext_vidmode',
libxserver_xext_vidmode = static_library('libxserver_xext_vidmode',
'vidmode.c',
include_directories: inc,
dependencies: common_dep,

View File

@ -11,6 +11,14 @@
#include "namespace.h"
#include "hooks.h"
static inline Bool winIsRoot(WindowPtr pWin) {
if (!pWin)
return FALSE;
if (pWin->drawable.pScreen->root == pWin)
return TRUE;
return FALSE;
}
void hookWindowProperty(CallbackListPtr *pcbl, void *unused, void *calldata)
{
XNS_HOOK_HEAD(PropertyFilterParam);

View File

@ -1,5 +1,5 @@
libxserver_namespace = static_library(
'xserver_namespace',
'libxserver_namespace',
[
'config.c',
'hook-client.c',

View File

@ -53,14 +53,14 @@ srcs_xi = [
'xiwarppointer.c',
]
libxserver_xi = static_library('xserver_xi',
libxserver_xi = static_library('libxserver_xi',
srcs_xi,
include_directories: inc,
dependencies: common_dep,
)
srcs_xi_stubs = ['stubs.c']
libxserver_xi_stubs = static_library('xserver_xi_stubs',
libxserver_xi_stubs = static_library('libxserver_xi_stubs',
srcs_xi_stubs,
include_directories: inc,
dependencies: common_dep,

View File

@ -10,7 +10,7 @@ hdrs_composite = [
'compositeext.h',
]
libxserver_composite = static_library('xserver_composite',
libxserver_composite = static_library('libxserver_composite',
srcs_composite,
include_directories: inc,
dependencies: common_dep,

View File

@ -28,7 +28,7 @@ if build_xorg
install_dir: join_paths(get_option('datadir'), 'X11/xorg.conf.d'))
endif
libxserver_config = static_library('xserver_config',
libxserver_config = static_library('libxserver_config',
srcs_config,
include_directories: inc,
dependencies: config_dep,

View File

@ -2,7 +2,7 @@ srcs_damageext = [
'damageext.c',
]
libxserver_damageext = static_library('xserver_damageext',
libxserver_damageext = static_library('libxserver_damageext',
srcs_damageext,
include_directories: inc,
dependencies: common_dep,

View File

@ -3,7 +3,7 @@ srcs_dbe = [
'midbe.c',
]
libxserver_dbe = static_library('xserver_dbe',
libxserver_dbe = static_library('libxserver_dbe',
srcs_dbe,
include_directories: inc,
dependencies: common_dep,

View File

@ -57,13 +57,13 @@ endif
dtrace_dep = declare_dependency(sources: [dtrace_src, dtrace_hdr])
libxserver_dix = static_library('xserver_dix',
libxserver_dix = static_library('libxserver_dix',
[ srcs_dix, builtinatoms_src ],
include_directories: inc,
dependencies: [ dtrace_dep, common_dep, ]
)
libxserver_main = static_library('xserver_main',
libxserver_main = static_library('libxserver_main',
'stubmain.c',
include_directories: inc,
dependencies: common_dep,

View File

@ -23,7 +23,6 @@ void dixFreeScreen(ScreenPtr pScreen)
DeleteCallbackList(&pScreen->hookWindowDestroy);
DeleteCallbackList(&pScreen->hookWindowPosition);
DeleteCallbackList(&pScreen->hookClose);
DeleteCallbackList(&pScreen->hookPostClose);
DeleteCallbackList(&pScreen->hookPixmapDestroy);
free(pScreen);
}

View File

@ -28,7 +28,6 @@
DECLARE_HOOK_PROC(WindowDestroy, hookWindowDestroy, XorgScreenWindowDestroyProcPtr);
DECLARE_HOOK_PROC(WindowPosition, hookWindowPosition, XorgScreenWindowPositionProcPtr);
DECLARE_HOOK_PROC(Close, hookClose, XorgScreenCloseProcPtr);
DECLARE_HOOK_PROC(PostClose, hookPostClose, XorgScreenCloseProcPtr);
DECLARE_HOOK_PROC(PixmapDestroy, hookPixmapDestroy, XorgScreenPixmapDestroyProcPtr);
DECLARE_HOOK_PROC(PostCreateResources, hookPostCreateResources,
XorgScreenPostCreateResourcesProcPtr);
@ -72,8 +71,6 @@ void dixScreenRaiseClose(ScreenPtr pScreen) {
if (pScreen->CloseScreen)
pScreen->CloseScreen(pScreen);
CallCallbacks(&pScreen->hookPostClose, NULL);
}
void dixScreenRaisePixmapDestroy(PixmapPtr pPixmap)

View File

@ -147,37 +147,6 @@ _X_EXPORT
void dixScreenUnhookClose(ScreenPtr pScreen,
XorgScreenCloseProcPtr func);
/**
* @brief register a screen post close notify hook on the given screen
*
* @param pScreen pointer to the screen to register the notify hook into
* @param func pointer to the hook function
*
* In contrast to Close hook, it's called *after* the driver's CloseScreen()
* proc had been called.
*
* When registration fails, the server aborts.
**/
void dixScreenHookPostClose(ScreenPtr pScreen,
XorgScreenCloseProcPtr func);
/**
* @brief unregister a screen close notify hook on the given screen
*
* @param pScreen pointer to the screen to unregister the hook from
* @param func pointer to the hook function
* @param arg opaque pointer passed to the destructor
*
* @see dixScreenHookPostClose
*
* Unregister a screen close notify hook registered via @ref dixScreenHookPostClose
*
* In contrast to Close hook, it's called *after* the driver's CloseScreen()
* proc had been called.
**/
void dixScreenUnhookPostClose(ScreenPtr pScreen,
XorgScreenCloseProcPtr func);
/* prototype of pixmap destroy notification handler */
typedef void (*XorgScreenPixmapDestroyProcPtr)(CallbackListPtr *pcbl,
ScreenPtr pScreen,

View File

@ -10,7 +10,7 @@ hdrs_dri3 = [
libxserver_dri3 = []
if build_dri3
libxserver_dri3 = static_library('xserver_dri3',
libxserver_dri3 = static_library('libxserver_dri3',
srcs_dri3,
include_directories: inc,
dependencies: [ common_dep, libdrm_dep ],

View File

@ -12,7 +12,7 @@ srcs_exa = [
'exa_unaccel.c',
]
libxserver_exa = static_library('xserver_exa',
libxserver_exa = static_library('libxserver_exa',
srcs_exa,
include_directories: inc,
dependencies: common_dep,

View File

@ -37,7 +37,7 @@ hdrs_fb = [
'wfbrename.h'
]
libxserver_fb = static_library('xserver_fb',
libxserver_fb = static_library('libxserver_fb',
srcs_fb,
include_directories: inc,
dependencies: common_dep,
@ -46,7 +46,7 @@ libxserver_fb = static_library('xserver_fb',
wfb_args = '-DFB_ACCESS_WRAPPER'
libxserver_wfb = static_library('xserver_wfb',
libxserver_wfb = static_library('libxserver_wfb',
srcs_fb,
c_args: wfb_args,
include_directories: inc,

View File

@ -128,10 +128,13 @@ __glXSendReply(ClientPtr client, const void *data, size_t elements,
.retval = retval,
};
/* Single element goes in reply padding; don't leak uninitialized data. */
if (elements == 1) {
(void) memcpy(&reply.pad3, data, element_size);
}
/* It is faster on almost always every architecture to just copy the 8
* bytes, even when not necessary, than check to see of the value of
* elements requires it. Copying the data when not needed will do no
* harm.
*/
(void) memcpy(&reply.pad3, data, 8);
WriteToClient(client, sizeof(xGLXSingleReply), &reply);
if (reply_ints != 0) {
@ -173,10 +176,13 @@ __glXSendReplySwap(ClientPtr client, const void *data, size_t elements,
.retval = bswap_32(retval),
};
/* Single element goes in reply padding; don't leak uninitialized data. */
if (elements == 1) {
(void) memcpy(&reply.pad3, data, element_size);
}
/* It is faster on almost always every architecture to just copy the 8
* bytes, even when not necessary, than check to see of the value of
* elements requires it. Copying the data when not needed will do no
* harm.
*/
(void) memcpy(&reply.pad3, data, 8);
WriteToClient(client, sizeof(xGLXSingleReply), &reply);
if (reply_ints != 0) {

View File

@ -32,7 +32,7 @@ srcs_glx = [
libxserver_glx = []
if build_glx
libxserver_glx = static_library('xserver_glx',
libxserver_glx = static_library('libxserver_glx',
srcs_glx,
include_directories: inc,
dependencies: [
@ -68,7 +68,7 @@ hdrs_vnd = [
libglxvnd = []
if build_glx
libglxvnd = static_library('glxvnd',
libglxvnd = static_library('libglxvnd',
srcs_vnd,
include_directories: inc,
dependencies: [

View File

@ -105,7 +105,7 @@ __glGetMap_size(GLenum target, GLenum query)
}
break;
}
return 0;
return -1;
}
GLint
@ -164,7 +164,7 @@ __glGetPixelMap_size(GLenum map)
query = GL_PIXEL_MAP_A_TO_A_SIZE;
break;
default:
return 0;
return -1;
}
glGetIntegerv(query, &size);
return size;

View File

@ -370,23 +370,6 @@ ddxProcessArgument(int argc, char **argv, int i)
return KdProcessArgument(argc, argv, i);
}
static int
EphyrInit(void)
{
/*
* make sure at least one screen
* has been added to the system.
*/
if (!KdCardInfoLast()) {
processScreenArg("640x480", NULL);
}
return hostx_init();
}
KdOsFuncs EphyrOsFuncs = {
.Init = EphyrInit,
};
void
OsVendorInit(void)
{
@ -398,7 +381,12 @@ OsVendorInit(void)
if (hostx_want_host_cursor())
ephyrFuncs.initCursor = &ephyrCursorInit;
KdOsInit(&EphyrOsFuncs);
if (serverGeneration == 1) {
if (!KdCardInfoLast()) {
processScreenArg("640x480", NULL);
}
hostx_init();
}
}
KdCardFuncs ephyrFuncs = {

View File

@ -91,14 +91,6 @@ const char *kdGlobalXkbLayout = NULL;
const char *kdGlobalXkbVariant = NULL;
const char *kdGlobalXkbOptions = NULL;
/*
* Carry arguments from InitOutput through driver initialization
* to KdScreenInit
*/
KdOsFuncs *kdOsFuncs = NULL;
void
KdDisableScreen(ScreenPtr pScreen)
{
@ -525,19 +517,6 @@ KdProcessArgument(int argc, char **argv, int i)
return 0;
}
void
KdOsInit(KdOsFuncs * pOsFuncs)
{
kdOsFuncs = pOsFuncs;
if (pOsFuncs) {
if (serverGeneration == 1) {
KdDoSwitchCmd("start");
if (pOsFuncs->Init)
(*pOsFuncs->Init) ();
}
}
}
static Bool
KdAllocatePrivates(ScreenPtr pScreen)
{

View File

@ -278,16 +278,6 @@ int KdAddConfigKeyboard(char *pointer);
int KdAddKeyboard(KdKeyboardInfo * ki);
void KdRemoveKeyboard(KdKeyboardInfo * ki);
typedef struct _KdOsFuncs {
int (*Init) (void); /* Only called when the X server is started, when serverGeneration == 1 */
void (*Enable) (void);
Bool (*SpecialKey) (KeySym);
void (*Disable) (void);
void (*Fini) (void);
void (*pollEvents) (void);
void (*Bell) (int, int, int);
} KdOsFuncs;
typedef struct _KdPointerMatrix {
int matrix[2][3];
} KdPointerMatrix;
@ -299,8 +289,6 @@ extern DevPrivateKeyRec kdScreenPrivateKeyRec;
extern Bool kdEmulateMiddleButton;
extern Bool kdDisableZaphod;
extern KdOsFuncs *kdOsFuncs;
#define KdGetScreenPriv(pScreen) ((KdPrivScreenPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey))
#define KdSetScreenPriv(pScreen,v) \
@ -357,9 +345,6 @@ void
int
KdProcessArgument(int argc, char **argv, int i);
void
KdOsInit(KdOsFuncs * pOsFuncs);
void
KdOsAddInputDrivers(void);

View File

@ -259,6 +259,13 @@ ddxGiveUp(enum ExitCode error)
}
}
#ifdef __APPLE__
void
DarwinHandleGUI(int argc, char *argv[])
{
}
#endif
void
OsVendorInit(void)
{

View File

@ -39,12 +39,7 @@ _X_EXPORT void xf86MsgVerb(MessageType type, int verb, const char *format, ...)
void
xf86MsgVerb(MessageType type, int verb, const char *format, ...)
{
static char reportxf86MsgVerb = 1;
if (reportxf86MsgVerb) {
xf86NVidiaBugInternalFunc("xf86MsgVerb()");
reportxf86MsgVerb = 0;
}
xf86NVidiaBugInternalFunc("xf86MsgVerb()");
va_list ap;
va_start(ap, format);

View File

@ -154,6 +154,13 @@ ddxGiveUp(enum ExitCode error)
xnestCloseDisplay();
}
#ifdef __APPLE__
void
DarwinHandleGUI(int argc, char *argv[])
{
}
#endif
void
OsVendorInit(void)
{

View File

@ -690,6 +690,7 @@ SNotifyEvent(xAppleWMNotifyEvent *from, xAppleWMNotifyEvent *to)
static int
SProcAppleWMQueryVersion(register ClientPtr client)
{
REQUEST(xAppleWMQueryVersionReq);
return ProcAppleWMQueryVersion(client);
}

View File

@ -50,7 +50,7 @@
* needs and simply execs the startup script which then execs the main binary.
*/
static char *executable_path(void) {
static char *executable_path() {
uint32_t bufsize = PATH_MAX;
char *buf = calloc(1, bufsize);

View File

@ -394,6 +394,7 @@ SNotifyEvent(xAppleDRINotifyEvent *from,
static int
SProcAppleDRIQueryVersion(register ClientPtr client)
{
REQUEST(xAppleDRIQueryVersionReq);
return ProcAppleDRIQueryVersion(client);
}

View File

@ -696,10 +696,6 @@ typedef struct _Screen {
CallbackListPtr hookPostCreateResources;
SetWindowVRRModeProcPtr SetWindowVRRMode;
/* additional screen post-close notify hooks (replaces wrapping CloseScreen)
should NOT be touched outside of DIX core */
CallbackListPtr hookPostClose;
} ScreenRec;
static inline RegionPtr

View File

@ -3,10 +3,10 @@ project('xserver', 'c',
'buildtype=debugoptimized',
'c_std=gnu99',
],
version: '25.0.0.4',
version: '25.0.0.2',
meson_version: '>= 0.58.0',
)
release_date = '2025-07-04'
release_date = '2025-06-30'
add_project_arguments('-DHAVE_DIX_CONFIG_H', language: ['c', 'objc'])
cc = meson.get_compiler('c')
@ -777,8 +777,7 @@ endif
subdir('hw')
build_tests = get_option('tests') and host_machine.system() != 'windows'
if build_tests
if host_machine.system() != 'windows'
subdir('test')
endif

View File

@ -110,8 +110,6 @@ option('sha1', type: 'combo', choices: ['libc', 'CommonCrypto', 'CryptoAPI', 'li
description: 'SHA1 implementation')
option('xf86-input-inputtest', type: 'boolean', value: true,
description: 'Test input driver support on Xorg')
option('tests', type: 'boolean', value: true,
description: 'Build tests for the X server on platforms that support it')
option('dri1', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', description: 'Build DRI1 extension (default: auto)')
option('dri2', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto', description: 'Build DRI2 extension (default: auto)')

View File

@ -40,7 +40,7 @@ hdrs_mi = [
'mizerarc.h',
]
libxserver_mi = static_library('xserver_mi',
libxserver_mi = static_library('libxserver_mi',
srcs_mi,
include_directories: inc,
dependencies: [

View File

@ -141,7 +141,7 @@ miPointerInitialize(ScreenPtr pScreen,
pScreenPriv->screenFuncs = screenFuncs;
pScreenPriv->waitForUpdate = waitForUpdate;
pScreenPriv->showTransparent = FALSE;
dixScreenHookPostClose(pScreen, miPointerCloseScreen);
dixScreenHookClose(pScreen, miPointerCloseScreen);
dixSetPrivate(&pScreen->devPrivates, miPointerScreenKey, pScreenPriv);
/*
* set up screen cursor method table
@ -169,7 +169,7 @@ static void miPointerCloseScreen(CallbackListPtr *pcbl, ScreenPtr pScreen, void
{
SetupScreen(pScreen);
dixScreenUnhookPostClose(pScreen, miPointerCloseScreen);
dixScreenUnhookClose(pScreen, miPointerCloseScreen);
free((void *) pScreenPriv);
dixSetPrivate(&pScreen->devPrivates, miPointerScreenKey, NULL);
FreeEventList(mipointermove_events, GetMaximumEventsNum());

View File

@ -1569,7 +1569,7 @@ damageWindowDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, WindowPtr pWindow)
static void damageCloseScreen(CallbackListPtr *pcbl, ScreenPtr pScreen, void *unused)
{
dixScreenUnhookPostClose(pScreen, damageCloseScreen);
dixScreenUnhookClose(pScreen, damageCloseScreen);
dixScreenUnhookWindowDestroy(pScreen, damageWindowDestroy);
dixScreenUnhookPixmapDestroy(pScreen, damagePixmapDestroy);
@ -1667,7 +1667,7 @@ DamageSetup(ScreenPtr pScreen)
pScrPriv->internalLevel = 0;
pScrPriv->pScreenDamage = 0;
dixScreenHookPostClose(pScreen, damageCloseScreen);
dixScreenHookClose(pScreen, damageCloseScreen);
dixScreenHookWindowDestroy(pScreen, damageWindowDestroy);
dixScreenHookPixmapDestroy(pScreen, damagePixmapDestroy);
@ -1714,7 +1714,8 @@ DamageCreate(DamageReportFunc damageReport,
pDamage->damageDestroy = damageDestroy;
pDamage->pScreen = pScreen;
(*pScrPriv->funcs.Create) (pDamage);
if (pScrPriv && pScrPriv->funcs.Create)
pScrPriv->funcs.Create(pDamage);
return pDamage;
}
@ -1755,7 +1756,8 @@ DamageRegister(DrawablePtr pDrawable, DamagePtr pDamage)
pDamage->isWindow = FALSE;
pDamage->pDrawable = pDrawable;
damageInsertDamage(getDrawableDamageRef(pDrawable), pDamage);
(*pScrPriv->funcs.Register) (pDrawable, pDamage);
if (pScrPriv && pScrPriv->funcs.Register)
pScrPriv->funcs.Register(pDrawable, pDamage);
}
void
@ -1774,7 +1776,10 @@ DamageUnregister(DamagePtr pDamage)
damageScrPriv(pScreen);
(*pScrPriv->funcs.Unregister) (pDrawable, pDamage);
if (pScrPriv && pScrPriv->funcs.Unregister)
pScrPriv->funcs.Unregister(pDrawable, pDamage);
else
miDamageUnregister(pDrawable, pDamage);
if (pDrawable->type == DRAWABLE_WINDOW) {
WindowPtr pWindow = (WindowPtr) pDrawable;
@ -1817,7 +1822,9 @@ DamageDestroy(DamagePtr pDamage)
if (pDamage->damageDestroy)
(*pDamage->damageDestroy) (pDamage, pDamage->closure);
(*pScrPriv->funcs.Destroy) (pDamage);
if (pScrPriv && pScrPriv->funcs.Destroy)
pScrPriv->funcs.Destroy(pDamage);
RegionUninit(&pDamage->damage);
RegionUninit(&pDamage->pendingDamage);
free(pDamage);

View File

@ -7,7 +7,7 @@ hdrs_miext_damage = [
'damagestr.h',
]
libxserver_miext_damage = static_library('xserver_miext_damage',
libxserver_miext_damage = static_library('libxserver_miext_damage',
srcs_miext_damage,
include_directories: inc,
dependencies: common_dep,

View File

@ -6,7 +6,7 @@ srcs_miext_rootless = [
'rootlessWindow.c',
]
libxserver_miext_rootless = static_library('xserver_miext_rootless',
libxserver_miext_rootless = static_library('libxserver_miext_rootless',
srcs_miext_rootless,
include_directories: inc,
dependencies: common_dep,

View File

@ -29,7 +29,7 @@ hdrs_miext_shadow = [
'shadow.h',
]
libxserver_miext_shadow = static_library('xserver_miext_shadow',
libxserver_miext_shadow = static_library('libxserver_miext_shadow',
srcs_miext_shadow,
include_directories: inc,
dependencies: common_dep,

View File

@ -14,7 +14,7 @@ if build_dri3
srcs_miext_sync += 'misyncshm.c'
endif
libxserver_miext_sync = static_library('xserver_miext_sync',
libxserver_miext_sync = static_library('libxserver_miext_sync',
srcs_miext_sync,
include_directories: inc,
dependencies: [

View File

@ -79,7 +79,7 @@ endif
libxlibc = []
if srcs_libc.length() > 0
libxlibc = static_library('xlibc',
libxlibc = static_library('libxlibc',
srcs_libc,
include_directories: inc,
dependencies: [
@ -92,7 +92,7 @@ if enable_input_thread
os_dep += cc.find_library('pthread')
endif
libxserver_os = static_library('xserver_os',
libxserver_os = static_library('libxserver_os',
srcs_os,
include_directories: inc,
dependencies: [

View File

@ -15,7 +15,7 @@ hdrs_present = [
'present.h',
]
libxserver_present = static_library('xserver_present',
libxserver_present = static_library('libxserver_present',
srcs_present,
include_directories: inc,
dependencies: [

View File

@ -1,4 +1,4 @@
libxserver_pseudoramix = static_library('xserver_pseudoramiX',
libxserver_pseudoramix = static_library('libxserver_pseudoramiX',
'pseudoramiX.c',
include_directories: inc,
dependencies: common_dep,

View File

@ -25,7 +25,7 @@ if build_xinerama
srcs_randr += 'rrxinerama.c'
endif
libxserver_randr = static_library('xserver_randr',
libxserver_randr = static_library('libxserver_randr',
srcs_randr,
include_directories: inc,
dependencies: common_dep,

View File

@ -3,7 +3,7 @@ srcs_record = [
'set.c',
]
libxserver_record = static_library('xserver_record',
libxserver_record = static_library('libxserver_record',
srcs_record,
include_directories: inc,
dependencies: common_dep,

View File

@ -19,7 +19,7 @@ hdrs_render = [
'picturestr.h',
]
libxserver_render = static_library('xserver_render',
libxserver_render = static_library('libxserver_render',
srcs_render,
include_directories: inc,
dependencies: common_dep,

View File

@ -7,7 +7,7 @@ srcs_xfixes = [
'xfixes.c',
]
libxserver_xfixes = static_library('xserver_xfixes',
libxserver_xfixes = static_library('libxserver_xfixes',
srcs_xfixes,
include_directories: inc,
dependencies: common_dep,

View File

@ -23,7 +23,7 @@ srcs_xkb = [
'XKBMAlloc.c',
]
libxserver_xkb = static_library('xserver_xkb',
libxserver_xkb = static_library('libxserver_xkb',
srcs_xkb,
include_directories: inc,
dependencies: common_dep,
@ -35,7 +35,7 @@ srcs_xkb_stubs = [
'ddxVT.c',
]
libxserver_xkb_stubs = static_library('xserver_xkb_stubs',
libxserver_xkb_stubs = static_library('libxserver_xkb_stubs',
srcs_xkb_stubs,
include_directories: inc,
dependencies: common_dep,