Re: [PATCH] cifs: make sure we allocate enough storage for socketaddress

From: Joe Perches
Date: Thu Jan 22 2009 - 15:01:44 EST


On Thu, 2009-01-22 at 10:48 -0500, Jeff Layton wrote:
> The sockaddr declared on the stack in cifs_get_tcp_session is too small
> for IPv6 addresses. Change it from "struct sockaddr" to "struct
> sockaddr_storage" to prevent stack corruption when IPv6 is used.
>
> Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
> ---
> fs/cifs/connect.c | 16 ++++++++--------
> 1 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index a3537a9..2209be9 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -1374,11 +1374,11 @@ cifs_find_tcp_session(struct sockaddr *addr)
> if (server->tcpStatus == CifsNew)
> continue;
>
> - if (addr->sa_family == AF_INET &&
> + if (addr->ss_family == AF_INET &&
> (addr4->sin_addr.s_addr !=
> server->addr.sockAddr.sin_addr.s_addr))
> continue;
> - else if (addr->sa_family == AF_INET6 &&
> + else if (addr->ss_family == AF_INET6 &&
> memcmp(&server->addr.sockAddr6.sin6_addr,
> &addr6->sin6_addr, sizeof(addr6->sin6_addr)))

!ipv6_addr_equal


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/