Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2640823yba; Mon, 22 Apr 2019 10:18:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMppX0nk71FKTLaSWBkjdGLhVLHdsDSjwNkDHa/BESO0cQWVRAAjAt9w3QrmzkFKiuRb6r X-Received: by 2002:a17:902:2ec5:: with SMTP id r63mr21503544plb.139.1555953508593; Mon, 22 Apr 2019 10:18:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555953508; cv=none; d=google.com; s=arc-20160816; b=MJGMI/Q/f/kRbyX1Aw26/AKvlrwshR9HjzNgK7evhFd1oePiXoqmXi89CBS1Xfz4lG ag49oFUephW2g21uiXsBPlSSMxDW+YFYsol8UjAbtEtjWbpjd8xocF1Prms7XstE9Lx/ sUqfLEjZeoBFDiqLUptQFHi3B2QfWUfbAeSQoAvwUGbcC5RT0lQj/kXBVljUoac2SpBe 4a+EsSOs9ckuuDV98N9hgYEruutmTj/zYLb5Wjx+XikeT7f7ZhFarp6V1Hut1CaTRnNz c+InxTxRKIsoq6b8/D3hF8vBL3aEeLqo1vtO/nMXf1ABKKdpMKIqB+xuSwz8oooklBYQ te+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=6xSQ2HaBp4VGGOaQ5AmjairlFsxNFXDYMnHC9JTDLQA=; b=MsnhcPectLx/gSTGAs8qlWx7VIFT0x4GlCODRNsE0HWzD5j1vJwTxJVdqJdLS84bVF idRmlP2ACNRSxCpFlyE7+2mtb+wqst5c9lAToJJL2JB5UmHy6nCCLWMaB1uK8nnJpWqy H6TobtdWc8LA0oyFwQSKdaKz+4ji3k8ITJ9P8woNlB3cZCF/Z9o394NfICqz0ueaypLJ bkSlCmk8ZXfRE9Tdu6tP1S7YERSS3gOiR+mK+MFFElH+m3ns0lVuqQe4vSmYVn12vZQi T7jtySAw+UCeX5e2qW51PZA2EdoUs5VZSCIFP5f2d73ZVDBId262yiEONkwTZV7GYJkq bpag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="Z/pQMMBU"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si13208065pgi.330.2019.04.22.10.18.12; Mon, 22 Apr 2019 10:18:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="Z/pQMMBU"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728233AbfDVQc1 (ORCPT + 99 others); Mon, 22 Apr 2019 12:32:27 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:43595 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727294AbfDVQc0 (ORCPT ); Mon, 22 Apr 2019 12:32:26 -0400 Received: by mail-lj1-f194.google.com with SMTP id f18so10793251lja.10 for ; Mon, 22 Apr 2019 09:32:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6xSQ2HaBp4VGGOaQ5AmjairlFsxNFXDYMnHC9JTDLQA=; b=Z/pQMMBUlGyOB8H85WuIeuwHzg6mopT5yJKnUmy71VmGvnPUI8qHmOEaXVPHjw1UuX 74v2FHJ84fP3N75pJ0VHJAf23tGCxgFUDbATwWP9Ikz6+ZBZnZz+Rk9/EGEZzc1oR86A d6KibssRcIiW9xsYi8AfO7IFTOIdA5/YHiFsU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6xSQ2HaBp4VGGOaQ5AmjairlFsxNFXDYMnHC9JTDLQA=; b=hzj5p6B/lNfc03NhjCGErTXylFqUAkezcrsxHMGsusU/om4qucsmCo96l7hmP6oOno vmsSw7CAumynnxasaB0hbPWN463T19woyccmP9gVPGBEzym3dsqsX2bMLsLDFz0IMO4j KTXp5147fTmLkK0gFjEBmNNM4+IMMAXFNgGb/615ErHbT9VWTnGujA+HBYEfW+Nacxu/ cwAo/wZK9IZZ/wKLlZ+/jicAci+Ko2Bak5T65XmZRFqi6Bm4Ntf0n5te8m51u+8umH96 RrWjuPLASbYYqLB4L90OtkHLDN1J88yxo0WCbhaUn6mCFbWbyDkhQxZCcSMskwnSeMcC nHjg== X-Gm-Message-State: APjAAAU1NjO5eW30Ksp+ET50b51rZKSg8fTxHF5FBVAKxI75cyoDSGkW yAflYdcm1/TmSe74eHpHngTHhYYqH50= X-Received: by 2002:a2e:8050:: with SMTP id p16mr10707471ljg.160.1555950744195; Mon, 22 Apr 2019 09:32:24 -0700 (PDT) Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com. [209.85.208.173]) by smtp.gmail.com with ESMTPSA id w2sm3552417lfa.63.2019.04.22.09.32.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Apr 2019 09:32:23 -0700 (PDT) Received: by mail-lj1-f173.google.com with SMTP id l7so10826691ljg.6 for ; Mon, 22 Apr 2019 09:32:23 -0700 (PDT) X-Received: by 2002:a2e:9213:: with SMTP id k19mr10159740ljg.118.1555950249750; Mon, 22 Apr 2019 09:24:09 -0700 (PDT) MIME-Version: 1.0 References: <00000000000043fe9c058720a5d3@google.com> In-Reply-To: <00000000000043fe9c058720a5d3@google.com> From: Linus Torvalds Date: Mon, 22 Apr 2019 09:23:53 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: WARNING in percpu_ref_kill_and_confirm To: syzbot Cc: Arnd Bergmann , Jens Axboe , Borislav Petkov , "Darrick J. Wong" , Greg Kroah-Hartman , Peter Anvin , Linux API , linux-arch , linux-block , linux-fsdevel , Linux List Kernel Mailing , Andrew Lutomirski , Mathieu Desnoyers , Ingo Molnar , Michael Ellerman , syzkaller-bugs , Thomas Gleixner , Al Viro , "the arch/x86 maintainers" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 22, 2019 at 9:06 AM syzbot wrote: > > > The bug was bisected to: > > commit 38e7571c07be01f9f19b355a9306a4e3d5cb0f5b > Author: Linus Torvalds > Date: Fri Mar 8 22:48:40 2019 +0000 > > Merge tag 'io_uring-2019-03-06' of git://git.kernel.dk/linux-block > > percpu_ref_kill_and_confirm called more than once on io_ring_ctx_ref_free! So I don't see how that happens in the original code (because __io_uring_register() is called with the uring_lock held), but let's see. HOWEVER. I do see how it happens now as of the latest kernel as of commit b19062a56726 ("io_uring: fix possible deadlock between io_uring_{enter,register}") where the code explicitly drops the mutex in order to wait for other uring users to finish. So Jens, I think that commit was buggy. I suspect that io_uring_register() should perhaps do something like --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2934,7 +2934,10 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode, { int ret; + if (!percpu_ref_tryget(&ctx->refs)) + return -EBUSY; percpu_ref_kill(&ctx->refs); + percpu_ref_put(&ctx->refs); /* * Drop uring mutex before waiting for references to exit. If another to guarantee that it's the *only* case of io_uring_register() doing that kill. Hmm? Linus