[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220601175318.1117f8dc@kernel.org>
Date: Wed, 1 Jun 2022 17:53:18 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Hoang Le <hoang.h.le@...tech.com.au>
Cc: jmaloy@...hat.com, maloy@...jonn.com, ying.xue@...driver.com,
tung.q.nguyen@...tech.com.au, netdev@...r.kernel.org,
tipc-discussion@...ts.sourceforge.net,
syzbot+e820fdc8ce362f2dea51@...kaller.appspotmail.com
Subject: Re: [net] tipc: check attribute length for bearer name
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.
Powered by blists - more mailing lists