1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
|
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2004/12/08 13:33:08-08:00 davem@nuts.davemloft.net
# [NET]: CMSG compat code needs signedness fixes too.
#
# Signed-off-by: David S. Miller <davem@davemloft.net>
#
# arch/ia64/ia32/sys_ia32.c
# 2004/12/08 13:32:46-08:00 davem@nuts.davemloft.net +6 -4
# [NET]: CMSG compat code needs signedness fixes too.
#
# arch/mips64/kernel/linux32.c
# 2004/12/08 13:32:46-08:00 davem@nuts.davemloft.net +7 -5
# [NET]: CMSG compat code needs signedness fixes too.
#
# arch/parisc/kernel/sys_parisc32.c
# 2004/12/08 13:32:46-08:00 davem@nuts.davemloft.net +6 -5
# [NET]: CMSG compat code needs signedness fixes too.
#
# arch/ppc64/kernel/sys_ppc32.c
# 2004/12/08 13:32:46-08:00 davem@nuts.davemloft.net +6 -5
# [NET]: CMSG compat code needs signedness fixes too.
#
# arch/s390x/kernel/linux32.c
# 2004/12/08 13:32:46-08:00 davem@nuts.davemloft.net +6 -5
# [NET]: CMSG compat code needs signedness fixes too.
#
# arch/sparc64/kernel/sys_sparc32.c
# 2004/12/08 13:32:46-08:00 davem@nuts.davemloft.net +6 -5
# [NET]: CMSG compat code needs signedness fixes too.
#
# arch/x86_64/ia32/socket32.c
# 2004/12/08 13:32:46-08:00 davem@nuts.davemloft.net +2 -5
# [NET]: CMSG compat code needs signedness fixes too.
#
# include/asm-x86_64/socket32.h
# 2004/12/08 13:32:46-08:00 davem@nuts.davemloft.net +5 -0
# [NET]: CMSG compat code needs signedness fixes too.
#
# ChangeSet
# 2004/12/15 09:25:31-02:00 marcelo@logos.cnet
# [PATCH] Make sure VC resizing fits in s16
#
# Noted by George Guninski
#
# drivers/char/console.c
# 2004/12/15 10:58:17-02:00 marcelo@logos.cnet +6 -0
# Import patch vc-patch
#
diff -Nru a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
--- a/arch/ia64/ia32/sys_ia32.c 2005-02-15 11:50:28 -08:00
+++ b/arch/ia64/ia32/sys_ia32.c 2005-02-15 11:50:28 -08:00
@@ -1369,6 +1369,11 @@
#define __CMSG32_FIRSTHDR(ctl,len) \
((len) >= sizeof(struct cmsghdr32) ? (struct cmsghdr32 *)(ctl) : (struct cmsghdr32 *)NULL)
#define CMSG32_FIRSTHDR(msg) __CMSG32_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
+#define CMSG32_OK(ucmlen, ucmsg, mhdr) \
+ ((ucmlen) >= sizeof(struct cmsghdr) && \
+ (ucmlen) <= (unsigned long) \
+ ((mhdr)->msg_controllen - \
+ ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
static inline struct cmsghdr32 *
__cmsg32_nxthdr (void *ctl, __kernel_size_t size, struct cmsghdr32 *cmsg, int cmsg_len)
@@ -1429,10 +1434,7 @@
return -EFAULT;
/* Catch bogons. */
- if (CMSG32_ALIGN(ucmlen) < CMSG32_ALIGN(sizeof(struct cmsghdr32)))
- return -EINVAL;
- if ((unsigned long)(((char *)ucmsg - (char *)kmsg->msg_control) + ucmlen)
- > kmsg->msg_controllen)
+ if (!CMSG32_OK(ucmlen, ucmsg, kmsg))
return -EINVAL;
tmp = ((ucmlen - CMSG32_ALIGN(sizeof(*ucmsg))) +
diff -Nru a/arch/mips64/kernel/linux32.c b/arch/mips64/kernel/linux32.c
--- a/arch/mips64/kernel/linux32.c 2005-02-15 11:50:28 -08:00
+++ b/arch/mips64/kernel/linux32.c 2005-02-15 11:50:28 -08:00
@@ -2483,6 +2483,12 @@
(struct cmsghdr32 *)(ctl) : \
(struct cmsghdr32 *)NULL)
#define CMSG32_FIRSTHDR(msg) __CMSG32_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
+#define CMSG32_OK(ucmlen, ucmsg, mhdr) \
+ ((ucmlen) >= sizeof(struct cmsghdr) && \
+ (ucmlen) <= (unsigned long) \
+ ((mhdr)->msg_controllen - \
+ ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
+
__inline__ struct cmsghdr32 *__cmsg32_nxthdr(void *__ctl, __kernel_size_t __size,
struct cmsghdr32 *__cmsg, int __cmsg_len)
@@ -2623,11 +2629,7 @@
return -EFAULT;
/* Catch bogons. */
- if(CMSG32_ALIGN(ucmlen) <
- CMSG32_ALIGN(sizeof(struct cmsghdr32)))
- return -ENOBUFS;
- if((unsigned long)(((char *)ucmsg - (char *)kmsg->msg_control)
- + ucmlen) > kmsg->msg_controllen)
+ if (!CMSG32_OK(ucmlen, ucmsg, kmsg))
return -EINVAL;
tmp = ((ucmlen - CMSG32_ALIGN(sizeof(*ucmsg))) +
diff -Nru a/arch/parisc/kernel/sys_parisc32.c b/arch/parisc/kernel/sys_parisc32.c
--- a/arch/parisc/kernel/sys_parisc32.c 2005-02-15 11:50:28 -08:00
+++ b/arch/parisc/kernel/sys_parisc32.c 2005-02-15 11:50:28 -08:00
@@ -1814,6 +1814,11 @@
(struct cmsghdr32 *)(ctl) : \
(struct cmsghdr32 *)NULL)
#define CMSG32_FIRSTHDR(msg) __CMSG32_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
+#define CMSG32_OK(ucmlen, ucmsg, mhdr) \
+ ((ucmlen) >= sizeof(struct cmsghdr) && \
+ (ucmlen) <= (unsigned long) \
+ ((mhdr)->msg_controllen - \
+ ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
__inline__ struct cmsghdr32 *__cmsg32_nxthdr(void *__ctl, __kernel_size_t __size,
struct cmsghdr32 *__cmsg, int __cmsg_len)
@@ -1940,11 +1945,7 @@
return -EFAULT;
/* Catch bogons. */
- if(CMSG32_ALIGN(ucmlen) <
- CMSG32_ALIGN(sizeof(struct cmsghdr32)))
- return -EINVAL;
- if((unsigned long)(((char *)ucmsg - (char *)kmsg->msg_control)
- + ucmlen) > kmsg->msg_controllen)
+ if (!CMSG32_OK(ucmlen, ucmsg, kmsg))
return -EINVAL;
tmp = ((ucmlen - CMSG32_ALIGN(sizeof(*ucmsg))) +
diff -Nru a/arch/ppc64/kernel/sys_ppc32.c b/arch/ppc64/kernel/sys_ppc32.c
--- a/arch/ppc64/kernel/sys_ppc32.c 2005-02-15 11:50:28 -08:00
+++ b/arch/ppc64/kernel/sys_ppc32.c 2005-02-15 11:50:28 -08:00
@@ -3273,6 +3273,11 @@
(struct cmsghdr32 *)(ctl) : \
(struct cmsghdr32 *)NULL)
#define CMSG32_FIRSTHDR(msg) __CMSG32_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
+#define CMSG32_OK(ucmlen, ucmsg, mhdr) \
+ ((ucmlen) >= sizeof(struct cmsghdr) && \
+ (ucmlen) <= (unsigned long) \
+ ((mhdr)->msg_controllen - \
+ ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
struct msghdr32
{
@@ -3448,11 +3453,7 @@
return -EFAULT;
/* Catch bogons. */
- if(CMSG32_ALIGN(ucmlen) <
- CMSG32_ALIGN(sizeof(struct cmsghdr32)))
- return -EINVAL;
- if((unsigned long)(((char *)ucmsg - (char *)kmsg->msg_control)
- + ucmlen) > kmsg->msg_controllen)
+ if (!CMSG32_OK(ucmlen, ucmsg, kmsg))
return -EINVAL;
tmp = ((ucmlen - CMSG32_ALIGN(sizeof(*ucmsg))) +
diff -Nru a/arch/s390x/kernel/linux32.c b/arch/s390x/kernel/linux32.c
--- a/arch/s390x/kernel/linux32.c 2005-02-15 11:50:28 -08:00
+++ b/arch/s390x/kernel/linux32.c 2005-02-15 11:50:28 -08:00
@@ -2306,6 +2306,11 @@
(struct cmsghdr32 *)(ctl) : \
(struct cmsghdr32 *)NULL)
#define CMSG32_FIRSTHDR(msg) __CMSG32_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
+#define CMSG32_OK(ucmlen, ucmsg, mhdr) \
+ ((ucmlen) >= sizeof(struct cmsghdr) && \
+ (ucmlen) <= (unsigned long) \
+ ((mhdr)->msg_controllen - \
+ ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
__inline__ struct cmsghdr32 *__cmsg32_nxthdr(void *__ctl, __kernel_size_t __size,
struct cmsghdr32 *__cmsg, int __cmsg_len)
@@ -2432,11 +2437,7 @@
return -EFAULT;
/* Catch bogons. */
- if(CMSG32_ALIGN(ucmlen) <
- CMSG32_ALIGN(sizeof(struct cmsghdr32)))
- return -EINVAL;
- if((unsigned long)(((char *)ucmsg - (char *)kmsg->msg_control)
- + ucmlen) > kmsg->msg_controllen)
+ if (!CMSG32_OK(ucmlen, ucmsg, kmsg))
return -EINVAL;
tmp = ((ucmlen - CMSG32_ALIGN(sizeof(*ucmsg))) +
diff -Nru a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c
--- a/arch/sparc64/kernel/sys_sparc32.c 2005-02-15 11:50:28 -08:00
+++ b/arch/sparc64/kernel/sys_sparc32.c 2005-02-15 11:50:28 -08:00
@@ -2354,6 +2354,11 @@
(struct cmsghdr32 *)(ctl) : \
(struct cmsghdr32 *)NULL)
#define CMSG32_FIRSTHDR(msg) __CMSG32_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
+#define CMSG32_OK(ucmlen, ucmsg, mhdr) \
+ ((ucmlen) >= sizeof(struct cmsghdr) && \
+ (ucmlen) <= (unsigned long) \
+ ((mhdr)->msg_controllen - \
+ ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
__inline__ struct cmsghdr32 *__cmsg32_nxthdr(void *__ctl, __kernel_size_t __size,
struct cmsghdr32 *__cmsg, int __cmsg_len)
@@ -2480,11 +2485,7 @@
return -EFAULT;
/* Catch bogons. */
- if(CMSG32_ALIGN(ucmlen) <
- CMSG32_ALIGN(sizeof(struct cmsghdr32)))
- return -EINVAL;
- if((unsigned long)(((char *)ucmsg - (char *)kmsg->msg_control)
- + ucmlen) > kmsg->msg_controllen)
+ if (!CMSG32_OK(ucmlen, ucmsg, kmsg))
return -EINVAL;
tmp = ((ucmlen - CMSG32_ALIGN(sizeof(*ucmsg))) +
diff -Nru a/arch/x86_64/ia32/socket32.c b/arch/x86_64/ia32/socket32.c
--- a/arch/x86_64/ia32/socket32.c 2005-02-15 11:50:28 -08:00
+++ b/arch/x86_64/ia32/socket32.c 2005-02-15 11:50:28 -08:00
@@ -136,12 +136,9 @@
return -EFAULT;
/* Catch bogons. */
- if(CMSG32_ALIGN(ucmlen) <
- CMSG32_ALIGN(sizeof(struct cmsghdr32)))
- return -EINVAL;
- if((unsigned long)(((char *)ucmsg - (char *)kmsg->msg_control)
- + ucmlen) > kmsg->msg_controllen)
+ if (!CMSG32_OK(ucmlen, ucmsg, kmsg))
return -EINVAL;
+
if (kmsg->msg_controllen > 65536)
return -EINVAL;
diff -Nru a/include/asm-x86_64/socket32.h b/include/asm-x86_64/socket32.h
--- a/include/asm-x86_64/socket32.h 2005-02-15 11:50:28 -08:00
+++ b/include/asm-x86_64/socket32.h 2005-02-15 11:50:28 -08:00
@@ -45,6 +45,11 @@
(struct cmsghdr32 *)(ctl) : \
(struct cmsghdr32 *)NULL)
#define CMSG32_FIRSTHDR(msg) __CMSG32_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
+#define CMSG32_OK(ucmlen, ucmsg, mhdr) \
+ ((ucmlen) >= sizeof(struct cmsghdr) && \
+ (ucmlen) <= (unsigned long) \
+ ((mhdr)->msg_controllen - \
+ ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
__inline__ struct cmsghdr32 *__cmsg32_nxthdr(void *__ctl, __kernel_size_t __size,
struct cmsghdr32 *__cmsg, int __cmsg_len)
diff -Nru a/drivers/char/console.c b/drivers/char/console.c
--- a/drivers/char/console.c 2005-02-15 11:52:04 -08:00
+++ b/drivers/char/console.c 2005-02-15 11:52:04 -08:00
@@ -705,6 +705,9 @@
return 0;
}
+#define VC_RESIZE_MAXCOL (32767)
+#define VC_RESIZE_MAXROW (32767)
+
/*
* Change # of rows and columns (0 means unchanged/the size of fg_console)
* [this is to be used together with some user program
@@ -716,6 +719,9 @@
unsigned int cc, ll, ss, sr, todo = 0;
unsigned int currcons = fg_console, i;
unsigned short *newscreens[MAX_NR_CONSOLES];
+
+ if (cols > VC_RESIZE_MAXCOL || lines > VC_RESIZE_MAXROW)
+ return -EINVAL;
cc = (cols ? cols : video_num_columns);
ll = (lines ? lines : video_num_lines);
|