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(-)
23 diff --git a/glx/singlepix.c b/glx/singlepix.c
24 index 506fdaa..8b6c261 100644
27 @@ -65,7 +65,7 @@ __glXDisp_ReadPixels(__GLXclientState * cl, GLbyte * pc)
28 lsbFirst = *(GLboolean *) (pc + 25);
29 compsize = __glReadPixels_size(format, type, width, height);
34 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
35 glPixelStorei(GL_PACK_LSB_FIRST, lsbFirst);
36 @@ -124,7 +124,7 @@ __glXDisp_GetTexImage(__GLXclientState * cl, GLbyte * pc)
38 __glGetTexImage_size(target, level, format, type, width, height, depth);
43 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
44 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
45 @@ -218,9 +218,9 @@ GetSeparableFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
46 compsize2 = __glGetTexImage_size(target, 1, format, type, height, 1, 1);
54 compsize = __GLX_PAD(compsize);
55 compsize2 = __GLX_PAD(compsize2);
57 @@ -296,7 +296,7 @@ GetConvolutionFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
59 compsize = __glGetTexImage_size(target, 1, format, type, width, height, 1);
64 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
65 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
66 @@ -365,7 +365,7 @@ GetHistogram(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
68 compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
73 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
74 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
75 @@ -426,7 +426,7 @@ GetMinmax(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
77 compsize = __glGetTexImage_size(target, 1, format, type, 2, 1, 1);
82 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
83 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
84 @@ -491,7 +491,7 @@ GetColorTable(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
86 compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
91 glPixelStorei(GL_PACK_SWAP_BYTES, swapBytes);
92 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
93 diff --git a/glx/singlepixswap.c b/glx/singlepixswap.c
94 index 8469101..8dc304f 100644
95 --- a/glx/singlepixswap.c
96 +++ b/glx/singlepixswap.c
97 @@ -75,7 +75,7 @@ __glXDispSwap_ReadPixels(__GLXclientState * cl, GLbyte * pc)
98 lsbFirst = *(GLboolean *) (pc + 25);
99 compsize = __glReadPixels_size(format, type, width, height);
104 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
105 glPixelStorei(GL_PACK_LSB_FIRST, lsbFirst);
106 @@ -144,7 +144,7 @@ __glXDispSwap_GetTexImage(__GLXclientState * cl, GLbyte * pc)
108 __glGetTexImage_size(target, level, format, type, width, height, depth);
113 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
114 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
115 @@ -252,9 +252,9 @@ GetSeparableFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
116 compsize2 = __glGetTexImage_size(target, 1, format, type, height, 1, 1);
124 compsize = __GLX_PAD(compsize);
125 compsize2 = __GLX_PAD(compsize2);
127 @@ -338,7 +338,7 @@ GetConvolutionFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
129 compsize = __glGetTexImage_size(target, 1, format, type, width, height, 1);
134 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
135 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
136 @@ -415,7 +415,7 @@ GetHistogram(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
138 compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
143 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
144 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
145 @@ -483,7 +483,7 @@ GetMinmax(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
147 compsize = __glGetTexImage_size(target, 1, format, type, 2, 1, 1);
152 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
153 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);
154 @@ -554,7 +554,7 @@ GetColorTable(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
156 compsize = __glGetTexImage_size(target, 1, format, type, width, 1, 1);
161 glPixelStorei(GL_PACK_SWAP_BYTES, !swapBytes);
162 __GLX_GET_ANSWER_BUFFER(answer, cl, compsize, 1);