Skip to contentSkip to conversation

IPv6: Fix the return value of get destination options with NULL data pointer

PATCH In review Yang Hongyang 2 participants 2 messages May 28, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 IPv6: Fix the return value of get destination options with NULL data pointer

If we pass NULL data buffer to getsockopt(), it will return 0, and the option length is set to -EFAULT:

    getsockopt(sk, IPPROTO_IPV6, IPV6_DSTOPTS, NULL, &len);

This is because ipv6_getsockopt_sticky() will return -EFAULT or -EINVAL if some error occur.

This patch fix this problem.

---
 net/ipv6/ipv6_sockglue.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
net/ipv6/ipv6_sockglue.c +3 -0
index 56d55fe..aa7bedf 100644
@@ -975,6 +975,9 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
 		len = ipv6_getsockopt_sticky(sk, np->opt,
 					     optname, optval, len);
 		release_sock(sk);
+		/* check if ipv6_getsockopt_sticky() returns err code */
+		if (len < 0)
+			return len;
 		return put_user(len, optlen);
 	}
 

-- 1.5.3.8

#1 lore raw

In article <[email protected]> (at Wed, 28 May 2008 16:23:47 +0800), Yang Hongyang <[email protected]> says:

Quoted 8 lines

If we pass NULL data buffer to getsockopt(), it will return 0, and the option length is set to -EFAULT:

    getsockopt(sk, IPPROTO_IPV6, IPV6_DSTOPTS, NULL, &len);

This is because ipv6_getsockopt_sticky() will return -EFAULT or -EINVAL if some error occur.

This patch fix this problem.

I'm going to apply this in my tree. Thanks.

--yoshfuji