Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp737745ybc; Sat, 16 Nov 2019 07:50:30 -0800 (PST) X-Google-Smtp-Source: APXvYqzkXS3Yj5V2CFv1/vxjHn2Pcks8Gf2dNdSPrLsoCQxFa0t0irr0YeJBvtwfUaMDvVhgMSmI X-Received: by 2002:a17:906:c797:: with SMTP id cw23mr10547906ejb.19.1573919430031; Sat, 16 Nov 2019 07:50:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573919430; cv=none; d=google.com; s=arc-20160816; b=Vbk59VTz2HeG9q97gjbdt51qQC26q43VitooIo2HmpMhksspRZwzOiZebAW/BhNq5N TkGwR6RC9aW6G/b3eP03EKEkmJNW1AMCsN6Rd8hWhxOwpFtw01JHQoUB8QH9RV5BTjtZ dcRfjck0rqnjIR+GFPL73JoPcCM/6y1AMDYLctS1Qo+mfxH4P44L0vQSuhhFEzpBXUeZ CvatZCN/Scj+sUw7542uAQ9SYrzUH+iCZbRpF/0RbxewlzzuX4r+y2k9aeykuGiq9pmq 62/6hrW0e3rw7qMzPfZzeX6MFl1UIFNCw3fwn3NdXYs5WHpbwbxAERUmHPYpBwQHaL5M b9Nw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cVlU1ba1Lo7+bgipX5ICVkE143UeKulscspBrqCYmrg=; b=cR7WooKyZcI/O22Iw4lD4bM5Wpkx3+2lYpOlmIId1nYPp6a0knxUTyW2eFgNUNVgWH 16VprA1t7HFXN3ohTLfeTxkq3g8ML5h0c1OXidQ+on+vbMcrzuStINRvcGOdMCYK/AVW iXhlDoA4DvJ2XgmWn0jnUr68oPz9uqbVKNihNROfAxVz8wJWDxtfeQwGD6rzbI5puDir iVWoEGRmYkynEriGiDEr/kY1Zh9jtpLXpniXG4YTA/nmpsk8pWj05tILdp2OYfYxzKDW RP2CP20E6ctuJYpal3fqad+O7nDGzQGPc0VkFvF3zoaiUM2MPpBWA4gRN+JLqv6UjEg7 ADyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FxYOKZcT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b11si7845762ejv.278.2019.11.16.07.50.05; Sat, 16 Nov 2019 07:50:30 -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=FxYOKZcT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729211AbfKPPpn (ORCPT + 99 others); Sat, 16 Nov 2019 10:45:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:51360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729198AbfKPPpk (ORCPT ); Sat, 16 Nov 2019 10:45:40 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CBDD620803; Sat, 16 Nov 2019 15:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919140; bh=veA1u/NFRMPjxmg2z9Ts0nba0JTcv5GCfC6drOMXbiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FxYOKZcTMZ4XxW1kYvZ5rMBx5QgdIJ7xA1WM37Og/e32snxbLhfxlXHG0RhwY+8es nWEsXmSOKGEjaMxSZZ2E3zz+wP4RRRxvGY+Sbjwx2ex7cQI/VxLoqD2GYfUN8ygiTy I1rzLCKe1PbQe6Ixm3omE0l1kp5fB3YIQY8Okx0o= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Colin Ian King , "Ernesto A . Fernndez" , David Howells , Al Viro , Hin-Tak Leung , Vyacheslav Dubeyko , Andrew Morton , Linus Torvalds , Sasha Levin , linux-fsdevel@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 161/237] fs/hfs/extent.c: fix array out of bounds read of array extent Date: Sat, 16 Nov 2019 10:39:56 -0500 Message-Id: <20191116154113.7417-161-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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