aboutsummaryrefslogtreecommitdiffstats
path: root/net/compat.c
diff options
context:
space:
mode:
authorJesper Juhl <jj@chaosbits.net>2012-07-22 07:37:20 -0400
committerDavid S. Miller <davem@davemloft.net>2012-07-22 20:50:49 -0400
commit818810472b129004c16fc51bf0a570b60776bfb7 (patch)
tree132cc06300eee66d5e29905a652e79bf585416f6 /net/compat.c
parent5e9965c15ba88319500284e590733f4a4629a288 (diff)
net: Fix references to out-of-scope variables in put_cmsg_compat()
In net/compat.c::put_cmsg_compat() we may assign 'data' the address of either the 'ctv' or 'cts' local variables inside the 'if (!COMPAT_USE_64BIT_TIME)' branch. Those variables go out of scope at the end of the 'if' statement, so when we use 'data' further down in 'copy_to_user(CMSG_COMPAT_DATA(cm), data, cmlen - sizeof(struct compat_cmsghdr))' there's no telling what it may be refering to - not good. Fix the problem by simply giving 'ctv' and 'cts' function scope. Signed-off-by: Jesper Juhl <jj@chaosbits.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/compat.c')
-rw-r--r--net/compat.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/net/compat.c b/net/compat.c
index 1b96281892de..74ed1d7a84a2 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -221,6 +221,8 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
221{ 221{
222 struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control; 222 struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
223 struct compat_cmsghdr cmhdr; 223 struct compat_cmsghdr cmhdr;
224 struct compat_timeval ctv;
225 struct compat_timespec cts[3];
224 int cmlen; 226 int cmlen;
225 227
226 if (cm == NULL || kmsg->msg_controllen < sizeof(*cm)) { 228 if (cm == NULL || kmsg->msg_controllen < sizeof(*cm)) {
@@ -229,8 +231,6 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
229 } 231 }
230 232
231 if (!COMPAT_USE_64BIT_TIME) { 233 if (!COMPAT_USE_64BIT_TIME) {
232 struct compat_timeval ctv;
233 struct compat_timespec cts[3];
234 if (level == SOL_SOCKET && type == SCM_TIMESTAMP) { 234 if (level == SOL_SOCKET && type == SCM_TIMESTAMP) {
235 struct timeval *tv = (struct timeval *)data; 235 struct timeval *tv = (struct timeval *)data;
236 ctv.tv_sec = tv->tv_sec; 236 ctv.tv_sec = tv->tv_sec;