lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20181017232820.dyvl7crdlilcqtaw@eaf>
Date:   Wed, 17 Oct 2018 20:28:20 -0300
From:   Ernesto A. Fernández 
        <ernesto.mnd.fernandez@...il.com>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     Colin King <colin.king@...onical.com>,
        linux-fsdevel@...r.kernel.org, dhowells@...hat.com,
        viro@...iv.linux.org.uk, kernel-janitors@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Vyacheslav Dubeyko <slava@...eyko.com>
Subject: Re: [PATCH] hfs: fix array out of bounds read of array extent

On Wed, Oct 17, 2018 at 03:01:17PM -0700, Andrew Morton wrote:
> On Fri, 31 Aug 2018 15:05:38 +0100 Colin King <colin.king@...onical.com> wrote:
> 
> > From: Colin Ian King <colin.king@...onical.com>
> > 
> > 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.
> > 
> > Detected by CoverityScan, CID#711541 ("Out of bounds read")
> > 
> > Fixes: d1081202f1d0 ("HFS rewrite")
> 
> No such commit here.  I assume this is 7cb74be6fd827e314f8.

Sorry, I missed that.  This bug has actually been here since before the
first git commit.

> 
> > --- a/fs/hfs/extent.c
> > +++ b/fs/hfs/extent.c
> > @@ -300,7 +300,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);
> 
> Well, that's quite the bug.  Question is, why didn't anyone notice it. 
> What are the runtime effects?

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.
 
> I worry a bit that, given the fs was evidently working "ok", perhaps
> this error was corrected elsewhere in the code and that "fixing" this
> site will have unexpected and undesirable runtime effects.  Can someone
> help me out here?

I don't think so.  This bug also makes extent point to the wrong place on
the following call to hfs_free_extents().  There is no way this can work
correctly in general.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ