From: Eric Sesterhenn <snakebyte@gmx.de>
To: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: zippel@linux-m68k.org, linux-kernel@vger.kernel.org
Subject: Re: [Patch] Fix Buffer overflow in hfsplus with a corrupted image
Date: Sun, 24 Aug 2008 17:24:54 +0200 [thread overview]
Message-ID: <20080824152454.GA27964@alice> (raw)
In-Reply-To: <84144f020808240814l41be03a6x53d4c521d7d95eb6@mail.gmail.com>
* Pekka Enberg (penberg@cs.helsinki.fi) wrote:
> Hi Eric,
>
> On Sun, Aug 24, 2008 at 4:07 PM, Eric Sesterhenn <snakebyte@gmx.de> wrote:
> > when an hfsplus image gets corrupted it might happen that the catalog
> > namelength field gets b0rked. If we mount such an image
> > the memcpy() in hfsplus_cat_build_key_uni() writes more than the 255
> > that fit in the name field. Depending on the size of the overwritten
> > data, we either only get memory corruption or also trigger an oops like
> > this:
> >
> > --- linux/fs/hfsplus/catalog.c.orig 2008-08-24 14:52:03.000000000 +0200
> > +++ linux/fs/hfsplus/catalog.c 2008-08-24 14:54:15.000000000 +0200
> > @@ -168,6 +168,11 @@ int hfsplus_find_cat(struct super_block
> > return -EIO;
> > }
> >
> > + if (be16_to_cpu(tmp.thread.nodeName.length) >= 127) {
> > + printk(KERN_ERR "hfs: catalog name length corrupted\n");
> > + return -EIO;
> > + }
>
> So, where does this 127 come from? I can only find reference to a
> maximum length of 255 unicode characters (16 bits per character) in
> the following technical note for HFS+ (see sections "HFS Plus Names"
> and "Catalog Thread Records"):
>
> http://developer.apple.com/technotes/tn/tn1150.html
>
> Hmm?
Ah, i missed that the name array is __be16, i somehow assumed it was a
char array, and tried to account for the multiplication by 2 in
hfsplus_cat_build_key_uni(). here is an updated fix.
Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
--- linux/fs/hfsplus/catalog.c.orig 2008-08-24 14:52:03.000000000 +0200
+++ linux/fs/hfsplus/catalog.c 2008-08-24 14:54:15.000000000 +0200
@@ -168,6 +168,11 @@ int hfsplus_find_cat(struct super_block
return -EIO;
}
+ if (be16_to_cpu(tmp.thread.nodeName.length) > 255) {
+ printk(KERN_ERR "hfs: catalog name length corrupted\n");
+ return -EIO;
+ }
+
hfsplus_cat_build_key_uni(fd->search_key, be32_to_cpu(tmp.thread.parentID),
&tmp.thread.nodeName);
return hfs_brec_find(fd);
next prev parent reply other threads:[~2008-08-24 15:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-24 13:07 [Patch] Fix Buffer overflow in hfsplus with a corrupted image Eric Sesterhenn
2008-08-24 15:14 ` Pekka Enberg
2008-08-24 15:24 ` Eric Sesterhenn [this message]
2008-08-24 15:23 ` Pekka Enberg
Reply instructions:
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080824152454.GA27964@alice \
--to=snakebyte@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=penberg@cs.helsinki.fi \
--cc=zippel@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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