Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5293018ybl; Tue, 27 Aug 2019 02:21:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMF1yulmk8xhU0188Y3fUXdjmWGRQDpokq8lHXrE8I8bnMhIQAHkq3VJ7W6AgZYsP3PiQz X-Received: by 2002:a62:34c4:: with SMTP id b187mr25529676pfa.161.1566897718612; Tue, 27 Aug 2019 02:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566897718; cv=none; d=google.com; s=arc-20160816; b=RYW7/rDZvhXET9EjHUu6ytN0pFa0XOqcipYuDg7UmVO8CLHWTdlpSyaT65IPreAqQL agmerCKuYqu5nJclJwUlCDclAPjmdIjOfl7S4oa+XCKE/Wa3/7XBviAhpQ+cv45qrJj/ sNOJfP/bmyDZv9Prxmowrah3RcYJWVtN+o2KZTOYmPMIBIaUCgpz6l1xXH4ItA3EvASH F1aW3WIDXu4sf6e5P6KdvUULI0CQOi++Pi+Ztga4o9rTpo4/LIJFoele7puDx7pW+dJp 8AO2kNYR/jC2AFkpHnHvi9MuAfFe+IFWmwMwpVmWC+hhw8NHulUEwabs1JoDCalMRRUZ 604g== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=tv/xC3T7l3VSodhzCuXTYX0YaEybNm6gvmcSXlGu/Mk=; b=fo+eaTDrFgNeG6QYaMNF6AYQerhNw89eaBj/LGKLOhZJZDj5tPaVdGZIj8WObyyyw9 YvT144zt4cJCcjY74P2sWuohQ3MDV6eUEIoZIEEx6TI2MyGHr7zMH0WOMBkkRlESrKCZ pTs6lYEBsbCDv4BCqJtvmQuHVsGHiQCoJvJc1OiZO8bDfIboakPSmhkFLf/he6muec6c Ttw7I2D7rJnfXl1LiG36LrLlQDzuGVLevy1Q/cFA+Ke+2Zq+eBYknJIu090Bty5FOaR7 GaXbGzcEHugtYtQVn3HtClAfYC0BwpOPXt9jKFZ3xV63/gYTbwYvZmTHHtaPMkFzFAp8 Bd/w== 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 l184si11310472pge.286.2019.08.27.02.21.36; Tue, 27 Aug 2019 02:21:58 -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 S1729377AbfH0JUu (ORCPT + 99 others); Tue, 27 Aug 2019 05:20:50 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:5221 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725912AbfH0JUt (ORCPT ); Tue, 27 Aug 2019 05:20:49 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id B349910FF19798F531BF; Tue, 27 Aug 2019 17:20:46 +0800 (CST) Received: from [127.0.0.1] (10.177.244.145) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Tue, 27 Aug 2019 17:20:41 +0800 Subject: Re: [PATCH v5] ext4: fix potential use after free in system zone via remount with noblock_validity To: Jan Kara 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> <20190826150350.GH10614@quack2.suse.cz> CC: "Theodore Y. Ts'o" , , From: "zhangyi (F)" Message-ID: <6874efe7-17e9-6651-0b38-22b8b8946599@huawei.com> Date: Tue, 27 Aug 2019 17:20:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20190826150350.GH10614@quack2.suse.cz> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.177.244.145] X-CFilter-Loop: Reflected Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 2019/8/26 23:03, Jan Kara Wrote: > 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)); > Totally agree, will resend the patch. Thanks, Yi.