From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0E9BC432C0 for ; Wed, 27 Nov 2019 21:43:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A6F6121555 for ; Wed, 27 Nov 2019 21:43:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574891038; bh=Ubzdtado8qpF9VSRmYdGAtTkvjECdbzj1U/T/2pUfco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=zh1jE8uIx8AoepsQkOQDKF9BakNPLzoMpOKu3TojjbYjIMKU/4ft6b2nDe5TMHbG4 8osmbMjkZIFUntBMPvmRITVpPdo/VxA+XEarGdQehDar1vJPav63YFUKMMT/ptfa0I PZ2vabQpfLm04mbeLUUPMxNIH7rod/8+lbkhZ8N8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727646AbfK0Vnx (ORCPT ); Wed, 27 Nov 2019 16:43:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:41562 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728685AbfK0UiK (ORCPT ); Wed, 27 Nov 2019 15:38:10 -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 0A82621771; Wed, 27 Nov 2019 20:38:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574887090; bh=Ubzdtado8qpF9VSRmYdGAtTkvjECdbzj1U/T/2pUfco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vu1aNK+hPQzt7GIBmcG9bz1MtdrddhDggj8nW2iTXgRyLpjslbPaxtyiNQwtPa+eh f19TtN7Df34lUwynTEPaS4LYnpit/AxqGNdkXYWuhMJ40jZFib4tklR+SkcO8jUzsa Ffl8AjsVl6y2n2BwCBAgnTnzoSX+zKiSpk7Z6r2k= 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.4 072/132] fs/hfs/extent.c: fix array out of bounds read of array extent Date: Wed, 27 Nov 2019 21:31:03 +0100 Message-Id: <20191127203007.572023848@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127202857.270233486@linuxfoundation.org> References: <20191127202857.270233486@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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