All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net/smc: fix error return code in smc_setsockopt()
@ 2018-05-31  2:31 ` Wei Yongjun
  0 siblings, 0 replies; 6+ messages in thread
From: Wei Yongjun @ 2018-05-31  2:31 UTC (permalink / raw)
  To: Ursula Braun; +Cc: Wei Yongjun, linux-s390, netdev, kernel-janitors

Fix to return error code -EINVAL instead of 0 if optlen is invalid.

Fixes: 01d2f7e2cdd3 ("net/smc: sockopts TCP_NODELAY and TCP_CORK")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 net/smc/af_smc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 2c369d4..973b447 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -1420,7 +1420,7 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
 		return rc;
 
 	if (optlen < sizeof(int))
-		return rc;
+		return -EINVAL;
 	get_user(val, (int __user *)optval);
 
 	lock_sock(sk);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next] net/smc: fix error return code in smc_setsockopt()
@ 2018-05-31  2:31 ` Wei Yongjun
  0 siblings, 0 replies; 6+ messages in thread
From: Wei Yongjun @ 2018-05-31  2:31 UTC (permalink / raw)
  To: Ursula Braun; +Cc: Wei Yongjun, linux-s390, netdev, kernel-janitors

Fix to return error code -EINVAL instead of 0 if optlen is invalid.

Fixes: 01d2f7e2cdd3 ("net/smc: sockopts TCP_NODELAY and TCP_CORK")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 net/smc/af_smc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 2c369d4..973b447 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -1420,7 +1420,7 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
 		return rc;
 
 	if (optlen < sizeof(int))
-		return rc;
+		return -EINVAL;
 	get_user(val, (int __user *)optval);
 
 	lock_sock(sk);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] net/smc: fix error return code in smc_setsockopt()
  2018-05-31  2:31 ` Wei Yongjun
@ 2018-06-01  7:02   ` Ursula Braun
  -1 siblings, 0 replies; 6+ messages in thread
From: Ursula Braun @ 2018-06-01  7:02 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: linux-s390, netdev, kernel-janitors



On 05/31/2018 04:31 AM, Wei Yongjun wrote:
> Fix to return error code -EINVAL instead of 0 if optlen is invalid.
> 
> Fixes: 01d2f7e2cdd3 ("net/smc: sockopts TCP_NODELAY and TCP_CORK")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  net/smc/af_smc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
> index 2c369d4..973b447 100644
> --- a/net/smc/af_smc.c
> +++ b/net/smc/af_smc.c
> @@ -1420,7 +1420,7 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
>  		return rc;
>  
>  	if (optlen < sizeof(int))
> -		return rc;
> +		return -EINVAL;
>  	get_user(val, (int __user *)optval);
>  
>  	lock_sock(sk);
> 

Thanks for reporting this error. Your fix is fine, but I think we can get rid of
this check at all, since it is already checked in the tcp-code invoked before with

   smc->clcsock->ops->setsockopt(smc->clcsock, level, optname, optval, optlen)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] net/smc: fix error return code in smc_setsockopt()
@ 2018-06-01  7:02   ` Ursula Braun
  0 siblings, 0 replies; 6+ messages in thread
From: Ursula Braun @ 2018-06-01  7:02 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: linux-s390, netdev, kernel-janitors



On 05/31/2018 04:31 AM, Wei Yongjun wrote:
> Fix to return error code -EINVAL instead of 0 if optlen is invalid.
> 
> Fixes: 01d2f7e2cdd3 ("net/smc: sockopts TCP_NODELAY and TCP_CORK")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  net/smc/af_smc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
> index 2c369d4..973b447 100644
> --- a/net/smc/af_smc.c
> +++ b/net/smc/af_smc.c
> @@ -1420,7 +1420,7 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
>  		return rc;
>  
>  	if (optlen < sizeof(int))
> -		return rc;
> +		return -EINVAL;
>  	get_user(val, (int __user *)optval);
>  
>  	lock_sock(sk);
> 

Thanks for reporting this error. Your fix is fine, but I think we can get rid of
this check at all, since it is already checked in the tcp-code invoked before with

   smc->clcsock->ops->setsockopt(smc->clcsock, level, optname, optval, optlen)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] net/smc: fix error return code in smc_setsockopt()
  2018-05-31  2:31 ` Wei Yongjun
@ 2018-06-03 14:39   ` David Miller
  -1 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2018-06-03 14:39 UTC (permalink / raw)
  To: weiyongjun1; +Cc: ubraun, linux-s390, netdev, kernel-janitors

From: Wei Yongjun <weiyongjun1@huawei.com>
Date: Thu, 31 May 2018 02:31:22 +0000

> Fix to return error code -EINVAL instead of 0 if optlen is invalid.
> 
> Fixes: 01d2f7e2cdd3 ("net/smc: sockopts TCP_NODELAY and TCP_CORK")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Although the TCP code should be checking this in the previous lines,
it's not good practice to depend so tightly upon that.

And it makes this code easier to audit if the check exists here
explicitly too.

So I'll apply this, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next] net/smc: fix error return code in smc_setsockopt()
@ 2018-06-03 14:39   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2018-06-03 14:39 UTC (permalink / raw)
  To: weiyongjun1; +Cc: ubraun, linux-s390, netdev, kernel-janitors

From: Wei Yongjun <weiyongjun1@huawei.com>
Date: Thu, 31 May 2018 02:31:22 +0000

> Fix to return error code -EINVAL instead of 0 if optlen is invalid.
> 
> Fixes: 01d2f7e2cdd3 ("net/smc: sockopts TCP_NODELAY and TCP_CORK")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Although the TCP code should be checking this in the previous lines,
it's not good practice to depend so tightly upon that.

And it makes this code easier to audit if the check exists here
explicitly too.

So I'll apply this, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-06-03 14:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-31  2:31 [PATCH net-next] net/smc: fix error return code in smc_setsockopt() Wei Yongjun
2018-05-31  2:31 ` Wei Yongjun
2018-06-01  7:02 ` Ursula Braun
2018-06-01  7:02   ` Ursula Braun
2018-06-03 14:39 ` David Miller
2018-06-03 14:39   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.