From: Al Viro <viro@ZenIV.linux.org.uk>
To: Andrew Morton <firstname.lastname@example.org>
Cc: Colin King <email@example.com>,
Vyacheslav Dubeyko <firstname.lastname@example.org>,
"Ernesto A. Fernndez" <email@example.com>
Subject: Re: [PATCH] hfs: fix array out of bounds read of array extent
Date: Thu, 18 Oct 2018 00:17:08 +0100 [thread overview]
Message-ID: <20181017231708.GB32577@ZenIV.linux.org.uk> (raw)
On Wed, Oct 17, 2018 at 03:01:17PM -0700, Andrew Morton wrote:
> On Fri, 31 Aug 2018 15:05:38 +0100 Colin King <firstname.lastname@example.org> wrote:
> > From: Colin Ian King <email@example.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.
> > --- 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? A disk space leak, perhaps?
> 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?
hfs_free_extents() seems to expect the 'offset' argument to be the
sum of ->count of 1--3 starting elements of extent array. In case of
mismatch, it returns -EIO and that's it - hfs_free_fork() will bugger
off with -EIO at that point. If it does match, block_nr is supposed
to be in range 0..offset and blocks offset - block_nr .. offset - 1
So at a guess, that sucker mostly ends up leaking blocks. Said that,
it means that the rest of hfs_free_fork() has never been tested.
I'd suggest somebody to turn that
/* panic? */
in hfs_free_extents() into
printk(KERN_ERR "hfs_free_extents is fucked");
and see if it's triggerable. Then check if there's a block leak in
the reproducer, whatever it is.
next prev parent reply other threads:[~2018-10-18 7:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-31 14:05 [PATCH] hfs: fix array out of bounds read of array extent Colin King
2018-10-17 17:49 ` Ernesto A. Fernández
[not found] ` <firstname.lastname@example.org>
2018-10-17 23:17 ` Al Viro [this message]
2018-10-17 23:28 ` Ernesto A. Fernández
2018-10-17 23:36 ` Viacheslav Dubeyko
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).