Patchwork [0/1,CVE-2012-2319] hfsplus: Fix potential buffer overflows

login
register
mail settings
Submitter Tim Gardner
Date May 24, 2012, 1:21 p.m.
Message ID <4FBE35E8.2030200@canonical.com>
Download mbox | patch
Permalink /patch/161137/
State New
Headers show

Comments

Tim Gardner - May 24, 2012, 1:21 p.m.
On 05/23/2012 09:21 PM, Brad Figg wrote:
> Following this cover-letter is a single patch that applies the same CVE
> fix to the xen and openvz sections of the Hardy git tree.
> 
> CVE-2012-2319
> 
> Commit ec81aecb2966 ("hfs: fix a potential buffer overflow") fixed a few
> potential buffer overflows in the hfs filesystem.  But as Timo Warns
> pointed out, these changes also need to be made on the hfsplus
> filesystem as well.
> 
> Greg Kroah-Hartman (1):
>   hfsplus: Fix potential buffer overflows
> 
>  fs/hfsplus/catalog.c |    4 ++++
>  fs/hfsplus/dir.c     |   11 +++++++++++
>  2 files changed, 15 insertions(+)
> 

I'm a bit confused. Is there any reason that this patch shouldn't also
apply to the regular hfsplus files, e.g., as in the attached patch ?

rtg
Tim Gardner - May 24, 2012, 1:26 p.m.
On 05/24/2012 07:21 AM, Tim Gardner wrote:
> On 05/23/2012 09:21 PM, Brad Figg wrote:
>> Following this cover-letter is a single patch that applies the same CVE
>> fix to the xen and openvz sections of the Hardy git tree.
>>
>> CVE-2012-2319
>>
>> Commit ec81aecb2966 ("hfs: fix a potential buffer overflow") fixed a few
>> potential buffer overflows in the hfs filesystem.  But as Timo Warns
>> pointed out, these changes also need to be made on the hfsplus
>> filesystem as well.
>>
>> Greg Kroah-Hartman (1):
>>   hfsplus: Fix potential buffer overflows
>>
>>  fs/hfsplus/catalog.c |    4 ++++
>>  fs/hfsplus/dir.c     |   11 +++++++++++
>>  2 files changed, 15 insertions(+)
>>
> 
> I'm a bit confused. Is there any reason that this patch shouldn't also
> apply to the regular hfsplus files, e.g., as in the attached patch ?
> 
> rtg
> 
> 
> 

Oh, never mind. I didn't see the initial patch because of the way my
email client orders things. However, I went ahead and applied the
combined patch for Hardy. Isn't that preferable to having 2 patches with
identical subject lines ?

rtg
Herton Ronaldo Krzesinski - May 24, 2012, 1:29 p.m.
On Thu, May 24, 2012 at 07:21:44AM -0600, Tim Gardner wrote:
> On 05/23/2012 09:21 PM, Brad Figg wrote:
> > Following this cover-letter is a single patch that applies the same CVE
> > fix to the xen and openvz sections of the Hardy git tree.
> > 
> > CVE-2012-2319
> > 
> > Commit ec81aecb2966 ("hfs: fix a potential buffer overflow") fixed a few
> > potential buffer overflows in the hfs filesystem.  But as Timo Warns
> > pointed out, these changes also need to be made on the hfsplus
> > filesystem as well.
> > 
> > Greg Kroah-Hartman (1):
> >   hfsplus: Fix potential buffer overflows
> > 
> >  fs/hfsplus/catalog.c |    4 ++++
> >  fs/hfsplus/dir.c     |   11 +++++++++++
> >  2 files changed, 15 insertions(+)
> > 
> 
> I'm a bit confused. Is there any reason that this patch shouldn't also
> apply to the regular hfsplus files, e.g., as in the attached patch ?

Brad did it "separate" in the other email with [HARDY] [LUCID] subject.

Either way is fine, Ack on both. Just minor issue here as well, the
identation for the change added on hfsplus_rename_cat is spaces instead
of tab.

> 
> rtg
> -- 
> Tim Gardner tim.gardner@canonical.com

> From fe5fe1b526c410aa7a4daffca6fcf82b8c879db3 Mon Sep 17 00:00:00 2001
> From: Brad Figg <brad.figg@canonical.com>
> Date: Wed, 23 May 2012 20:21:56 -0700
> Subject: [PATCH] hfsplus: Fix potential buffer overflows
> 
> CVE-2012-2319
> 
> Commit ec81aecb2966 ("hfs: fix a potential buffer overflow") fixed a few
> potential buffer overflows in the hfs filesystem.  But as Timo Warns
> pointed out, these changes also need to be made on the hfsplus
> filesystem as well.
> 
> Reported-by: Timo Warns <warns@pre-sense.de>
> Acked-by: WANG Cong <amwang@redhat.com>
> Cc: Alexey Khoroshilov <khoroshilov@ispras.ru>
> Cc: Miklos Szeredi <mszeredi@suse.cz>
> Cc: Sage Weil <sage@newdream.net>
> Cc: Eugene Teo <eteo@redhat.com>
> Cc: Roman Zippel <zippel@linux-m68k.org>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Alexey Dobriyan <adobriyan@gmail.com>
> Cc: Dave Anderson <anderson@redhat.com>
> Cc: stable <stable@vger.kernel.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> (backported from commit 6f24f892871acc47b40dd594c63606a17c714f77 upstream)
> Signed-off-by: Brad Figg <brad.figg@canonical.com>
> 
> Acked-by: Stefan Bader <stefan.bader@canonical.com>
> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
> ---
>  .../openvz/src/fs/hfsplus/catalog.c                |    4 ++++
>  debian/binary-custom.d/openvz/src/fs/hfsplus/dir.c |   11 +++++++++++
>  .../binary-custom.d/xen/src/fs/hfsplus/catalog.c   |    4 ++++
>  debian/binary-custom.d/xen/src/fs/hfsplus/dir.c    |   11 +++++++++++
>  fs/hfsplus/catalog.c                               |    4 ++++
>  fs/hfsplus/dir.c                                   |   11 +++++++++++
>  6 files changed, 45 insertions(+)
> 
> diff --git a/debian/binary-custom.d/openvz/src/fs/hfsplus/catalog.c b/debian/binary-custom.d/openvz/src/fs/hfsplus/catalog.c
> index f6874ac..8a7cbcf 100644
> --- a/debian/binary-custom.d/openvz/src/fs/hfsplus/catalog.c
> +++ b/debian/binary-custom.d/openvz/src/fs/hfsplus/catalog.c
> @@ -329,6 +329,10 @@ int hfsplus_rename_cat(u32 cnid,
>  	err = hfs_brec_find(&src_fd);
>  	if (err)
>  		goto out;
> +    if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) {
> +        err = -EIO;
> +        goto out;
> +    }
>  
>  	hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset,
>  				src_fd.entrylength);
> diff --git a/debian/binary-custom.d/openvz/src/fs/hfsplus/dir.c b/debian/binary-custom.d/openvz/src/fs/hfsplus/dir.c
> index 078684f..2d57b2b 100644
> --- a/debian/binary-custom.d/openvz/src/fs/hfsplus/dir.c
> +++ b/debian/binary-custom.d/openvz/src/fs/hfsplus/dir.c
> @@ -138,6 +138,11 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
>  		filp->f_pos++;
>  		/* fall through */
>  	case 1:
> +		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
> +			err = -EIO;
> +			goto out;
> +		}
> +
>  		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
>  		if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) {
>  			printk(KERN_ERR "hfs: bad catalog folder thread\n");
> @@ -168,6 +173,12 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
>  			err = -EIO;
>  			goto out;
>  		}
> +
> +		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
> +			err = -EIO;
> +			goto out;
> +		}
> +
>  		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
>  		type = be16_to_cpu(entry.type);
>  		len = HFSPLUS_MAX_STRLEN;
> diff --git a/debian/binary-custom.d/xen/src/fs/hfsplus/catalog.c b/debian/binary-custom.d/xen/src/fs/hfsplus/catalog.c
> index f6874ac..8a7cbcf 100644
> --- a/debian/binary-custom.d/xen/src/fs/hfsplus/catalog.c
> +++ b/debian/binary-custom.d/xen/src/fs/hfsplus/catalog.c
> @@ -329,6 +329,10 @@ int hfsplus_rename_cat(u32 cnid,
>  	err = hfs_brec_find(&src_fd);
>  	if (err)
>  		goto out;
> +    if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) {
> +        err = -EIO;
> +        goto out;
> +    }
>  
>  	hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset,
>  				src_fd.entrylength);
> diff --git a/debian/binary-custom.d/xen/src/fs/hfsplus/dir.c b/debian/binary-custom.d/xen/src/fs/hfsplus/dir.c
> index 078684f..2d57b2b 100644
> --- a/debian/binary-custom.d/xen/src/fs/hfsplus/dir.c
> +++ b/debian/binary-custom.d/xen/src/fs/hfsplus/dir.c
> @@ -138,6 +138,11 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
>  		filp->f_pos++;
>  		/* fall through */
>  	case 1:
> +		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
> +			err = -EIO;
> +			goto out;
> +		}
> +
>  		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
>  		if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) {
>  			printk(KERN_ERR "hfs: bad catalog folder thread\n");
> @@ -168,6 +173,12 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
>  			err = -EIO;
>  			goto out;
>  		}
> +
> +		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
> +			err = -EIO;
> +			goto out;
> +		}
> +
>  		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
>  		type = be16_to_cpu(entry.type);
>  		len = HFSPLUS_MAX_STRLEN;
> diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
> index f6874ac..8a7cbcf 100644
> --- a/fs/hfsplus/catalog.c
> +++ b/fs/hfsplus/catalog.c
> @@ -329,6 +329,10 @@ int hfsplus_rename_cat(u32 cnid,
>  	err = hfs_brec_find(&src_fd);
>  	if (err)
>  		goto out;
> +    if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) {
> +        err = -EIO;
> +        goto out;
> +    }
>  
>  	hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset,
>  				src_fd.entrylength);
> diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
> index 078684f..2d57b2b 100644
> --- a/fs/hfsplus/dir.c
> +++ b/fs/hfsplus/dir.c
> @@ -138,6 +138,11 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
>  		filp->f_pos++;
>  		/* fall through */
>  	case 1:
> +		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
> +			err = -EIO;
> +			goto out;
> +		}
> +
>  		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
>  		if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) {
>  			printk(KERN_ERR "hfs: bad catalog folder thread\n");
> @@ -168,6 +173,12 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
>  			err = -EIO;
>  			goto out;
>  		}
> +
> +		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
> +			err = -EIO;
> +			goto out;
> +		}
> +
>  		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
>  		type = be16_to_cpu(entry.type);
>  		len = HFSPLUS_MAX_STRLEN;
> -- 
> 1.7.9.5
> 

> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team

Patch

From fe5fe1b526c410aa7a4daffca6fcf82b8c879db3 Mon Sep 17 00:00:00 2001
From: Brad Figg <brad.figg@canonical.com>
Date: Wed, 23 May 2012 20:21:56 -0700
Subject: [PATCH] hfsplus: Fix potential buffer overflows

CVE-2012-2319

Commit ec81aecb2966 ("hfs: fix a potential buffer overflow") fixed a few
potential buffer overflows in the hfs filesystem.  But as Timo Warns
pointed out, these changes also need to be made on the hfsplus
filesystem as well.

Reported-by: Timo Warns <warns@pre-sense.de>
Acked-by: WANG Cong <amwang@redhat.com>
Cc: Alexey Khoroshilov <khoroshilov@ispras.ru>
Cc: Miklos Szeredi <mszeredi@suse.cz>
Cc: Sage Weil <sage@newdream.net>
Cc: Eugene Teo <eteo@redhat.com>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Dave Anderson <anderson@redhat.com>
Cc: stable <stable@vger.kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(backported from commit 6f24f892871acc47b40dd594c63606a17c714f77 upstream)
Signed-off-by: Brad Figg <brad.figg@canonical.com>

Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 .../openvz/src/fs/hfsplus/catalog.c                |    4 ++++
 debian/binary-custom.d/openvz/src/fs/hfsplus/dir.c |   11 +++++++++++
 .../binary-custom.d/xen/src/fs/hfsplus/catalog.c   |    4 ++++
 debian/binary-custom.d/xen/src/fs/hfsplus/dir.c    |   11 +++++++++++
 fs/hfsplus/catalog.c                               |    4 ++++
 fs/hfsplus/dir.c                                   |   11 +++++++++++
 6 files changed, 45 insertions(+)

diff --git a/debian/binary-custom.d/openvz/src/fs/hfsplus/catalog.c b/debian/binary-custom.d/openvz/src/fs/hfsplus/catalog.c
index f6874ac..8a7cbcf 100644
--- a/debian/binary-custom.d/openvz/src/fs/hfsplus/catalog.c
+++ b/debian/binary-custom.d/openvz/src/fs/hfsplus/catalog.c
@@ -329,6 +329,10 @@  int hfsplus_rename_cat(u32 cnid,
 	err = hfs_brec_find(&src_fd);
 	if (err)
 		goto out;
+    if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) {
+        err = -EIO;
+        goto out;
+    }
 
 	hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset,
 				src_fd.entrylength);
diff --git a/debian/binary-custom.d/openvz/src/fs/hfsplus/dir.c b/debian/binary-custom.d/openvz/src/fs/hfsplus/dir.c
index 078684f..2d57b2b 100644
--- a/debian/binary-custom.d/openvz/src/fs/hfsplus/dir.c
+++ b/debian/binary-custom.d/openvz/src/fs/hfsplus/dir.c
@@ -138,6 +138,11 @@  static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
 		filp->f_pos++;
 		/* fall through */
 	case 1:
+		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
+			err = -EIO;
+			goto out;
+		}
+
 		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
 		if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) {
 			printk(KERN_ERR "hfs: bad catalog folder thread\n");
@@ -168,6 +173,12 @@  static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
 			err = -EIO;
 			goto out;
 		}
+
+		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
+			err = -EIO;
+			goto out;
+		}
+
 		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
 		type = be16_to_cpu(entry.type);
 		len = HFSPLUS_MAX_STRLEN;
diff --git a/debian/binary-custom.d/xen/src/fs/hfsplus/catalog.c b/debian/binary-custom.d/xen/src/fs/hfsplus/catalog.c
index f6874ac..8a7cbcf 100644
--- a/debian/binary-custom.d/xen/src/fs/hfsplus/catalog.c
+++ b/debian/binary-custom.d/xen/src/fs/hfsplus/catalog.c
@@ -329,6 +329,10 @@  int hfsplus_rename_cat(u32 cnid,
 	err = hfs_brec_find(&src_fd);
 	if (err)
 		goto out;
+    if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) {
+        err = -EIO;
+        goto out;
+    }
 
 	hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset,
 				src_fd.entrylength);
diff --git a/debian/binary-custom.d/xen/src/fs/hfsplus/dir.c b/debian/binary-custom.d/xen/src/fs/hfsplus/dir.c
index 078684f..2d57b2b 100644
--- a/debian/binary-custom.d/xen/src/fs/hfsplus/dir.c
+++ b/debian/binary-custom.d/xen/src/fs/hfsplus/dir.c
@@ -138,6 +138,11 @@  static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
 		filp->f_pos++;
 		/* fall through */
 	case 1:
+		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
+			err = -EIO;
+			goto out;
+		}
+
 		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
 		if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) {
 			printk(KERN_ERR "hfs: bad catalog folder thread\n");
@@ -168,6 +173,12 @@  static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
 			err = -EIO;
 			goto out;
 		}
+
+		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
+			err = -EIO;
+			goto out;
+		}
+
 		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
 		type = be16_to_cpu(entry.type);
 		len = HFSPLUS_MAX_STRLEN;
diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
index f6874ac..8a7cbcf 100644
--- a/fs/hfsplus/catalog.c
+++ b/fs/hfsplus/catalog.c
@@ -329,6 +329,10 @@  int hfsplus_rename_cat(u32 cnid,
 	err = hfs_brec_find(&src_fd);
 	if (err)
 		goto out;
+    if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) {
+        err = -EIO;
+        goto out;
+    }
 
 	hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset,
 				src_fd.entrylength);
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 078684f..2d57b2b 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -138,6 +138,11 @@  static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
 		filp->f_pos++;
 		/* fall through */
 	case 1:
+		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
+			err = -EIO;
+			goto out;
+		}
+
 		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
 		if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) {
 			printk(KERN_ERR "hfs: bad catalog folder thread\n");
@@ -168,6 +173,12 @@  static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
 			err = -EIO;
 			goto out;
 		}
+
+		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
+			err = -EIO;
+			goto out;
+		}
+
 		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
 		type = be16_to_cpu(entry.type);
 		len = HFSPLUS_MAX_STRLEN;
-- 
1.7.9.5