Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3521670rwa; Tue, 23 Aug 2022 06:11:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR60cvqj1zMDeXIOChu/keSWtluRTLkHdVHUVnjyi/miLMQmzS51tfGjOZUxh4j8jx14abtn X-Received: by 2002:a63:c5:0:b0:40d:d290:24ef with SMTP id 188-20020a6300c5000000b0040dd29024efmr20658449pga.141.1661260274641; Tue, 23 Aug 2022 06:11:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661260274; cv=none; d=google.com; s=arc-20160816; b=B52zHKooJuKBnVydDAxZFut22hTH4jXq6v0C4oX4xGPuL+L/MwiIOXUpMVVEYhXTnL 5ISmTg73791UU2RJfxhjlM1/RWdy2BIZsHzBOK2cqOkHjaIJ4HndT7YnNX++mJuKkuzC I/FT9baRUAMFLVN6cUyuD238eR7YCPVHZ0m4X/rlYxeU1KfN0w2GbPlkmVrBfwJWClYS nOWDXMPDep4oDnVM1Qks0WAxD9PTy9hR0NKcR7ltfGX8MhONhJFsc00waMJvGOf45Fvq 6nvtHpfL2ttuqzkorgPGMbrfEsomksuPEx5X705jHzOYx7Z4PwJRvLhGI55Cm5vpyKyK F6vQ== 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; bh=fSKjEkPwBNECJWm8x7JSs95bpa+IJORUywN0gdEUTNA=; b=tVQ1lpoWMtn5AWKPu+u0qvh0gCcL927gSZXIgadp0WOFsNOXTWpkYCerwmIoZCSp1X 4GR1LSq4v9yvOxmT3CmS619KBPJj40VqAE3d9owrxv/iqtI84QYRe60jXUolD4ba0P4U 62EW1Ne3NTJWMfAC95EVIPE3QigoFBEGvtcCYiwcUVJW+aJGvRcvrRX8pN/34Qjn+tBo 4ShDLUSEKxN26WxczPW3jZiieLRqP+SsvNC5DWKPghdqF4s5G9P/IZ1ZUY3sxxaMUq9N GFHYzl42zGPrSu3fwkfuRDTj+fLo5T4bmDqWnW1oXdDEuAJkJfU6hGCBM8cdLLj+axFx YTPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Gfpmc78W; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x28-20020a634a1c000000b0041d00dbda9fsi15417642pga.285.2022.08.23.06.10.47; Tue, 23 Aug 2022 06:11:14 -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=@redhat.com header.s=mimecast20190719 header.b=Gfpmc78W; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243250AbiHWM4W (ORCPT + 99 others); Tue, 23 Aug 2022 08:56:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243336AbiHWMzy (ORCPT ); Tue, 23 Aug 2022 08:55:54 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F09F37B7BE for ; Tue, 23 Aug 2022 03:01:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661248826; h=from:from:reply-to:subject:subject: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=fSKjEkPwBNECJWm8x7JSs95bpa+IJORUywN0gdEUTNA=; b=Gfpmc78Wpq5RGlOJM1wF5SfWppeL2I2dqzbvJnrattYfDtR/mJozJFJHjHfnj/AmXDlhjG iXWA/GXrxrriVbQkSY9PQz8hfQ29gvFmM2G4uAxTwOa9wyq0bcNhztifen6oc2J3YS1rFC 0BGtRAxVH2y0gb7mcyyy0kC7ohRTeeM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-217-OJwysFzpPuicEiN_cP8fhA-1; Tue, 23 Aug 2022 06:00:22 -0400 X-MC-Unique: OJwysFzpPuicEiN_cP8fhA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 798023C0D854; Tue, 23 Aug 2022 10:00:22 +0000 (UTC) Received: from fedora (unknown [10.40.193.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8920F40D2830; Tue, 23 Aug 2022 10:00:21 +0000 (UTC) Date: Tue, 23 Aug 2022 12:00:19 +0200 From: Lukas Czerner To: Jan Kara Cc: Ted Tso , linux-ext4@vger.kernel.org, Salvatore Bonaccorso , stable@vger.kernel.org Subject: Re: [PATCH] ext4: Fix check for block being out of directory size Message-ID: <20220823100019.wukhx7a6bul4isjl@fedora> References: <20220822114832.1482-1-jack@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220822114832.1482-1-jack@suse.cz> X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On Mon, Aug 22, 2022 at 01:48:32PM +0200, Jan Kara wrote: > The check in __ext4_read_dirblock() for block being outside of directory > size was wrong because it compared block number against directory size > in bytes. Fix it. Good catch, thanks! Reviewed-by: Lukas Czerner > > Fixes: 65f8ea4cd57d ("ext4: check if directory block is within i_size") > CVE: CVE-2022-1184 > CC: stable@vger.kernel.org > Signed-off-by: Jan Kara > --- > fs/ext4/namei.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c > index 3a31b662f661..bc2e0612ec32 100644 > --- a/fs/ext4/namei.c > +++ b/fs/ext4/namei.c > @@ -126,7 +126,7 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode, > struct ext4_dir_entry *dirent; > int is_dx_block = 0; > > - if (block >= inode->i_size) { > + if (block >= inode->i_size >> inode->i_blkbits) { > ext4_error_inode(inode, func, line, block, > "Attempting to read directory block (%u) that is past i_size (%llu)", > block, inode->i_size); > -- > 2.35.3 >