uprobes: Guard against kmemdup() failing in dup_return_instance()
authorAndrii Nakryiko <andrii@kernel.org>
Fri, 6 Dec 2024 18:34:36 +0000 (10:34 -0800)
committerIngo Molnar <mingo@kernel.org>
Mon, 9 Dec 2024 14:50:32 +0000 (15:50 +0100)
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
kernel/events/uprobes.c

index 1af950208c2b4b469be974d2b90a32fa5b0798b3..1f75a2f9120676c4967791730adb9e9143885b3d 100644 (file)
@@ -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,