Skip to content

Commit

Permalink
uprobes: Guard against kmemdup() failing in dup_return_instance()
Browse files Browse the repository at this point in the history
If kmemdup() failed to alloc memory, don't proceed with extra_consumers
copy.

Fixes: e62f2d492728 ("uprobes: Simplify session consumer tracking")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20241206183436.968068-1-andrii@kernel.org
  • Loading branch information
Andrii Nakryiko authored and Ingo Molnar committed Dec 9, 2024
1 parent d29e744 commit 02c5636
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kernel/events/uprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,8 @@ static struct return_instance *dup_return_instance(struct return_instance *old)
struct return_instance *ri;

ri = kmemdup(old, sizeof(*ri), GFP_KERNEL);
if (!ri)
return NULL;

if (unlikely(old->cons_cnt > 1)) {
ri->extra_consumers = kmemdup(old->extra_consumers,
Expand Down

0 comments on commit 02c5636

Please sign in to comment.