All of lore.kernel.org
 help / color / mirror / Atom feed
* [syzbot] memory leak in iovec_from_user
@ 2022-04-17  1:27 syzbot
  2022-04-17  2:17 ` Jens Axboe
  2022-04-17 13:27 ` Jens Axboe
  0 siblings, 2 replies; 4+ messages in thread
From: syzbot @ 2022-04-17  1:27 UTC (permalink / raw)
  To: asml.silence, axboe, io-uring, linux-kernel, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    ce522ba9ef7e Linux 5.18-rc2
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=14225724f00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=b8f1a3425e05af27
dashboard link: https://syzkaller.appspot.com/bug?extid=96b43810dfe9c3bb95ed
compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=13c45d88f00000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=17b428af700000

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

executing program
BUG: memory leak
unreferenced object 0xffff88810d698300 (size 192):
  comm "syz-executor156", pid 3595, jiffies 4294944234 (age 12.580s)
  hex dump (first 32 bytes):
    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 00  ................
  backtrace:
    [<ffffffff823357be>] kmalloc_array include/linux/slab.h:621 [inline]
    [<ffffffff823357be>] iovec_from_user lib/iov_iter.c:1922 [inline]
    [<ffffffff823357be>] iovec_from_user+0x13e/0x280 lib/iov_iter.c:1905
    [<ffffffff82335945>] __import_iovec+0x45/0x250 lib/iov_iter.c:1948
    [<ffffffff81668c8e>] __io_import_iovec+0xfe/0x800 fs/io_uring.c:3497
    [<ffffffff8166d92f>] io_import_iovec fs/io_uring.c:3508 [inline]
    [<ffffffff8166d92f>] io_read+0x59f/0x880 fs/io_uring.c:3803
    [<ffffffff816727b4>] io_issue_sqe+0x364/0x3270 fs/io_uring.c:7122
    [<ffffffff816761c3>] __io_queue_sqe fs/io_uring.c:7489 [inline]
    [<ffffffff816761c3>] io_queue_sqe fs/io_uring.c:7531 [inline]
    [<ffffffff816761c3>] io_submit_sqe fs/io_uring.c:7736 [inline]
    [<ffffffff816761c3>] io_submit_sqes+0x553/0x3030 fs/io_uring.c:7842
    [<ffffffff81679390>] __do_sys_io_uring_enter+0x6f0/0x1100 fs/io_uring.c:10780
    [<ffffffff8451ca25>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    [<ffffffff8451ca25>] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
    [<ffffffff84600068>] entry_SYSCALL_64_after_hwframe+0x44/0xae

BUG: memory leak
unreferenced object 0xffff88810d6983c0 (size 192):
  comm "syz-executor156", pid 3603, jiffies 4294944759 (age 7.330s)
  hex dump (first 32 bytes):
    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 00  ................
  backtrace:
    [<ffffffff823357be>] kmalloc_array include/linux/slab.h:621 [inline]
    [<ffffffff823357be>] iovec_from_user lib/iov_iter.c:1922 [inline]
    [<ffffffff823357be>] iovec_from_user+0x13e/0x280 lib/iov_iter.c:1905
    [<ffffffff82335945>] __import_iovec+0x45/0x250 lib/iov_iter.c:1948
    [<ffffffff81668c8e>] __io_import_iovec+0xfe/0x800 fs/io_uring.c:3497
    [<ffffffff8166d92f>] io_import_iovec fs/io_uring.c:3508 [inline]
    [<ffffffff8166d92f>] io_read+0x59f/0x880 fs/io_uring.c:3803
    [<ffffffff816727b4>] io_issue_sqe+0x364/0x3270 fs/io_uring.c:7122
    [<ffffffff816761c3>] __io_queue_sqe fs/io_uring.c:7489 [inline]
    [<ffffffff816761c3>] io_queue_sqe fs/io_uring.c:7531 [inline]
    [<ffffffff816761c3>] io_submit_sqe fs/io_uring.c:7736 [inline]
    [<ffffffff816761c3>] io_submit_sqes+0x553/0x3030 fs/io_uring.c:7842
    [<ffffffff81679390>] __do_sys_io_uring_enter+0x6f0/0x1100 fs/io_uring.c:10780
    [<ffffffff8451ca25>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    [<ffffffff8451ca25>] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
    [<ffffffff84600068>] entry_SYSCALL_64_after_hwframe+0x44/0xae



---
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 syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

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

* Re: [syzbot] memory leak in iovec_from_user
  2022-04-17  1:27 [syzbot] memory leak in iovec_from_user syzbot
@ 2022-04-17  2:17 ` Jens Axboe
  2022-04-17 13:27 ` Jens Axboe
  1 sibling, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2022-04-17  2:17 UTC (permalink / raw)
  To: syzbot, asml.silence, io-uring, linux-kernel, syzkaller-bugs

On 4/16/22 7:27 PM, syzbot wrote:
> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    ce522ba9ef7e Linux 5.18-rc2
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=14225724f00000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=b8f1a3425e05af27
> dashboard link: https://syzkaller.appspot.com/bug?extid=96b43810dfe9c3bb95ed
> compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=13c45d88f00000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=17b428af700000
> 
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+96b43810dfe9c3bb95ed@syzkaller.appspotmail.com
> 
> executing program
> BUG: memory leak
> unreferenced object 0xffff88810d698300 (size 192):
>   comm "syz-executor156", pid 3595, jiffies 4294944234 (age 12.580s)
>   hex dump (first 32 bytes):
>     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 00  ................
>   backtrace:
>     [<ffffffff823357be>] kmalloc_array include/linux/slab.h:621 [inline]
>     [<ffffffff823357be>] iovec_from_user lib/iov_iter.c:1922 [inline]
>     [<ffffffff823357be>] iovec_from_user+0x13e/0x280 lib/iov_iter.c:1905
>     [<ffffffff82335945>] __import_iovec+0x45/0x250 lib/iov_iter.c:1948
>     [<ffffffff81668c8e>] __io_import_iovec+0xfe/0x800 fs/io_uring.c:3497
>     [<ffffffff8166d92f>] io_import_iovec fs/io_uring.c:3508 [inline]
>     [<ffffffff8166d92f>] io_read+0x59f/0x880 fs/io_uring.c:3803
>     [<ffffffff816727b4>] io_issue_sqe+0x364/0x3270 fs/io_uring.c:7122
>     [<ffffffff816761c3>] __io_queue_sqe fs/io_uring.c:7489 [inline]
>     [<ffffffff816761c3>] io_queue_sqe fs/io_uring.c:7531 [inline]
>     [<ffffffff816761c3>] io_submit_sqe fs/io_uring.c:7736 [inline]
>     [<ffffffff816761c3>] io_submit_sqes+0x553/0x3030 fs/io_uring.c:7842
>     [<ffffffff81679390>] __do_sys_io_uring_enter+0x6f0/0x1100 fs/io_uring.c:10780
>     [<ffffffff8451ca25>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
>     [<ffffffff8451ca25>] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
>     [<ffffffff84600068>] entry_SYSCALL_64_after_hwframe+0x44/0xae
> 
> BUG: memory leak
> unreferenced object 0xffff88810d6983c0 (size 192):
>   comm "syz-executor156", pid 3603, jiffies 4294944759 (age 7.330s)
>   hex dump (first 32 bytes):
>     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 00  ................
>   backtrace:
>     [<ffffffff823357be>] kmalloc_array include/linux/slab.h:621 [inline]
>     [<ffffffff823357be>] iovec_from_user lib/iov_iter.c:1922 [inline]
>     [<ffffffff823357be>] iovec_from_user+0x13e/0x280 lib/iov_iter.c:1905
>     [<ffffffff82335945>] __import_iovec+0x45/0x250 lib/iov_iter.c:1948
>     [<ffffffff81668c8e>] __io_import_iovec+0xfe/0x800 fs/io_uring.c:3497
>     [<ffffffff8166d92f>] io_import_iovec fs/io_uring.c:3508 [inline]
>     [<ffffffff8166d92f>] io_read+0x59f/0x880 fs/io_uring.c:3803
>     [<ffffffff816727b4>] io_issue_sqe+0x364/0x3270 fs/io_uring.c:7122
>     [<ffffffff816761c3>] __io_queue_sqe fs/io_uring.c:7489 [inline]
>     [<ffffffff816761c3>] io_queue_sqe fs/io_uring.c:7531 [inline]
>     [<ffffffff816761c3>] io_submit_sqe fs/io_uring.c:7736 [inline]
>     [<ffffffff816761c3>] io_submit_sqes+0x553/0x3030 fs/io_uring.c:7842
>     [<ffffffff81679390>] __do_sys_io_uring_enter+0x6f0/0x1100 fs/io_uring.c:10780
>     [<ffffffff8451ca25>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
>     [<ffffffff8451ca25>] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
>     [<ffffffff84600068>] entry_SYSCALL_64_after_hwframe+0x44/0xae


diff --git a/fs/io_uring.c b/fs/io_uring.c
index 659f8ecba5b7..d4feb5ca63ba 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3825,8 +3825,10 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags)
 		iovec = NULL;
 	}
 	ret = io_rw_init_file(req, FMODE_READ);
-	if (unlikely(ret))
+	if (unlikely(ret)) {
+		kfree(iovec);
 		return ret;
+	}
 	req->result = iov_iter_count(&s->iter);
 
 	if (force_nonblock) {
@@ -3951,8 +3953,10 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags)
 		iovec = NULL;
 	}
 	ret = io_rw_init_file(req, FMODE_WRITE);
-	if (unlikely(ret))
+	if (unlikely(ret)) {
+		kfree(iovec);
 		return ret;
+	}
 	req->result = iov_iter_count(&s->iter);
 
 	if (force_nonblock) {

-- 
Jens Axboe


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

* Re: [syzbot] memory leak in iovec_from_user
  2022-04-17  1:27 [syzbot] memory leak in iovec_from_user syzbot
  2022-04-17  2:17 ` Jens Axboe
@ 2022-04-17 13:27 ` Jens Axboe
  2022-04-17 13:37   ` syzbot
  1 sibling, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2022-04-17 13:27 UTC (permalink / raw)
  To: syzbot, asml.silence, io-uring, linux-kernel, syzkaller-bugs

#syz test: git://git.kernel.dk/linux-block io_uring-5.18

-- 
Jens Axboe


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

* Re: [syzbot] memory leak in iovec_from_user
  2022-04-17 13:27 ` Jens Axboe
@ 2022-04-17 13:37   ` syzbot
  0 siblings, 0 replies; 4+ messages in thread
From: syzbot @ 2022-04-17 13:37 UTC (permalink / raw)
  To: asml.silence, axboe, io-uring, linux-kernel, syzkaller-bugs

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+96b43810dfe9c3bb95ed@syzkaller.appspotmail.com

Tested on:

commit:         c0713540 io_uring: fix leaks on IOPOLL and CQE_SKIP
git tree:       git://git.kernel.dk/linux-block io_uring-5.18
kernel config:  https://syzkaller.appspot.com/x/.config?x=b8f1a3425e05af27
dashboard link: https://syzkaller.appspot.com/bug?extid=96b43810dfe9c3bb95ed
compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2

Note: no patches were applied.
Note: testing is done by a robot and is best-effort only.

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

end of thread, other threads:[~2022-04-17 13:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-17  1:27 [syzbot] memory leak in iovec_from_user syzbot
2022-04-17  2:17 ` Jens Axboe
2022-04-17 13:27 ` Jens Axboe
2022-04-17 13:37   ` syzbot

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.