1 From 74e31c4809dbfe437a3e2a53ee38658da1f3c8ed Mon Sep 17 00:00:00 2001
2 From: Adam Jackson <ajax@redhat.com>
3 Date: Mon, 10 Nov 2014 12:13:37 -0500
4 Subject: [PATCH 21/33] glx: Be more strict about rejecting invalid image
5 sizes [CVE-2014-8093 2/6]
7 Before this we'd just clamp the image size to 0, which was just
8 hideously stupid; if the parameters were such that they'd overflow an
9 integer, you'd allocate a small buffer, then pass huge values into (say)
10 ReadPixels, and now you're scribbling over arbitrary server memory.
12 Reviewed-by: Keith Packard <keithp@keithp.com>
13 Reviewed-by: Julien Cristau <jcristau@debian.org>
14 Reviewed-by: Michal Srb <msrb@suse.com>
15 Reviewed-by: Andy Ritger <aritger@nvidia.com>
16 Signed-off-by: Adam Jackson <ajax@redhat.com>
17 Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
19 glx/singlepix.c | 16 ++++++++--------
20 glx/singlepixswap.c | 16 ++++++++--------
21 2 files changed, 16 insertions(+), 16 deletions(-)
25 @@ -65,7 +65,7 @@ __glXDisp_ReadPixels(__GLXclientState *
26 lsbFirst = *(GLboolean *) (pc + 25);
27 compsize = __glReadPixels_size(format, type, width, height);
32 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
33 glPixelStorei(GL_PACK_LSB_FIRST, lsbFirst);
34 @@ -124,7 +124,7 @@ __glXDisp_GetTexImage(__GLXclientState *
36 __glGetTexImage_size(target, level, format, type, width, height, depth);
41 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
42 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
43 @@ -218,9 +218,9 @@ GetSeparableFilter(__GLXclientState * cl
44 compsize2 = __glGetTexImage_size(target, 1, format, type, height, 1, 1);
52 compsize = __GLX_PAD(compsize);
53 compsize2 = __GLX_PAD(compsize2);
55 @@ -296,7 +296,7 @@ GetConvolutionFilter(__GLXclientState *
57 compsize = __glGetTexImage_size(target, 1, format, type, width, height, 1);
62 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
63 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
64 @@ -365,7 +365,7 @@ GetHistogram(__GLXclientState * cl, GLby
66 compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
71 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
72 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
73 @@ -426,7 +426,7 @@ GetMinmax(__GLXclientState * cl, GLbyte
75 compsize = __glGetTexImage_size(target, 1, format, type, 2, 1, 1);
80 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
81 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
82 @@ -491,7 +491,7 @@ GetColorTable(__GLXclientState * cl, GLb
84 compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
89 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
90 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
91 --- a/glx/singlepixswap.c
92 +++ b/glx/singlepixswap.c
93 @@ -75,7 +75,7 @@ __glXDispSwap_ReadPixels(__GLXclientStat
94 lsbFirst = *(GLboolean *) (pc + 25);
95 compsize = __glReadPixels_size(format, type, width, height);
100 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
101 glPixelStorei(GL_PACK_LSB_FIRST, lsbFirst);
102 @@ -144,7 +144,7 @@ __glXDispSwap_GetTexImage(__GLXclientSta
104 __glGetTexImage_size(target, level, format, type, width, height, depth);
109 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
110 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
111 @@ -252,9 +252,9 @@ GetSeparableFilter(__GLXclientState * cl
112 compsize2 = __glGetTexImage_size(target, 1, format, type, height, 1, 1);
120 compsize = __GLX_PAD(compsize);
121 compsize2 = __GLX_PAD(compsize2);
123 @@ -338,7 +338,7 @@ GetConvolutionFilter(__GLXclientState *
125 compsize = __glGetTexImage_size(target, 1, format, type, width, height, 1);
130 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
131 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
132 @@ -415,7 +415,7 @@ GetHistogram(__GLXclientState * cl, GLby
134 compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
139 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
140 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
141 @@ -483,7 +483,7 @@ GetMinmax(__GLXclientState * cl, GLbyte
143 compsize = __glGetTexImage_size(target, 1, format, type, 2, 1, 1);
148 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
149 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
150 @@ -554,7 +554,7 @@ GetColorTable(__GLXclientState * cl, GLb
152 compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
157 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
158 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);