All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] sctp: fix error return code in sctp_send_add_streams()
@ 2017-10-31 13:28 ` Wei Yongjun
  0 siblings, 0 replies; 29+ messages in thread
From: Wei Yongjun @ 2017-10-31 13:28 UTC (permalink / raw)
  To: Vlad Yasevich, Neil Horman, Marcelo Ricardo Leitner
  Cc: Wei Yongjun, linux-sctp, netdev

Fix to returnerror code -ENOMEM from the sctp_make_strreset_addstrm()
error handling case instead of 0. 'retval' can be overwritten to 0 after
call sctp_stream_alloc_out().

Fixes: e090abd0d81c ("sctp: factor out stream->out allocation")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 net/sctp/stream.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/sctp/stream.c b/net/sctp/stream.c
index 03764fc..b8c8cab 100644
--- a/net/sctp/stream.c
+++ b/net/sctp/stream.c
@@ -393,7 +393,7 @@ int sctp_send_add_streams(struct sctp_association *asoc,
 {
 	struct sctp_stream *stream = &asoc->stream;
 	struct sctp_chunk *chunk = NULL;
-	int retval = -ENOMEM;
+	int retval;
 	__u32 outcnt, incnt;
 	__u16 out, in;
 
@@ -425,8 +425,10 @@ int sctp_send_add_streams(struct sctp_association *asoc,
 	}
 
 	chunk = sctp_make_strreset_addstrm(asoc, out, in);
-	if (!chunk)
+	if (!chunk) {
+		retval = -ENOMEM;
 		goto out;
+	}
 
 	asoc->strreset_chunk = chunk;
 	sctp_chunk_hold(asoc->strreset_chunk);

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

* [PATCH net-next] sctp: fix error return code in sctp_send_add_streams()
@ 2017-10-31 13:28 ` Wei Yongjun
  0 siblings, 0 replies; 29+ messages in thread
From: Wei Yongjun @ 2017-10-31 13:28 UTC (permalink / raw)
  To: Vlad Yasevich, Neil Horman, Marcelo Ricardo Leitner
  Cc: Wei Yongjun, linux-sctp, netdev

Fix to returnerror code -ENOMEM from the sctp_make_strreset_addstrm()
error handling case instead of 0. 'retval' can be overwritten to 0 after
call sctp_stream_alloc_out().

Fixes: e090abd0d81c ("sctp: factor out stream->out allocation")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 net/sctp/stream.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/sctp/stream.c b/net/sctp/stream.c
index 03764fc..b8c8cab 100644
--- a/net/sctp/stream.c
+++ b/net/sctp/stream.c
@@ -393,7 +393,7 @@ int sctp_send_add_streams(struct sctp_association *asoc,
 {
 	struct sctp_stream *stream = &asoc->stream;
 	struct sctp_chunk *chunk = NULL;
-	int retval = -ENOMEM;
+	int retval;
 	__u32 outcnt, incnt;
 	__u16 out, in;
 
@@ -425,8 +425,10 @@ int sctp_send_add_streams(struct sctp_association *asoc,
 	}
 
 	chunk = sctp_make_strreset_addstrm(asoc, out, in);
-	if (!chunk)
+	if (!chunk) {
+		retval = -ENOMEM;
 		goto out;
+	}
 
 	asoc->strreset_chunk = chunk;
 	sctp_chunk_hold(asoc->strreset_chunk);


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

* Re: [PATCH net-next] sctp: fix error return code in sctp_send_add_streams()
  2017-10-31 13:28 ` Wei Yongjun
@ 2017-10-31 13:33   ` Marcelo Ricardo Leitner
  -1 siblings, 0 replies; 29+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-10-31 13:33 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: Vlad Yasevich, Neil Horman, linux-sctp, netdev

On Tue, Oct 31, 2017 at 01:28:16PM +0000, Wei Yongjun wrote:
> Fix to returnerror code -ENOMEM from the sctp_make_strreset_addstrm()
> error handling case instead of 0. 'retval' can be overwritten to 0 after
> call sctp_stream_alloc_out().
> 
> Fixes: e090abd0d81c ("sctp: factor out stream->out allocation")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

> ---
>  net/sctp/stream.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sctp/stream.c b/net/sctp/stream.c
> index 03764fc..b8c8cab 100644
> --- a/net/sctp/stream.c
> +++ b/net/sctp/stream.c
> @@ -393,7 +393,7 @@ int sctp_send_add_streams(struct sctp_association *asoc,
>  {
>  	struct sctp_stream *stream = &asoc->stream;
>  	struct sctp_chunk *chunk = NULL;
> -	int retval = -ENOMEM;
> +	int retval;
>  	__u32 outcnt, incnt;
>  	__u16 out, in;
>  
> @@ -425,8 +425,10 @@ int sctp_send_add_streams(struct sctp_association *asoc,
>  	}
>  
>  	chunk = sctp_make_strreset_addstrm(asoc, out, in);
> -	if (!chunk)
> +	if (!chunk) {
> +		retval = -ENOMEM;
>  		goto out;
> +	}
>  
>  	asoc->strreset_chunk = chunk;
>  	sctp_chunk_hold(asoc->strreset_chunk);
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH net-next] sctp: fix error return code in sctp_send_add_streams()
@ 2017-10-31 13:33   ` Marcelo Ricardo Leitner
  0 siblings, 0 replies; 29+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-10-31 13:33 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: Vlad Yasevich, Neil Horman, linux-sctp, netdev

On Tue, Oct 31, 2017 at 01:28:16PM +0000, Wei Yongjun wrote:
> Fix to returnerror code -ENOMEM from the sctp_make_strreset_addstrm()
> error handling case instead of 0. 'retval' can be overwritten to 0 after
> call sctp_stream_alloc_out().
> 
> Fixes: e090abd0d81c ("sctp: factor out stream->out allocation")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

> ---
>  net/sctp/stream.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sctp/stream.c b/net/sctp/stream.c
> index 03764fc..b8c8cab 100644
> --- a/net/sctp/stream.c
> +++ b/net/sctp/stream.c
> @@ -393,7 +393,7 @@ int sctp_send_add_streams(struct sctp_association *asoc,
>  {
>  	struct sctp_stream *stream = &asoc->stream;
>  	struct sctp_chunk *chunk = NULL;
> -	int retval = -ENOMEM;
> +	int retval;
>  	__u32 outcnt, incnt;
>  	__u16 out, in;
>  
> @@ -425,8 +425,10 @@ int sctp_send_add_streams(struct sctp_association *asoc,
>  	}
>  
>  	chunk = sctp_make_strreset_addstrm(asoc, out, in);
> -	if (!chunk)
> +	if (!chunk) {
> +		retval = -ENOMEM;
>  		goto out;
> +	}
>  
>  	asoc->strreset_chunk = chunk;
>  	sctp_chunk_hold(asoc->strreset_chunk);
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH net-next] sctp: fix error return code in sctp_send_add_streams()
  2017-10-31 13:28 ` Wei Yongjun
@ 2017-10-31 17:06   ` Neil Horman
  -1 siblings, 0 replies; 29+ messages in thread
From: Neil Horman @ 2017-10-31 17:06 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: Vlad Yasevich, Marcelo Ricardo Leitner, linux-sctp, netdev

On Tue, Oct 31, 2017 at 01:28:16PM +0000, Wei Yongjun wrote:
> Fix to returnerror code -ENOMEM from the sctp_make_strreset_addstrm()
> error handling case instead of 0. 'retval' can be overwritten to 0 after
> call sctp_stream_alloc_out().
> 
> Fixes: e090abd0d81c ("sctp: factor out stream->out allocation")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  net/sctp/stream.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sctp/stream.c b/net/sctp/stream.c
> index 03764fc..b8c8cab 100644
> --- a/net/sctp/stream.c
> +++ b/net/sctp/stream.c
> @@ -393,7 +393,7 @@ int sctp_send_add_streams(struct sctp_association *asoc,
>  {
>  	struct sctp_stream *stream = &asoc->stream;
>  	struct sctp_chunk *chunk = NULL;
> -	int retval = -ENOMEM;
> +	int retval;
>  	__u32 outcnt, incnt;
>  	__u16 out, in;
>  
> @@ -425,8 +425,10 @@ int sctp_send_add_streams(struct sctp_association *asoc,
>  	}
>  
>  	chunk = sctp_make_strreset_addstrm(asoc, out, in);
> -	if (!chunk)
> +	if (!chunk) {
> +		retval = -ENOMEM;
>  		goto out;
> +	}
>  
>  	asoc->strreset_chunk = chunk;
>  	sctp_chunk_hold(asoc->strreset_chunk);
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
Acked-by: Neil Horman <nhorman@tuxdriver.com>

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

* Re: [PATCH net-next] sctp: fix error return code in sctp_send_add_streams()
@ 2017-10-31 17:06   ` Neil Horman
  0 siblings, 0 replies; 29+ messages in thread
From: Neil Horman @ 2017-10-31 17:06 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: Vlad Yasevich, Marcelo Ricardo Leitner, linux-sctp, netdev

On Tue, Oct 31, 2017 at 01:28:16PM +0000, Wei Yongjun wrote:
> Fix to returnerror code -ENOMEM from the sctp_make_strreset_addstrm()
> error handling case instead of 0. 'retval' can be overwritten to 0 after
> call sctp_stream_alloc_out().
> 
> Fixes: e090abd0d81c ("sctp: factor out stream->out allocation")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  net/sctp/stream.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sctp/stream.c b/net/sctp/stream.c
> index 03764fc..b8c8cab 100644
> --- a/net/sctp/stream.c
> +++ b/net/sctp/stream.c
> @@ -393,7 +393,7 @@ int sctp_send_add_streams(struct sctp_association *asoc,
>  {
>  	struct sctp_stream *stream = &asoc->stream;
>  	struct sctp_chunk *chunk = NULL;
> -	int retval = -ENOMEM;
> +	int retval;
>  	__u32 outcnt, incnt;
>  	__u16 out, in;
>  
> @@ -425,8 +425,10 @@ int sctp_send_add_streams(struct sctp_association *asoc,
>  	}
>  
>  	chunk = sctp_make_strreset_addstrm(asoc, out, in);
> -	if (!chunk)
> +	if (!chunk) {
> +		retval = -ENOMEM;
>  		goto out;
> +	}
>  
>  	asoc->strreset_chunk = chunk;
>  	sctp_chunk_hold(asoc->strreset_chunk);
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
Acked-by: Neil Horman <nhorman@tuxdriver.com>


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

* Re: [PATCH net-next] sctp: fix error return code in sctp_send_add_streams()
  2017-10-31 13:28 ` Wei Yongjun
@ 2017-11-01 12:26   ` David Miller
  -1 siblings, 0 replies; 29+ messages in thread
From: David Miller @ 2017-11-01 12:26 UTC (permalink / raw)
  To: weiyongjun1; +Cc: vyasevich, nhorman, marcelo.leitner, linux-sctp, netdev

From: Wei Yongjun <weiyongjun1@huawei.com>
Date: Tue, 31 Oct 2017 13:28:16 +0000

> Fix to returnerror code -ENOMEM from the sctp_make_strreset_addstrm()
> error handling case instead of 0. 'retval' can be overwritten to 0 after
> call sctp_stream_alloc_out().
> 
> Fixes: e090abd0d81c ("sctp: factor out stream->out allocation")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Applied.

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

* Re: [PATCH net-next] sctp: fix error return code in sctp_send_add_streams()
@ 2017-11-01 12:26   ` David Miller
  0 siblings, 0 replies; 29+ messages in thread
From: David Miller @ 2017-11-01 12:26 UTC (permalink / raw)
  To: weiyongjun1; +Cc: vyasevich, nhorman, marcelo.leitner, linux-sctp, netdev

From: Wei Yongjun <weiyongjun1@huawei.com>
Date: Tue, 31 Oct 2017 13:28:16 +0000

> Fix to returnerror code -ENOMEM from the sctp_make_strreset_addstrm()
> error handling case instead of 0. 'retval' can be overwritten to 0 after
> call sctp_stream_alloc_out().
> 
> Fixes: e090abd0d81c ("sctp: factor out stream->out allocation")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Applied.

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

* [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()
  2017-10-31 13:28 ` Wei Yongjun
@ 2018-03-12 12:16 ` Wei Yongjun
  -1 siblings, 0 replies; 29+ messages in thread
From: Wei Yongjun @ 2018-03-12 12:16 UTC (permalink / raw)
  To: Vlad Yasevich, Neil Horman, Xin Long
  Cc: Wei Yongjun, linux-sctp, netdev, kernel-janitors

Return error code -EINVAL in the address len check error handling
case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
in the for loop.

Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 net/sctp/socket.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 7d3476a..5e7bfc2 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
 		memset(daddr, 0, sizeof(*daddr));
 		dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
 		if (cmsg->cmsg_type == SCTP_DSTADDRV4) {
-			if (dlen < sizeof(struct in_addr))
+			if (dlen < sizeof(struct in_addr)) {
+				err = -EINVAL;
 				goto free;
+			}
 
 			dlen = sizeof(struct in_addr);
 			daddr->v4.sin_family = AF_INET;
 			daddr->v4.sin_port = htons(asoc->peer.port);
 			memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
 		} else {
-			if (dlen < sizeof(struct in6_addr))
+			if (dlen < sizeof(struct in6_addr)) {
+				err = -EINVAL;
 				goto free;
+			}
 
 			dlen = sizeof(struct in6_addr);
 			daddr->v6.sin6_family = AF_INET6;

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

* [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()
@ 2018-03-12 12:16 ` Wei Yongjun
  0 siblings, 0 replies; 29+ messages in thread
From: Wei Yongjun @ 2018-03-12 12:16 UTC (permalink / raw)
  To: Vlad Yasevich, Neil Horman, Xin Long
  Cc: Wei Yongjun, linux-sctp, netdev, kernel-janitors

Return error code -EINVAL in the address len check error handling
case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
in the for loop.

Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 net/sctp/socket.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 7d3476a..5e7bfc2 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
 		memset(daddr, 0, sizeof(*daddr));
 		dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
 		if (cmsg->cmsg_type = SCTP_DSTADDRV4) {
-			if (dlen < sizeof(struct in_addr))
+			if (dlen < sizeof(struct in_addr)) {
+				err = -EINVAL;
 				goto free;
+			}
 
 			dlen = sizeof(struct in_addr);
 			daddr->v4.sin_family = AF_INET;
 			daddr->v4.sin_port = htons(asoc->peer.port);
 			memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
 		} else {
-			if (dlen < sizeof(struct in6_addr))
+			if (dlen < sizeof(struct in6_addr)) {
+				err = -EINVAL;
 				goto free;
+			}
 
 			dlen = sizeof(struct in6_addr);
 			daddr->v6.sin6_family = AF_INET6;


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

* Re: [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()
  2018-03-12 12:16 ` Wei Yongjun
@ 2018-03-12 13:38   ` Xin Long
  -1 siblings, 0 replies; 29+ messages in thread
From: Xin Long @ 2018-03-12 13:38 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Vlad Yasevich, Neil Horman, linux-sctp, network dev, kernel-janitors

On Mon, Mar 12, 2018 at 8:16 PM, Wei Yongjun <weiyongjun1@huawei.com> wrote:
> Return error code -EINVAL in the address len check error handling
> case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
> in the for loop.
>
> Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  net/sctp/socket.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 7d3476a..5e7bfc2 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
>                 memset(daddr, 0, sizeof(*daddr));
>                 dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
>                 if (cmsg->cmsg_type == SCTP_DSTADDRV4) {
> -                       if (dlen < sizeof(struct in_addr))
> +                       if (dlen < sizeof(struct in_addr)) {
> +                               err = -EINVAL;
>                                 goto free;
> +                       }
>
>                         dlen = sizeof(struct in_addr);
>                         daddr->v4.sin_family = AF_INET;
>                         daddr->v4.sin_port = htons(asoc->peer.port);
>                         memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
>                 } else {
> -                       if (dlen < sizeof(struct in6_addr))
> +                       if (dlen < sizeof(struct in6_addr)) {
> +                               err = -EINVAL;
>                                 goto free;
> +                       }
>
>                         dlen = sizeof(struct in6_addr);
>                         daddr->v6.sin6_family = AF_INET6;
>
Unfortunately, this can't be fixed right now, because of
https://lkml.org/lkml/2018/3/7/1175
Pls hold it until net-next merges linus tree.

Btw, the 'err' initialization can also be removed in your patch.

Thanks.

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

* Re: [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()
@ 2018-03-12 13:38   ` Xin Long
  0 siblings, 0 replies; 29+ messages in thread
From: Xin Long @ 2018-03-12 13:38 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Vlad Yasevich, Neil Horman, linux-sctp, network dev, kernel-janitors

On Mon, Mar 12, 2018 at 8:16 PM, Wei Yongjun <weiyongjun1@huawei.com> wrote:
> Return error code -EINVAL in the address len check error handling
> case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
> in the for loop.
>
> Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  net/sctp/socket.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 7d3476a..5e7bfc2 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
>                 memset(daddr, 0, sizeof(*daddr));
>                 dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
>                 if (cmsg->cmsg_type = SCTP_DSTADDRV4) {
> -                       if (dlen < sizeof(struct in_addr))
> +                       if (dlen < sizeof(struct in_addr)) {
> +                               err = -EINVAL;
>                                 goto free;
> +                       }
>
>                         dlen = sizeof(struct in_addr);
>                         daddr->v4.sin_family = AF_INET;
>                         daddr->v4.sin_port = htons(asoc->peer.port);
>                         memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
>                 } else {
> -                       if (dlen < sizeof(struct in6_addr))
> +                       if (dlen < sizeof(struct in6_addr)) {
> +                               err = -EINVAL;
>                                 goto free;
> +                       }
>
>                         dlen = sizeof(struct in6_addr);
>                         daddr->v6.sin6_family = AF_INET6;
>
Unfortunately, this can't be fixed right now, because of
https://lkml.org/lkml/2018/3/7/1175
Pls hold it until net-next merges linus tree.

Btw, the 'err' initialization can also be removed in your patch.

Thanks.

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

* Re: [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()
  2018-03-12 12:16 ` Wei Yongjun
@ 2018-03-12 15:19   ` David Miller
  -1 siblings, 0 replies; 29+ messages in thread
From: David Miller @ 2018-03-12 15:19 UTC (permalink / raw)
  To: weiyongjun1
  Cc: vyasevich, nhorman, lucien.xin, linux-sctp, netdev, kernel-janitors

From: Wei Yongjun <weiyongjun1@huawei.com>
Date: Mon, 12 Mar 2018 12:16:04 +0000

> Return error code -EINVAL in the address len check error handling
> case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
> in the for loop.
> 
> Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Xin, I do not want to have a bug fix like this blocked because of that
SCTP options merge nightmare which is of no fault of our own.

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

* Re: [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()
@ 2018-03-12 15:19   ` David Miller
  0 siblings, 0 replies; 29+ messages in thread
From: David Miller @ 2018-03-12 15:19 UTC (permalink / raw)
  To: weiyongjun1
  Cc: vyasevich, nhorman, lucien.xin, linux-sctp, netdev, kernel-janitors

From: Wei Yongjun <weiyongjun1@huawei.com>
Date: Mon, 12 Mar 2018 12:16:04 +0000

> Return error code -EINVAL in the address len check error handling
> case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
> in the for loop.
> 
> Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Xin, I do not want to have a bug fix like this blocked because of that
SCTP options merge nightmare which is of no fault of our own.

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

* Re: [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()
  2018-03-12 12:16 ` Wei Yongjun
@ 2018-03-12 15:40   ` Neil Horman
  -1 siblings, 0 replies; 29+ messages in thread
From: Neil Horman @ 2018-03-12 15:40 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: Vlad Yasevich, Xin Long, linux-sctp, netdev, kernel-janitors

On Mon, Mar 12, 2018 at 12:16:04PM +0000, Wei Yongjun wrote:
> Return error code -EINVAL in the address len check error handling
> case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
> in the for loop.
> 
> Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  net/sctp/socket.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 7d3476a..5e7bfc2 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
>  		memset(daddr, 0, sizeof(*daddr));
>  		dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
>  		if (cmsg->cmsg_type == SCTP_DSTADDRV4) {
> -			if (dlen < sizeof(struct in_addr))
> +			if (dlen < sizeof(struct in_addr)) {
> +				err = -EINVAL;
>  				goto free;
> +			}
>  
>  			dlen = sizeof(struct in_addr);
>  			daddr->v4.sin_family = AF_INET;
>  			daddr->v4.sin_port = htons(asoc->peer.port);
>  			memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
>  		} else {
> -			if (dlen < sizeof(struct in6_addr))
> +			if (dlen < sizeof(struct in6_addr)) {
> +				err = -EINVAL;
>  				goto free;
> +			}
>  
>  			dlen = sizeof(struct in6_addr);
>  			daddr->v6.sin6_family = AF_INET6;
> 
> 
Acked-by: Neil Horman <nhorman@tuxdriver.com>

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

* Re: [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()
@ 2018-03-12 15:40   ` Neil Horman
  0 siblings, 0 replies; 29+ messages in thread
From: Neil Horman @ 2018-03-12 15:40 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: Vlad Yasevich, Xin Long, linux-sctp, netdev, kernel-janitors

On Mon, Mar 12, 2018 at 12:16:04PM +0000, Wei Yongjun wrote:
> Return error code -EINVAL in the address len check error handling
> case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
> in the for loop.
> 
> Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  net/sctp/socket.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 7d3476a..5e7bfc2 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
>  		memset(daddr, 0, sizeof(*daddr));
>  		dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
>  		if (cmsg->cmsg_type = SCTP_DSTADDRV4) {
> -			if (dlen < sizeof(struct in_addr))
> +			if (dlen < sizeof(struct in_addr)) {
> +				err = -EINVAL;
>  				goto free;
> +			}
>  
>  			dlen = sizeof(struct in_addr);
>  			daddr->v4.sin_family = AF_INET;
>  			daddr->v4.sin_port = htons(asoc->peer.port);
>  			memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
>  		} else {
> -			if (dlen < sizeof(struct in6_addr))
> +			if (dlen < sizeof(struct in6_addr)) {
> +				err = -EINVAL;
>  				goto free;
> +			}
>  
>  			dlen = sizeof(struct in6_addr);
>  			daddr->v6.sin6_family = AF_INET6;
> 
> 
Acked-by: Neil Horman <nhorman@tuxdriver.com>


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

* Re: [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()
  2018-03-12 13:38   ` Xin Long
@ 2018-03-12 15:50     ` Marcelo Ricardo Leitner
  -1 siblings, 0 replies; 29+ messages in thread
From: Marcelo Ricardo Leitner @ 2018-03-12 15:50 UTC (permalink / raw)
  To: Xin Long
  Cc: Wei Yongjun, Vlad Yasevich, Neil Horman, linux-sctp, network dev,
	kernel-janitors

On Mon, Mar 12, 2018 at 09:38:53PM +0800, Xin Long wrote:
> On Mon, Mar 12, 2018 at 8:16 PM, Wei Yongjun <weiyongjun1@huawei.com> wrote:
...
> Btw, the 'err' initialization can also be removed in your patch.
 
I second this.

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

* Re: [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()
@ 2018-03-12 15:50     ` Marcelo Ricardo Leitner
  0 siblings, 0 replies; 29+ messages in thread
From: Marcelo Ricardo Leitner @ 2018-03-12 15:50 UTC (permalink / raw)
  To: Xin Long
  Cc: Wei Yongjun, Vlad Yasevich, Neil Horman, linux-sctp, network dev,
	kernel-janitors

On Mon, Mar 12, 2018 at 09:38:53PM +0800, Xin Long wrote:
> On Mon, Mar 12, 2018 at 8:16 PM, Wei Yongjun <weiyongjun1@huawei.com> wrote:
...
> Btw, the 'err' initialization can also be removed in your patch.
 
I second this.


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

* Re: [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()
  2018-03-12 15:19   ` David Miller
@ 2018-03-12 17:34     ` Xin Long
  -1 siblings, 0 replies; 29+ messages in thread
From: Xin Long @ 2018-03-12 17:34 UTC (permalink / raw)
  To: David Miller
  Cc: Wei Yongjun, Vlad Yasevich, Neil Horman, linux-sctp, network dev,
	kernel-janitors

On Mon, Mar 12, 2018 at 11:19 PM, David Miller <davem@davemloft.net> wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> Date: Mon, 12 Mar 2018 12:16:04 +0000
>
>> Return error code -EINVAL in the address len check error handling
>> case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
>> in the for loop.
>>
>> Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
>> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
>
> Xin, I do not want to have a bug fix like this blocked because of that
> SCTP options merge nightmare which is of no fault of our own.
Okay, sorry, I was over worried recently, thank you.

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

* Re: [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()
@ 2018-03-12 17:34     ` Xin Long
  0 siblings, 0 replies; 29+ messages in thread
From: Xin Long @ 2018-03-12 17:34 UTC (permalink / raw)
  To: David Miller
  Cc: Wei Yongjun, Vlad Yasevich, Neil Horman, linux-sctp, network dev,
	kernel-janitors

On Mon, Mar 12, 2018 at 11:19 PM, David Miller <davem@davemloft.net> wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> Date: Mon, 12 Mar 2018 12:16:04 +0000
>
>> Return error code -EINVAL in the address len check error handling
>> case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
>> in the for loop.
>>
>> Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
>> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
>
> Xin, I do not want to have a bug fix like this blocked because of that
> SCTP options merge nightmare which is of no fault of our own.
Okay, sorry, I was over worried recently, thank you.

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

* [PATCH net-next v2] sctp: fix error return code in sctp_sendmsg_new_asoc()
  2018-03-12 12:16 ` Wei Yongjun
  (?)
@ 2018-03-13  2:57   ` Wei Yongjun
  -1 siblings, 0 replies; 29+ messages in thread
From: Wei Yongjun @ 2018-03-13  2:57 UTC (permalink / raw)
  To: Vlad Yasevich, Neil Horman, Xin Long
  Cc: Wei Yongjun, linux-sctp, netdev, kernel-janitors

Return error code -EINVAL in the address len check error handling
case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
in the for loop.

Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
---
v1 -> v2: remove the 'err' initialization
---
 net/sctp/socket.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 7d3476a..af5cf29 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1677,7 +1677,7 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
 	struct sctp_association *asoc;
 	enum sctp_scope scope;
 	struct cmsghdr *cmsg;
-	int err = -EINVAL;
+	int err;
 
 	*tp = NULL;
 
@@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
 		memset(daddr, 0, sizeof(*daddr));
 		dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
 		if (cmsg->cmsg_type = SCTP_DSTADDRV4) {
-			if (dlen < sizeof(struct in_addr))
+			if (dlen < sizeof(struct in_addr)) {
+				err = -EINVAL;
 				goto free;
+			}
 
 			dlen = sizeof(struct in_addr);
 			daddr->v4.sin_family = AF_INET;
 			daddr->v4.sin_port = htons(asoc->peer.port);
 			memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
 		} else {
-			if (dlen < sizeof(struct in6_addr))
+			if (dlen < sizeof(struct in6_addr)) {
+				err = -EINVAL;
 				goto free;
+			}
 
 			dlen = sizeof(struct in6_addr);
 			daddr->v6.sin6_family = AF_INET6;


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

* [PATCH net-next v2] sctp: fix error return code in sctp_sendmsg_new_asoc()
@ 2018-03-13  2:57   ` Wei Yongjun
  0 siblings, 0 replies; 29+ messages in thread
From: Wei Yongjun @ 2018-03-13  2:57 UTC (permalink / raw)
  To: Vlad Yasevich, Neil Horman, Xin Long
  Cc: Wei Yongjun, linux-sctp, netdev, kernel-janitors

Return error code -EINVAL in the address len check error handling
case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
in the for loop.

Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
---
v1 -> v2: remove the 'err' initialization
---
 net/sctp/socket.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 7d3476a..af5cf29 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1677,7 +1677,7 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
 	struct sctp_association *asoc;
 	enum sctp_scope scope;
 	struct cmsghdr *cmsg;
-	int err = -EINVAL;
+	int err;
 
 	*tp = NULL;
 
@@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
 		memset(daddr, 0, sizeof(*daddr));
 		dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
 		if (cmsg->cmsg_type = SCTP_DSTADDRV4) {
-			if (dlen < sizeof(struct in_addr))
+			if (dlen < sizeof(struct in_addr)) {
+				err = -EINVAL;
 				goto free;
+			}
 
 			dlen = sizeof(struct in_addr);
 			daddr->v4.sin_family = AF_INET;
 			daddr->v4.sin_port = htons(asoc->peer.port);
 			memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
 		} else {
-			if (dlen < sizeof(struct in6_addr))
+			if (dlen < sizeof(struct in6_addr)) {
+				err = -EINVAL;
 				goto free;
+			}
 
 			dlen = sizeof(struct in6_addr);
 			daddr->v6.sin6_family = AF_INET6;


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

* [PATCH net-next v2] sctp: fix error return code in sctp_sendmsg_new_asoc()
@ 2018-03-13  2:57   ` Wei Yongjun
  0 siblings, 0 replies; 29+ messages in thread
From: Wei Yongjun @ 2018-03-13  3:03 UTC (permalink / raw)
  To: Vlad Yasevich, Neil Horman, Xin Long
  Cc: Wei Yongjun, linux-sctp, netdev, kernel-janitors

Return error code -EINVAL in the address len check error handling
case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
in the for loop.

Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
---
v1 -> v2: remove the 'err' initialization
---
 net/sctp/socket.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 7d3476a..af5cf29 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1677,7 +1677,7 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
 	struct sctp_association *asoc;
 	enum sctp_scope scope;
 	struct cmsghdr *cmsg;
-	int err = -EINVAL;
+	int err;
 
 	*tp = NULL;
 
@@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
 		memset(daddr, 0, sizeof(*daddr));
 		dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
 		if (cmsg->cmsg_type == SCTP_DSTADDRV4) {
-			if (dlen < sizeof(struct in_addr))
+			if (dlen < sizeof(struct in_addr)) {
+				err = -EINVAL;
 				goto free;
+			}
 
 			dlen = sizeof(struct in_addr);
 			daddr->v4.sin_family = AF_INET;
 			daddr->v4.sin_port = htons(asoc->peer.port);
 			memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
 		} else {
-			if (dlen < sizeof(struct in6_addr))
+			if (dlen < sizeof(struct in6_addr)) {
+				err = -EINVAL;
 				goto free;
+			}
 
 			dlen = sizeof(struct in6_addr);
 			daddr->v6.sin6_family = AF_INET6;

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

* Re: [PATCH net-next v2] sctp: fix error return code in sctp_sendmsg_new_asoc()
  2018-03-13  2:57   ` Wei Yongjun
@ 2018-03-13  6:57     ` Xin Long
  -1 siblings, 0 replies; 29+ messages in thread
From: Xin Long @ 2018-03-13  6:57 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Vlad Yasevich, Neil Horman, linux-sctp, network dev, kernel-janitors

On Tue, Mar 13, 2018 at 11:03 AM, Wei Yongjun <weiyongjun1@huawei.com> wrote:
> Return error code -EINVAL in the address len check error handling
> case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
> in the for loop.
>
> Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> Acked-by: Neil Horman <nhorman@tuxdriver.com>
> ---
> v1 -> v2: remove the 'err' initialization
> ---
>  net/sctp/socket.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 7d3476a..af5cf29 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -1677,7 +1677,7 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
>         struct sctp_association *asoc;
>         enum sctp_scope scope;
>         struct cmsghdr *cmsg;
> -       int err = -EINVAL;
> +       int err;
>
>         *tp = NULL;
>
> @@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
>                 memset(daddr, 0, sizeof(*daddr));
>                 dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
>                 if (cmsg->cmsg_type == SCTP_DSTADDRV4) {
> -                       if (dlen < sizeof(struct in_addr))
> +                       if (dlen < sizeof(struct in_addr)) {
> +                               err = -EINVAL;
>                                 goto free;
> +                       }
>
>                         dlen = sizeof(struct in_addr);
>                         daddr->v4.sin_family = AF_INET;
>                         daddr->v4.sin_port = htons(asoc->peer.port);
>                         memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
>                 } else {
> -                       if (dlen < sizeof(struct in6_addr))
> +                       if (dlen < sizeof(struct in6_addr)) {
> +                               err = -EINVAL;
>                                 goto free;
> +                       }
>
>                         dlen = sizeof(struct in6_addr);
>                         daddr->v6.sin6_family = AF_INET6;
>
Reviewed-by: Xin Long <lucien.xin@gmail.com>

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

* Re: [PATCH net-next v2] sctp: fix error return code in sctp_sendmsg_new_asoc()
@ 2018-03-13  6:57     ` Xin Long
  0 siblings, 0 replies; 29+ messages in thread
From: Xin Long @ 2018-03-13  6:57 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Vlad Yasevich, Neil Horman, linux-sctp, network dev, kernel-janitors

On Tue, Mar 13, 2018 at 11:03 AM, Wei Yongjun <weiyongjun1@huawei.com> wrote:
> Return error code -EINVAL in the address len check error handling
> case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
> in the for loop.
>
> Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> Acked-by: Neil Horman <nhorman@tuxdriver.com>
> ---
> v1 -> v2: remove the 'err' initialization
> ---
>  net/sctp/socket.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 7d3476a..af5cf29 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -1677,7 +1677,7 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
>         struct sctp_association *asoc;
>         enum sctp_scope scope;
>         struct cmsghdr *cmsg;
> -       int err = -EINVAL;
> +       int err;
>
>         *tp = NULL;
>
> @@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
>                 memset(daddr, 0, sizeof(*daddr));
>                 dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
>                 if (cmsg->cmsg_type = SCTP_DSTADDRV4) {
> -                       if (dlen < sizeof(struct in_addr))
> +                       if (dlen < sizeof(struct in_addr)) {
> +                               err = -EINVAL;
>                                 goto free;
> +                       }
>
>                         dlen = sizeof(struct in_addr);
>                         daddr->v4.sin_family = AF_INET;
>                         daddr->v4.sin_port = htons(asoc->peer.port);
>                         memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
>                 } else {
> -                       if (dlen < sizeof(struct in6_addr))
> +                       if (dlen < sizeof(struct in6_addr)) {
> +                               err = -EINVAL;
>                                 goto free;
> +                       }
>
>                         dlen = sizeof(struct in6_addr);
>                         daddr->v6.sin6_family = AF_INET6;
>
Reviewed-by: Xin Long <lucien.xin@gmail.com>

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

* Re: [PATCH net-next v2] sctp: fix error return code in sctp_sendmsg_new_asoc()
  2018-03-13  2:57   ` Wei Yongjun
@ 2018-03-13 10:48     ` Neil Horman
  -1 siblings, 0 replies; 29+ messages in thread
From: Neil Horman @ 2018-03-13 10:48 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: Vlad Yasevich, Xin Long, linux-sctp, netdev, kernel-janitors

On Tue, Mar 13, 2018 at 03:03:30AM +0000, Wei Yongjun wrote:
> Return error code -EINVAL in the address len check error handling
> case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
> in the for loop.
> 
> Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> Acked-by: Neil Horman <nhorman@tuxdriver.com>
> ---
> v1 -> v2: remove the 'err' initialization
> ---
>  net/sctp/socket.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 7d3476a..af5cf29 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -1677,7 +1677,7 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
>  	struct sctp_association *asoc;
>  	enum sctp_scope scope;
>  	struct cmsghdr *cmsg;
> -	int err = -EINVAL;
> +	int err;
>  
>  	*tp = NULL;
>  
> @@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
>  		memset(daddr, 0, sizeof(*daddr));
>  		dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
>  		if (cmsg->cmsg_type == SCTP_DSTADDRV4) {
> -			if (dlen < sizeof(struct in_addr))
> +			if (dlen < sizeof(struct in_addr)) {
> +				err = -EINVAL;
>  				goto free;
> +			}
>  
>  			dlen = sizeof(struct in_addr);
>  			daddr->v4.sin_family = AF_INET;
>  			daddr->v4.sin_port = htons(asoc->peer.port);
>  			memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
>  		} else {
> -			if (dlen < sizeof(struct in6_addr))
> +			if (dlen < sizeof(struct in6_addr)) {
> +				err = -EINVAL;
>  				goto free;
> +			}
>  
>  			dlen = sizeof(struct in6_addr);
>  			daddr->v6.sin6_family = AF_INET6;
> 
> 
Acked-by: Neil Horman <nhorman@tuxdriver.com>

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

* Re: [PATCH net-next v2] sctp: fix error return code in sctp_sendmsg_new_asoc()
@ 2018-03-13 10:48     ` Neil Horman
  0 siblings, 0 replies; 29+ messages in thread
From: Neil Horman @ 2018-03-13 10:48 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: Vlad Yasevich, Xin Long, linux-sctp, netdev, kernel-janitors

On Tue, Mar 13, 2018 at 03:03:30AM +0000, Wei Yongjun wrote:
> Return error code -EINVAL in the address len check error handling
> case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
> in the for loop.
> 
> Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> Acked-by: Neil Horman <nhorman@tuxdriver.com>
> ---
> v1 -> v2: remove the 'err' initialization
> ---
>  net/sctp/socket.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 7d3476a..af5cf29 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -1677,7 +1677,7 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
>  	struct sctp_association *asoc;
>  	enum sctp_scope scope;
>  	struct cmsghdr *cmsg;
> -	int err = -EINVAL;
> +	int err;
>  
>  	*tp = NULL;
>  
> @@ -1761,16 +1761,20 @@ static int sctp_sendmsg_new_asoc(struct sock *sk, __u16 sflags,
>  		memset(daddr, 0, sizeof(*daddr));
>  		dlen = cmsg->cmsg_len - sizeof(struct cmsghdr);
>  		if (cmsg->cmsg_type = SCTP_DSTADDRV4) {
> -			if (dlen < sizeof(struct in_addr))
> +			if (dlen < sizeof(struct in_addr)) {
> +				err = -EINVAL;
>  				goto free;
> +			}
>  
>  			dlen = sizeof(struct in_addr);
>  			daddr->v4.sin_family = AF_INET;
>  			daddr->v4.sin_port = htons(asoc->peer.port);
>  			memcpy(&daddr->v4.sin_addr, CMSG_DATA(cmsg), dlen);
>  		} else {
> -			if (dlen < sizeof(struct in6_addr))
> +			if (dlen < sizeof(struct in6_addr)) {
> +				err = -EINVAL;
>  				goto free;
> +			}
>  
>  			dlen = sizeof(struct in6_addr);
>  			daddr->v6.sin6_family = AF_INET6;
> 
> 
Acked-by: Neil Horman <nhorman@tuxdriver.com>

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

* Re: [PATCH net-next v2] sctp: fix error return code in sctp_sendmsg_new_asoc()
  2018-03-13  2:57   ` Wei Yongjun
@ 2018-03-13 14:45     ` David Miller
  -1 siblings, 0 replies; 29+ messages in thread
From: David Miller @ 2018-03-13 14:45 UTC (permalink / raw)
  To: weiyongjun1
  Cc: vyasevich, nhorman, lucien.xin, linux-sctp, netdev, kernel-janitors

From: Wei Yongjun <weiyongjun1@huawei.com>
Date: Tue, 13 Mar 2018 03:03:30 +0000

> Return error code -EINVAL in the address len check error handling
> case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
> in the for loop.
> 
> Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> Acked-by: Neil Horman <nhorman@tuxdriver.com>
> ---
> v1 -> v2: remove the 'err' initialization

Applied, thank you.

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

* Re: [PATCH net-next v2] sctp: fix error return code in sctp_sendmsg_new_asoc()
@ 2018-03-13 14:45     ` David Miller
  0 siblings, 0 replies; 29+ messages in thread
From: David Miller @ 2018-03-13 14:45 UTC (permalink / raw)
  To: weiyongjun1
  Cc: vyasevich, nhorman, lucien.xin, linux-sctp, netdev, kernel-janitors

From: Wei Yongjun <weiyongjun1@huawei.com>
Date: Tue, 13 Mar 2018 03:03:30 +0000

> Return error code -EINVAL in the address len check error handling
> case since 'err' can be overwrite to 0 by 'err = sctp_verify_addr()'
> in the for loop.
> 
> Fixes: 2c0dbaa0c43d ("sctp: add support for SCTP_DSTADDRV4/6 Information for sendmsg")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> Acked-by: Neil Horman <nhorman@tuxdriver.com>
> ---
> v1 -> v2: remove the 'err' initialization

Applied, thank you.

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

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

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-12 12:16 [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc() Wei Yongjun
2018-03-12 12:16 ` Wei Yongjun
2018-03-12 13:38 ` Xin Long
2018-03-12 13:38   ` Xin Long
2018-03-12 15:50   ` Marcelo Ricardo Leitner
2018-03-12 15:50     ` Marcelo Ricardo Leitner
2018-03-12 15:19 ` David Miller
2018-03-12 15:19   ` David Miller
2018-03-12 17:34   ` Xin Long
2018-03-12 17:34     ` Xin Long
2018-03-12 15:40 ` Neil Horman
2018-03-12 15:40   ` Neil Horman
2018-03-13  2:57 ` [PATCH net-next v2] " Wei Yongjun
2018-03-13  3:03   ` Wei Yongjun
2018-03-13  2:57   ` Wei Yongjun
2018-03-13  6:57   ` Xin Long
2018-03-13  6:57     ` Xin Long
2018-03-13 10:48   ` Neil Horman
2018-03-13 10:48     ` Neil Horman
2018-03-13 14:45   ` David Miller
2018-03-13 14:45     ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2017-10-31 13:28 [PATCH net-next] sctp: fix error return code in sctp_send_add_streams() Wei Yongjun
2017-10-31 13:28 ` Wei Yongjun
2017-10-31 13:33 ` Marcelo Ricardo Leitner
2017-10-31 13:33   ` Marcelo Ricardo Leitner
2017-10-31 17:06 ` Neil Horman
2017-10-31 17:06   ` Neil Horman
2017-11-01 12:26 ` David Miller
2017-11-01 12:26   ` 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.