Skip to content

Commit c12296b

Browse files
FlorentRevestkuba-moo
authored andcommitted
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: [email protected] Fixes: 80f7c66 ("team: add support for per-port options") Signed-off-by: Florent Revest <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Reviewed-by: Hangbin Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent bd4a816 commit c12296b

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
@@ -281,8 +281,10 @@ static int __team_options_register(struct team *team,
281281
return 0;
282282

283283
inst_rollback:
284-
for (i--; i >= 0; i--)
284+
for (i--; i >= 0; i--) {
285285
__team_option_inst_del_option(team, dst_opts[i]);
286+
list_del(&dst_opts[i]->list);
287+
}
286288

287289
i = option_count;
288290
alloc_rollback:

0 commit comments

Comments
 (0)