From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zeniv.linux.org.uk ([195.92.253.2]:59058 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727433AbeHaSDw (ORCPT ); Fri, 31 Aug 2018 14:03:52 -0400 Date: Fri, 31 Aug 2018 14:56:15 +0100 From: Al Viro To: Colin Ian King Cc: linux-fsdevel@vger.kernel.org, David Howells , "linux-kernel@vger.kernel.org" Subject: Re: fs: hfs: Possible issue with increment of extent Message-ID: <20180831135614.GC19965@ZenIV.linux.org.uk> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, Aug 31, 2018 at 02:39:11PM +0100, Colin Ian King wrote: > Hi, > > Static analysis has picked up a potential issue with an out of bounds > read in fs/hfs/extent.c; the following for-loop in hfs_free_fork() > increments i and also extent while also reading extent[i].count. This > looks incorrect to me, I think the increment of extent is not needed: > > for (i = 0; i < 3; extent++, i++) > blocks += be16_to_cpu(extent[i].count); > > res = hfs_free_extents(sb, extent, blocks, blocks); > > I'm not familiar enough with the code to conclude that removing the > increment of extent is necessary a correct fix just in case I'm missing > something subtle here. Goes back to commit d1081202f1d0 (in bk-to-git historical tree) Author: Andrew Morton Date: Wed Feb 25 16:17:36 2004 -0800 [PATCH] HFS rewrite From: Roman Zippel and it's almost certainly a bug in there, judging by the code nearby...