[syzbot] [ntfs3?] memory leak in run_add_entry (2)

0 views
Skip to first unread message

syzbot

unread,
6:56 PM (5 hours ago) 6:56 PM
to almaz.ale...@paragon-software.com, linux-...@vger.kernel.org, nt...@lists.linux.dev, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 0e4f8f1a3d08 Merge tag 'parisc-for-7.0-rc5' of git://git.k..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=129f8cba580000
kernel config: https://syzkaller.appspot.com/x/.config?x=e2bba615ee79faa5
dashboard link: https://syzkaller.appspot.com/bug?extid=7adcddaeeb860e5d3f2f
compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1716bada580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=169f8cba580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/022aea4aa8f7/disk-0e4f8f1a.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/2698fe956577/vmlinux-0e4f8f1a.xz
kernel image: https://storage.googleapis.com/syzbot-assets/49c3df9c1f67/bzImage-0e4f8f1a.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/f0d7b4f7d563/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+7adcdd...@syzkaller.appspotmail.com

BUG: memory leak
unreferenced object 0xffff88811e304200 (size 64):
comm "syz.0.17", pid 6098, jiffies 4294950427
hex dump (first 32 bytes):
00 00 00 00 01 00 00 00 1e 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc 692543f4):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
slab_post_alloc_hook mm/slub.c:4543 [inline]
slab_alloc_node mm/slub.c:4866 [inline]
__do_kmalloc_node mm/slub.c:5259 [inline]
__kvmalloc_node_noprof+0x53d/0x770 mm/slub.c:6752
run_add_entry+0x108/0x730 fs/ntfs3/run.c:390
attr_allocate_clusters+0x15a/0x450 fs/ntfs3/attrib.c:199
indx_create_allocate fs/ntfs3/index.c:1449 [inline]
indx_insert_into_root+0x575/0xb20 fs/ntfs3/index.c:1705
indx_insert_entry+0x182/0x290 fs/ntfs3/index.c:1993
ni_add_name+0x1ab/0x2e0 fs/ntfs3/frecord.c:2764
ntfs_link_inode+0x95/0xc0 fs/ntfs3/inode.c:1794
ntfs_link+0xb4/0x180 fs/ntfs3/namei.c:146
vfs_link+0x270/0x5a0 fs/namei.c:5746
filename_linkat+0x262/0x3c0 fs/namei.c:5814
__do_sys_link fs/namei.c:5847 [inline]
__se_sys_link fs/namei.c:5843 [inline]
__x64_sys_link+0x4b/0x70 fs/namei.c:5843
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xe2/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f

BUG: memory leak
unreferenced object 0xffff888105b7a380 (size 64):
comm "syz.0.18", pid 6114, jiffies 4294950436
hex dump (first 32 bytes):
00 00 00 00 01 00 00 00 1e 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc 692543f4):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
slab_post_alloc_hook mm/slub.c:4543 [inline]
slab_alloc_node mm/slub.c:4866 [inline]
__do_kmalloc_node mm/slub.c:5259 [inline]
__kvmalloc_node_noprof+0x53d/0x770 mm/slub.c:6752
run_add_entry+0x108/0x730 fs/ntfs3/run.c:390
attr_allocate_clusters+0x15a/0x450 fs/ntfs3/attrib.c:199
indx_create_allocate fs/ntfs3/index.c:1449 [inline]
indx_insert_into_root+0x575/0xb20 fs/ntfs3/index.c:1705
indx_insert_entry+0x182/0x290 fs/ntfs3/index.c:1993
ni_add_name+0x1ab/0x2e0 fs/ntfs3/frecord.c:2764
ntfs_link_inode+0x95/0xc0 fs/ntfs3/inode.c:1794
ntfs_link+0xb4/0x180 fs/ntfs3/namei.c:146
vfs_link+0x270/0x5a0 fs/namei.c:5746
filename_linkat+0x262/0x3c0 fs/namei.c:5814
__do_sys_link fs/namei.c:5847 [inline]
__se_sys_link fs/namei.c:5843 [inline]
__x64_sys_link+0x4b/0x70 fs/namei.c:5843
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xe2/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f

BUG: memory leak
unreferenced object 0xffff88810ea19a40 (size 64):
comm "syz.0.19", pid 6125, jiffies 4294950445
hex dump (first 32 bytes):
00 00 00 00 01 00 00 00 1e 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc 692543f4):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
slab_post_alloc_hook mm/slub.c:4543 [inline]
slab_alloc_node mm/slub.c:4866 [inline]
__do_kmalloc_node mm/slub.c:5259 [inline]
__kvmalloc_node_noprof+0x53d/0x770 mm/slub.c:6752
run_add_entry+0x108/0x730 fs/ntfs3/run.c:390
attr_allocate_clusters+0x15a/0x450 fs/ntfs3/attrib.c:199
indx_create_allocate fs/ntfs3/index.c:1449 [inline]
indx_insert_into_root+0x575/0xb20 fs/ntfs3/index.c:1705
indx_insert_entry+0x182/0x290 fs/ntfs3/index.c:1993
ni_add_name+0x1ab/0x2e0 fs/ntfs3/frecord.c:2764
ntfs_link_inode+0x95/0xc0 fs/ntfs3/inode.c:1794
ntfs_link+0xb4/0x180 fs/ntfs3/namei.c:146
vfs_link+0x270/0x5a0 fs/namei.c:5746
filename_linkat+0x262/0x3c0 fs/namei.c:5814
__do_sys_link fs/namei.c:5847 [inline]
__se_sys_link fs/namei.c:5843 [inline]
__x64_sys_link+0x4b/0x70 fs/namei.c:5843
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xe2/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f

connection error: failed to recv *flatrpc.ExecutorMessageRawT: EOF


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
10:09 PM (2 hours ago) 10:09 PM
to linux-...@vger.kernel.org, syzkall...@googlegroups.com
For archival purposes, forwarding an incoming command email to
linux-...@vger.kernel.org, syzkall...@googlegroups.com.

***

Subject: [PATCH] ntfs3: fix memory leak in indx_insert_into_root()
Author: karti...@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master


When indx_create_allocate() succeeds but a subsequent
operation fails (indx_get_root() returning NULL,
indx_new() failing, or the allocation itself failing),
the run list allocated in run_add_entry() via
attr_allocate_clusters() is never freed, causing a
memory leak.

Fix this by adding a new out_free_alloc label that
calls run_close() on indx->alloc_run before the
existing cleanup labels, and redirecting the affected
error paths to use it.

Reported-by: syzbot+7adcdd...@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=7adcddaeeb860e5d3f2f
Signed-off-by: Deepanshu Kartikey <Karti...@gmail.com>
---
fs/ntfs3/index.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c
index 97f06c26fe1a..16479b6ce845 100644
--- a/fs/ntfs3/index.c
+++ b/fs/ntfs3/index.c
@@ -1711,7 +1711,7 @@ static int indx_insert_into_root(struct ntfs_index *indx, struct ntfs_inode *ni,
/* Bug? */
ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
err = -EINVAL;
- goto out_free_re;
+ goto out_free_alloc;
}

if (err) {
@@ -1722,7 +1722,7 @@ static int indx_insert_into_root(struct ntfs_index *indx, struct ntfs_inode *ni,
/* Bug? */
ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
}
- goto out_free_re;
+ goto out_free_alloc;
}

e = (struct NTFS_DE *)(root + 1);
@@ -1733,7 +1733,7 @@ static int indx_insert_into_root(struct ntfs_index *indx, struct ntfs_inode *ni,
n = indx_new(indx, ni, new_vbn, sub_vbn);
if (IS_ERR(n)) {
err = PTR_ERR(n);
- goto out_free_re;
+ goto out_free_alloc;
}

hdr = &n->index->ihdr;
@@ -1781,6 +1781,8 @@ static int indx_insert_into_root(struct ntfs_index *indx, struct ntfs_inode *ni,

out_put_n:
put_indx_node(n);
+out_free_alloc:
+ run_close(&indx->alloc_run);
out_free_re:
kfree(re);
out_free_root:
--
2.43.0

syzbot

unread,
11:36 PM (7 minutes ago) 11:36 PM
to karti...@gmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
memory leak in run_add_entry

BUG: memory leak
unreferenced object 0xffff8881293eb400 (size 64):
comm "syz.0.17", pid 6727, jiffies 4294946367
hex dump (first 32 bytes):
00 00 00 00 01 00 00 00 1e 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc 692543f4):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
slab_post_alloc_hook mm/slub.c:4543 [inline]
slab_alloc_node mm/slub.c:4866 [inline]
__do_kmalloc_node mm/slub.c:5259 [inline]
__kvmalloc_node_noprof+0x53d/0x770 mm/slub.c:6752
run_add_entry+0x108/0x730 fs/ntfs3/run.c:390
attr_allocate_clusters+0x15a/0x450 fs/ntfs3/attrib.c:199
indx_create_allocate fs/ntfs3/index.c:1449 [inline]
indx_insert_into_root+0x575/0xb50 fs/ntfs3/index.c:1705
indx_insert_entry+0x182/0x290 fs/ntfs3/index.c:1995
ni_add_name+0x1ab/0x2e0 fs/ntfs3/frecord.c:2764
ntfs_link_inode+0x95/0xc0 fs/ntfs3/inode.c:1794
ntfs_link+0xb4/0x180 fs/ntfs3/namei.c:146
vfs_link+0x270/0x5a0 fs/namei.c:5746
filename_linkat+0x262/0x3c0 fs/namei.c:5814
__do_sys_link fs/namei.c:5847 [inline]
__se_sys_link fs/namei.c:5843 [inline]
__x64_sys_link+0x4b/0x70 fs/namei.c:5843
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xe2/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f

BUG: memory leak
unreferenced object 0xffff888108dbf5c0 (size 64):
comm "syz.0.18", pid 6734, jiffies 4294946376
hex dump (first 32 bytes):
00 00 00 00 01 00 00 00 1e 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc 692543f4):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
slab_post_alloc_hook mm/slub.c:4543 [inline]
slab_alloc_node mm/slub.c:4866 [inline]
__do_kmalloc_node mm/slub.c:5259 [inline]
__kvmalloc_node_noprof+0x53d/0x770 mm/slub.c:6752
run_add_entry+0x108/0x730 fs/ntfs3/run.c:390
attr_allocate_clusters+0x15a/0x450 fs/ntfs3/attrib.c:199
indx_create_allocate fs/ntfs3/index.c:1449 [inline]
indx_insert_into_root+0x575/0xb50 fs/ntfs3/index.c:1705
indx_insert_entry+0x182/0x290 fs/ntfs3/index.c:1995
ni_add_name+0x1ab/0x2e0 fs/ntfs3/frecord.c:2764
ntfs_link_inode+0x95/0xc0 fs/ntfs3/inode.c:1794
ntfs_link+0xb4/0x180 fs/ntfs3/namei.c:146
vfs_link+0x270/0x5a0 fs/namei.c:5746
filename_linkat+0x262/0x3c0 fs/namei.c:5814
__do_sys_link fs/namei.c:5847 [inline]
__se_sys_link fs/namei.c:5843 [inline]
__x64_sys_link+0x4b/0x70 fs/namei.c:5843
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xe2/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f

connection error: failed to recv *flatrpc.ExecutorMessageRawT: EOF


Tested on:

commit: 42bddab0 Merge tag 'execve-v7.0-rc5' of git://git.kern..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1059ca06580000
kernel config: https://syzkaller.appspot.com/x/.config?x=e2bba615ee79faa5
dashboard link: https://syzkaller.appspot.com/bug?extid=7adcddaeeb860e5d3f2f
compiler: gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
patch: https://syzkaller.appspot.com/x/patch.diff?x=10d866da580000

Reply all
Reply to author
Forward
0 new messages