Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4317548ybl; Mon, 26 Aug 2019 08:40:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzTUcFWUvVKdwj/zeltjC8DbpeXbHiOvTA+/mHpHyQeJwXZ3C3VwBK8+4LcAUFKBcdq102R X-Received: by 2002:a17:902:1122:: with SMTP id d31mr20007021pla.254.1566834012941; Mon, 26 Aug 2019 08:40:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566834012; cv=none; d=google.com; s=arc-20160816; b=SNDJsgMJzNU00b19sd7GygEOsTk/lU9ZH50JxwblmqBlzWqmbxI9BkB7DYWoz7TW/j jr+z/6R30vYJvkQTxQ/SMDL9lSbJE617qVuKTl4W4ZG/7H/fONJf/fx7kF7jw5hcWc8i CSERiBo1n9zXVqETwh5YUEM2FYOM4PEQ2m0Dx4yaHt4NIY+yw2eBKynRrPOIaR2eDqV9 E+K/fif7WqwUtXi5mn8iOYtlVTNnlp6gU8n28Q1pdaY9bWr1TptfFH/8kSmiQuiLxXhI MzQxfYD/BfGr1EcrGqm2Cep2qe7qZcPwEebc3mC9Qtsecw+PxYwy36NkoBrORCMBsvJC ozOw== 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=DtoQ901w+2kRyULIzj3wXo+k37oLoF7P8AzbP8Z8WtU=; b=MhQcJDfFHv7A3C3/SP2/vAstjPjAUyWrBfM9qfuAl1SjknYlGL/sW/ZXuRmm3QvA1w eFVOAfJxnYG5AhOVPB2qiUyfGqCbeCgImaMx5cQaAUmcMr3uCkHmAJmRcCoVJZVTGCa5 ZFynMcuqKTei5sAc9xtpOqEzGi/e4xUPbAQ9dDTeJZ+EcIvExEVv+5+95Bz76Qox5QR8 aHX6D/kRXa/hZ/xuLVHWuV12Kw6aLOYhgJn6AncOcyYUF9HWWOGu7eIHvU6r8wycHrpn 4KlQRDig2kkQWspLZv4v0y6iajUK35Nf5v2cFihVMK5DONkv/XSw1H6P5R9Z0e67+lDt Ln9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 c13si9398234pgi.588.2019.08.26.08.39.55; Mon, 26 Aug 2019 08:40:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732803AbfHZPDw (ORCPT + 99 others); Mon, 26 Aug 2019 11:03:52 -0400 Received: from mx2.suse.de ([195.135.220.15]:41168 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727031AbfHZPDv (ORCPT ); Mon, 26 Aug 2019 11:03:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C6784B07B; Mon, 26 Aug 2019 15:03:50 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 479291E3DA1; Mon, 26 Aug 2019 17:03:50 +0200 (CEST) Date: Mon, 26 Aug 2019 17:03:50 +0200 From: Jan Kara To: "zhangyi (F)" Cc: "Theodore Y. Ts'o" , linux-ext4@vger.kernel.org, jack@suse.cz, adilger.kernel@dilger.ca Subject: Re: [PATCH v5] ext4: fix potential use after free in system zone via remount with noblock_validity Message-ID: <20190826150350.GH10614@quack2.suse.cz> References: <1565869639-105420-1-git-send-email-yi.zhang@huawei.com> <20190825034000.GE5163@mit.edu> <20190826025612.GB4918@mit.edu> <33767946-1e6f-5165-94b3-46e2da15172f@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <33767946-1e6f-5165-94b3-46e2da15172f@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon 26-08-19 16:31:41, zhangyi (F) wrote: > On 2019/8/26 10:56, Theodore Y. Ts'o Wrote: > > I added a missing rcu_read_lock() to prevent a suspicious RCU > > warning when CONFIG_PROVE_RCU is enabled: > > > > diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c > > index 003dc1dc2da3..f7bc914a74df 100644 > > --- a/fs/ext4/block_validity.c > > +++ b/fs/ext4/block_validity.c > > @@ -330,11 +330,13 @@ void ext4_release_system_zone(struct super_block *sb) > > { > > struct ext4_system_blocks *system_blks; > > > > + rcu_read_lock(); > > system_blks = rcu_dereference(EXT4_SB(sb)->system_blks); > > rcu_assign_pointer(EXT4_SB(sb)->system_blks, NULL); > > > > if (system_blks) > > call_rcu(&system_blks->rcu, ext4_destroy_system_zone); > > + rcu_read_unlock(); > > } > > > > int ext4_data_block_valid(struct ext4_sb_info *sbi, ext4_fsblk_t start_blk, > > > > Hi Ted, > Sorry about missing this warning, I think switch to use: > system_blks = rcu_dereference_raw(EXT4_SB(sb)->system_blks); > or > system_blks = rcu_dereference_protected(EXT4_SB(sb)->system_blks, true); > is enough to fix this waring, am I missing something? Proper fix for this is actually using: system_blks = rcu_dereference_protected(EXT4_SB(sb)->system_blks, lockdep_is_held(&sb->s_umount)); Honza -- Jan Kara SUSE Labs, CR