Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4670084ybb; Tue, 7 Apr 2020 12:01:05 -0700 (PDT) X-Google-Smtp-Source: APiQypLENBaXrBTpbRlxn6PKWTjQ3HdSYdeLpURAqfgGTMdslQHPv2yfaP3T5pOk77eGhxaPQCMG X-Received: by 2002:aca:d503:: with SMTP id m3mr213850oig.165.1586286065181; Tue, 07 Apr 2020 12:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586286065; cv=none; d=google.com; s=arc-20160816; b=Op12hgE1NYkR8D72/qODnQUnn6p/W6E+7Z6QxGy85vQ/gNNK0fiuwCOMXH1cbFKmvJ yk42hbNnoFK8CW9gvHGKS/ObFMzu/tR4r2w60KaaeBtX5+YOn7ot/gXhl1D6Mj2ZxpVi 1CQKbW6V/pUm5NWEu8z6X8QXucFmJg2ZPBsnS0d7WnTTbwGYaMs5VZRRWW4SB/HghvtD sSPQVuQtMZL3JMtzOluWgpYTfgceRZbyBu+erX6/UT4QZwwxJRUW5IcOi9gUp/TeFpMf Zv4Wwy5bvBcNRLtK2FjnSUHghQc2/ON8zU8CDErdn05Hj2IlYL4oeN6pdkqcMH9AfRBQ ZaSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=8g+YOhto+FId7IOGUsnB9ouZCy1lzdR5Jj8DGscjgPI=; b=iEI1fqi4z6MYeQdbufrMDN4om5R+HQD9zKc+2aPsB0A42tSt3BkQLHGaeNkFPnQJ1N JnRDiMdc+mbNkBVP7RJlFzkMFaLr2bw6/21wY6HLAmjJ7lDjaIbvTLC1F1DPz7rmb/tH GSRPL/yix1HyvU7ThHVYhHbNhtOonFLHar8pMCX9bsunp3A8b2Dmm7dFfbP1W6cGPer/ 0qgn/LQyVsK98Qch0DUEEa+2D/OT7ERN1qvadx/J2EpPhOdJpKLP6dqLycGHURI1/Iob A6V6jC/rSVAMTyV25eGtQ8dXLwPLJ+aPtWWu+PNvmXPhupq6MkXVup0MtQ0yW8asBXWz pdjw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x8si1404289otq.313.2020.04.07.12.00.49; Tue, 07 Apr 2020 12:01:05 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726734AbgDGTAK (ORCPT + 99 others); Tue, 7 Apr 2020 15:00:10 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:44153 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726332AbgDGTAK (ORCPT ); Tue, 7 Apr 2020 15:00:10 -0400 Received: by mail-pg1-f196.google.com with SMTP id n13so725394pgp.11; Tue, 07 Apr 2020 12:00:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=8g+YOhto+FId7IOGUsnB9ouZCy1lzdR5Jj8DGscjgPI=; b=lZ1KjvpXvtj33QhvN+6L47Fl7nyV9BQgah/WiiuNfrJRnXXoKpzRIASMmJI1U6DJfY Nspm7KlQkEt9JzC7SRfIaVSOe1OehX5PlhgO0i1EM7L2HwITRo0Nk6y5o2ZVyMPrrcb/ iavfpmP/lhUyvEXk4x17fzVzR+zJ4RSxho4zpA4x/wERThmineXfAH3Ra1HtldHJKYJ6 Csg3C6XedQAV6sqrYlv1bOw7g9HOntHqEP1TfRUnc869NpCp/TJKIu1VODW7ukO261FL QeZi45Au/nwwBrgThMeuD5kqtCsRYeVm98qFKaZLciXpJHPtnPaRiPLZO/VHBGSrIf0c rcTg== X-Gm-Message-State: AGi0PubnlF2qgaelbQlFdCLc6H5OXhjdRcsOyGR2mC0TQ1E4yIiwJrwD WzGrP1UDE0eaDI1TRQMDJrI= X-Received: by 2002:aa7:96c1:: with SMTP id h1mr3991833pfq.212.1586286007677; Tue, 07 Apr 2020 12:00:07 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id i2sm14616408pfr.203.2020.04.07.12.00.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 12:00:05 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 60B4B40246; Tue, 7 Apr 2020 19:00:04 +0000 (UTC) Date: Tue, 7 Apr 2020 19:00:04 +0000 From: Luis Chamberlain To: "yukuai (C)" Cc: Ming Lei , axboe@kernel.dk, viro@zeniv.linux.org.uk, gregkh@linuxfoundation.org, rostedt@goodmis.org, mingo@redhat.com, jack@suse.cz, nstange@suse.de, mhocko@suse.com, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC 0/3] block: address blktrace use-after-free Message-ID: <20200407190004.GG11244@42.do-not-panic.com> References: <20200402000002.7442-1-mcgrof@kernel.org> <20200403081929.GC6887@ming.t460p> <0e753195-72fb-ce83-16a1-176f2c3cea6a@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0e753195-72fb-ce83-16a1-176f2c3cea6a@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 07, 2020 at 10:47:01AM +0800, yukuai (C) wrote: > On 2020/4/3 16:19, Ming Lei wrote: > > > BTW, Yu Kuai posted one patch for this issue, looks that approach > > is simpler: > > > > https://lore.kernel.org/linux-block/20200324132315.22133-1-yukuai3@huawei.com/ > > > > > > I think the issue might not be fixed with the patch seires. > > At first, I think there are two key points for the issure: > 1. The final release of queue is delayed in a workqueue > 2. The creation of 'q->debugfs_dir' might failed(only if 1 exist) > And if we can fix any of the above problem, the UAF issue will be fixed. > (BTW, I did not come up with a good idea for problem 1, and my approach > is for problem 2.) > > The third patch "block: avoid deferral of blk_release_queue() work" is > not enough to fix problem 1: > a. if CONFIG_DEBUG_KOBJECT_RELEASE is enable: > static void kobject_release(struct kref *kref) > { > struct kobject *kobj = container_of(kref, struct kobject, kref); > #ifdef CONFIG_DEBUG_KOBJECT_RELEASE > unsigned long delay = HZ + HZ * (get_random_int() & 0x3); > pr_info("kobject: '%s' (%p): %s, parent %p (delayed %ld)\n", > ┊kobject_name(kobj), kobj, __func__, kobj->parent, delay); > INIT_DELAYED_WORK(&kobj->release, kobject_delayed_cleanup); > > schedule_delayed_work(&kobj->release, delay); > #else > kobject_cleanup(kobj); > #endif > } > b. when 'kobject_put' is called from blk_cleanup_queue, can we make sure > it is the last reference? You are right, I think I know the fix for this now. Will run some more tests. Luis