From patchwork Mon Oct 24 11:27:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9028 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp441745wru; Mon, 24 Oct 2022 06:06:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5opCqIvUIp5JS5CC9mYSz41G/YRFndWAzPf2nbo5WOyVkJsDoobmhUCIQiEm9T5RS0d01x X-Received: by 2002:a63:5a50:0:b0:429:8580:fc61 with SMTP id k16-20020a635a50000000b004298580fc61mr29006010pgm.215.1666616780372; Mon, 24 Oct 2022 06:06:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616780; cv=none; d=google.com; s=arc-20160816; b=SjAhNKsc6XPrlvIJrCeoZtsgcPT4xE+vol/rhumJDoD2dnLQ1NbOSm9Bow22SPQnK4 nurjhV0GvSVWmpnH+hzw2CL2Czc8j+WJUcDm+3Iy2BS2gtvSGhfT1EZ0JZz+wf0u2ku9 klg3P1TIcky+cmRZdDngV+/PGmYu58EVviqwgrrLEciEe0cLdVe1EKQSsgkawWtDAK9P zTLXueOXRa6DCBxhoiGLHQFsGXJL5WVtNWqjLaZroz1Tr80iH2BLhS0WSeoAdzAA3r8T bSbRwzx6vduoJgUFgcD+eaEeDeVryLsHGFd0fM1VYHQnIWtoHFxO6BOBrXZA3Q86rlkZ KaOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=x216VQvHYjNgIpdOK41xJyQn9hNTOQ1XoGJya8MFtEA=; b=i8j3PRmLe8F2BdsK/RGErfewb/A9zP8JO50Hao01cD9DkzhH/af22Dlu6ZPPGMIgkm hO7NimOYfSXZ/AaBTbGCjUWEHXnmmahC4u0mFtJGM9vChU26T9pVyLFD98H/CV+0izBr E+g/vHDJvrDq/BcydxBUlSI0brS6ahECqHXwRUp16j9S+86x1Cg+X2zABpNVaPWCHZjc kpber6iZH2IfKq1331RIdyrvEO5rwR2pLWTpmnWCvLmCAzJnrvlTLvr4HN2o2LCg5GAd sIQo864PgwwBhxnIU7h0X7Ct0QSSjmSRFxo+nOoWjkJGTlAD+WTo1EMWMD2eVKmLBZ0d KGtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="iRYPsgh/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m16-20020a170902db1000b00186ba4ba494si439188plx.475.2022.10.24.06.05.57; Mon, 24 Oct 2022 06:06:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b="iRYPsgh/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235159AbiJXNFI (ORCPT + 99 others); Mon, 24 Oct 2022 09:05:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234817AbiJXNB4 (ORCPT ); Mon, 24 Oct 2022 09:01:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA76629833; Mon, 24 Oct 2022 05:19:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AE5ED61017; Mon, 24 Oct 2022 12:18:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFDFAC433D6; Mon, 24 Oct 2022 12:18:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613916; bh=27Hf3qBM+M05HOpUtzlV8FDc4ctAK6wPLlqXLlJMDOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iRYPsgh/K92UUj0KtVoE+ysdmSRyORJFzYD7Gz6wcharhkb8lqQSkvl9USIqsBiJ8 IYZRIezMOqeUgSI3gFPC6j6dMWCMFNwlb6c1ee56lckEN1p0AyGHHqCp9wWYRBLRY6 /AOusEVU7Z4K/5+GfE+RK9prTLs7LCmYn8GP06dQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kara , Lukas Czerner , Theodore Tso Subject: [PATCH 5.10 063/390] ext4: fix check for block being out of directory size Date: Mon, 24 Oct 2022 13:27:40 +0200 Message-Id: <20221024113025.307918321@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747574357305968934?= X-GMAIL-MSGID: =?utf-8?q?1747574357305968934?= From: Jan Kara commit 61a1d87a324ad5e3ed27c6699dfc93218fcf3201 upstream. 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. 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 Reviewed-by: Lukas Czerner Link: https://lore.kernel.org/r/20220822114832.1482-1-jack@suse.cz Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -125,7 +125,7 @@ static struct buffer_head *__ext4_read_d 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);