lkml.org 
[lkml]   [2024]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4.19 5.4 5.15] btrfs: defrag: fix memory leak in btrfs_ioctl_defrag
On Tue, Mar 19, 2024 at 07:57:11PM +0100, David Sterba wrote:
>
> On Tue, Mar 19, 2024 at 05:00:55PM +0000, Maximilian Heyne wrote:
> > Prior to commit c853a5783ebe ("btrfs: allocate
> > btrfs_ioctl_defrag_range_args on stack") range is allocated on the heap
> > and must be freed. However, commit 173431b274a9 ("btrfs: defrag: reject
> > unknown flags of btrfs_ioctl_defrag_range_args") didn't take care of
> > this when it was backported to kernel < 5.15.
> >
> > Add a kfree on the error path for stable kernels that lack
> > commit c853a5783ebe ("btrfs: allocate btrfs_ioctl_defrag_range_args on
> > stack").
> >
> > This bug was discovered and resolved using Coverity Static Analysis
> > Security Testing (SAST) by Synopsys, Inc.
>
> Good catch, thanks.
>
> The affected versions are as you say 4.19, 5.4, 5.15, the fixup is

I had a typo. Should go to 5.10 because c853a5783ebe is already in 5.15.

> sufficient and minimal fix, c853a5783ebe is reasonably safe for backport
> too.

I think you're right. To avoid divergence it might be better to simply
backport c853a5783ebe. Let me send this out.



Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879




\
 
 \ /
  Last update: 2024-05-27 15:55    [W:0.046 / U:0.548 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site