Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5995506ybc; Wed, 27 Nov 2019 13:06:04 -0800 (PST) X-Google-Smtp-Source: APXvYqzxtkc+R2S6V97GgLZ1W+V4hqpH4EWXISy4hPeDb5aQvgGBX0OxT9IZANv5c1b1FHbqqqZU X-Received: by 2002:a50:e68c:: with SMTP id z12mr35532003edm.53.1574888764341; Wed, 27 Nov 2019 13:06:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888764; cv=none; d=google.com; s=arc-20160816; b=w8O18MbBDbuygUTjhNCO0k/28QItK8Z3jngbRKU6PDxFhe+O4twefmuGQ6D3PPwQ6u 7icky7wqGcEcySkTn5dCTSY2wMjGwMov+1tNnFqq+JFABpjdAo0huhAMAeZm7i8UOdgT PGSpSdRJSZrbQZpApophjj5xrRTEkLv345M3wOpA2dE3oWuUAaWGqmQuOTGtvQwTtr0n WkYema2GcoRXfsI4Kr8uwN0AWXL4TXE+/zlMI6Xdnbk1nK94wveVTQcfSNWPAhXgeODL yqQf1ZlRZuvowhg2DzamRwkMmXxROfUg/CFCm1pdm/c783KPSz+qWdZPMACgpINixxH8 hhHQ== 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=cVlU1ba1Lo7+bgipX5ICVkE143UeKulscspBrqCYmrg=; b=ygsnyFK7RHqqEWKwuoxz8TqsFKD47psuatwEg0chKtiJpfJdLNePprL4Y3jc11jEzV OfnvsYi4/7+0QfKF0BDjtTDwPQf6pXAjMwQGp1GsQJ42mXfWnjuNZ6MZz196ZAuGcALx RKFHhiJwRXHWOuZ2Z0a0YVQG4ad00nu1g1PTXvAVHiA5LI9+G+cInrrmX1cUUpsrI7Us vsaFCf0P+si/rqqyottvIfiAfldwWCQaupO5T5+vqQuTcylQQtyshzFhyPGTk/egYpvX JcdczjazyTUX2n7PHSPGj2yd7HMXB1YjkfgafVDBhbxqv54qhnfWmEPTCtwgF5hhM1Cs PklA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=N43HgLyZ; 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 a2si10627722ejb.257.2019.11.27.13.05.40; Wed, 27 Nov 2019 13:06:04 -0800 (PST) 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=N43HgLyZ; 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 S1731572AbfK0VCg (ORCPT + 99 others); Wed, 27 Nov 2019 16:02:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:55304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731898AbfK0VCf (ORCPT ); Wed, 27 Nov 2019 16:02:35 -0500 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 311E3215A4; Wed, 27 Nov 2019 21:02:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888554; bh=veA1u/NFRMPjxmg2z9Ts0nba0JTcv5GCfC6drOMXbiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N43HgLyZCKfoUf7kH7PwIdKUzpw4+yUZsFqOJTE0oPJVjiHu3fTXM2jM6AYMb20Xk eH49CX3jSaxOCplusMBavEp8p87pLcuSb9WeRvCh7exobuSv4TPbcE5VZ0JxNeeTvy 2F1nzSErWSbhQHYJ3FyV2WYxnKRcRet9ASMliFAs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , "Ernesto A. Fernndez" , David Howells , Al Viro , Hin-Tak Leung , Vyacheslav Dubeyko , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.19 178/306] fs/hfs/extent.c: fix array out of bounds read of array extent Date: Wed, 27 Nov 2019 21:30:28 +0100 Message-Id: <20191127203128.342409822@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@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: Colin Ian King [ Upstream commit 6c9a3f843a29d6894dfc40df338b91dbd78f0ae3 ] Currently extent and index i are both being incremented causing an array out of bounds read on extent[i]. Fix this by removing the extraneous increment of extent. Ernesto said: : This is only triggered when deleting a file with a resource fork. I : may be wrong because the documentation isn't clear, but I don't think : you can create those under linux. So I guess nobody was testing them. : : > A disk space leak, perhaps? : : That's what it looks like in general. hfs_free_extents() won't do : anything if the block count doesn't add up, and the error will be : ignored. Now, if the block count randomly does add up, we could see : some corruption. Detected by CoverityScan, CID#711541 ("Out of bounds read") Link: http://lkml.kernel.org/r/20180831140538.31566-1-colin.king@canonical.com Signed-off-by: Colin Ian King Reviewed-by: Ernesto A. Fernndez Cc: David Howells Cc: Al Viro Cc: Hin-Tak Leung Cc: Vyacheslav Dubeyko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/hfs/extent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c index 5f1ff97a3b987..263d5028d9d18 100644 --- a/fs/hfs/extent.c +++ b/fs/hfs/extent.c @@ -304,7 +304,7 @@ int hfs_free_fork(struct super_block *sb, struct hfs_cat_file *file, int type) return 0; blocks = 0; - for (i = 0; i < 3; extent++, i++) + for (i = 0; i < 3; i++) blocks += be16_to_cpu(extent[i].count); res = hfs_free_extents(sb, extent, blocks, blocks); -- 2.20.1