public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: Check the argument for listen(2)
@ 2013-06-28 16:14 Changli Gao
  2013-06-28 16:29 ` Eric Dumazet
  2013-06-28 16:30 ` Stephen Hemminger
  0 siblings, 2 replies; 6+ messages in thread
From: Changli Gao @ 2013-06-28 16:14 UTC (permalink / raw)
  To: David S. Miller; +Cc: Changli Gao, netdev

As we use u16 to save the value of the argument for listen(2),
we'd better check if the value is larger than SINT_MAX other
than cut it down silently on error.
---
 net/ipv4/af_inet.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index b4d0be2..35aaf00 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -198,6 +198,9 @@ int inet_listen(struct socket *sock, int backlog)
 	unsigned char old_state;
 	int err;
 
+	if (backlog >= (1 << 16))
+		return EINVAL;
+
 	lock_sock(sk);
 
 	err = -EINVAL;
-- 
1.7.9.5

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

end of thread, other threads:[~2013-06-28 16:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-28 16:14 [PATCH] net: Check the argument for listen(2) Changli Gao
2013-06-28 16:29 ` Eric Dumazet
2013-06-28 16:32   ` Hannes Frederic Sowa
2013-06-28 16:34     ` Hannes Frederic Sowa
2013-06-28 16:48       ` Eric Dumazet
2013-06-28 16:30 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox