From patchwork Sat Oct 22 07:20:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7241 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1091231wrr; Sat, 22 Oct 2022 00:49:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4gwM9PrU+/xLaEjFTyzHeNVeCQLU8zi26rJ2emVFzI2gVkYVexs/oyVxtklM8QtRoa8exe X-Received: by 2002:a63:5063:0:b0:46e:cd36:ce0c with SMTP id q35-20020a635063000000b0046ecd36ce0cmr3846248pgl.617.1666424995241; Sat, 22 Oct 2022 00:49:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424995; cv=none; d=google.com; s=arc-20160816; b=wrlRwlF9Z3Y/GW8Hd7KB8qu2vQ+Qop3oV2TTiBCKa0If3wxEos5r7UzKH1q2+xI2S+ 2pA8nUtcWfgaXg4e7GhrxjtCO05bMYqWrDOe4dwdumTxjoQZBOW7i5tIJ6mII+xO3A6x UI013o3qWqbya8BIUpg5Fr0WlWQtAedBRhOSOo+oHHJDVlF01RtkEc3F8qDEC1k+ID64 4l+Pmx1/frXrClShU4KIrsGVXmIHxBJ22nGSkAA8LZXr/QYH5ROQ+p+h85L/e5jmVx3g ijQ8Ybeibf7j5TJ84Z85gC6zi5BmAdqJvBkHKeFRHigT1W18doDiWmdAq4KWvnmdQLHm u5Jg== 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=do6Y+uq814wMAU3HzzFU+uzCSKN5Pu7AXEOOKnWguvw=; b=0Ay0AFzwO/sxVeXPB+CCsta566KKcq9dEe6QpLuX11vJ5eY/g95cWBQTdie6s+n969 rmVdLJp5BV6JaIGZZf8Y3wVJI1modJg5Rc2psCqqJ6I5GzlmeAqWHDGTBEzyfBnoAhVs QXtQmSdFpANDN+zZGYeCBPr8nAIdau4g6J/SGmz3JMVbO3UzHXZey/4nwkKFIFJxHBQQ HvuTuWHTBBb49CUitB+9N4CIgpZTIGkazMRN87rg98bZIQ4OyZ8X/r/18oi5nJRm/nCk Hr+VoaBHLYgEGsfj/j5QpsDcs5Wm/ItorynXcJelxJYOp+1mENgOBovbm/t2ep9NLXft latw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WQIY5iPz; 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 11-20020a17090a194b00b001fdd4a9fd3fsi2208690pjh.146.2022.10.22.00.49.43; Sat, 22 Oct 2022 00:49:55 -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=WQIY5iPz; 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 S231613AbiJVHsw (ORCPT + 99 others); Sat, 22 Oct 2022 03:48:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231575AbiJVHsN (ORCPT ); Sat, 22 Oct 2022 03:48:13 -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 9158E8A6F0; Sat, 22 Oct 2022 00:45:07 -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 39AE460B46; Sat, 22 Oct 2022 07:39:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A433C433D6; Sat, 22 Oct 2022 07:39:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424388; bh=mGqmo0S/cZ1DZJ0WQ/Bt9WjSLdXTjqMxohIkX6GdePo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WQIY5iPz9de/wT9voHE5RUo/Ut5f14sBUjJcReYitRfo94YYi2o1V2yuFz0G0/u7/ 3zXuEFh4JKzsPY98mjrm2jVRwx+bCYULwNH5EBwbDX5LZFr1GdrCrVvT+T7V5MiE2K Mgvz3QzrXwE2PKM4rNB/d2PmO2vYCb9U6EMcjTLU= 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.19 126/717] ext4: fix check for block being out of directory size Date: Sat, 22 Oct 2022 09:20:05 +0200 Message-Id: <20221022072437.773984046@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747373255662467895?= X-GMAIL-MSGID: =?utf-8?q?1747373255662467895?= 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 @@ -126,7 +126,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);