summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorent Revest <revest@chromium.org>2023-12-06 13:37:18 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-12-20 15:38:03 +0100
commite900ebbc511d2493123c1fd83d5665fa2ad12eff (patch)
treeb9e62c02e942b177eaef9bd4eba9cc02e5d9c9d3
parent81468a9a1b42cc7ca68fef96fd319c394133cced (diff)
downloadlinux-stable-e900ebbc511d2493123c1fd83d5665fa2ad12eff.tar.gz
linux-stable-e900ebbc511d2493123c1fd83d5665fa2ad12eff.tar.bz2
linux-stable-e900ebbc511d2493123c1fd83d5665fa2ad12eff.zip
team: Fix use-after-free when an option instance allocation fails
commit c12296bbecc488623b7d1932080e394d08f3226b upstream. 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. Cc: stable@vger.kernel.org Fixes: 80f7c6683fe0 ("team: add support for per-port options") Signed-off-by: Florent Revest <revest@chromium.org> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Reviewed-by: Hangbin Liu <liuhangbin@gmail.com> Link: https://lore.kernel.org/r/20231206123719.1963153-1-revest@chromium.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/net/team/team.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 08f9530fd5b1..05c3e539cb0a 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -291,8 +291,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: