From patchwork Mon Oct 24 11:27:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9312 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp465077wru; Mon, 24 Oct 2022 06:51:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6dN2W7CpCE4uf3QGdwnTzgS1qgXvW+HefTAk3QfhiIsEm3fRA7O5feha0h531VgHTuMJ3t X-Received: by 2002:a05:6402:51d0:b0:45d:5ba4:c3d2 with SMTP id r16-20020a05640251d000b0045d5ba4c3d2mr30923961edd.132.1666619513606; Mon, 24 Oct 2022 06:51:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666619513; cv=none; d=google.com; s=arc-20160816; b=Zzzrs20Sy1qWx4AttwdCWFblaZN9Nt6wS3+PXIqUaRwGo/honmIsiBFcKUNyaZs194 DiYaB16Y1sfL7xbOpu96zRNcBmn9FW0/vH7HP7T5SoaJyg5+i82NPC9ol4shYTzcPCkf kYEPk6NKor/3om3/MkASS1uAsMw/S/Grl+0lUg2ziwAaDFRPKOaEbLFqqMn3CuhyEWSE 4tK9g5iFqwEMsFpEzQU/RvNqgWs/psraEHbiwffcb0MN2MdV0iFx9pQGu0OXHHn4HGb/ LtNS5t5KPM2RMgK+g3NKopT3ud/3d3j8vvj38X4HXIfbBxOUf2ofMNV6MLvKe2fye6mH aZvw== 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=QhjvbCe4xTWTziIYXilkc+cSFrkEz0THJSYjxjAebORwn8U+MA+VDZ7YuNCqdqFsKD i1izRgpuaAtp9cyoXaotHJBNivEiLg4p3ChAZeDhvIoW577CzbPPjwQbECMAF4LGXCIH yu7D6sPF0AAmsM9HkSbgJOCCx9tZDUnJKQ129wBhmeX/yRGhTaEBwVWtlQFNJzqeqlu7 DdbaJXi48QtIxR7uosRUgHIdHzYHDticYJY12pM9WfkfyiWbQnYuM46ufs9qJVUU1nHx lsav1BY6sTRz0fGWvtmTaeUjjYzjaXwMOwbAKkhrNoRyTxkA3fwmU7odNwoNbenB6+TG dCHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zN0XRl7F; 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 b14-20020a056402084e00b00457205ae2b5si33494353edz.358.2022.10.24.06.51.28; Mon, 24 Oct 2022 06:51:53 -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=zN0XRl7F; 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 S236456AbiJXNqw (ORCPT + 99 others); Mon, 24 Oct 2022 09:46:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236664AbiJXNpC (ORCPT ); Mon, 24 Oct 2022 09:45:02 -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 5EBA848CA3; Mon, 24 Oct 2022 05:40:27 -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 30103612B2; Mon, 24 Oct 2022 12:38:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4395BC433C1; Mon, 24 Oct 2022 12:38:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615135; bh=mGqmo0S/cZ1DZJ0WQ/Bt9WjSLdXTjqMxohIkX6GdePo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zN0XRl7FQrxqthb0iSMZVMCZInoqyms8WvmXJ8HrBDhg4009W3fDehI66+a8lCtjN HG3T6thrO1DpM9v7jyA7/mXHCzYdWQ8wbdXSjJqP/N7LIsgrVB3ffuqR7sAvnlnR0U jBeikqUAFhyNNTEweYayi4cjy/7gsxqCQHa2dFfc= 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.15 095/530] ext4: fix check for block being out of directory size Date: Mon, 24 Oct 2022 13:27:19 +0200 Message-Id: <20221024113049.320400755@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@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?1747577222825020420?= X-GMAIL-MSGID: =?utf-8?q?1747577222825020420?= 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);