Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp273522yba; Mon, 20 May 2019 08:29:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMIwgUIGCY30BlMzP4SKZiMC7sDzVo/KkslCyKZoSdx0FhasxahmFm0t8ANQofXKNnPPjv X-Received: by 2002:a63:9242:: with SMTP id s2mr59134501pgn.220.1558366141815; Mon, 20 May 2019 08:29:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558366141; cv=none; d=google.com; s=arc-20160816; b=YIMXFHXcp3BpgN7nCGZtDPao1Vi5ebd4EL++T021eeX5UC1ONrcsUnDH4wVWsC/d0o SVdX2pEgaqJmwJcS7vU+aJw7zzjwHQDijJ9Vwn1O97yf/z8Obxrn1ahp4Oe/pJ0ZL3V1 XYHtYs86UanR1wtpTOYG2zG4f+HaSCKrtt6VkeI2xz65kd+TyogxtDlz8cn289XV5dtY O5GbhiuzqECmyPVFhp3KNYzjLb8MSEAKdpiMoBNQnzweBmlC6TZ7asLHW6ka22NpeDKz uq5yJ72UtnCPgmiYpNxq4K/YvoasxVdSoFp3mszI6jgVsB8nLSPjzQVhUlH9iS4FpIJ3 qYkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Mes2bcN/9s82pCevkDGoaD+N5KvCIfCk1jnEhBddvdM=; b=nI7WU0psNwOSkPdRSM7TscDwHtZ26c2N53wavF8ncwjLLBk8HUJ7yWWiCW8kofB8/1 rDhJ159mMksxAYKwWVgC+bsLbzSM+qidaRCnwZQafnE1qHoWdfhTMKQpkTDgm97RjRbY hZPPzFRI2krDdB1pCHOulE8DIy5RL34FuS+CunW7Waz9FHhDRVaSs7L1V2gl7qH3FDRb PNUs4Wwm1ThSVl6ZoGNJlhBIJHGow77nxDKccCon/dUaWG5hbyM2RxgAhcKuMw+3WyhK djoJQkP2f8MHZc7zVSWnNfMzI61w5OfkzThNC4thZBS8qQ+iG3NCySbGJsO338JIBYOo 2eew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rCH0ReiB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5si14975333pfr.52.2019.05.20.08.28.46; Mon, 20 May 2019 08:29:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rCH0ReiB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388658AbfETMXl (ORCPT + 99 others); Mon, 20 May 2019 08:23:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:38212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388637AbfETMXk (ORCPT ); Mon, 20 May 2019 08:23:40 -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 EF22020645; Mon, 20 May 2019 12:23:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355019; bh=gjf+mOszHMrKvbqtvIw9132vFb8gT0KeTwcDppoOEo0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rCH0ReiBA6o3rLmcr7TrhKcFr0S7MQcrSMCKu0s7SAszwhp/nRmHdLv08LvczxvJb 0EFDaamJgxpheu9PNtR5tyH3ZSzLI/DUWfvyE8c5FBIe6EtZdjCxxsgrz4AigJzgt0 jr09hBhQO7XqBGclWijEuGO92AkPTN3r/X8o1kyI= 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.19 066/105] ext4: make sanity check in mballoc more strict Date: Mon, 20 May 2019 14:14:12 +0200 Message-Id: <20190520115251.734458015@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115247.060821231@linuxfoundation.org> References: <20190520115247.060821231@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 @@ -1539,7 +1539,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 "