Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp58894rwo; Fri, 21 Jul 2023 08:29:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlGNPYlIADM+bmu+HCDCBxMwdo1HusR6uh4jdtDlGzBIqjNZ1+7V2yQUxs38oMBsEsjDHlCO X-Received: by 2002:a19:7515:0:b0:4f8:70f8:d424 with SMTP id y21-20020a197515000000b004f870f8d424mr1530198lfe.65.1689953374689; Fri, 21 Jul 2023 08:29:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689953374; cv=none; d=google.com; s=arc-20160816; b=Kfr3IcM8Zom76rZwCh4nsKvhXL45VtMa+dLZOEB2r1FKORvS9c7NLHvVHQ7X9P0H3c HtTUsmIlcEeom6mXeSJqLQN7KH43Gko5Bwu3hLIRHAvsrF6tqfL5XTI8W1iVUU/tVpa5 ZrPbAcPvq7pYmB30AuwF5KLzlvI4hcF/bDxeo8gaF6AsC4gUJbMz1FUN3FlJfPTU9+Wy 4u3Gy9YgtJkhVnTxhTK6/LO4fwxJUUdJxxabyoc5cCvlVLnT/zvzE5YmHa5zGh15pfcK QeYV3fQcq8KOlkVby0WvW4289l18MeXCgr7dTqeslcYUrqBpLsRyn8zG+OR4cgWP58U/ FIrg== 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=sc/DTasP+qpzciCLfF1JlTQRXfUStyF2Qp67Z3I2zcE=; fh=h1ghZINZiFLLlrt4p1llC4IfVINLt2KICwBfPlwm7kM=; b=H5R/dNFtT1vKOPwmQumeEXnw0atQfgqsDcTVHx+kPKE1891Mw5DTOOroQDDFIgi7wa Js1is1m35oD10P4Z5/7uUsO5lY5PokpD8iUUnINFiQ/CuYjsQXJK7YOBqEjKPBQMdTnl XgU7otQFaCzDjQ2Kos4QO6NB0vsWQeGsL+VuwhhXwKVMJ6+1eyFrKeQEFIjP3dUa8PgF 8YOU1lCRtFEaEtRc+Sj9wLxiNYz1DEI599nmo4L/tXvg8WqQgBYMqMtC5/hTffAr0RcN j4p68yNi/V/WJTkl3oFXuA2eHjQze3fX26Y536BOf16s5PNJ8xWr6yJP1q1fIfOOLFMJ 9kag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=mwNakMTy; 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 d15-20020a056402516f00b00521a4a67f73si2404078ede.464.2023.07.21.08.29.07; Fri, 21 Jul 2023 08:29:34 -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=mwNakMTy; 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 S231945AbjGUPXc (ORCPT + 99 others); Fri, 21 Jul 2023 11:23:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231391AbjGUPXQ (ORCPT ); Fri, 21 Jul 2023 11:23:16 -0400 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA5683C35; Fri, 21 Jul 2023 08:22:54 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-6b9ed0831bcso1703911a34.0; Fri, 21 Jul 2023 08:22:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689952974; x=1690557774; h=in-reply-to:subject:cc:to:from:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=sc/DTasP+qpzciCLfF1JlTQRXfUStyF2Qp67Z3I2zcE=; b=mwNakMTygU7aeOlyMGN+1YRXfckEAaBjZjgrsxiGExbe1JtrAWqD07Qye6c9hqpqhS NSvfGLEod46/FYQq+BwuOs10pt7FBKcScPwYNc1gpP2IynnNI8Oug1W4oRjPO1Q7VT/Y qzCI5leeaCHf2iXugSrEa+TfozQZie+QYDxT7Qh5nLDHkaZe0XCUJvvL2+ZxvDrj2oGF ijotZv1mRYKioa+esPC95sZ5tz4XnRunRYMqfOVzo0YiZTLoxiKmrABWm+cT+oeLe7dU MKOSID+fJHIDH+uW2wNvxrRALEMUJaPLjChWlftPk7eV+SO77w8Wxu33Abumu2mVemXw ol/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689952974; x=1690557774; 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=sc/DTasP+qpzciCLfF1JlTQRXfUStyF2Qp67Z3I2zcE=; b=ATMrs7YIeI8Esu5zuOuPywuZJK+2RVJHkqzh94ocRV9VwReKY1+ceIuMLcn1AVEdRt ujDgAG0bVzeMG1DBgRI88cn8ADZ1ldnGQF/MGpJUx4sJS/EFduuBqaPt5iK9mkadEA11 2lj3OJ4b3jkBTyfYCHr/hs2gtdb3FmdSM/8eFGXP+TRSBHKO905vZqPCXNwBxhEyyePY lpaWxolvj95CUFKY8ugeI1lLh0Tv3Xg3gRjNiinYj5KC60EcDBvwURXsA3Y7rxaJPsVk bQImkzKGYdsWazGN08vQjL1p1su3xJLh2UxreEgNqA2nAgjiYAmMIC7JGgBtsuzbsAPb gYyA== X-Gm-Message-State: ABy/qLbPFHDqGr1aLUUtOFCZe3gEJbYCGtc0Ukt48zMVEozecGFJ3zrF tYuXo6JIUvXgrn15WqyyWsejOREgf0s= X-Received: by 2002:a05:6808:2897:b0:39c:475e:d78a with SMTP id eu23-20020a056808289700b0039c475ed78amr2307330oib.17.1689952973691; Fri, 21 Jul 2023 08:22:53 -0700 (PDT) Received: from dw-tp ([49.207.232.207]) by smtp.gmail.com with ESMTPSA id 3-20020a17090a01c300b00263c8b33bcfsm2878401pjd.14.2023.07.21.08.22.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 08:22:52 -0700 (PDT) Date: Fri, 21 Jul 2023 20:52:49 +0530 Message-Id: <87iladl25y.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 01/10] ext4: correct grp validation in ext4_mb_good_group In-Reply-To: <20230721171007.2065423-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_BLOCKED,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(-) > > diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c > index 3ab37533349f..90ffabac100b 100644 > --- a/fs/ext4/mballoc.c > +++ b/fs/ext4/mballoc.c > @@ -2554,7 +2554,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 (!grp || unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(grp))) maybe like below? if (unlikely(!grp || EXT4_MB_GRP_BBITMAP_CORRUPT(grp))) -ritesh > return false; > > free = grp->bb_free; > -- > 2.30.0