Skip to contentSkip to conversation

ipv4: inet_bind: check the addr_len first

PATCH Superseded Denis Kirjanov 2 participants 2 messages Jun 2, 2015 – Jun 4, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv4: inet_bind: check the addr_len first

Perform the address length check first, before calling the the proto specific bind() function

---
 net/ipv4/af_inet.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
net/ipv4/af_inet.c +4 -3
index 6ad0f7a..333e2fa 100644
@@ -426,14 +426,15 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 	int chk_addr_ret;
 	int err;
 
+	err = -EINVAL;
+	if (addr_len < sizeof(struct sockaddr_in))
+		goto out;
+
 	/* If the socket has its own bind function then use it. (RAW) */
 	if (sk->sk_prot->bind) {
 		err = sk->sk_prot->bind(sk, uaddr, addr_len);
 		goto out;
 	}
-	err = -EINVAL;
-	if (addr_len < sizeof(struct sockaddr_in))
-		goto out;
 
 	if (addr->sin_family != AF_INET) {
 		/* Compatibility games : accept AF_UNSPEC (mapped to AF_INET)
Signature · 1 line
1.7.10.4
maintainer
#1 lore raw

From: Denis Kirjanov <[email protected]>
Date: Tue, 2 Jun 2015 12:08:00 +0300

Quoted 4 lines

Perform the address length check first, before calling the the proto specific bind() function

This doesn't fix any actual bug, doesn't improve the code in preparation for another change that actually benefits from this adjustment, and so this is really an unwanted change.

This change and it's commit log message look totally arbitrary and opaque, even to people who have been working with this code and it's interfaces for decades. That should tell you something.

You have to let us know exactly why you are making a change, and what real _actual_ bug it fixes, when you want us to consider your changes seriously.

I'm not applying this, sorry.