Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp982695rwi; Wed, 19 Oct 2022 05:28:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM51jNqOaAgfxBLUeXpGuIdzWacr3l45g3ky4rsrCrdp9gq1bbcRH/JRTNKkEXwDPE/leqav X-Received: by 2002:a17:902:f08c:b0:183:9296:8b65 with SMTP id p12-20020a170902f08c00b0018392968b65mr8536893pla.59.1666182503239; Wed, 19 Oct 2022 05:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666182503; cv=none; d=google.com; s=arc-20160816; b=iQ4d9K1LRvG26KT24J/T1UxJsVKDwftnqV7aSvzLLIGhyYAweKL3foXlyeaRnhzbb9 7NRB6pxZ97zgqw8lry17UcgOLL1jwOZQ3ooPMKvev9IHLOnt5goOGZwej/nDv9XysCUC ImaaE8PmF4lT4fh0hX24PEyZ7CRFUy5HjSVb8hO7NQhLNaCbotto3Hm80rctYdxM2Cfx zsM+ao1UjMOC7YO/MdZQvCz0Giea4EymWk/LH5UzeKCrcVN+4Bzozk/8R3U+NmsPgmVv wv3u8YWKDHF5iCxjwREthYvM+K0D9RDbg4aSVf2zzdq07JUF3wjFzrL4YNGf+PVkCz2o 8IFw== 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=JHKeWLEeAt7ae5dbfUXs3Uu5cTf26DcvG43Ld5X17unWhvhBlCOx/9l1Tvp0yyQjY8 E8XfXqzjM7oQ+PMfn05yFdfjV1yofMOTB1P+S4A1e2sYq558yhSFm7QMs3xZlVb6sBP+ efLkYNuXY3uB0YucJFmu1qcm0KBI5r3YSV2MYva5ttxoi1hBRc0t/n0QgiC1ZIeENoUt 8p2rzz8m9qFM1Bk7mojadgpIrkXAFiOcDjvYsgrd8rIbcx6vvrkMo0nww+x6yzeUTgbE uwvr/1QIBPc8eCtLVXifyMee40Xj9Le5JnWfumVSDLRq82/u+KX3Ja0P+Ch68AKgTGoU 5Kmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=we71KixH; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j2-20020a056a00174200b00554245aac47si19056718pfc.283.2022.10.19.05.28.11; Wed, 19 Oct 2022 05:28:23 -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=we71KixH; 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 S230247AbiJSMR6 (ORCPT + 99 others); Wed, 19 Oct 2022 08:17:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232944AbiJSMRW (ORCPT ); Wed, 19 Oct 2022 08:17:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1DBA6051D; Wed, 19 Oct 2022 04:53:23 -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 ams.source.kernel.org (Postfix) with ESMTPS id B09EFB822EF; Wed, 19 Oct 2022 08:44:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D992C433D6; Wed, 19 Oct 2022 08:43:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169040; bh=mGqmo0S/cZ1DZJ0WQ/Bt9WjSLdXTjqMxohIkX6GdePo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=we71KixHcSMFLmA9PPV8btBkfZoVPANvwJW/jYFOqdtblhfmO9qQQnaZ2UHMzYwR/ NLFLI+prnBCVY+DtmXuoAVCkQYa3gQKmj9HSVQQBBrXfAXx0+RoQAqb6eLagj5sI1f FRIrBmn7MOrX27jbTWCyJsFlc/NI06SJvrZkr8X4= 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 6.0 138/862] ext4: fix check for block being out of directory size Date: Wed, 19 Oct 2022 10:23:45 +0200 Message-Id: <20221019083256.084935161@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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 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);