Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2026963pxa; Mon, 24 Aug 2020 03:01:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy12o4S4LYHHEtHmJT/T6elrGhngGYSPIwgZkyJAe2M/+WQnivP+88z4qZyivIO3DSU6Ygy X-Received: by 2002:a05:6402:174d:: with SMTP id v13mr4381015edx.231.1598263293511; Mon, 24 Aug 2020 03:01:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598263293; cv=none; d=google.com; s=arc-20160816; b=npy7BxegPeCigoqhm0kzQPcrjGAs8/G1UK089Ir6lJ4gb75hl5i0dnaqZmkbAod1Qq HiO5DWiKO/RiExwqU+biS2YIqTSbjfzdx737a8yM9VaIj7OfVMt5KB/utbojWHwhQYG+ DkLBmAyC7fo4tNYkyBXdQ6il0LeMy5lCASPJMCWUv2cPo3gNyHzQH9bdJkSsv+fr4vtG A9TKt+SKckVB3XLGV9U0nWURdBay/FOB+IRT1xdEUMS++vynlAIkU1S4YquOuj81VCMT T91eJhlotK1PAZQuZ/qVNW/KR1ztbzQ5oH7v7Ms9WuKYv2ug32Nr4luqzsvnw965jJS0 oDyw== 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=LUITuLKCGfVeZYWfwvJagQ/PGfdzDYI7ncIvu1oftfQ=; b=wslPH8n0n3EEmFBc8Xp2CATxfbbU9j7fY5pKfnloZBP1fOfdjZ6Nhh4hD52OIAGE45 7A7RVDC6opy2aIqGbbqxk7r2C6NkYfcADMZ0R4UEyqqKd1wVeBkrYHbapZY1RUTIs9mH xMu4gtq/pZdWa0jwfMqT1+haiVnfYb1xAGIMN/gU7MaeW8gyNTtj85U2ifa4HMMYWcvG ELofCs7K81F1s2dnWkwwLE9XrtCpxiA8Objbr6IGAVHR5pDCIMmRY8wRUddKgkK9XdeC YJCgHpY0OEv1imjKdoqzeE/KYXxyXmWQNCTAJTF9+VOaUZnxbKIncmV8PGdbCOW4oLsf CMAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mQVPFBea; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t19si6206707ejd.62.2020.08.24.03.01.10; Mon, 24 Aug 2020 03:01:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mQVPFBea; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729952AbgHXJ6k (ORCPT + 99 others); Mon, 24 Aug 2020 05:58:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:42294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727858AbgHXIeK (ORCPT ); Mon, 24 Aug 2020 04:34:10 -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 EFEDB206F0; Mon, 24 Aug 2020 08:34:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598258049; bh=rtC3OLtXYHuMs7YIrJ/3veZpLifW/r675BNRatgvRZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mQVPFBeau0V7c9x67W4VmLnYDSSKToy+LEcQWY0Fuzo2Vs2yXU2X1xJw/WhtAdTNF sDMgeumurCAKaSfNDNUtZznrtekDIoql6y2hORYwn+rAnuNKcqmbVJGVB3F6wIyjRX YNqLfNDhavpqPhbY4CksX3BpeQYGbJxI40oOsEvc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kara , Theodore Tso Subject: [PATCH 5.8 026/148] ext4: fix checking of directory entry validity for inline directories Date: Mon, 24 Aug 2020 10:28:44 +0200 Message-Id: <20200824082415.209981456@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200824082413.900489417@linuxfoundation.org> References: <20200824082413.900489417@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 7303cb5bfe845f7d43cd9b2dbd37dbb266efda9b upstream. ext4_search_dir() and ext4_generic_delete_entry() can be called both for standard director blocks and for inline directories stored inside inode or inline xattr space. For the second case we didn't call ext4_check_dir_entry() with proper constraints that could result in accepting corrupted directory entry as well as false positive filesystem errors like: EXT4-fs error (device dm-0): ext4_search_dir:1395: inode #28320400: block 113246792: comm dockerd: bad entry in directory: directory entry too close to block end - offset=0, inode=28320403, rec_len=32, name_len=8, size=4096 Fix the arguments passed to ext4_check_dir_entry(). Fixes: 109ba779d6cc ("ext4: check for directory entries too close to block end") CC: stable@vger.kernel.org Signed-off-by: Jan Kara Link: https://lore.kernel.org/r/20200731162135.8080-1-jack@suse.cz Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/namei.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1396,8 +1396,8 @@ int ext4_search_dir(struct buffer_head * ext4_match(dir, fname, de)) { /* found a match - just to be sure, do * a full check */ - if (ext4_check_dir_entry(dir, NULL, de, bh, bh->b_data, - bh->b_size, offset)) + if (ext4_check_dir_entry(dir, NULL, de, bh, search_buf, + buf_size, offset)) return -1; *res_dir = de; return 1; @@ -2472,7 +2472,7 @@ int ext4_generic_delete_entry(handle_t * de = (struct ext4_dir_entry_2 *)entry_buf; while (i < buf_size - csum_size) { if (ext4_check_dir_entry(dir, NULL, de, bh, - bh->b_data, bh->b_size, i)) + entry_buf, buf_size, i)) return -EFSCORRUPTED; if (de == de_del) { if (pde)