stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Maximilian Heyne <mheyne@amazon.de>
Cc: stable@vger.kernel.org, Chris Mason <clm@fb.com>,
	Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	Filipe Manana <fdmanana@suse.com>, Qu Wenruo <wqu@suse.com>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4.19 5.4 5.15] btrfs: defrag: fix memory leak in btrfs_ioctl_defrag
Date: Tue, 19 Mar 2024 19:57:11 +0100	[thread overview]
Message-ID: <20240319185711.GA14596@suse.cz> (raw)
In-Reply-To: <20240319170055.17942-1-mheyne@amazon.de>

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
sufficient and minimal fix, c853a5783ebe is reasonably safe for backport
too.

  parent reply	other threads:[~2024-03-19 19:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-19 17:00 [PATCH 4.19 5.4 5.15] btrfs: defrag: fix memory leak in btrfs_ioctl_defrag Maximilian Heyne
2024-03-19 17:04 ` kernel test robot
2024-03-19 18:57 ` David Sterba [this message]
2024-03-20  9:27   ` Maximilian Heyne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240319185711.GA14596@suse.cz \
    --to=dsterba@suse.cz \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=fdmanana@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mheyne@amazon.de \
    --cc=stable@vger.kernel.org \
    --cc=wqu@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).