From: Jakub Kicinski <kuba@kernel.org>
To: Hoang Le <hoang.h.le@dektech.com.au>
Cc: jmaloy@redhat.com, maloy@donjonn.com, ying.xue@windriver.com,
tung.q.nguyen@dektech.com.au, netdev@vger.kernel.org,
tipc-discussion@lists.sourceforge.net,
syzbot+e820fdc8ce362f2dea51@syzkaller.appspotmail.com
Subject: Re: [net] tipc: check attribute length for bearer name
Date: Wed, 1 Jun 2022 17:53:18 -0700 [thread overview]
Message-ID: <20220601175318.1117f8dc@kernel.org> (raw)
In-Reply-To: <20220601014853.4904-1-hoang.h.le@dektech.com.au>
On Wed, 1 Jun 2022 08:48:53 +0700 Hoang Le wrote:
> diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
> index 6d39ca05f249..0fd7554c7cde 100644
> --- a/net/tipc/bearer.c
> +++ b/net/tipc/bearer.c
> @@ -258,10 +258,10 @@ static int tipc_enable_bearer(struct net *net, const char *name,
> char *errstr = "";
> u32 i;
>
> - if (!bearer_name_validate(name, &b_names)) {
> - errstr = "illegal name";
> + if (strlen(name) > TIPC_MAX_BEARER_NAME ||
> + !bearer_name_validate(name, &b_names)) {
The strlen() check looks unnecessary, the first thing
bearer_name_validate() does is:
/* copy bearer name & ensure length is OK */
if (strscpy(name_copy, name, TIPC_MAX_BEARER_NAME) < 0)
return 0;
So it will handle non-terminated or over-sized names correctly already.
> NL_SET_ERR_MSG(extack, "Illegal name");
> - goto rejected;
> + return res;
Seems like we only need the change of goto to return for the fix.
prev parent reply other threads:[~2022-06-02 0:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-01 1:48 [net] tipc: check attribute length for bearer name Hoang Le
2022-06-02 0:53 ` Jakub Kicinski [this message]
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=20220601175318.1117f8dc@kernel.org \
--to=kuba@kernel.org \
--cc=hoang.h.le@dektech.com.au \
--cc=jmaloy@redhat.com \
--cc=maloy@donjonn.com \
--cc=netdev@vger.kernel.org \
--cc=syzbot+e820fdc8ce362f2dea51@syzkaller.appspotmail.com \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=tung.q.nguyen@dektech.com.au \
--cc=ying.xue@windriver.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).