From: Wei Yongjun <weiyongjun1@huawei.com>
To: Vlad Yasevich <vyasevich@gmail.com>,
Neil Horman <nhorman@tuxdriver.com>,
Xin Long <lucien.xin@gmail.com>
Cc: Wei Yongjun <weiyongjun1@huawei.com>,
<linux-sctp@vger.kernel.org>, <netdev@vger.kernel.org>,
<kernel-janitors@vger.kernel.org>
Subject: [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc()
Date: Mon, 12 Mar 2018 12:16:04 +0000 [thread overview]
Message-ID: <1520856964-132516-1-git-send-email-weiyongjun1@huawei.com> (raw)
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;
next reply other threads:[~2018-03-12 12:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-12 12:16 Wei Yongjun [this message]
2018-03-12 13:38 ` [PATCH net-next] sctp: fix error return code in sctp_sendmsg_new_asoc() Xin Long
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=1520856964-132516-1-git-send-email-weiyongjun1@huawei.com \
--to=weiyongjun1@huawei.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-sctp@vger.kernel.org \
--cc=lucien.xin@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=vyasevich@gmail.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).