aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>2007-03-30 17:45:35 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-02 16:30:54 -0400
commitb59e139bbd5c789700aa9cefe7eb6590bc516b86 (patch)
tree32dfe5facbbf2e4ca83f4254986e05900a7693da
parent31ba548f9683c5c5809567549b404404b6017088 (diff)
[IPv6]: Fix incorrect length check in rawv6_sendmsg()
In article <20070329.142644.70222545.davem@davemloft.net> (at Thu, 29 Mar 2007 14:26:44 -0700 (PDT)), David Miller <davem@davemloft.net> says: > From: Sridhar Samudrala <sri@us.ibm.com> > Date: Thu, 29 Mar 2007 14:17:28 -0700 > > > The check for length in rawv6_sendmsg() is incorrect. > > As len is an unsigned int, (len < 0) will never be TRUE. > > I think checking for IPV6_MAXPLEN(65535) is better. > > > > Is it possible to send ipv6 jumbo packets using raw > > sockets? If so, we can remove this check. > > I don't see why such a limitation against jumbo would exist, > does anyone else? > > Thanks for catching this Sridhar. A good compiler should simply > fail to compile "if (x < 0)" when 'x' is an unsigned type, don't > you think :-) Dave, we use "int" for returning value, so we should fix this anyway, IMHO; we should not allow len > INT_MAX. Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Acked-by: Sridhar Samudrala <sri@us.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv6/raw.c4
-rw-r--r--net/ipv6/udp.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 306d5d83c068..203e069e7fe9 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -687,9 +687,9 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
687 int err; 687 int err;
688 688
689 /* Rough check on arithmetic overflow, 689 /* Rough check on arithmetic overflow,
690 better check is made in ip6_build_xmit 690 better check is made in ip6_append_data().
691 */ 691 */
692 if (len < 0) 692 if (len > INT_MAX)
693 return -EMSGSIZE; 693 return -EMSGSIZE;
694 694
695 /* Mirror BSD error message compatibility */ 695 /* Mirror BSD error message compatibility */
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 0ad471909881..f590db57a7c9 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -615,7 +615,7 @@ do_udp_sendmsg:
615 return udp_sendmsg(iocb, sk, msg, len); 615 return udp_sendmsg(iocb, sk, msg, len);
616 616
617 /* Rough check on arithmetic overflow, 617 /* Rough check on arithmetic overflow,
618 better check is made in ip6_build_xmit 618 better check is made in ip6_append_data().
619 */ 619 */
620 if (len > INT_MAX - sizeof(struct udphdr)) 620 if (len > INT_MAX - sizeof(struct udphdr))
621 return -EMSGSIZE; 621 return -EMSGSIZE;