Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2154500pxb; Sun, 17 Apr 2022 11:48:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMRM2JaU8Pw2xkrG/+z6bugkh5DEDt7J6qB0PAA3hKuW7BgbcT6IrqYAxFLRsEikK17ep6 X-Received: by 2002:a17:902:ccc4:b0:156:5d37:b42f with SMTP id z4-20020a170902ccc400b001565d37b42fmr7602372ple.157.1650221317996; Sun, 17 Apr 2022 11:48:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650221317; cv=none; d=google.com; s=arc-20160816; b=LTanUHhAr1AqZErD+EFC/mA8RaOqTS+o6BNN9e9UHcuCsg82hHMfIlnzmLQNCkqYFW dWb9GNoGaoODSvSPJZzjme4+AgkFvdjS9dNUjFga9YK5HANo5lG+5qv9QiTnaCe+/Y6k SQaZ/hiX8YPIRiu5RSyGSreCfc4wlr/kxD0iDSJucMCVo5hI+vhttHDYjqMRlKqkJs4+ Dk9oVbpKA0E2iEiRfVs7SLKwzHioVl75TrxyOryVRCN/FIGP1WOjZaXmHjuP08CCQRB0 w9CfIjMobxLaweHCMgaQpC9Ngqo2ySQfC3pJAjmdBWawnUKrlfKKYi0YRrGLzORno7q/ BsUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=e7rLfnATy9xIaXgzkFV4mffpoCy71ONwr7sohfESaIY=; b=yB/yXHPbGTqWsrg4jGLhU49NtCIb1TV7gXvAfA1bLdChxgwtjYJ72jOGj3W5CKZila o/SKaR+t0O7uYWIzN2KK1baNdc3BAa4wtF/JtOroFuIDzYpRf/orUhx11n1+euuarN06 +/2KAs0LlxZuiDcw9rmjhMPKqYJu5AfEvLvsEB0tr7Xoow9cAvEx09VgbKmcLTWZYGpd cR2IapeRxlqHd9lcPGiJtn81HQUdGC0PiUmd2P3GKi1ClRmWmxuFzgkK3xkm5fqtF34M APPcYUty8ha48PflkP3dOWCs1Eu6xfQuY9LBvVpRkAsS6wnMzzoxmAqfHhOCJqiMiXYe aa2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b="7qcwe/J2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 2-20020a17090a198200b001cba3fda35fsi6934732pji.85.2022.04.17.11.48.22; Sun, 17 Apr 2022 11:48:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b="7qcwe/J2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233288AbiDQCTs (ORCPT + 99 others); Sat, 16 Apr 2022 22:19:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233393AbiDQCTm (ORCPT ); Sat, 16 Apr 2022 22:19:42 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4186396B0 for ; Sat, 16 Apr 2022 19:17:04 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id p10so9932580plf.9 for ; Sat, 16 Apr 2022 19:17:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=e7rLfnATy9xIaXgzkFV4mffpoCy71ONwr7sohfESaIY=; b=7qcwe/J2quyhBkiT1FkypRPoDAmxgA9ao4ZiV44u03GptMWq5TwB4FFsmFdy5crMzL qVPEkR6RAWYbSu4tYuCdJGWqw61piz+8xqmWk72RQ/RfRtg5S+mIpTpWyly4jPxI+EWd siF5qVaOQLRqdXwQwvk7GpxMkF92ZWz+DOdLD/dM03oOKhBqzIriGNexBb2nqahcg99N 0uvFsXl26vwTMPuMTEPhaHSw7d8cgeIO/Hd1td8X7K8O2eQnsfqc61t9MzDoGxi3Dqik cupmLeWjraNoIOx6TSMNeEgmg/7F5tVLaYYIinDYhkjupYPKUJChJmFio4+2jL89OIRE QZzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=e7rLfnATy9xIaXgzkFV4mffpoCy71ONwr7sohfESaIY=; b=sz2nLgfagt+Pr83idC4RYDqpxr1Sa7O3F4jY3dgFhqDUa4qHgw4wiGpq9BCyl3npJL lA5Jbsb7oCoOWS9xSXEjWF34IqMHw8aS8ktPBywSyFtSFLt8ZuTxTvuRhC8UGCdSm3u8 kAiX6/dz/pgpJySA6CEtAH4XptEZesOwFFeZEchpSm6oKbKqe8oTA5pOlgxXeb7m3QVM H9eY30LFgbWzfUFSbSuk49A0Fh6QQTNtfgdn/qp/P3c44H7V8wsDOdxkKRImJfFB6zeU 3rl4RAuaDb7RMJ+lZLoLcyOyB+sPd+0mwivfq8Houc/x6MIQfHnFr3/PJYnwgK80dLMj Xvqw== X-Gm-Message-State: AOAM532L18Fis5KWNW3MDXx0T77QfxxCMn56Lp2RhW8Yz1yMK4ST7dXV VQptSxUFeZ3VewH2uPiLtUnHGg== X-Received: by 2002:a17:90a:558a:b0:1ca:a819:d2d1 with SMTP id c10-20020a17090a558a00b001caa819d2d1mr11693111pji.126.1650161824181; Sat, 16 Apr 2022 19:17:04 -0700 (PDT) Received: from [192.168.1.100] ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id k187-20020a636fc4000000b003983a01b896sm8393327pgc.90.2022.04.16.19.17.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 16 Apr 2022 19:17:03 -0700 (PDT) Message-ID: <004e2f64-cf4e-2490-ed2c-29c073f76704@kernel.dk> Date: Sat, 16 Apr 2022 20:17:02 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [syzbot] memory leak in iovec_from_user Content-Language: en-US To: syzbot , asml.silence@gmail.com, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com References: <000000000000951a1505dccf8b73@google.com> From: Jens Axboe In-Reply-To: <000000000000951a1505dccf8b73@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: > [] kmalloc_array include/linux/slab.h:621 [inline] > [] iovec_from_user lib/iov_iter.c:1922 [inline] > [] iovec_from_user+0x13e/0x280 lib/iov_iter.c:1905 > [] __import_iovec+0x45/0x250 lib/iov_iter.c:1948 > [] __io_import_iovec+0xfe/0x800 fs/io_uring.c:3497 > [] io_import_iovec fs/io_uring.c:3508 [inline] > [] io_read+0x59f/0x880 fs/io_uring.c:3803 > [] io_issue_sqe+0x364/0x3270 fs/io_uring.c:7122 > [] __io_queue_sqe fs/io_uring.c:7489 [inline] > [] io_queue_sqe fs/io_uring.c:7531 [inline] > [] io_submit_sqe fs/io_uring.c:7736 [inline] > [] io_submit_sqes+0x553/0x3030 fs/io_uring.c:7842 > [] __do_sys_io_uring_enter+0x6f0/0x1100 fs/io_uring.c:10780 > [] do_syscall_x64 arch/x86/entry/common.c:50 [inline] > [] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 > [] 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: > [] kmalloc_array include/linux/slab.h:621 [inline] > [] iovec_from_user lib/iov_iter.c:1922 [inline] > [] iovec_from_user+0x13e/0x280 lib/iov_iter.c:1905 > [] __import_iovec+0x45/0x250 lib/iov_iter.c:1948 > [] __io_import_iovec+0xfe/0x800 fs/io_uring.c:3497 > [] io_import_iovec fs/io_uring.c:3508 [inline] > [] io_read+0x59f/0x880 fs/io_uring.c:3803 > [] io_issue_sqe+0x364/0x3270 fs/io_uring.c:7122 > [] __io_queue_sqe fs/io_uring.c:7489 [inline] > [] io_queue_sqe fs/io_uring.c:7531 [inline] > [] io_submit_sqe fs/io_uring.c:7736 [inline] > [] io_submit_sqes+0x553/0x3030 fs/io_uring.c:7842 > [] __do_sys_io_uring_enter+0x6f0/0x1100 fs/io_uring.c:10780 > [] do_syscall_x64 arch/x86/entry/common.c:50 [inline] > [] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 > [] 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