* [PATCH net-next ] net: ipv4: memset addr before calling copy_to_user()
@ 2015-11-09 6:52 Loganaden Velvindron
2015-11-09 10:09 ` Hannes Frederic Sowa
0 siblings, 1 reply; 2+ messages in thread
From: Loganaden Velvindron @ 2015-11-09 6:52 UTC (permalink / raw)
To: netdev
zero addr before calling copy_to_user()
Signed-off-by: Loganaden Velvindron <logan@elandsys.com>
---
net/ipv4/ip_sockglue.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index c3c359a..d7a5a8b 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -1373,6 +1373,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
case IP_MULTICAST_IF:
{
struct in_addr addr;
+ memset(&addr, 0, sizeof(addr));
len = min_t(unsigned int, len, sizeof(struct in_addr));
addr.s_addr = inet->mc_addr;
release_sock(sk);
--
2.6.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next ] net: ipv4: memset addr before calling copy_to_user()
2015-11-09 6:52 [PATCH net-next ] net: ipv4: memset addr before calling copy_to_user() Loganaden Velvindron
@ 2015-11-09 10:09 ` Hannes Frederic Sowa
0 siblings, 0 replies; 2+ messages in thread
From: Hannes Frederic Sowa @ 2015-11-09 10:09 UTC (permalink / raw)
To: Loganaden Velvindron, netdev
Hello,
On Mon, Nov 9, 2015, at 07:52, Loganaden Velvindron wrote:
> zero addr before calling copy_to_user()
>
> Signed-off-by: Loganaden Velvindron <logan@elandsys.com>
> ---
> net/ipv4/ip_sockglue.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
> index c3c359a..d7a5a8b 100644
> --- a/net/ipv4/ip_sockglue.c
> +++ b/net/ipv4/ip_sockglue.c
> @@ -1373,6 +1373,7 @@ static int do_ip_getsockopt(struct sock *sk, int
> level, int optname,
> case IP_MULTICAST_IF:
> {
> struct in_addr addr;
> + memset(&addr, 0, sizeof(addr));
> len = min_t(unsigned int, len, sizeof(struct in_addr));
> addr.s_addr = inet->mc_addr;
> release_sock(sk);
There is no possibility we leak any unwanted data to user space here.
If you are not sure if sizeof(addr) > sizeof(addr.s_addr) use a
designated initializer:
addr = { .s_addr = inet->mc_addr };
which clears all other non-initialized elements. But here we are very
certain.
We do not do defensive programming, we try to do logical things, and
only logical things.
— Eric Dumazet (Thanks to Dan Carpenter.)
Bye,
Hannes
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-09 10:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-09 6:52 [PATCH net-next ] net: ipv4: memset addr before calling copy_to_user() Loganaden Velvindron
2015-11-09 10:09 ` Hannes Frederic Sowa
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.