From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5269C04AAC for ; Mon, 20 May 2019 12:51:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BA84A216FD for ; Mon, 20 May 2019 12:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558356686; bh=FNyDz1pMxz6Z+YQxf9P827uXTCVV/xaBJ++WrK60164=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=jBIDes5XJSeHKSKmjGymez5hWEXgLbU0xBZAHhj5JsEc95ZWOOwZpqck4p9repUys xkO323LgUKEphONM3UlhURVK+wu84l+vhmVvbm1eJJQap3AhfQu4hDTj4O3bOAOqIp QFTvOHsN5zaZT7VVIp+r20LkUSy7ydcdObs6H+9Y= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732262AbfETMTs (ORCPT ); Mon, 20 May 2019 08:19:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:32986 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387855AbfETMTp (ORCPT ); Mon, 20 May 2019 08:19:45 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6391820815; Mon, 20 May 2019 12:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558354784; bh=FNyDz1pMxz6Z+YQxf9P827uXTCVV/xaBJ++WrK60164=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tZhLjBtNPThlYR2HLXkQR5vOedRmUrGBloNQkuzVpo7K3XqpNnSKUI+uqgnh2TTxq f7Bo637BVOnzFkBgNBZhl/DsAjeTezEr6Tfw9r2J3qur44W8RcByxJ83SCe7QqeWBW 1Sdp7eZJtPpbdsxKXdC1Aw53+LLMXIDdQi3KgprA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kara , Theodore Tso , stable@kernel.org Subject: [PATCH 4.14 41/63] ext4: make sanity check in mballoc more strict Date: Mon, 20 May 2019 14:14:20 +0200 Message-Id: <20190520115235.648852887@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115231.137981521@linuxfoundation.org> References: <20190520115231.137981521@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jan Kara commit 31562b954b60f02acb91b7349dc6432d3f8c3c5f upstream. The sanity check in mb_find_extent() only checked that returned extent does not extend past blocksize * 8, however it should not extend past EXT4_CLUSTERS_PER_GROUP(sb). This can happen when clusters_per_group < blocksize * 8 and the tail of the bitmap is not properly filled by 1s which happened e.g. when ancient kernels have grown the filesystem. Signed-off-by: Jan Kara Signed-off-by: Theodore Ts'o Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/mballoc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -1555,7 +1555,7 @@ static int mb_find_extent(struct ext4_bu ex->fe_len += 1 << order; } - if (ex->fe_start + ex->fe_len > (1 << (e4b->bd_blkbits + 3))) { + if (ex->fe_start + ex->fe_len > EXT4_CLUSTERS_PER_GROUP(e4b->bd_sb)) { /* Should never happen! (but apparently sometimes does?!?) */ WARN_ON(1); ext4_error(e4b->bd_sb, "corruption or bug in mb_find_extent "