Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1505638

[PATCH 4.4 18/25] ext4: fix memory leak in ext4_insert_range()

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 4.4 18/25] ext4: fix memory leak in ext4_insert_range()
Date 2016-10-21 11:20 +0200
Message-ID <suE9B-3xe-73@gated-at.bofh.it> (permalink)
References <suE9A-3xe-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Fabian Frederick <fabf@skynet.be>

commit edf15aa180d7b98fe16bd3eda42f9dd0e60dee20 upstream.

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>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/ext4/extents.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -5738,6 +5738,9 @@ int ext4_insert_range(struct inode *inod
 			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,

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 4.4 00/25] 4.4.27-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:20 +0200
  [PATCH 4.4 06/25] fuse: fix killing s[ug]id in setattr Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:20 +0200
  [PATCH 4.4 09/25] ASoC: Intel: Atom: add a missing star in a memcpy call Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:20 +0200
  [PATCH 4.4 14/25] scsi: arcmsr: Simplify user_len checking Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:20 +0200
  [PATCH 4.4 01/25] serial: 8250_dw: Check the data->pclk when get apb_pclk Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:20 +0200
  [PATCH 4.4 11/25] reiserfs: switch to generic_{get,set,remove}xattr() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:20 +0200
  [PATCH 4.4 25/25] cfq: fix starvation of asynchronous writes Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:20 +0200
  [PATCH 4.4 18/25] ext4: fix memory leak in ext4_insert_range() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:20 +0200
  [PATCH 4.4 12/25] async_pq_val: fix DMA memory leak Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:20 +0200
  [PATCH 4.4 13/25] scsi: arcmsr: Buffer overflow in arcmsr_iop_message_xfer() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:20 +0200
  [PATCH 4.4 16/25] ext4: enforce online defrag restriction for encrypted files Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:20 +0200
  [PATCH 4.4 03/25] drivers: base: dma-mapping: page align the size when unmap_kernel_range Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:20 +0200
  [PATCH 4.4 02/25] btrfs: assign error values to the correct bio structs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:20 +0200
  [PATCH 4.4 04/25] fuse: listxattr: verify xattr list Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:50 +0200
  [PATCH 4.4 24/25] vfs: move permission checking into notify_change() for utimes(NULL) Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:50 +0200
  [PATCH 4.4 17/25] ext4: reinforce check of i_dtime when clearing high fields of uid and gid Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:50 +0200
  [PATCH 4.4 10/25] reiserfs: Unlock superblock before calling reiserfs_quota_on_mount() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:50 +0200
  [PATCH 4.4 15/25] scsi: ibmvfc: Fix I/O hang when port is not mapped Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:50 +0200
  [PATCH 4.4 20/25] ext4: release bh in make_indexed_dir Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:50 +0200
  [PATCH 4.4 19/25] ext4: allow DAX writeback for hole punch Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:50 +0200
  [PATCH 4.4 22/25] crypto: vmx - Fix memory corruption caused by p8_ghash Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-10-21 11:50 +0200
  Re: [PATCH 4.4 00/25] 4.4.27-stable review Shuah Khan <shuah.kh@samsung.com> - 2016-10-21 17:50 +0200
  Re: [PATCH 4.4 00/25] 4.4.27-stable review Guenter Roeck <linux@roeck-us.net> - 2016-10-21 21:20 +0200

csiph-web