Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp12620453rwl; Tue, 3 Jan 2023 18:01:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXtQhcALw/OAu6XsvLXP2UZdPcCDX9/TIKQD4W4ezevQ3KH4bKYB2sgjVU1DScc5HRYJe38t X-Received: by 2002:a05:6402:194d:b0:48a:518:77f2 with SMTP id f13-20020a056402194d00b0048a051877f2mr18656774edz.36.1672797701273; Tue, 03 Jan 2023 18:01:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672797701; cv=none; d=google.com; s=arc-20160816; b=aLewMgh7PeRqY4v3fygLYvqR9WCLCWvc8U8UBGDjULU3cNI0zgbKmGazheinvZivAC 3T5/gGn7x9v35I5s8XCWvBefvoFcu7cIWAgI+b4W/L/+PV4lY+2vsAp9Xv0zIRXLFKtb WKe/ghplTHaqOfC3iimQHAOlEsP0NH4ZMjIPCcmZIz3YSfne5zXWUaou4ekgcX5zcq55 mh43bbr0zD1DdNDgaZqR19WV/A7LhgDVZlsqGrP60JmgVoGo7HMruu0kQERV3/bI0LbM wIX83CGdxE7//b9UQBv2foGpOBTH/2GTyVg/Yt3TO84zawe45FCp2zSCLd+oq8qINve+ gUHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=TLKBUphXfs/UWZdenQBIRYJf0m4RI75UDSLQL1B/F20=; b=casShhY2c7U+ZN8mO4YZVG3vBD9zjQnIU024Fdzse1Z5+bt3shoEFvEa80HPNNp6eG 48csowKVXLQIojJ2mGP9z9hlYHN4dlTwesnmUC58dHV952rM4ts8HwY9ZtSjiZ1hsTK0 jW0OVKkFHw6pD1juJzjNG4FkiWYYsyWgX6i4Y+xMhHJ+/D9nvJv/LSOyZR+ftuifsNs9 M0v2YeAj5lo7qNDa4XOTsoxPW1+sYaQ7Pv7hYd3QfC9y5D1nvcuRCwMis+k4MabtAojM 6qoNumS1aUqK9Re+W5PWac4vJ0CEGmvfruOJt4ddqH1yDPUavhJ1n4J8+C4H+IbDPPMC yGvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KTelfnNN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a05640250cb00b0048b0ae570d8si15193467edb.508.2023.01.03.18.01.11; Tue, 03 Jan 2023 18:01:41 -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=@linaro.org header.s=google header.b=KTelfnNN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233893AbjADB5o (ORCPT + 99 others); Tue, 3 Jan 2023 20:57:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229534AbjADB5n (ORCPT ); Tue, 3 Jan 2023 20:57:43 -0500 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 978851740C for ; Tue, 3 Jan 2023 17:57:42 -0800 (PST) Received: by mail-lj1-x22b.google.com with SMTP id p2so18487551ljn.7 for ; Tue, 03 Jan 2023 17:57:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=TLKBUphXfs/UWZdenQBIRYJf0m4RI75UDSLQL1B/F20=; b=KTelfnNN/7MymnnCGQBQslfVwxbDJd4c80V4g70R0Px9RHiEZnKnMlGopzmHb/sHkD 7qOFXZwsVZ2unvCGIGSwxXbcgTFaFm59MaHjMYVuo3YrgjIKmU0ezIhQwoBpGBr25yW6 /pbMHzg7Ic+WOGK+R0q1ePBsSwbVKsiGce2iQNcKbd8PMMBMNPGpQRN7PIoUzaaB7ccj OWh/LTsiw/6vO+HRLH39dAQh/sZQHq2DEwFoG7zHR1vE+b8fUP89xZKQvyQZ1mGciMXJ eEahFtDJVCRsgmQaPWgQ4HVzjf9t6zW75QKrz0/8MigMknrKJakTub06FBCfVo1r33HY M8ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TLKBUphXfs/UWZdenQBIRYJf0m4RI75UDSLQL1B/F20=; b=HTuS49eB3AXoAI22oigLo66x3+8PGZWudSSBp7saTIEPaviYpTz/xIrujttPnW15Q/ ZArpCaQZ1avB08z7e0SUScdrmQEOKZYFwYRGhVgfco6fbaa4Xpu4WQcHUFPFWigGFpLr VoW86fqCDAyyMSIe8MrmeOLMhYfn6SpC8fTuPuPtPYXQsWpIR0g776SR6Cs0JBXeDD0r 8NVx0tcepRs6jvgiBSSKkKS+vC4/pJ3lnS1bcagjSdSDCwHTL0Hb5ZdGuYiYxF6a3i48 T6TUsBbgfntt8DG/FgsI2xRUhttfFFhFisYzFbRRUjuLM0ULXn3ZQXs6kZQzV220DsIp mjJg== X-Gm-Message-State: AFqh2kqG4hoW/RGbXllo3Ug2NE853TSjHKDXcLR3q4c/ZhOsG0C37RAT dw1qk674ISS/T1KLdpGuQOGUyGR3OlBCErtq/GZH5g== X-Received: by 2002:a2e:a593:0:b0:280:54b:9254 with SMTP id m19-20020a2ea593000000b00280054b9254mr74610ljp.165.1672797460849; Tue, 03 Jan 2023 17:57:40 -0800 (PST) MIME-Version: 1.0 References: <20221229014502.2322727-1-jun.nie@linaro.org> In-Reply-To: From: Jun Nie Date: Wed, 4 Jan 2023 09:58:03 +0800 Message-ID: Subject: Re: [PATCH] ext4: reject 1k block fs on the first block of disk To: "Darrick J. Wong" Cc: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, tudor.ambarus@linaro.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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-ext4@vger.kernel.org Darrick J. Wong =E4=BA=8E2023=E5=B9=B41=E6=9C=884=E6=97= =A5=E5=91=A8=E4=B8=89 03:17=E5=86=99=E9=81=93=EF=BC=9A > > On Thu, Dec 29, 2022 at 09:45:02AM +0800, Jun Nie wrote: > > For 1k-block filesystems, the filesystem starts at block 1, not block 0= . > > If start_fsb is 0, it will be bump up to s_first_data_block. Then > > ext4_get_group_no_and_offset don't know what to do and return garbage > > results (blockgroup 2^32-1). The underflow make index > > exceed es->s_groups_count in ext4_get_group_info() and trigger the BUG_= ON. > > > > Fixes: 4a4956249dac0 ("ext4: fix off-by-one fsmap error on 1k block fil= esystems") > > Link: https://syzkaller.appspot.com/bug?id=3D79d5768e9bfe362911ac1a5057= a36fc6b5c30002 > > Reported-by: syzbot+6be2b977c89f79b6b153@syzkaller.appspotmail.com > > Signed-off-by: Jun Nie > > --- > > fs/ext4/fsmap.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c > > index 4493ef0c715e..1aef127b0634 100644 > > --- a/fs/ext4/fsmap.c > > +++ b/fs/ext4/fsmap.c > > @@ -702,6 +702,12 @@ int ext4_getfsmap(struct super_block *sb, struct e= xt4_fsmap_head *head, > > if (handlers[i].gfd_dev > head->fmh_keys[0].fmr_device) > > memset(&dkeys[0], 0, sizeof(struct ext4_fsmap)); > > > > + /* > > + * Re-check the range after above limit operation and rej= ect > > + * 1K fs on block 0 as fs should start block 1. */ > > + if (dkeys[0].fmr_physical =3D=3D0 && dkeys[1].fmr_physica= l =3D=3D 0) > > + continue; > > ...and if this filesystem has 4k blocks, and therefore *does* define a > block 0? Yes, this is a real corner case test :-) > > --D > > > + > > info.gfi_dev =3D handlers[i].gfd_dev; > > info.gfi_last =3D false; > > info.gfi_agno =3D -1; > > -- > > 2.34.1 > >