Skip to content

Commit 9528656

Browse files
author
Hangbin Liu
committed
team: Fix use-after-free when an option instance allocation fails
JIRA: https://issues.redhat.com/browse/RHEL-31052 Upstream Status: net.git commit c12296b commit c12296b Author: Florent Revest <revest@chromium.org> Date: Wed Dec 6 13:37:18 2023 +0100 team: Fix use-after-free when an option instance allocation fails 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: 80f7c66 ("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: Hangbin Liu <haliu@redhat.com>
1 parent be39b27 commit 9528656

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/net/team/team.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,10 @@ static int __team_options_register(struct team *team,
285285
return 0;
286286

287287
inst_rollback:
288-
for (i--; i >= 0; i--)
288+
for (i--; i >= 0; i--) {
289289
__team_option_inst_del_option(team, dst_opts[i]);
290+
list_del(&dst_opts[i]->list);
291+
}
290292

291293
i = option_count;
292294
alloc_rollback:

0 commit comments

Comments
 (0)