diff options
author | Jesper Juhl <jj@chaosbits.net> | 2012-07-22 11:37:20 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-09 08:31:42 -0700 |
commit | 4deb65e759dd2ff7dd5e40bd6d4bf0dad6d88269 (patch) | |
tree | f3df7cc13f2bb4238e1ec23cf1fcdcf375404ff3 /net | |
parent | a080e65186d367508e2b4e68290656ddce493136 (diff) | |
download | linux-3.10-4deb65e759dd2ff7dd5e40bd6d4bf0dad6d88269.tar.gz linux-3.10-4deb65e759dd2ff7dd5e40bd6d4bf0dad6d88269.tar.bz2 linux-3.10-4deb65e759dd2ff7dd5e40bd6d4bf0dad6d88269.zip |
net: Fix references to out-of-scope variables in put_cmsg_compat()
[ Upstream commit 818810472b129004c16fc51bf0a570b60776bfb7 ]
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/compat.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/compat.c b/net/compat.c index e055708b8ec..ae6d67ad03b 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 { struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control; struct compat_cmsghdr cmhdr; + struct compat_timeval ctv; + struct compat_timespec cts[3]; int cmlen; 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 } if (!COMPAT_USE_64BIT_TIME) { - struct compat_timeval ctv; - struct compat_timespec cts[3]; if (level == SOL_SOCKET && type == SCM_TIMESTAMP) { struct timeval *tv = (struct timeval *)data; ctv.tv_sec = tv->tv_sec; |