netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xin Long <lucien.xin@gmail.com>
To: Wei Yongjun <weiyongjun1@huawei.com>
Cc: Vlad Yasevich <vyasevich@gmail.com>,
	Neil Horman <nhorman@tuxdriver.com>,
	linux-sctp@vger.kernel.org, network dev <netdev@vger.kernel.org>,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()
Date: Mon, 12 Mar 2018 21:38:53 +0800	[thread overview]
Message-ID: <CADvbK_fFdFJ4uREOP2bAYShB_TkP5Xi3d0v1_YodazNYyMjAdw@mail.gmail.com> (raw)
In-Reply-To: <1520856964-132516-1-git-send-email-weiyongjun1@huawei.com>

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.

  reply	other threads:[~2018-03-12 13:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-12 12:16 [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc() Wei Yongjun
2018-03-12 13:38 ` Xin Long [this message]
2018-03-12 15:50   ` Marcelo Ricardo Leitner
2018-03-12 15:19 ` David Miller
2018-03-12 17:34   ` Xin Long
2018-03-12 15:40 ` Neil Horman
2018-03-13  3:03 ` [PATCH net-next v2] " Wei Yongjun
2018-03-13  6:57   ` Xin Long
2018-03-13 10:48   ` Neil Horman
2018-03-13 14:45   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADvbK_fFdFJ4uREOP2bAYShB_TkP5Xi3d0v1_YodazNYyMjAdw@mail.gmail.com \
    --to=lucien.xin@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-sctp@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=vyasevich@gmail.com \
    --cc=weiyongjun1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).