Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1236705pxb; Tue, 1 Feb 2022 23:30:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0xqmuIYZrKU6D1zhWHL+P9hKdIiRjtlhh67yTwTjLjZjkdQbC8XRHvru9HVogLsI9sGA/ X-Received: by 2002:aa7:9e4a:: with SMTP id z10mr28198224pfq.53.1643787000193; Tue, 01 Feb 2022 23:30:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643787000; cv=none; d=google.com; s=arc-20160816; b=o6NX4kw039gZNQAgtqWWMUw2inLNUMuf40iU4Yte6y37BnvF0sJy+O34bbWgfADFkF E1u9FcL9BkA3j214w5wfEvY2CMPcV4Kuw0x/fX4T52xG/7M5ZWcjt7cglgQT7F0DH1It haDnP7PJNlu7jUg9qCOdavtG8kSv6oifSEdePV8rSvAYtjeYMxrwjQEo6jefubnPswDX pKSHMp2kfxEDHqEs0ZKWBIMHkCfrELVWh2ZMM9Xg9CrjTMGziPpmxhwIn/Dj6z8LVfUr md7uPLrmW0CgFxM+U4KqUOViuLEZntuaVgsib1MLfY0oKKoOa/kzgZJPBOH0yq9fcvFd RIDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=n7iNcT51hZ1Z3NxjkQY5xHCeIRSxzR75ruYUzUbMRxg=; b=eN0tNZsMEo3hfREr8UAgtKQZGs+4x2Z75FqX/GRjjkY60FTqDwTI/tYEHfaGQA/Qpt HVZdFZpG2r2nEM7plQlGyFiHpu5jFNdI/t/L4q4Q5kF6MedlYU2QakJT3+pvjsyvVsar rQAXqt74QX+MsMSIg2Ci8YEQgEKaz7ODWxCJyF+vvhcTUHMr55OxdCoS2J0cl3R88iu8 YGxJV/9kBRAClkpongFlfahU/6kWYg/QnyyG7TozXzRgxTjRMJX2s9rYTcDDh29XCwGR 23pHfHVtsd5rIItNhE+VwOhfI2KE5hK1KCFhJK5BQzTtUACSQGjaaHrAuvlje7R/w9L6 SThQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=cpgdqNr9; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=z3yEEocq; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q21si16884716plq.266.2022.02.01.23.29.36; Tue, 01 Feb 2022 23:30:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-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=@suse.cz header.s=susede2_rsa header.b=cpgdqNr9; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=z3yEEocq; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237374AbiBALrV (ORCPT + 99 others); Tue, 1 Feb 2022 06:47:21 -0500 Received: from smtp-out2.suse.de ([195.135.220.29]:52084 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237141AbiBALrV (ORCPT ); Tue, 1 Feb 2022 06:47:21 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id F26081F3AC; Tue, 1 Feb 2022 11:47:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1643716039; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=n7iNcT51hZ1Z3NxjkQY5xHCeIRSxzR75ruYUzUbMRxg=; b=cpgdqNr9XjsW/lL0T47hms//3hNKTRprkg+XwRD6+ZAVL/l43UvDlIOZt+9LqrmuKoVhna F5q7SdFGq0g2rlLgEpX1tgPGuNeYKtx/sFsQVmhB8zp4Wj9vnHs3U9Hi3qNBYQ9Q4ELFwI By+2veHZ3YLCftTFb2u7zm9VV8Pd/qY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1643716039; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=n7iNcT51hZ1Z3NxjkQY5xHCeIRSxzR75ruYUzUbMRxg=; b=z3yEEocq/H1Ni33Uv4SMliROfzI+346W9JYtl7LOyx23F+vmaRwQGHYV3Fts+zv8etB1IT KiPfff6357jyFYBA== Received: from quack3.suse.cz (unknown [10.163.28.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id E4528A3B81; Tue, 1 Feb 2022 11:47:19 +0000 (UTC) Received: by quack3.suse.cz (Postfix, from userid 1000) id 9C38DA05B1; Tue, 1 Feb 2022 12:47:19 +0100 (CET) Date: Tue, 1 Feb 2022 12:47:19 +0100 From: Jan Kara To: Ritesh Harjani Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, Theodore Ts'o , Jan Kara , Harshad Shirwadkar Subject: Re: [RFC 6/6] ext4: Add extra check in ext4_mb_mark_bb() to prevent against possible corruption Message-ID: <20220201114719.dzyeitz26kpde5zf@quack3.lan> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon 31-01-22 20:46:55, Ritesh Harjani wrote: > This patch adds an extra checks in ext4_mb_mark_bb() function > to make sure we mark & report error if we were to mark/clear any > of the critical FS metadata specific bitmaps (&bail out) to prevent > from any accidental corruption. > > Signed-off-by: Ritesh Harjani Again please rather use ext4_inode_block_valid() here. All the callers of ext4_mb_mark_bb() have the information available. Honza > --- > fs/ext4/mballoc.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c > index 5f20e355d08c..c94888534caa 100644 > --- a/fs/ext4/mballoc.c > +++ b/fs/ext4/mballoc.c > @@ -3920,6 +3920,13 @@ void ext4_mb_mark_bb(struct super_block *sb, ext4_fsblk_t block, > len -= overflow; > } > > + if (!ext4_group_block_valid(sb, group, block, len)) { > + ext4_error(sb, "Marking blocks in system zone - " > + "Block = %llu, len = %d", block, len); > + bitmap_bh = NULL; > + goto out_err; > + } > + > clen = EXT4_NUM_B2C(sbi, len); > > bitmap_bh = ext4_read_block_bitmap(sb, group); > -- > 2.31.1 > -- Jan Kara SUSE Labs, CR