All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: fix memory leak in ext4_fill_super
@ 2021-04-28 17:28 Pavel Skripkin
  2021-04-29 10:01 ` Vegard Nossum
  0 siblings, 1 reply; 16+ messages in thread
From: Pavel Skripkin @ 2021-04-28 17:28 UTC (permalink / raw)
  To: tytso, adilger.kernel
  Cc: linux-ext4, linux-kernel, Pavel Skripkin, syzbot+d9e482e303930fa4f6ff

syzbot reported memory leak in ext4 subsyetem.
The problem appears, when thread_stop() call happens
before wake_up_process().

Normally, this data will be freed by
created thread, but if kthread_stop()
returned -EINTR, this data should be freed manually

Reported-by: syzbot+d9e482e303930fa4f6ff@syzkaller.appspotmail.com
Tested-by: syzbot+d9e482e303930fa4f6ff@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
 fs/ext4/super.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index b9693680463a..9c33e97bd5c5 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5156,8 +5156,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 failed_mount3:
 	flush_work(&sbi->s_error_work);
 	del_timer_sync(&sbi->s_err_report);
-	if (sbi->s_mmp_tsk)
-		kthread_stop(sbi->s_mmp_tsk);
+	if (sbi->s_mmp_tsk) {
+		if (kthread_stop(sbi->s_mmp_tsk) == -EINTR)
+			kfree(kthread_data(sbi->s_mmp_tsk));
+	}
 failed_mount2:
 	rcu_read_lock();
 	group_desc = rcu_dereference(sbi->s_group_desc);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* Re: [PATCH] ext4: fix memory leak in ext4_fill_super
@ 2021-05-21  7:43 Alexey Makhalov
  2021-05-21  7:55 ` [PATCH v2] " Alexey Makhalov
  0 siblings, 1 reply; 16+ messages in thread
From: Alexey Makhalov @ 2021-05-21  7:43 UTC (permalink / raw)
  To: Theodore Y. Ts'o; +Cc: linux-ext4, stable, Andreas Dilger

[-- Attachment #1: Type: text/plain, Size: 958 bytes --]

Hi Ted,

Good point! This paragraph can be just dropped as the next one
describes the issue with superblock re-read. Will send v2 shortly.

Thanks,
—Alexey

> On May 20, 2021, at 9:43 PM, Theodore Y. Ts'o <tytso@mit.edu> wrote:
> 
> On Wed, Apr 28, 2021 at 10:19:28PM +0000, Alexey Makhalov wrote:
>> I've recently discovered that doing infinite loop of
>>  systemctl start <ext4_on_lvm>.mount, and
>>  systemctl stop <ext4_on_lvm>.mount
>> linearly increases percpu allocator memory consumption.
>> In several hours, it might lead to system instability by
>> consuming most of the memory.
>> 
>> Bug is not reproducible when the ext4 filesystem is on
>> physical partition, but it is persistent when ext4 is on
>> logical volume.
> 
> Why is this the case?  It sounds like we're looking a buffer for each
> mount where the block size is not 1k.  It shouldn't matter whether it
> is a physical partition or not.
> 
> 				- Ted


[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-06-17  1:15 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-28 17:28 [PATCH] ext4: fix memory leak in ext4_fill_super Pavel Skripkin
2021-04-29 10:01 ` Vegard Nossum
2021-04-29 11:08   ` Pavel Skripkin
2021-04-29 11:33   ` Pavel Skripkin
2021-04-29 17:05     ` Theodore Ts'o
2021-04-29 19:20       ` Pavel Skripkin
2021-04-29 20:09       ` Pavel Skripkin
2021-04-29 21:41         ` Theodore Ts'o
2021-04-29 22:05           ` Pavel Skripkin
2021-04-30  3:44             ` Theodore Ts'o
2021-04-30 18:50               ` [PATCH v2] " Pavel Skripkin
2021-05-17 13:40                 ` Pavel Skripkin
2021-05-17 18:34                   ` Pavel Skripkin
2021-06-05 12:52                     ` [RESEND PATCH " Pavel Skripkin
2021-06-17  1:15                 ` [PATCH " Theodore Ts'o
2021-05-21  7:43 [PATCH] " Alexey Makhalov
2021-05-21  7:55 ` [PATCH v2] " Alexey Makhalov

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.