Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6030708ybc; Wed, 27 Nov 2019 13:43:40 -0800 (PST) X-Google-Smtp-Source: APXvYqyjtg6bwZVV2P9AJuKAFu3knHQyDrxpQWAbTLVlh9oMOl3HTzxk17Nrh6rbGLcCmgyjTXrP X-Received: by 2002:a17:906:b2d2:: with SMTP id cf18mr8587725ejb.204.1574891020612; Wed, 27 Nov 2019 13:43:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574891020; cv=none; d=google.com; s=arc-20160816; b=kNkrKqffGeCvLmjFiNiOr/bg7Oa+PisGnGH456lVZpmbJeRAibfcabp+W0HMQvyjUj jIBYqI09oGly52d/kA7ZQoJ/bggnySAZtsPrkFKgKgKNU3araQt+METuqyIIxKKa4+Z8 h3EW6jQXHX2lZXwCy3fujoVpwh5OpAHwcP3TlW8TdRH752WBDr2x1zRcBupZhF7srEBX d28grHv76hMr3iZpbHXdv3mo8ali986UgGhc3IfFbYE6e1RZ1HKprHhQLpH/Y5bYhfOU c+bO4WDYLIQgnEgLlRtnfcrS1wJmUqOWV4cWCGj4+MiL9tToKF2/Yp4CHr/MT7WxIj9i yTdA== 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=K63QD0kgt/F6rb+B9KMJ/wWvC+dVP3mwkRiTOAv2wE0=; b=dq35ZJA+1T5h19Fh2JQpmCk5K8xQhWNjmPEwdrs0ffeQolV/ydgbM9pHjgNYnOZPo5 wf+bZwXmxnL8NbdQQT86WMv2srUOcWoVt0lPud96nLoULmQpceuzbR/dt2VefJu+UEYg zLVYJSLvdH/4dayOG0sJcCpz0Kp8INjCNpreRbdg8Z9/0dSYoOOQ8P7ALOe1bUPKllww sXKhCsHNGUG7HC9v0O1ytMYqwK7Palab0fwjMjclrny9OKLcmfSGyTUs8NJp5Jjj9HjN yLABnfT8XAUED2PaeMSzxLMeGnF9XDYIp23bwWQelQSqKr8ob16mW1e1dRQqDFJBUHkO d6YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uTG0UzGG; 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 s2si10888694edx.148.2019.11.27.13.43.16; Wed, 27 Nov 2019 13:43:40 -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=uTG0UzGG; 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 S1729339AbfK0Umi (ORCPT + 99 others); Wed, 27 Nov 2019 15:42:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:49026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729336AbfK0Umf (ORCPT ); Wed, 27 Nov 2019 15:42: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 0CEC321780; Wed, 27 Nov 2019 20:42:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574887354; bh=Ubzdtado8qpF9VSRmYdGAtTkvjECdbzj1U/T/2pUfco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uTG0UzGGxmagRce0NK+8dFR1xYqXBJNjnWOCTtVOmCiObzDn8ZJ1hXKFc2DNVTt2o LZDNSNKx1cPUbhAVIaf3tnmny4we+CZC9bzXP1Mewej29EFnGNgUSvSXKU7KJnIQCD h+XYBOw11Bpv/K5aTMPE/xLYCHG2ZQk81kmlbpF8= 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.9 079/151] fs/hfs/extent.c: fix array out of bounds read of array extent Date: Wed, 27 Nov 2019 21:31:02 +0100 Message-Id: <20191127203035.695941897@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203000.773542911@linuxfoundation.org> References: <20191127203000.773542911@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 16819d2a978b4..cbe4fca96378a 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