linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Johannes Thumshirn <jthumshirn@suse.de>
Cc: David Sterba <dsterba@suse.com>,
	Linux BTRFS Mailinglist <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] btrfs: free checksum hash on in close_ctree
Date: Wed, 17 Jul 2019 16:56:27 +0200	[thread overview]
Message-ID: <20190717145627.GG20977@twin.jikos.cz> (raw)
In-Reply-To: <20190711152304.11438-1-jthumshirn@suse.de>

On Thu, Jul 11, 2019 at 05:23:04PM +0200, Johannes Thumshirn wrote:
> fs_info::csum_hash gets initialized in btrfs_init_csum_hash() which is
> called by open_ctree().
> 
> But it only gets freed if open_ctree() fails, not on normal operation.
> 
> This leads to a memory leak like the following found by kmemleak:
> unreferenced object 0xffff888132cb8720 (size 96):
>   comm "mount", pid 450, jiffies 4294912436 (age 17.584s)
>   hex dump (first 32 bytes):
>     04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
>   backtrace:
>     [<000000000c9643d4>] crypto_create_tfm+0x2d/0xd0
>     [<00000000ae577f68>] crypto_alloc_tfm+0x4b/0xb0
>     [<000000002b5cdf30>] open_ctree+0xb84/0x2060 [btrfs]
>     [<0000000043204297>] btrfs_mount_root+0x552/0x640 [btrfs]
>     [<00000000c99b10ea>] legacy_get_tree+0x22/0x40
>     [<0000000071a6495f>] vfs_get_tree+0x1f/0xc0
>     [<00000000f180080e>] fc_mount+0x9/0x30
>     [<000000009e36cebd>] vfs_kern_mount.part.11+0x6a/0x80
>     [<0000000004594c05>] btrfs_mount+0x174/0x910 [btrfs]
>     [<00000000c99b10ea>] legacy_get_tree+0x22/0x40
>     [<0000000071a6495f>] vfs_get_tree+0x1f/0xc0
>     [<00000000b86e92c5>] do_mount+0x6b0/0x940
>     [<0000000097464494>] ksys_mount+0x7b/0xd0
>     [<0000000057213c80>] __x64_sys_mount+0x1c/0x20
>     [<00000000cb689b5e>] do_syscall_64+0x43/0x130
>     [<000000002194e289>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
> 
> Free fs_info::csum_hash in close_ctree() to avoid the memory leak.
> 
> Fixes: 6d97c6e31b55 ("btrfs: add boilerplate code for directly including the crypto framework")
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>

Added to 5.3 queue, thanks.

      parent reply	other threads:[~2019-07-17 14:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-11 15:23 [PATCH] btrfs: free checksum hash on in close_ctree Johannes Thumshirn
2019-07-12  7:34 ` Qu Wenruo
2019-07-12  9:21   ` Johannes Thumshirn
2019-07-17 14:02     ` David Sterba
2019-07-17 14:56 ` David Sterba [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=20190717145627.GG20977@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=dsterba@suse.com \
    --cc=jthumshirn@suse.de \
    --cc=linux-btrfs@vger.kernel.org \
    /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).