All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Luís Henriques" <lhenriques@suse.de>
To: Eric Biggers <ebiggers@kernel.org>
Cc: Theodore Ts'o <tytso@mit.edu>,
	Andreas Dilger <adilger.kernel@dilger.ca>,
	linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ext4: fix memory leak in ext4_fname_setup_filename() error path
Date: Wed, 02 Aug 2023 09:12:57 +0100	[thread overview]
Message-ID: <87wmydrhfa.fsf@suse.de> (raw)
In-Reply-To: <20230802042305.GB1543@sol.localdomain> (Eric Biggers's message of "Tue, 1 Aug 2023 21:23:05 -0700")

Eric Biggers <ebiggers@kernel.org> writes:

> On Tue, Aug 01, 2023 at 03:41:36PM +0100, Luís Henriques wrote:
>> If casefolding the filename fails, we'll be leaking fscrypt_buf name.
>> Make sure we free it in the error path.
>> 
>> Signed-off-by: Luís Henriques <lhenriques@suse.de>
>> ---
>>  fs/ext4/crypto.c | 2 ++
>>  1 file changed, 2 insertions(+)
>> 
>> diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c
>> index e20ac0654b3f..9e4503b051c4 100644
>> --- a/fs/ext4/crypto.c
>> +++ b/fs/ext4/crypto.c
>> @@ -33,6 +33,8 @@ int ext4_fname_setup_filename(struct inode *dir, const struct qstr *iname,
>>  
>>  #if IS_ENABLED(CONFIG_UNICODE)
>>  	err = ext4_fname_setup_ci_filename(dir, iname, fname);
>> +	if (err)
>> +		fscrypt_free_filename(&name);
>>  #endif
>>  	return err;
>>  }
>
> Doesn't ext4_fname_prepare_lookup() have the same bug?

Doh! I looked into that function too and then completely forgot about it.
It may also call fscrypt_setup_filename(), so it has to do the free in the
error path as well.  I'll send out v2 to include that fix too.

> Also, please include a Fixes tag.

Ok, makes sense.  Thanks!

Cheers,
-- 
Luís

      reply	other threads:[~2023-08-02  8:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01 14:41 [PATCH] ext4: fix memory leak in ext4_fname_setup_filename() error path Luís Henriques
2023-08-02  4:23 ` Eric Biggers
2023-08-02  8:12   ` Luís Henriques [this message]

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=87wmydrhfa.fsf@suse.de \
    --to=lhenriques@suse.de \
    --cc=adilger.kernel@dilger.ca \
    --cc=ebiggers@kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.