[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4D31D4A6.4040701@hartkopp.net>
Date: Sat, 15 Jan 2011 18:08:54 +0100
From: Oliver Hartkopp <socketcan@...tkopp.net>
To: Kurt Van Dijck <kurt.van.dijck@....be>
CC: netdev@...r.kernel.org, socketcan-core@...ts.berlios.de
Subject: Re: [PATCH] can: test size of struct sockaddr
On 14.01.2011 18:23, Kurt Van Dijck wrote:
> I think this patch makes the CAN socket code comform to the
> manpages of sendmsg & recvmsg.
Hello Kurt,
if you check similar code sniplets in the kernel you would see, that in
recvmsg()-cases the given namelen is not used from userspace.
If msg->msg_name is not NULL the msg_namelen is just set by the kernel. E.g.
see af_packet.c, af_econet.c, etc.
So the code in candump.c setting the msg_namelen before recvmsg() is obviously
obsolete ...
Btw. your two patches below for bcm_sendmsg() and raw_sendmesg() look good.
If you would like to resubmit these two patches, you may add my Acked-by
Thanks,
Oliver
> diff --git a/net/can/bcm.c b/net/can/bcm.c
> index 6faa825..dc0d5d6 100644
> --- a/net/can/bcm.c
> +++ b/net/can/bcm.c
> @@ -1256,6 +1256,9 @@ static int bcm_sendmsg(struct kiocb *iocb, struct socket *sock,
> struct sockaddr_can *addr =
> (struct sockaddr_can *)msg->msg_name;
>
> + if (msg->msg_namelen < sizeof(*addr))
> + return -EINVAL;
> +
> if (addr->can_family != AF_CAN)
> return -EINVAL;
>
> diff --git a/net/can/raw.c b/net/can/raw.c
> index e88f610..e68a6d3 100644
> --- a/net/can/raw.c
> +++ b/net/can/raw.c
> @@ -649,6 +649,9 @@ static int raw_sendmsg(struct kiocb *iocb, struct socket *sock,
> struct sockaddr_can *addr =
> (struct sockaddr_can *)msg->msg_name;
>
> + if (msg->msg_namelen < sizeof(*addr))
> + return -EINVAL;
> +
> if (addr->can_family != AF_CAN)
> return -EINVAL;
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists