From patchwork Wed Oct 19 08:23:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5352 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp296596wrs; Wed, 19 Oct 2022 05:27:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7S4KBjb6TqGbahQoShpvYxcgVGdM9MdXgF3V8yC75cJsyIH4I9jOpgNxOcWW8dSw7673HW X-Received: by 2002:a17:902:e88d:b0:185:3ac3:e1fd with SMTP id w13-20020a170902e88d00b001853ac3e1fdmr8288030plg.114.1666182469261; Wed, 19 Oct 2022 05:27:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666182469; cv=none; d=google.com; s=arc-20160816; b=gcWADy/l7pdCfhohz388BD+LlJi832D74Y3yD0lyL89qQ8807fxoEYWSYMGX9aFHq2 KmcOVJG2KhTcu7TBrknHzrQRFuVdldj0z5dTGuViKhZzlqlcyvwAubWCYU6PDvWHIL5c M7rng4e1svBL8Xf8pSgmN/YySjzZwhXteYI3qe63bzMGFa5hoFLxP/iV1YdinoD3cwur bIJZmKNtXOS4SwssmLxn7uvS03BTV2+1GoCzUV54ZPIFBAj0qOIjWr4HxJnL4fXx9Rop tR1w9EP+ncVafoGPwIeVYm+Cj6ktJRbaEBVTKR3L/P662sXrjt7u2OAE0q6f+D0/oSA+ S0hA== 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 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.27.24; Wed, 19 Oct 2022 05:27:49 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747118949015625379?= X-GMAIL-MSGID: =?utf-8?q?1747118949015625379?= 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);