Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3335617rwb; Tue, 16 Aug 2022 00:33:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR76tlST5XIMjHT/gufTLcjOIq7HNn46V9SR293wlsm+wf7fURs+N+zmrTYjlyrO86OgQaBw X-Received: by 2002:a17:906:ef8b:b0:730:e14f:d762 with SMTP id ze11-20020a170906ef8b00b00730e14fd762mr12800871ejb.519.1660635222783; Tue, 16 Aug 2022 00:33:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660635222; cv=none; d=google.com; s=arc-20160816; b=Iin9a3wui9flbIVh7OSzOLd2OtT86K1QZBxiFYeY7ppjrpM+BQVIY8TUAO9vzaya0N MWmtrAv0laaE4wt5NOOgibWdXK5iXJ5DOQs+jqg5PGUPcFMmxEmhriK1rNCEf+OXX9oV NzbswyjGB7NA7D/6Eya/CJEisfKqoZL2jjwyduIG/v3vk4YXCTKKbNboz6zqOJiXUthz Eb0Ve0U7rNrO4+m6fg8OG7mgA6VkPm9iAVBJ0EgNvGLXfx5M5Lg8RvXb97JPb/JT5Mz3 rpyuP9Of2o++VAFQ9jas7EshDsRaYu6wYuAIQP+Yro2fzS+a+zIL28KERBUtfW0FMoos rsdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=0+fOHte+oOjdt0ZcS9IxeZxJv4FE7v9fXbd9M9vTVIU=; b=d1lxtKpbcBDtKEuy36u73hRBJkiQGBo4i/lVBiPQhwhY0pPQ67EEwknovguzQHQDD+ V+vJ829KpmHtGWqmbSdx+FDmzdVS0zah1QMZfHgDcg3+FD/Z8NJ98l0rHvrEqZ+aArGN KFCd0xQ3VX0TzPUwZSF1zzNyo4i5mRs0VBTK4oeUnf8pgajzqX7u3ROvkie+Z1EfncfE WZp6dKCXql2gRZswbrDdtlOqcYtWfb0A3LPmuvwHhx/U8o/tpk2Pv8zIdkBxGg9TjfcU E6ZEFPOe+G3jdW5VK59PTqiq+nHQNAMC7eA20u0o3o2IYxVxU/pCbfnBg9wS7EYhX3Gu 0CZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KpnzdQRG; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g10-20020a50ec0a000000b0043d2569d289si8395686edr.390.2022.08.16.00.33.16; Tue, 16 Aug 2022 00:33:42 -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=@gmail.com header.s=20210112 header.b=KpnzdQRG; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229658AbiHPGk1 (ORCPT + 99 others); Tue, 16 Aug 2022 02:40:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230035AbiHPGj5 (ORCPT ); Tue, 16 Aug 2022 02:39:57 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E68FE8F971; Mon, 15 Aug 2022 20:25:26 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id dc19so16619619ejb.12; Mon, 15 Aug 2022 20:25:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=0+fOHte+oOjdt0ZcS9IxeZxJv4FE7v9fXbd9M9vTVIU=; b=KpnzdQRG3/WPprMvYVg5B3iZfpc5bUgwIiRuujqtM8qqYLp5nR8x01nJ5ZS1xvL4uy 871+vwwCOc0PkvDt0siufAeAvqFMyj3JcLqAgmA53l/CKS9Sw87+XeRs4L/vdhGF9Qb8 vQr4ksYMFRpJxhkifOawB1CCYt5Ez29v4PeyZxtvNg0lZ3xl2hVyclINQ/AJCgyoVP4k FW+03YnPcO8gPujo9nCTQ1LI5qEQE3B+Vqy2lUbFwhYO6XFmo0rckz82YVudlT0BQiF6 2MeZ2KAdjj3yRRykrleJ7rIpNyIWorxYK8y73Jk4M/yBXD8vWI9M2Wd0M6Lx6tvYlOOJ M4HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=0+fOHte+oOjdt0ZcS9IxeZxJv4FE7v9fXbd9M9vTVIU=; b=rnsM3rnt7WRz9Phw7Luz5e1w1mWH0xmbbGdPLMFMh6KGDqleshmxLWGZDSphy7n5JK mHzo0V5XvZ4WGFinmvcY2j7N/Tx39tCpOw/74aIY8MKdY1asp93+h20lO+x5bo6hERcG r4uu8fQWFZ2Y+Qj/ELFDTiGmjMxG9uXqQAJYv4ZtibLrcDLLbIXRZScNW+6eeOzdgWVC 5Lp2pQHOGVnlBtr/WkdAmVU8wdzBxEreMeOEFHW7feQ2fRCclWXtbrpqJpms9I7dkCJR rtJ7hAsnCTNDI3C5Tl+k0ebVMawphHO0Y3fAfd8usNL+gK2IFAirN6gvMHD1wxbgYisl j/gA== X-Gm-Message-State: ACgBeo0SpsGyT3bDHT5iyIQy5/ZE0I8IoaZbMcNtKF51POyaeZOxt1xy DVe567ph+1dreIKOkoE+BJkH7OU0xzqweovTLSk= X-Received: by 2002:a17:907:d9e:b0:731:1a5:8c68 with SMTP id go30-20020a1709070d9e00b0073101a58c68mr12186610ejc.365.1660620324829; Mon, 15 Aug 2022 20:25:24 -0700 (PDT) MIME-Version: 1.0 References: <20220815175114.23576-1-konishi.ryusuke@gmail.com> In-Reply-To: From: Dongliang Mu Date: Tue, 16 Aug 2022 11:24:10 +0800 Message-ID: Subject: Re: [PATCH] nilfs2: fix use-after-free bug in nilfs_mdt_destroy() To: Ryusuke Konishi Cc: Al Viro , Andrew Morton , linux-nilfs , LKML , Jiacheng Xu Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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 Tue, Aug 16, 2022 at 11:11 AM Ryusuke Konishi wrote: > > On Tue, Aug 16, 2022 at 8:04 AM Al Viro wrote: > > > > On Tue, Aug 16, 2022 at 05:34:12AM +0900, Ryusuke Konishi wrote: > > > > > Yes, I agree it's better if security_inode_alloc() is moved to the end as > > > possible in the sense of avoiding similar issues. > > > But, would that vfs change be safe to backport to stable trees? > > > > Yes. > > > > > It looks like the error handling for security_inode_alloc() is in the > > > middle of inode_init_always() for a very long time.. > > > > Look at the initializations done after it. The only thing with effects > > outside of inode itself is (since 2010) an increment of nr_inodes. > > > > > If you want to see the impact of the vfs change, I think it's one way > > > to apply this one in advance. Or if you want to fix it in one step, > > > I think it's good too. How do you feel about this ? > > > > IMO that should go into inode_init_always(), with Cc:stable. If you > > (or Dongliang Mu, or anybody else) would post such variant with > > reasonable commit message, I'll pick it into vfs.git and feed to Linus > > in the next window. E.g. into #work.inode, with that branch being > > made never-rebased, so that you could pull it into your development > > branch as soon as it's there... > > I agree with your thoughts on the course of action. > Andrew, I withdraw this patch. > > Dongliang (or Jiacheng?), would it be possible for you to post a revised patch > against inode_init_always() that moves the call of security_inode_alloc() > instead of i_private initialization (as Al Viro said in a nearby thread [1]) ? > If you have time, I would like to leave it to you since you wrote the > original patch for inode_init_always(). Sure, I will post a v2 patch that moves security_inode_alloc to the location just prior to this_cpu_inc(nr_inodes); with proper commit message. > > [1] https://lkml.kernel.org/r/CAO4S-mficMz1mQW06EuCF+o11+mRDiCpufqVfoHkcRbQbs8kVw@mail.gmail.com > > Thanks, > Ryusuke Konishi