Skip to contentSkip to conversation

decnet: fix shutdown parameter checking

PATCH Applied Xi Wang 3 participants 5 messages Aug 27, 2012 – Sep 5, 2012

Subsystems (2)
lore
Share & tools
lore

Xi Wang

author
#0 lore raw

PATCH 1/1 decnet: fix shutdown parameter checking

The allowed value of "how" is SHUT_RD/SHUT_WR/SHUT_RDWR (0/1/2), rather than SHUTDOWN_MASK (3).

---
 net/decnet/af_decnet.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/decnet/af_decnet.c +2 -2
index 2ba1a28..307c322 100644
@@ -1313,10 +1313,10 @@ static int dn_shutdown(struct socket *sock, int how)
 	if (scp->state == DN_O)
 		goto out;
 
-	if (how != SHUTDOWN_MASK)
+	if (how != SHUT_RDWR)
 		goto out;
 
-	sk->sk_shutdown = how;
+	sk->sk_shutdown = SHUTDOWN_MASK;
 	dn_destroy_sock(sk);
 	err = 0;
 
Signature · 1 line
1.7.9.5
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Xi Wang

The allowed value of "how" is SHUT_RD/SHUT_WR/SHUT_RDWR (0/1/2), rather than SHUTDOWN_MASK (3).

Although it could be argued that we should also continue to accept the value 3 just in case there is any userland software out there which sends that value,

Steve.

Quoted 21 lines
---
 net/decnet/af_decnet.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/decnet/af_decnet.c +2 -2
index 2ba1a28..307c322 100644
@@ -1313,10 +1313,10 @@ static int dn_shutdown(struct socket *sock, int how)
 	if (scp->state == DN_O)
 		goto out;
 
-	if (how != SHUTDOWN_MASK)
+	if (how != SHUT_RDWR)
 		goto out;
 
-	sk->sk_shutdown = how;
+	sk->sk_shutdown = SHUTDOWN_MASK;
 	dn_destroy_sock(sk);
 	err = 0;
 
maintainer Applied
#2 lore raw

From: Steven Whitehouse <[email protected]>
Date: Mon, 27 Aug 2012 10:16:41 +0100

Quoted 6 lines · Xi Wang
Quoted 4 lines

The allowed value of "how" is SHUT_RD/SHUT_WR/SHUT_RDWR (0/1/2), rather than SHUTDOWN_MASK (3).

Applied to net-next.

Quoted 3 lines

Although it could be argued that we should also continue to accept the value 3 just in case there is any userland software out there which sends that value,

True, but this is a rather standard BSD socket interface with a very specific small set of legitimate input parameters. Allowing deviation, even for compatability for specific protocols, is largely unwise.

#3 lore raw

Hi,

Quoted 12 lines · David Miller

From: Steven Whitehouse <[email protected]>
Date: Mon, 27 Aug 2012 10:16:41 +0100

Quoted 6 lines · Xi Wang
Quoted 4 lines

The allowed value of "how" is SHUT_RD/SHUT_WR/SHUT_RDWR (0/1/2), rather than SHUTDOWN_MASK (3).

Applied to net-next.

Quoted 8 lines
Quoted 3 lines

Although it could be argued that we should also continue to accept the value 3 just in case there is any userland software out there which sends that value,

True, but this is a rather standard BSD socket interface with a very specific small set of legitimate input parameters. Allowing deviation, even for compatability for specific protocols, is largely unwise.

Yes, I'd agree on the whole, and certainly if this was a recent addition. However since this code has been around for somewhere close to 16 years now, I'd say that means that either (a) nobody calls shutdown for DECnet or (b) existing users are buggy too.

We do have a precedent for this kind of compatibility, such as the AX.25 use of SOCK_SEQPACKET.

However, I'm not overly worried and we'll soon know if it will cause any problems or not,

Steve.

maintainer
#4 lore raw

From: Steven Whitehouse <[email protected]>
Date: Wed, 05 Sep 2012 09:37:56 +0100

Quoted 2 lines

However, I'm not overly worried and we'll soon know if it will cause any problems or not,

You can be sure that if we get real bug reports due to this change, I will revert it back to how it was before.