Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp532109pxa; Tue, 11 Aug 2020 08:50:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8Plm6ceWDRmROoNIcxO8cicigi1NlGqZZtp9xXY72Qwblswbwbypi66WCdqFbHR4Mf819 X-Received: by 2002:aa7:c688:: with SMTP id n8mr26952113edq.345.1597161024965; Tue, 11 Aug 2020 08:50:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597161024; cv=none; d=google.com; s=arc-20160816; b=dj4LlwvTmJ7YmQ3atV/p00SIxFunOaa67CkUtlAB4crRH5G3lw3zpY4Dh4DJYLTcNS EC5J2hDrIxc8+b8YxwFgsjKbIl4QoKwZ5vp63yvzg0ba7lGCvvhEHDz66WEeGVfsQhxU PbaCGTz8VsdFa/Qj9vEhzOghS1PBsy5YqPlRGurfLMuBKGTkv31sRAjQsfP8QSIkv0D0 ZlA7T9QjHnpVhVNu14SurIBibZBcb/R6coki3VyBfgPUBn63wQ7lV+F/4ZeGYK+LmZM4 XVmtT4xrj0s6mV8fJVr5amuqbAIJfbbmimmZIBELoWDdaGn7kRIqB6XC2VT3z+OZoKjY MOJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:to:from:subject:dkim-signature; bh=1RoNYDYvCgpLLRWCuumNMoAb1U/U13+su+iqhg08vrA=; b=WojK+d5w7MKkFu1SsVad1YMtyNwwMC+w1SNYOKoQIUs92pt9FOXwAtNkC/zWMGD8Kl LA/Jb5gBrS3HvCp0tu0tsflWCwio7BZ08AN9W4u2kmhg792KS2c0fM1ayBRw0bZtHmhx UzKJUCvdd3p4VpIpcrhm09Cvd14ubeV9bj2wNOzoaRIGkYGuav3l3UN73V+Qq0ex97HV 3uqxf1RKy2HchWHAQa5qd1EkVcCIk0GTidc0ByN0qGIeMZKWSNXn2pztKr/2Sb8yrIEl xtOTD0BKB4h8qM58j9Z4YTf+N2JP2j7w4yFb6E8IuFqei3dGjaxzy3DaVNNYWMzhJI/F u5PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=G+ZaOUTA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u24si15692122edi.194.2020.08.11.08.50.00; Tue, 11 Aug 2020 08:50:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=G+ZaOUTA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728873AbgHKPtc (ORCPT + 99 others); Tue, 11 Aug 2020 11:49:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728879AbgHKPtb (ORCPT ); Tue, 11 Aug 2020 11:49:31 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A13E1C061788 for ; Tue, 11 Aug 2020 08:49:31 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id p8so6891659pgn.13 for ; Tue, 11 Aug 2020 08:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:from:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=1RoNYDYvCgpLLRWCuumNMoAb1U/U13+su+iqhg08vrA=; b=G+ZaOUTABRY2uaa7exuF9V693p1+/Aq92mMnUXDM0xSjDLxYZHnk2loQum0lmZklvu gavDX8FnkFLF3m0LF13jEKwqunJXhebTR9C+PVK0+27BF2MdYni5G5s0QMPclcDbw33y pivUFiiYDDl+K8jkY08D8WSKQhccYO0eANN2qrLBsppanGGSLmyM0rg1KFCIuXeRtd5W ja2xxU/wZU1/K/GUKfE56yofuh/+8iY4+fq3391Id0hYaYmIJORKt4333Q+mZLEJVtyO uKh1JW/lNXMQvUmN3hcPiqbKSCdjLrPHI20sUx5TlnAAiAxsU/etOwfVJHX+qNmBBM9i LC4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=1RoNYDYvCgpLLRWCuumNMoAb1U/U13+su+iqhg08vrA=; b=Ec3grYT8JmWSFXQhrrX8d75BoaFX+Em29MJms+ySfpD7O1PFah2UwjulToHZcIfGXN 7M4yaiVbb+ZidrrikIUSY2xSQ4nbe9uxz/1Uty1/a0uP5xmi04lNMxbphqX/KQIVGJJx aAcJ2+E1mcwQYvufmda5p3Cn1ZQ0PA9SFuNnGwKPYuXs8yD2SY33G73oJWgT51m/5sw3 jTNVHiTpKCZ+RObBMr6NDQ9ZL0xKAC0aX8LZ6F/5R1F8YQmh7qlGg2FvMGaCACxgg1IQ 9O2TQe/f2vQJvFIqWlIwLo0rM3Zs/WlagSFHRnXZxtYQwL03MdlwvJs2S2I3DiHgsAG3 JmXQ== X-Gm-Message-State: AOAM532pi+eh1yGmoYe1Cxd5IjhfODjm1uymO+Q82v1LQ+pP8rHUtmh5 n49fp01uXnI9lAD+MpcsIZqR2A== X-Received: by 2002:a65:4103:: with SMTP id w3mr1362290pgp.426.1597160970982; Tue, 11 Aug 2020 08:49:30 -0700 (PDT) Received: from [192.168.1.182] ([66.219.217.173]) by smtp.gmail.com with ESMTPSA id bf8sm3311237pjb.4.2020.08.11.08.49.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Aug 2020 08:49:30 -0700 (PDT) Subject: Re: memory leak in io_submit_sqes From: Jens Axboe To: syzbot , io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, viro@zeniv.linux.org.uk References: <000000000000f50fb505ac9a72c9@google.com> Message-ID: Date: Tue, 11 Aug 2020 09:49:28 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/11/20 9:23 AM, Jens Axboe wrote: > On 8/11/20 8:59 AM, Jens Axboe wrote: >> On 8/11/20 7:57 AM, syzbot wrote: >>> Hello, >>> >>> syzbot found the following issue on: >>> >>> HEAD commit: d6efb3ac Merge tag 'tty-5.9-rc1' of git://git.kernel.org/p.. >>> git tree: upstream >>> console output: https://syzkaller.appspot.com/x/log.txt?x=13cb0762900000 >>> kernel config: https://syzkaller.appspot.com/x/.config?x=42163327839348a9 >>> dashboard link: https://syzkaller.appspot.com/bug?extid=a730016dc0bdce4f6ff5 >>> compiler: gcc (GCC) 10.1.0-syz 20200507 >>> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16e877dc900000 >>> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1608291a900000 >>> >>> IMPORTANT: if you fix the issue, please add the following tag to the commit: >>> Reported-by: syzbot+a730016dc0bdce4f6ff5@syzkaller.appspotmail.com >>> >>> executing program >>> executing program >>> executing program >>> executing program >>> executing program >>> BUG: memory leak >>> unreferenced object 0xffff888124949100 (size 256): >>> comm "syz-executor808", pid 6480, jiffies 4294949911 (age 33.960s) >>> hex dump (first 32 bytes): >>> 00 78 74 2a 81 88 ff ff 00 00 00 00 00 00 00 00 .xt*............ >>> 90 b0 51 81 ff ff ff ff 00 00 00 00 00 00 00 00 ..Q............. >>> backtrace: >>> [<0000000084e46f34>] io_alloc_req fs/io_uring.c:1503 [inline] >>> [<0000000084e46f34>] io_submit_sqes+0x5dc/0xc00 fs/io_uring.c:6306 >>> [<000000006d4e19eb>] __do_sys_io_uring_enter+0x582/0x830 fs/io_uring.c:8036 >>> [<00000000a4116b07>] do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 >>> [<0000000067b2aefc>] entry_SYSCALL_64_after_hwframe+0x44/0xa9 >>> >>> BUG: memory leak >>> unreferenced object 0xffff88811751d200 (size 96): >>> comm "syz-executor808", pid 6480, jiffies 4294949911 (age 33.960s) >>> hex dump (first 32 bytes): >>> 00 78 74 2a 81 88 ff ff 00 00 00 00 00 00 00 00 .xt*............ >>> 0e 01 00 00 00 00 75 22 00 00 00 00 00 0f 1f 04 ......u"........ >>> backtrace: >>> [<00000000073ea2ba>] kmalloc include/linux/slab.h:555 [inline] >>> [<00000000073ea2ba>] io_arm_poll_handler fs/io_uring.c:4773 [inline] >>> [<00000000073ea2ba>] __io_queue_sqe+0x445/0x6b0 fs/io_uring.c:5988 >>> [<000000001551bde0>] io_queue_sqe+0x309/0x550 fs/io_uring.c:6060 >>> [<000000002dfb908f>] io_submit_sqe fs/io_uring.c:6130 [inline] >>> [<000000002dfb908f>] io_submit_sqes+0x8b8/0xc00 fs/io_uring.c:6327 >>> [<000000006d4e19eb>] __do_sys_io_uring_enter+0x582/0x830 fs/io_uring.c:8036 >>> [<00000000a4116b07>] do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 >>> [<0000000067b2aefc>] entry_SYSCALL_64_after_hwframe+0x44/0xa9 >> >> This one looks very odd, and I cannot reproduce it. The socket() calls >> reliably fails for me, and even if I hack it to use 0 for protocol instead >> of 2, I don't see anything interesting happening here. An IORING_OP_WRITEV >> is submitted on the socket, which just fails with ENOTCONN. > > Dug a bit deeper and found the missing option, I can now reproduce this! > I'll take a look. This should fix it. diff --git a/fs/io_uring.c b/fs/io_uring.c index 99582cf5106b..8a2afd8c33c9 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4883,7 +4883,7 @@ static bool io_arm_poll_handler(struct io_kiocb *req) ret = __io_arm_poll_handler(req, &apoll->poll, &ipt, mask, io_async_wake); - if (ret) { + if (ret || ipt.error) { io_poll_remove_double(req, apoll->double_poll); spin_unlock_irq(&ctx->completion_lock); kfree(apoll->double_poll); -- Jens Axboe