login
Header Space

 
 

Re: [2.6 PATCH] IPV6: Check length of optval provided by user in setsockopt()

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@...>
Cc: <davem@...>, <netdev@...>
Date: Sunday, April 6, 2008 - 9:42 pm

YOSHIFUJI Hideaki said the following on 2008-3-31 18:53:

Check length of setsockopt's optval, which provided by user, before copy it
from user space.
For POSIX compliant, return -EINVAL for setsockopt of short lengths.

Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
---
 net/ipv6/ipv6_sockglue.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index bf2a686..a5ac121 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -557,6 +557,9 @@ done:
 	{
 		struct ipv6_mreq mreq;
 
+		if (optlen < sizeof(struct ipv6_mreq))
+			goto e_inval;
+
 		retv = -EPROTO;
 		if (inet_sk(sk)->is_icsk)
 			break;
@@ -576,7 +579,7 @@ done:
 	{
 		struct ipv6_mreq mreq;
 
-		if (optlen != sizeof(struct ipv6_mreq))
+		if (optlen < sizeof(struct ipv6_mreq))
 			goto e_inval;
 
 		retv = -EFAULT;
@@ -595,6 +598,9 @@ done:
 		struct group_req greq;
 		struct sockaddr_in6 *psin6;
 
+		if (optlen < sizeof(struct group_req))
+			goto e_inval;
+
 		retv = -EFAULT;
 		if (copy_from_user(&greq, optval, sizeof(struct group_req)))
 			break;
@@ -619,7 +625,7 @@ done:
 		struct group_source_req greqs;
 		int omode, add;
 
-		if (optlen != sizeof(struct group_source_req))
+		if (optlen < sizeof(struct group_source_req))
 			goto e_inval;
 		if (copy_from_user(&greqs, optval, sizeof(greqs))) {
 			retv = -EFAULT;
-- 
1.5.4

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [2.6 PATCH] IPV6: Check length of optval provided by use..., YOSHIFUJI Hideaki / , (Mon Mar 31, 5:15 am)
Re: [2.6 PATCH] IPV6: Check length of optval provided by use..., YOSHIFUJI Hideaki / , (Mon Mar 31, 6:53 am)
Re: [2.6 PATCH] IPV6: Check length of optval provided by use..., Wang Chen, (Sun Apr 6, 9:42 pm)
Re: [2.6 PATCH] IPV6: Check length of optval provided by use..., YOSHIFUJI Hideaki / , (Fri Apr 11, 3:15 am)
speck-geostationary