Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: shemminger@linux-foundation.org, netdev@vger.kernel.org,
	Marcus Meissner <meissner@suse.de>,
	r_meier@freenet.de
Subject: Re: [Bug 42012] New: regression on 2.6.39.3 with socket/bind; still there in 3.0.4
Date: Tue, 30 Aug 2011 22:19:22 +0200	[thread overview]
Message-ID: <1314735562.2556.20.camel@edumazet-laptop> (raw)
In-Reply-To: <1314734452.2556.12.camel@edumazet-laptop>

Le mardi 30 août 2011 à 22:00 +0200, Eric Dumazet a écrit :

> Sure, I will send a patch in a couple of minutes.
> 
> 

[PATCH] net: ipv4: relax AF_INET check in bind()

commit d0733d2e29b65 (Check for mistakenly passed in non-IPv4 address)
added regression on legacy apps that use bind() with AF_UNSPEC family.

Relax the check, but make sure the bind() is done on INADDR_ANY
addresses, as AF_UNSPEC has probably no sane meaning for other
addresses.

Bugzilla reference : https://bugzilla.kernel.org/show_bug.cgi?id=42012

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Reported-and-bisected-by: Rene Meier <r_meier@freenet.de>
CC: Marcus Meissner <meissner@suse.de>
---
 net/ipv4/af_inet.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 1b745d4..dd2b947 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -466,8 +466,13 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 		goto out;
 
 	if (addr->sin_family != AF_INET) {
+		/* Compatibility games : accept AF_UNSPEC (mapped to AF_INET)
+		 * only if s_addr is INADDR_ANY.
+		 */
 		err = -EAFNOSUPPORT;
-		goto out;
+		if (addr->sin_family != AF_UNSPEC ||
+		    addr->sin_addr.s_addr != htonl(INADDR_ANY))
+			goto out;
 	}
 
 	chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);

  reply	other threads:[~2011-08-30 20:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-30 15:47 Fw: [Bug 42012] New: regression on 2.6.39.3 with socket/bind; still there in 3.0.4 Stephen Hemminger
2011-08-30 16:11 ` Eric Dumazet
2011-08-30 18:07   ` David Miller
2011-08-30 19:16     ` Eric Dumazet
2011-08-30 19:44       ` Eric Dumazet
2011-08-30 19:52         ` David Miller
2011-08-30 20:00           ` Eric Dumazet
2011-08-30 20:19             ` Eric Dumazet [this message]
2011-08-30 22:57               ` 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=1314735562.2556.20.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=meissner@suse.de \
    --cc=netdev@vger.kernel.org \
    --cc=r_meier@freenet.de \
    --cc=shemminger@linux-foundation.org \
    /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