[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZXCNouKlBlAKgll9@Laptop-X1>
Date: Wed, 6 Dec 2023 23:05:06 +0800
From: Hangbin Liu <liuhangbin@...il.com>
To: Florent Revest <revest@...omium.org>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
jiri@...nulli.us, davem@...emloft.net, edumazet@...gle.com,
kuba@...nel.org, pabeni@...hat.com
Subject: Re: [PATCH] team: Fix use-after-free when an option instance
allocation fails
On Wed, Dec 06, 2023 at 01:37:18PM +0100, Florent Revest wrote:
> In __team_options_register, team_options are allocated and appended to
> the team's option_list.
> If one option instance allocation fails, the "inst_rollback" cleanup
> path frees the previously allocated options but doesn't remove them from
> the team's option_list.
> This leaves dangling pointers that can be dereferenced later by other
> parts of the team driver that iterate over options.
>
> This patch fixes the cleanup path to remove the dangling pointers from
> the list.
>
> As far as I can tell, this uaf doesn't have much security implications
> since it would be fairly hard to exploit (an attacker would need to make
> the allocation of that specific small object fail) but it's still nice
> to fix.
>
> Fixes: 80f7c6683fe0 ("team: add support for per-port options")
> Signed-off-by: Florent Revest <revest@...omium.org>
> ---
> drivers/net/team/team.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
> index 508d9a392ab18..f575f225d4178 100644
> --- a/drivers/net/team/team.c
> +++ b/drivers/net/team/team.c
> @@ -281,8 +281,10 @@ static int __team_options_register(struct team *team,
> return 0;
>
> inst_rollback:
> - for (i--; i >= 0; i--)
> + for (i--; i >= 0; i--) {
> __team_option_inst_del_option(team, dst_opts[i]);
> + list_del(&dst_opts[i]->list);
> + }
>
> i = option_count;
> alloc_rollback:
> --
> 2.43.0.rc2.451.g8631bc7472-goog
>
Reviewed-by: Hangbin Liu <liuhangbin@...il.com>
Powered by blists - more mailing lists