]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
perf/core: Preserve AUX buffer allocation failure result
authorThomas Gleixner <tglx@linutronix.de>
Mon, 4 Aug 2025 20:22:09 +0000 (22:22 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 14:39:30 +0000 (16:39 +0200)
commit 54473e0ef849f44e5ee43e6d6746c27030c3825b upstream.

A recent overhaul sets the return value to 0 unconditionally after the
allocations, which causes reference count leaks and corrupts the user->vm
accounting.

Preserve the AUX buffer allocation failure return value, so that the
subsequent code works correctly.

Fixes: 0983593f32c4 ("perf/core: Lift event->mmap_mutex in perf_mmap()")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/events/core.c

index 22fdf0c187cd970f59ad8d6de9c1b231f68ec2cb..c05262e15b7d7f6c99ff1ed23565f205030ed6b3 100644 (file)
@@ -7115,6 +7115,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
                perf_event_update_time(event);
                perf_event_init_userpage(event);
                perf_event_update_userpage(event);
+               ret = 0;
        } else {
                ret = rb_alloc_aux(rb, event, vma->vm_pgoff, nr_pages,
                                   event->attr.aux_watermark, flags);
@@ -7122,8 +7123,6 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
                        rb->aux_mmap_locked = extra;
        }
 
-       ret = 0;
-
 unlock:
        if (!ret) {
                atomic_long_add(user_extra, &user->locked_vm);