linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: syzbot <syzbot+0265846a0cb9a0547905@syzkaller.appspotmail.com>
Cc: akpm@linux-foundation.org, baijiaju1990@gmail.com,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	mhocko@suse.com, rppt@linux.ibm.com,
	syzkaller-bugs@googlegroups.com, willy@infradead.org
Subject: Re: memory leak in bio_clone_fast
Date: Wed, 14 Aug 2019 16:52:30 +0800	[thread overview]
Message-ID: <20190814085230.5772-1-hdanton@sina.com> (raw)


On Tue, 13 Aug 2019 14:08:06 -0700
> Hello,
> 
> syzbot found the following crash on:
> 
> HEAD commit:    d45331b0 Linux 5.3-rc4
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=1651e6d2600000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=6c5e70dcab57c6af
> dashboard link: https://syzkaller.appspot.com/bug?extid=0265846a0cb9a0547905
> compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=12c9c336600000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1766156a600000
> 
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+0265846a0cb9a0547905@syzkaller.appspotmail.com
> 
> executing program
> executing program
> executing program
> executing program
> BUG: memory leak
> unreferenced object 0xffff8881226da6c0 (size 192):
>    comm "syz-executor332", pid 6977, jiffies 4294941214 (age 15.840s)
>    hex dump (first 32 bytes):
>      00 00 00 00 00 00 00 00 00 f0 bc 28 81 88 ff ff  ...........(....
>      01 c8 60 00 02 0b 00 00 00 00 00 00 00 00 00 00  ..`.............
>    backtrace:
>      [<00000000b06a638e>] kmemleak_alloc_recursive  include/linux/kmemleak.h:43 [inline]
>      [<00000000b06a638e>] slab_post_alloc_hook mm/slab.h:522 [inline]
>      [<00000000b06a638e>] slab_alloc mm/slab.c:3319 [inline]
>      [<00000000b06a638e>] kmem_cache_alloc+0x13f/0x2c0 mm/slab.c:3483
>      [<00000000950a289d>] mempool_alloc_slab+0x1e/0x30 mm/mempool.c:513
>      [<00000000bfcc27e2>] mempool_alloc+0x64/0x1b0 mm/mempool.c:393
>      [<00000000cdf95a4a>] bio_alloc_bioset+0x180/0x2c0 block/bio.c:477
>      [<00000000b239bb68>] bio_clone_fast+0x25/0x90 block/bio.c:609
>      [<000000005d58c2dc>] bio_split+0x4a/0xd0 block/bio.c:1856
>      [<00000000ab943734>] blk_bio_segment_split block/blk-merge.c:250  [inline]
>      [<00000000ab943734>] __blk_queue_split+0x355/0x730 block/blk-merge.c:272
>      [<00000000e702c0ac>] blk_mq_make_request+0xb0/0x890 block/blk-mq.c:1943
>      [<000000003c89773a>] generic_make_request block/blk-core.c:1052 [inline]
>      [<000000003c89773a>] generic_make_request+0xf6/0x4a0   block/blk-core.c:994
>      [<00000000a4dcaf78>] submit_bio+0x5a/0x1e0 block/blk-core.c:1163
>      [<000000003e1ce7f8>] __blkdev_direct_IO fs/block_dev.c:459 [inline]
>      [<000000003e1ce7f8>] blkdev_direct_IO+0x2b3/0x6d0 fs/block_dev.c:515
>      [<0000000087ec76a4>] generic_file_direct_write+0xb0/0x1a0   mm/filemap.c:3230
>      [<00000000ff259b44>] __generic_file_write_iter+0xec/0x230   mm/filemap.c:3413
>      [<00000000223d9b6c>] blkdev_write_iter fs/block_dev.c:2026 [inline]
>      [<00000000223d9b6c>] blkdev_write_iter+0xbe/0x160 fs/block_dev.c:2003
>      [<000000003c4a5c94>] call_write_iter include/linux/fs.h:1870 [inline]
>      [<000000003c4a5c94>] aio_write+0x10b/0x1d0 fs/aio.c:1583
>      [<00000000581f0c84>] __io_submit_one fs/aio.c:1815 [inline]
>      [<00000000581f0c84>] io_submit_one+0x59b/0xe50 fs/aio.c:1862

1, add BLK_QC_T_EAGAIN

--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1004,7 +1004,8 @@ blk_qc_t generic_make_request(struct bio
 	blk_qc_t ret = BLK_QC_T_NONE;
 
 	if (!generic_make_request_checks(bio))
-		goto out;
+		/* feed error back to __blkdev_direct_IO fs/block_dev.c:459 */
+		return BLK_QC_T_EAGAIN;
 
 	/*
 	 * We only want one ->make_request_fn to be active at a time, else
--

2, plan-B, check status if BLK_QC_T_EAGAIN is bad

--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -461,7 +461,7 @@ __blkdev_direct_IO(struct kiocb *iocb, s
 		}
 
 		qc = submit_bio(bio);
-		if (qc == BLK_QC_T_EAGAIN) {
+		if (qc == BLK_QC_T_EAGAIN || bio->bi_status) {
 			if (!ret)
 				ret = -EAGAIN;
 			goto error;
--



             reply	other threads:[~2019-08-14  8:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-14  8:52 Hillf Danton [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-08-13 21:08 memory leak in bio_clone_fast syzbot
2019-08-13 21:33 ` Andrew Morton

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=20190814085230.5772-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=akpm@linux-foundation.org \
    --cc=baijiaju1990@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=rppt@linux.ibm.com \
    --cc=syzbot+0265846a0cb9a0547905@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=willy@infradead.org \
    /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).