From: Changli Gao <xiaosuo@gmail.com>
To: Neil Brown <neilb@suse.de>
Cc: David Miller <davem@davemloft.net>,
shemminger@vyatta.com, netdev@vger.kernel.org
Subject: Re: Undefined behaviour of connect(fd, NULL, 0);
Date: Thu, 1 Apr 2010 11:00:23 +0800 [thread overview]
Message-ID: <n2w412e6f7f1003312000o3a69802j120acd3946458517@mail.gmail.com> (raw)
In-Reply-To: <20100401090756.69bfb57d@notabene.brown>
I think the following patch is what Neil wants. The old code implies that
connect(fd, NULL, 0) is used to check the socket connecting status, but
Stephen's patch breaks it. The old code is wrong when it checks the address's
faimly but not check the sizeof of the address to determine the family member
is valid or not before.
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index be1a6ac..3ff51f0 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -576,7 +576,8 @@ int inet_stream_connect(struct socket *sock,
struct sockaddr *uaddr,
lock_sock(sk);
- if (uaddr->sa_family == AF_UNSPEC) {
+ if (addr_len >= sizeof(uaddr->sa_family) &&
+ uaddr->sa_family == AF_UNSPEC) {
err = sk->sk_prot->disconnect(sk, flags);
sock->state = err ? SS_DISCONNECTING : SS_UNCONNECTED;
goto out;
next prev parent reply other threads:[~2010-04-01 3:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-31 11:36 Undefined behaviour of connect(fd, NULL, 0); Neil Brown
2010-03-31 18:49 ` Stephen Hemminger
2010-03-31 20:24 ` Neil Brown
2010-03-31 21:14 ` Stephen Hemminger
2010-03-31 21:17 ` David Miller
2010-03-31 22:07 ` Neil Brown
2010-04-01 3:00 ` Changli Gao [this message]
2010-04-01 3:38 ` Neil Brown
2010-04-01 4:16 ` Changli Gao
2010-04-01 5:50 ` Changli Gao
2010-04-01 7:23 ` David Miller
2010-04-05 9:23 ` Changli Gao
2010-04-05 15:56 ` Eric Dumazet
2010-04-05 16:25 ` Andreas Schwab
2010-04-05 19:25 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=n2w412e6f7f1003312000o3a69802j120acd3946458517@mail.gmail.com \
--to=xiaosuo@gmail.com \
--cc=davem@davemloft.net \
--cc=neilb@suse.de \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).