netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] ipv6: return with appropriate error code when sending RH0 using setsockopt()
@ 2008-09-03  8:41 Shan Wei
  2008-09-03  9:23 ` David Miller
  2008-09-03 18:36 ` Brian Haley
  0 siblings, 2 replies; 9+ messages in thread
From: Shan Wei @ 2008-09-03  8:41 UTC (permalink / raw)
  To: davem; +Cc: netdev

 I'm sorry to resend the patch, for that no one replied it from Jun 27.

 The kernel had removed the RH0(Type 0 Routing Header), but we can still
 send IPv6 packet with RH0 using sendmsg() or setsockopt().

 Compare with sendmsg() that returns EINVAL, but setsockopt() return EPERM.
 The patch fix it.

Signed-off-by: Shan Wei <shanwei@cn.fujitsu.com>
---
 net/ipv6/ipv6_sockglue.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 4e5eac3..7a58597 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -353,9 +353,10 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
 			goto e_inval;
 
 		/* hop-by-hop / destination options are privileged option */
-		retv = -EPERM;
-		if (optname != IPV6_RTHDR && !capable(CAP_NET_RAW))
+		if (optname != IPV6_RTHDR && !capable(CAP_NET_RAW)) {
+			retv = -EPERM;
 			break;
+		}
 
 		opt = ipv6_renew_options(sk, np->opt, optname,
 					 (struct ipv6_opt_hdr __user *)optval,
@@ -365,6 +366,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
 			break;
 		}
 
+		retv = -EINVAL;
 		/* routing header option needs extra check */
 		if (optname == IPV6_RTHDR && opt && opt->srcrt) {
 			struct ipv6_rt_hdr *rthdr = opt->srcrt;
-- 
1.6.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-09-16  7:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-03  8:41 [PATCH RESEND] ipv6: return with appropriate error code when sending RH0 using setsockopt() Shan Wei
2008-09-03  9:23 ` David Miller
2008-09-03  9:41   ` Shan Wei
2008-09-03 18:36 ` Brian Haley
2008-09-04  3:44   ` Shan Wei
2008-09-12  3:14     ` David Miller
2008-09-16  7:13       ` Shan Wei
2008-09-04  5:53   ` Shan Wei
2008-09-04 13:54     ` Brian Haley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).