Commit cdf0c3e6 authored by Adam Jackson's avatar Adam Jackson Committed by Mike Gabriel

glx: Be more strict about rejecting invalid image sizes [CVE-2014-8093 2/6]

Before this we'd just clamp the image size to 0, which was just hideously stupid; if the parameters were such that they'd overflow an integer, you'd allocate a small buffer, then pass huge values into (say) ReadPixels, and now you're scribbling over arbitrary server memory. v2: backport to nx-libs 3.6.x (Mike DePaulo) Reviewed-by: 's avatarKeith Packard <keithp@keithp.com> Reviewed-by: 's avatarJulien Cristau <jcristau@debian.org> Reviewed-by: 's avatarMichal Srb <msrb@suse.com> Reviewed-by: 's avatarAndy Ritger <aritger@nvidia.com> Signed-off-by: 's avatarAdam Jackson <ajax@redhat.com> Signed-off-by: 's avatarAlan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: 's avatarFedora X Ninjas <x@fedoraproject.org> Signed-off-by: 's avatarDave Airlie <airlied@redhat.com>
parent 5c43bb24
...@@ -70,7 +70,7 @@ int __glXDisp_ReadPixels(__GLXclientState *cl, GLbyte *pc) ...@@ -70,7 +70,7 @@ int __glXDisp_ReadPixels(__GLXclientState *cl, GLbyte *pc)
swapBytes = *(GLboolean *)(pc + 24); swapBytes = *(GLboolean *)(pc + 24);
lsbFirst = *(GLboolean *)(pc + 25); lsbFirst = *(GLboolean *)(pc + 25);
compsize = __glReadPixels_size(format,type,width,height); compsize = __glReadPixels_size(format,type,width,height);
if (compsize < 0) compsize = 0; if (compsize < 0) return BadLength;
glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes); glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
glPixelStorei(GL_PACK_LSB_FIRST, lsbFirst); glPixelStorei(GL_PACK_LSB_FIRST, lsbFirst);
...@@ -130,7 +130,7 @@ int __glXDisp_GetTexImage(__GLXclientState *cl, GLbyte *pc) ...@@ -130,7 +130,7 @@ int __glXDisp_GetTexImage(__GLXclientState *cl, GLbyte *pc)
* are illegal, but then width, height, and depth would still be zero anyway. * are illegal, but then width, height, and depth would still be zero anyway.
*/ */
compsize = __glGetTexImage_size(target,level,format,type,width,height,depth); compsize = __glGetTexImage_size(target,level,format,type,width,height,depth);
if (compsize < 0) compsize = 0; if (compsize < 0) return BadLength;
glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes); glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
__GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
...@@ -227,7 +227,7 @@ int __glXDisp_GetSeparableFilter(__GLXclientState *cl, GLbyte *pc) ...@@ -227,7 +227,7 @@ int __glXDisp_GetSeparableFilter(__GLXclientState *cl, GLbyte *pc)
compsize = __glGetTexImage_size(target,1,format,type,width,1,1); compsize = __glGetTexImage_size(target,1,format,type,width,1,1);
compsize2 = __glGetTexImage_size(target,1,format,type,height,1,1); compsize2 = __glGetTexImage_size(target,1,format,type,height,1,1);
if (compsize < 0) compsize = 0; if (compsize < 0) return BadLength;
if (compsize2 < 0) compsize2 = 0; if (compsize2 < 0) compsize2 = 0;
compsize = __GLX_PAD(compsize); compsize = __GLX_PAD(compsize);
compsize2 = __GLX_PAD(compsize2); compsize2 = __GLX_PAD(compsize2);
...@@ -291,7 +291,7 @@ int __glXDisp_GetConvolutionFilter(__GLXclientState *cl, GLbyte *pc) ...@@ -291,7 +291,7 @@ int __glXDisp_GetConvolutionFilter(__GLXclientState *cl, GLbyte *pc)
* are illegal, but then width and height would still be zero anyway. * are illegal, but then width and height would still be zero anyway.
*/ */
compsize = __glGetTexImage_size(target,1,format,type,width,height,1); compsize = __glGetTexImage_size(target,1,format,type,width,height,1);
if (compsize < 0) compsize = 0; if (compsize < 0) return BadLength;
glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes); glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
__GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
...@@ -346,7 +346,7 @@ int __glXDisp_GetHistogram(__GLXclientState *cl, GLbyte *pc) ...@@ -346,7 +346,7 @@ int __glXDisp_GetHistogram(__GLXclientState *cl, GLbyte *pc)
* are illegal, but then width would still be zero anyway. * are illegal, but then width would still be zero anyway.
*/ */
compsize = __glGetTexImage_size(target,1,format,type,width,1,1); compsize = __glGetTexImage_size(target,1,format,type,width,1,1);
if (compsize < 0) compsize = 0; if (compsize < 0) return BadLength;
glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes); glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
__GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
...@@ -389,7 +389,7 @@ int __glXDisp_GetMinmax(__GLXclientState *cl, GLbyte *pc) ...@@ -389,7 +389,7 @@ int __glXDisp_GetMinmax(__GLXclientState *cl, GLbyte *pc)
reset = *(GLboolean *)(pc + 13); reset = *(GLboolean *)(pc + 13);
compsize = __glGetTexImage_size(target,1,format,type,2,1,1); compsize = __glGetTexImage_size(target,1,format,type,2,1,1);
if (compsize < 0) compsize = 0; if (compsize < 0) return BadLength;
glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes); glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
__GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
...@@ -436,7 +436,7 @@ int __glXDisp_GetColorTable(__GLXclientState *cl, GLbyte *pc) ...@@ -436,7 +436,7 @@ int __glXDisp_GetColorTable(__GLXclientState *cl, GLbyte *pc)
* are illegal, but then width would still be zero anyway. * are illegal, but then width would still be zero anyway.
*/ */
compsize = __glGetTexImage_size(target,1,format,type,width,1,1); compsize = __glGetTexImage_size(target,1,format,type,width,1,1);
if (compsize < 0) compsize = 0; if (compsize < 0) return BadLength;
glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes); glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
__GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
......
...@@ -79,7 +79,7 @@ int __glXDispSwap_ReadPixels(__GLXclientState *cl, GLbyte *pc) ...@@ -79,7 +79,7 @@ int __glXDispSwap_ReadPixels(__GLXclientState *cl, GLbyte *pc)
swapBytes = *(GLboolean *)(pc + 24); swapBytes = *(GLboolean *)(pc + 24);
lsbFirst = *(GLboolean *)(pc + 25); lsbFirst = *(GLboolean *)(pc + 25);
compsize = __glReadPixels_size(format,type,width,height); compsize = __glReadPixels_size(format,type,width,height);
if (compsize < 0) compsize = 0; if (compsize < 0) return BadLength;
glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes); glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
glPixelStorei(GL_PACK_LSB_FIRST, lsbFirst); glPixelStorei(GL_PACK_LSB_FIRST, lsbFirst);
...@@ -148,7 +148,7 @@ int __glXDispSwap_GetTexImage(__GLXclientState *cl, GLbyte *pc) ...@@ -148,7 +148,7 @@ int __glXDispSwap_GetTexImage(__GLXclientState *cl, GLbyte *pc)
* are illegal, but then width, height, and depth would still be zero anyway. * are illegal, but then width, height, and depth would still be zero anyway.
*/ */
compsize = __glGetTexImage_size(target,level,format,type,width,height,depth); compsize = __glGetTexImage_size(target,level,format,type,width,height,depth);
if (compsize < 0) compsize = 0; if (compsize < 0) return BadLength;
glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes); glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
__GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
...@@ -257,7 +257,7 @@ int __glXDispSwap_GetSeparableFilter(__GLXclientState *cl, GLbyte *pc) ...@@ -257,7 +257,7 @@ int __glXDispSwap_GetSeparableFilter(__GLXclientState *cl, GLbyte *pc)
compsize = __glGetTexImage_size(target,1,format,type,width,1,1); compsize = __glGetTexImage_size(target,1,format,type,width,1,1);
compsize2 = __glGetTexImage_size(target,1,format,type,height,1,1); compsize2 = __glGetTexImage_size(target,1,format,type,height,1,1);
if (compsize < 0) compsize = 0; if (compsize < 0) return BadLength;
if (compsize2 < 0) compsize2 = 0; if (compsize2 < 0) compsize2 = 0;
compsize = __GLX_PAD(compsize); compsize = __GLX_PAD(compsize);
compsize2 = __GLX_PAD(compsize2); compsize2 = __GLX_PAD(compsize2);
...@@ -328,7 +328,7 @@ int __glXDispSwap_GetConvolutionFilter(__GLXclientState *cl, GLbyte *pc) ...@@ -328,7 +328,7 @@ int __glXDispSwap_GetConvolutionFilter(__GLXclientState *cl, GLbyte *pc)
* are illegal, but then width and height would still be zero anyway. * are illegal, but then width and height would still be zero anyway.
*/ */
compsize = __glGetTexImage_size(target,1,format,type,width,height,1); compsize = __glGetTexImage_size(target,1,format,type,width,height,1);
if (compsize < 0) compsize = 0; if (compsize < 0) return BadLength;
glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes); glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
__GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
...@@ -390,7 +390,7 @@ int __glXDispSwap_GetHistogram(__GLXclientState *cl, GLbyte *pc) ...@@ -390,7 +390,7 @@ int __glXDispSwap_GetHistogram(__GLXclientState *cl, GLbyte *pc)
* are illegal, but then width would still be zero anyway. * are illegal, but then width would still be zero anyway.
*/ */
compsize = __glGetTexImage_size(target,1,format,type,width,1,1); compsize = __glGetTexImage_size(target,1,format,type,width,1,1);
if (compsize < 0) compsize = 0; if (compsize < 0) return BadLength;
glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes); glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
__GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
...@@ -439,7 +439,7 @@ int __glXDispSwap_GetMinmax(__GLXclientState *cl, GLbyte *pc) ...@@ -439,7 +439,7 @@ int __glXDispSwap_GetMinmax(__GLXclientState *cl, GLbyte *pc)
reset = *(GLboolean *)(pc + 13); reset = *(GLboolean *)(pc + 13);
compsize = __glGetTexImage_size(target,1,format,type,2,1,1); compsize = __glGetTexImage_size(target,1,format,type,2,1,1);
if (compsize < 0) compsize = 0; if (compsize < 0) return BadLength;
glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes); glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
__GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
...@@ -491,7 +491,7 @@ int __glXDispSwap_GetColorTable(__GLXclientState *cl, GLbyte *pc) ...@@ -491,7 +491,7 @@ int __glXDispSwap_GetColorTable(__GLXclientState *cl, GLbyte *pc)
* are illegal, but then width would still be zero anyway. * are illegal, but then width would still be zero anyway.
*/ */
compsize = __glGetTexImage_size(target,1,format,type,width,1,1); compsize = __glGetTexImage_size(target,1,format,type,width,1,1);
if (compsize < 0) compsize = 0; if (compsize < 0) return BadLength;
glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes); glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
__GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1); __GLX_GET_ANSWER_BUFFER(answer,cl,compsize,1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment