Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4301415rwo; Tue, 25 Jul 2023 04:08:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlFcxbrplsVETAgzCwb7eLCzBIWMfHe1EsHdCF8qv/RtnyQ7nRAhPiBmhcS7hpvSlh8STD56 X-Received: by 2002:aa7:ce1a:0:b0:522:30cc:a1ec with SMTP id d26-20020aa7ce1a000000b0052230cca1ecmr4109275edv.0.1690283334056; Tue, 25 Jul 2023 04:08:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690283334; cv=none; d=google.com; s=arc-20160816; b=I0Ehh3Pixz+oSq+0kp8nfh1p+5NyIpoFgu8C6elflo/xPXxETAbrIQecIPEtymkm5b 9hn1IYFV18mGXi57al7CY2qpGW6+eqzJlC+DKH50duQo1kOBWRdPsyppJ6pvRd3691UH jz+/f5pxcjrfr83dbirNK0r+R19hNPWMEighwA1nn9G211hPSOIEhU8dY+he9Mu3RQfx LraNi55z1Vp+O3IftexrBcL0jVYtMYNKvgjxoeN2Fqu608otxLWqX78Madt+2CrCPcBQ 5MS4q/jvIBLNstGZ9jvrfrWXKbaVdySYiEErVIK0ZXGldjRdWp32Xn/bK+9erHodia3y X1Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:subject:cc:to:from:message-id:date :dkim-signature; bh=jxo6App/CgZGpWLnlrQ5JN9zlgf5XBdiJvk1vlDo3iA=; fh=h1ghZINZiFLLlrt4p1llC4IfVINLt2KICwBfPlwm7kM=; b=Me4UfRw3NVu7+E7zPSMhYhjf/WOth/BROUOt9bf7iSXBjBQRrBvriuMT79yy+eyFL9 tI7Ai+4F61XV1mhe7/fKekpUtCh3lkaoZq2rAA9baSuF2vQHuvDr9fwkqUSlNG7CAQBO DdhQvxq+03AOimJKnR1sP0UfAoi1MBSAAQ92yXrE04Qn1YgAJp9fEdDP0kdjJKyxPWv1 tK1jW4u4LmDh2JtmEAVGiS8+ghII2ctixf7syypc8YD/Dv+eiUV8jqq6ZSSM4s4mE0Qh 0Xr2Rc1FRYJdq2ywBio4MiU1DnaOt8hgkY6SI1AqTVd0MTrxaJurfSJX3AiC1hwsjZ9X 5vqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=cv9wUDYG; 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=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 f3-20020a056402150300b0051e33b5ee68si7650554edw.250.2023.07.25.04.08.27; Tue, 25 Jul 2023 04:08:54 -0700 (PDT) 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=@gmail.com header.s=20221208 header.b=cv9wUDYG; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233853AbjGYLIT (ORCPT + 99 others); Tue, 25 Jul 2023 07:08:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234100AbjGYLIA (ORCPT ); Tue, 25 Jul 2023 07:08:00 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA4AB19A0; Tue, 25 Jul 2023 04:06:33 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-68336d06620so5031777b3a.1; Tue, 25 Jul 2023 04:06:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690283193; x=1690887993; h=in-reply-to:subject:cc:to:from:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=jxo6App/CgZGpWLnlrQ5JN9zlgf5XBdiJvk1vlDo3iA=; b=cv9wUDYGjfqpNaB58SD8ThhvBpLaBiF/sXeDoHd/7Y+ZpbHv7Y8CO6+wVI3acHT4Bv CHfeCexJJDavZma+i4mV+sqYN7a+oK/dkoW8rkupyOh4TZRv4qJ+0RiCEG+frPgNXLkh Zjj7tK+G+W5N57Qc7MdfuOz06Kqj4au6yIJBMhduZxy5b7AJ+7lDIXZQCBP7XV9caRZJ LiaZAMXCp01riRPPNYUsJx8l4YBh8GexAzncVYS4OgH41CH9wmFXpupILyf+9Nl9YWi+ xJM3Rv/5ZgcTaCaVhwWEeeaC661tTv8RS5Wo4YiNC1WCAJsF4XX0AwxU+FOyOU3waPh6 kFhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690283193; x=1690887993; h=in-reply-to:subject:cc:to:from:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=jxo6App/CgZGpWLnlrQ5JN9zlgf5XBdiJvk1vlDo3iA=; b=QQ5veCkpH5b9pp+gSAQ3fnTho3rc4bi7YYnmVHr40S/tdwx1E01UJvh2t82GXIXu95 RS39Zo8ZSbVgJw8JvcgMHE16WgG9QLLO1fgTZ69qtLq4EOj5Itg8t9XVjBtbQavcUPk/ 2iz7TR+7eDKyHZfEBADhpOfEAmUveNFacapkBCoRfSQXCR48ce79V6zL8WE5CSy6v/ov MUlVSNaC4MxLxprVoETlrcca7aS5C1R58L8TnSZTBkUSJJSiFoobc4v7qN08iAMvK8FL SyrQEAQG/Vy3N5IMwfBS9LiAIOP7ID8wTfy0XJUwpMtD114GRCLmLTyZsiDB6VpJ2SbS 8jbQ== X-Gm-Message-State: ABy/qLbxgCxy6+6cX/WHHUtR3U1+XPZhmPrbe05eielkAekviHY4o3qu NdWRS5qyAg5xPnNpozAOkIU= X-Received: by 2002:a05:6a20:1058:b0:133:bc8:8a47 with SMTP id gt24-20020a056a20105800b001330bc88a47mr12562878pzc.3.1690283193035; Tue, 25 Jul 2023 04:06:33 -0700 (PDT) Received: from dw-tp ([49.207.232.207]) by smtp.gmail.com with ESMTPSA id k9-20020a633d09000000b0054fd46531a1sm10328402pga.5.2023.07.25.04.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 04:06:32 -0700 (PDT) Date: Tue, 25 Jul 2023 16:36:24 +0530 Message-Id: <87a5vkw8r3.fsf@doe.com> From: Ritesh Harjani (IBM) To: Kemeng Shi , tytso@mit.edu, adilger.kernel@dilger.ca, ojaswin@linux.ibm.com, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Cc: shikemeng@huaweicloud.com Subject: Re: [PATCH v2 01/10] ext4: correct grp validation in ext4_mb_good_group In-Reply-To: <20230725185106.2147273-2-shikemeng@huaweicloud.com> 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-ext4@vger.kernel.org Kemeng Shi writes: > Group corruption check will access memory of grp and will trigger kernel > crash if grp is NULL. So do NULL check before corruption check. > > Fixes: 5354b2af3406 ("ext4: allow ext4_get_group_info() to fail") > Signed-off-by: Kemeng Shi > --- > fs/ext4/mballoc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Looks good to me. Feel free to add: Reviewed-by: Ritesh Harjani (IBM) > > diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c > index 456150ef6111..62e7a045ad79 100644 > --- a/fs/ext4/mballoc.c > +++ b/fs/ext4/mballoc.c > @@ -2553,7 +2553,7 @@ static bool ext4_mb_good_group(struct ext4_allocation_context *ac, > > BUG_ON(cr < CR_POWER2_ALIGNED || cr >= EXT4_MB_NUM_CRS); > > - if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(grp) || !grp)) > + if (unlikely(!grp || EXT4_MB_GRP_BBITMAP_CORRUPT(grp))) > return false; > > free = grp->bb_free; > -- > 2.30.0