dix: remove caching of drawables and graphics contexts. The security checks

simply bypass the cached values so they are unused.
This commit is contained in:
Eamon Walsh 2007-08-14 11:39:26 -04:00 committed by Eamon Walsh
parent 2763056ab5
commit 9a183d7ba5
9 changed files with 10 additions and 103 deletions

View File

@ -235,7 +235,7 @@ MultibufferExtensionInit()
* create the resource types * create the resource types
*/ */
MultibufferDrawableResType = MultibufferDrawableResType =
CreateNewResourceType(MultibufferDrawableDelete)|RC_CACHED|RC_DRAWABLE; CreateNewResourceType(MultibufferDrawableDelete)|RC_DRAWABLE;
MultibufferResType = CreateNewResourceType(MultibufferDelete); MultibufferResType = CreateNewResourceType(MultibufferDelete);
MultibuffersResType = CreateNewResourceType(MultibuffersDelete); MultibuffersResType = CreateNewResourceType(MultibuffersDelete);
OtherClientResType = CreateNewResourceType(OtherClientDelete); OtherClientResType = CreateNewResourceType(OtherClientDelete);

View File

@ -1783,7 +1783,7 @@ DbeExtensionInit(void)
/* Create the resource types. */ /* Create the resource types. */
dbeDrawableResType = dbeDrawableResType =
CreateNewResourceType(DbeDrawableDelete) | RC_CACHED | RC_DRAWABLE; CreateNewResourceType(DbeDrawableDelete) | RC_DRAWABLE;
dbeWindowPrivResType = dbeWindowPrivResType =
CreateNewResourceType(DbeWindowPrivDelete); CreateNewResourceType(DbeWindowPrivDelete);

View File

@ -258,34 +258,6 @@ InitSelections(void)
CurrentSelections = (Selection *)NULL; CurrentSelections = (Selection *)NULL;
NumCurrentSelections = 0; NumCurrentSelections = 0;
} }
void
FlushClientCaches(XID id)
{
int i;
ClientPtr client;
client = clients[CLIENT_ID(id)];
if (client == NullClient)
return ;
for (i=0; i<currentMaxClients; i++)
{
client = clients[i];
if (client != NullClient)
{
if (client->lastDrawableID == id)
{
client->lastDrawableID = WindowTable[0]->drawable.id;
client->lastDrawable = (DrawablePtr)WindowTable[0];
}
else if (client->lastGCID == id)
{
client->lastGCID = INVALID;
client->lastGC = (GCPtr)NULL;
}
}
}
}
#ifdef SMART_SCHEDULE #ifdef SMART_SCHEDULE
#undef SMART_DEBUG #undef SMART_DEBUG
@ -3702,20 +3674,7 @@ void InitClient(ClientPtr client, int i, pointer ospriv)
client->sequence = 0; client->sequence = 0;
client->clientAsMask = ((Mask)i) << CLIENTOFFSET; client->clientAsMask = ((Mask)i) << CLIENTOFFSET;
client->clientGone = FALSE; client->clientGone = FALSE;
if (i) client->closeDownMode = i ? DestroyAll : RetainPermanent;
{
client->closeDownMode = DestroyAll;
client->lastDrawable = (DrawablePtr)WindowTable[0];
client->lastDrawableID = WindowTable[0]->drawable.id;
}
else
{
client->closeDownMode = RetainPermanent;
client->lastDrawable = (DrawablePtr)NULL;
client->lastDrawableID = INVALID;
}
client->lastGC = (GCPtr) NULL;
client->lastGCID = INVALID;
client->numSaved = 0; client->numSaved = 0;
client->saveSet = (SaveSetElt *)NULL; client->saveSet = (SaveSetElt *)NULL;
client->noClientException = Success; client->noClientException = Success;

View File

@ -208,7 +208,6 @@ dixLookupDrawable(DrawablePtr *pDraw, XID id, ClientPtr client,
Mask type, Mask access) Mask type, Mask access)
{ {
DrawablePtr pTmp; DrawablePtr pTmp;
RESTYPE rtype;
int rc; int rc;
*pDraw = NULL; *pDraw = NULL;
@ -217,28 +216,15 @@ dixLookupDrawable(DrawablePtr *pDraw, XID id, ClientPtr client,
if (id == INVALID) if (id == INVALID)
return BadDrawable; return BadDrawable;
if (id == client->lastDrawableID) { rc = dixLookupResource((pointer *)&pTmp, id, RC_DRAWABLE, client, access);
pTmp = client->lastDrawable;
/* an access check is required for cached drawables */ if (rc == BadValue)
rtype = (type & M_WINDOW) ? RT_WINDOW : RT_PIXMAP; return BadDrawable;
rc = XaceHook(XACE_RESOURCE_ACCESS, client, id, rtype, access, pTmp);
if (rc != Success) if (rc != Success)
return rc; return rc;
} else
dixLookupResource((void **)&pTmp, id, RC_DRAWABLE, client, access);
if (!pTmp)
return BadDrawable;
if (!((1 << pTmp->type) & (type ? type : M_DRAWABLE))) if (!((1 << pTmp->type) & (type ? type : M_DRAWABLE)))
return BadMatch; return BadMatch;
if (type & M_DRAWABLE) {
client->lastDrawable = pTmp;
client->lastDrawableID = id;
client->lastGCID = INVALID;
client->lastGC = (GCPtr)NULL;
}
*pDraw = pTmp; *pDraw = pTmp;
return Success; return Success;
} }

View File

@ -585,8 +585,6 @@ FreeResource(XID id, RESTYPE skipDeleteFuncType)
CallResourceStateCallback(ResourceStateFreeing, res); CallResourceStateCallback(ResourceStateFreeing, res);
if (rtype & RC_CACHED)
FlushClientCaches(res->id);
if (rtype != skipDeleteFuncType) if (rtype != skipDeleteFuncType)
(*DeleteFuncs[rtype & TypeMask])(res->value, res->id); (*DeleteFuncs[rtype & TypeMask])(res->value, res->id);
xfree(res); xfree(res);
@ -597,11 +595,6 @@ FreeResource(XID id, RESTYPE skipDeleteFuncType)
else else
prev = &res->next; prev = &res->next;
} }
if(clients[cid] && (id == clients[cid]->lastDrawableID))
{
clients[cid]->lastDrawable = (DrawablePtr)WindowTable[0];
clients[cid]->lastDrawableID = WindowTable[0]->drawable.id;
}
} }
if (!gotOne) if (!gotOne)
ErrorF("Freeing resource id=%lX which isn't there.\n", ErrorF("Freeing resource id=%lX which isn't there.\n",
@ -632,8 +625,6 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree)
CallResourceStateCallback(ResourceStateFreeing, res); CallResourceStateCallback(ResourceStateFreeing, res);
if (type & RC_CACHED)
FlushClientCaches(res->id);
if (!skipFree) if (!skipFree)
(*DeleteFuncs[type & TypeMask])(res->value, res->id); (*DeleteFuncs[type & TypeMask])(res->value, res->id);
xfree(res); xfree(res);
@ -642,11 +633,6 @@ FreeResourceByType(XID id, RESTYPE type, Bool skipFree)
else else
prev = &res->next; prev = &res->next;
} }
if(clients[cid] && (id == clients[cid]->lastDrawableID))
{
clients[cid]->lastDrawable = (DrawablePtr)WindowTable[0];
clients[cid]->lastDrawableID = WindowTable[0]->drawable.id;
}
} }
} }
@ -669,8 +655,6 @@ ChangeResourceValue (XID id, RESTYPE rtype, pointer value)
for (; res; res = res->next) for (; res; res = res->next)
if ((res->id == id) && (res->type == rtype)) if ((res->id == id) && (res->type == rtype))
{ {
if (rtype & RC_CACHED)
FlushClientCaches(res->id);
res->value = value; res->value = value;
return TRUE; return TRUE;
} }
@ -801,8 +785,6 @@ FreeClientNeverRetainResources(ClientPtr client)
CallResourceStateCallback(ResourceStateFreeing, this); CallResourceStateCallback(ResourceStateFreeing, this);
if (rtype & RC_CACHED)
FlushClientCaches(this->id);
(*DeleteFuncs[rtype & TypeMask])(this->value, this->id); (*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
xfree(this); xfree(this);
} }
@ -854,8 +836,6 @@ FreeClientResources(ClientPtr client)
CallResourceStateCallback(ResourceStateFreeing, this); CallResourceStateCallback(ResourceStateFreeing, this);
if (rtype & RC_CACHED)
FlushClientCaches(this->id);
(*DeleteFuncs[rtype & TypeMask])(this->value, this->id); (*DeleteFuncs[rtype & TypeMask])(this->value, this->id);
xfree(this); xfree(this);
} }

View File

@ -431,7 +431,6 @@ winProcSetSelectionOwner (ClientPtr client)
* and we currently own the Win32 clipboard. * and we currently own the Win32 clipboard.
*/ */
if (None == stuff->window if (None == stuff->window
&& g_iClipboardWindow != client->lastDrawableID
&& (None == s_iOwners[CLIP_OWN_PRIMARY] && (None == s_iOwners[CLIP_OWN_PRIMARY]
|| g_iClipboardWindow == s_iOwners[CLIP_OWN_PRIMARY]) || g_iClipboardWindow == s_iOwners[CLIP_OWN_PRIMARY])
&& (None == s_iOwners[CLIP_OWN_CLIPBOARD] && (None == s_iOwners[CLIP_OWN_CLIPBOARD]

View File

@ -82,8 +82,6 @@ SOFTWARE.
} }
#define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, pGC, client)\ #define VALIDATE_DRAWABLE_AND_GC(drawID, pDraw, pGC, client)\
if ((stuff->gc == INVALID) || (client->lastGCID != stuff->gc) ||\
(client->lastDrawableID != drawID))\
{\ {\
int rc;\ int rc;\
rc = dixLookupDrawable(&(pDraw), drawID, client, M_ANY,\ rc = dixLookupDrawable(&(pDraw), drawID, client, M_ANY,\
@ -95,15 +93,6 @@ SOFTWARE.
return rc;\ return rc;\
if ((pGC->depth != pDraw->depth) || (pGC->pScreen != pDraw->pScreen))\ if ((pGC->depth != pDraw->depth) || (pGC->pScreen != pDraw->pScreen))\
return (BadMatch);\ return (BadMatch);\
client->lastDrawable = pDraw;\
client->lastDrawableID = drawID;\
client->lastGC = pGC;\
client->lastGCID = stuff->gc;\
}\
else\
{\
pGC = client->lastGC;\
pDraw = client->lastDrawable;\
}\ }\
if (pGC->serialNumber != pDraw->serialNumber)\ if (pGC->serialNumber != pDraw->serialNumber)\
ValidateGC(pDraw, pGC); ValidateGC(pDraw, pGC);
@ -160,8 +149,6 @@ extern void UpdateCurrentTimeIf(void);
extern void InitSelections(void); extern void InitSelections(void);
extern void FlushClientCaches(XID /*id*/);
extern int dixDestroyPixmap( extern int dixDestroyPixmap(
pointer /*value*/, pointer /*value*/,
XID /*pid*/); XID /*pid*/);

View File

@ -101,10 +101,6 @@ typedef struct _Client {
int clientGone; int clientGone;
int noClientException; /* this client died or needs to be int noClientException; /* this client died or needs to be
* killed */ * killed */
DrawablePtr lastDrawable;
Drawable lastDrawableID;
GCPtr lastGC;
GContext lastGCID;
SaveSetElt *saveSet; SaveSetElt *saveSet;
int numSaved; int numSaved;
pointer screenPrivate[MAXSCREENS]; pointer screenPrivate[MAXSCREENS];

View File

@ -72,9 +72,9 @@ typedef unsigned long RESTYPE;
/* types for Resource routines */ /* types for Resource routines */
#define RT_WINDOW ((RESTYPE)1|RC_CACHED|RC_DRAWABLE) #define RT_WINDOW ((RESTYPE)1|RC_DRAWABLE)
#define RT_PIXMAP ((RESTYPE)2|RC_CACHED|RC_DRAWABLE) #define RT_PIXMAP ((RESTYPE)2|RC_DRAWABLE)
#define RT_GC ((RESTYPE)3|RC_CACHED) #define RT_GC ((RESTYPE)3)
#undef RT_FONT #undef RT_FONT
#undef RT_CURSOR #undef RT_CURSOR
#define RT_FONT ((RESTYPE)4) #define RT_FONT ((RESTYPE)4)