linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fabian Frederick <fabf@skynet.be>
To: tytso@mit.edu, Andreas Dilger <adilger.kernel@dilger.ca>
Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, fabf@skynet.be
Subject: [PATCH 6/6 linux-next] ext4: fix memory leak in ext4_insert_range()
Date: Wed, 24 Aug 2016 22:03:20 +0200	[thread overview]
Message-ID: <1472069000-18897-7-git-send-email-fabf@skynet.be> (raw)
In-Reply-To: <1472069000-18897-1-git-send-email-fabf@skynet.be>

Running xfstests generic/013 with kmemleak gives the following:

unreferenced object 0xffff8801d3d27de0 (size 96):
  comm "fsstress", pid 4941, jiffies 4294860168 (age 53.485s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffffffff818eaaf3>] kmemleak_alloc+0x23/0x40
    [<ffffffff81179805>] __kmalloc+0xf5/0x1d0
    [<ffffffff8122ef5c>] ext4_find_extent+0x1ec/0x2f0
    [<ffffffff8123530c>] ext4_insert_range+0x34c/0x4a0
    [<ffffffff81235942>] ext4_fallocate+0x4e2/0x8b0
    [<ffffffff81181334>] vfs_fallocate+0x134/0x210
    [<ffffffff8118203f>] SyS_fallocate+0x3f/0x60
    [<ffffffff818efa9b>] entry_SYSCALL_64_fastpath+0x13/0x8f
    [<ffffffffffffffff>] 0xffffffffffffffff

Problem seems mitigated by dropping refs and freeing path
when there's no path[depth].p_ext

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 fs/ext4/extents.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 5b0913d..2774df4 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -5711,6 +5711,9 @@ int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len)
 			up_write(&EXT4_I(inode)->i_data_sem);
 			goto out_stop;
 		}
+	} else {
+		ext4_ext_drop_refs(path);
+		kfree(path);
 	}
 
 	ret = ext4_es_remove_extent(inode, offset_lblk,
-- 
2.8.1

  parent reply	other threads:[~2016-08-24 20:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-24 20:03 [PATCH 0/6 linux-next] ext4: fix extent leaking and clean-up Fabian Frederick
2016-08-24 20:03 ` [PATCH 1/6 linux-next] ext4: avoid EXT4_INODE_EXTENTS double checking Fabian Frederick
2016-09-15 15:43   ` Theodore Ts'o
2016-08-24 20:03 ` [PATCH 2/6 linux-next] ext4: remove unneeded test in ext4_alloc_file_blocks() Fabian Frederick
2016-09-15 15:52   ` Theodore Ts'o
2016-08-24 20:03 ` [PATCH 3/6 linux-next] ext4: create EXT4_MAX_BLOCKS() macro Fabian Frederick
2016-09-15 15:55   ` Theodore Ts'o
2016-08-24 20:03 ` [PATCH 4/6 linux-next] ext4: use bool for check in ext4_ext_space_() Fabian Frederick
2016-09-15 15:57   ` Theodore Ts'o
2016-08-24 20:03 ` [PATCH 5/6 linux-next] ext4: remove unused definition Fabian Frederick
2016-09-15 15:59   ` Theodore Ts'o
2016-08-24 20:03 ` Fabian Frederick [this message]
2016-09-15 15:40   ` [PATCH 6/6 linux-next] ext4: fix memory leak in ext4_insert_range() Theodore Ts'o

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=1472069000-18897-7-git-send-email-fabf@skynet.be \
    --to=fabf@skynet.be \
    --cc=adilger.kernel@dilger.ca \
    --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 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).