[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241026191255.15528-1-kuniyu@amazon.com>
Date: Sat, 26 Oct 2024 12:12:55 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <christophe.jaillet@...adoo.fr>
CC: <davem@...emloft.net>, <edumazet@...gle.com>, <horms@...nel.org>,
<kernel-janitors@...r.kernel.org>, <kuba@...nel.org>, <kuniyu@...zon.com>,
<linux-kernel@...r.kernel.org>, <netdev@...r.kernel.org>, <pabeni@...hat.com>
Subject: Re: [PATCH] rtnetlink: Fix an error handling path in rtnl_newlink()
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
Date: Sat, 26 Oct 2024 16:17:44 +0200
> When some code has been moved in the commit in Fixes, some "return err;"
> have correctly been changed in goto <some_where_in_the_error_handling_path>
> but this one was missed.
>
> Should "ops->maxtype > RTNL_MAX_TYPE" happen, then some resources would
> leak.
>
> Go through the error handling path to fix these leaks.
>
> Fixes: 0d3008d1a9ae ("rtnetlink: Move ops->validate to rtnl_newlink().")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
Reviewed-by: Kuniyuki Iwashima <kuniyu@...zon.com>
Thanks for catching!
> ---
> Compile tested only
> ---
> net/core/rtnetlink.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index 194a81e5f608..e269fae2b579 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -3829,8 +3829,10 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
> }
>
> if (ops) {
> - if (ops->maxtype > RTNL_MAX_TYPE)
> - return -EINVAL;
> + if (ops->maxtype > RTNL_MAX_TYPE) {
> + ret = -EINVAL;
> + goto put_ops;
> + }
>
> if (ops->maxtype && linkinfo[IFLA_INFO_DATA]) {
> ret = nla_parse_nested_deprecated(tbs->attr, ops->maxtype,
> --
> 2.47.0
Powered by blists - more mailing lists