2012-08-27 02:37:20

by Xi Wang

[permalink] [raw]
Subject: [PATCH] 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).

Signed-off-by: Xi Wang <[email protected]>
---
net/decnet/af_decnet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index 2ba1a28..307c322 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -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;

--
1.7.9.5


2012-08-27 09:17:44

by Steven Whitehouse

[permalink] [raw]
Subject: Re: [PATCH] decnet: fix shutdown parameter checking


On Sun, 2012-08-26 at 22:37 -0400, Xi Wang wrote:
> The allowed value of "how" is SHUT_RD/SHUT_WR/SHUT_RDWR (0/1/2),
> rather than SHUTDOWN_MASK (3).
>
> Signed-off-by: Xi Wang <[email protected]>
Acked-by: Steven Whitehouse <[email protected]>

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.

> ---
> net/decnet/af_decnet.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
> index 2ba1a28..307c322 100644
> --- a/net/decnet/af_decnet.c
> +++ b/net/decnet/af_decnet.c
> @@ -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;
>

2012-08-31 19:57:23

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] decnet: fix shutdown parameter checking

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

> On Sun, 2012-08-26 at 22:37 -0400, Xi Wang wrote:
>> The allowed value of "how" is SHUT_RD/SHUT_WR/SHUT_RDWR (0/1/2),
>> rather than SHUTDOWN_MASK (3).
>>
>> Signed-off-by: Xi Wang <[email protected]>
> Acked-by: Steven Whitehouse <[email protected]>

Applied to net-next.

> 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.