This is a note to let you know that I've just added the patch titled

    Fix corrupted OSF partition table parsing

to the 2.6.32-longterm tree which can be found at:
    
http://www.kernel.org/git/?p=linux/kernel/git/longterm/longterm-queue-2.6.32.git;a=summary

The filename of the patch is:
     fix-corrupted-osf-partition-table-parsing.patch
and it can be found in the queue-2.6.32 subdirectory.

If you, or anyone else, feels it should not be added to the 2.6.32 longterm 
tree,
please let <[email protected]> know about it.


>From 2caa77209ff3dbe02edf9d9b701a91142f8f6983 Mon Sep 17 00:00:00 2001
From: Timo Warns <[email protected]>
Date: Mon, 14 Mar 2011 14:59:33 +0100
Subject: Fix corrupted OSF partition table parsing

From: Timo Warns <[email protected]>

commit 1eafbfeb7bdf59cfe173304c76188f3fd5f1fd05 upstream.

The kernel automatically evaluates partition tables of storage devices.
The code for evaluating OSF partitions contains a bug that leaks data
from kernel heap memory to userspace for certain corrupted OSF
partitions.

In more detail:

  for (i = 0 ; i < le16_to_cpu(label->d_npartitions); i++, partition++) {

iterates from 0 to d_npartitions - 1, where d_npartitions is read from
the partition table without validation and partition is a pointer to an
array of at most 8 d_partitions.

Add the proper and obvious validation.

Signed-off-by: Timo Warns <[email protected]>
Cc: [email protected]
[ Changed the patch trivially to not repeat the whole le16_to_cpu()
  thing, and to use an explicit constant for the magic value '8' ]
Signed-off-by: Linus Torvalds <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
 fs/partitions/osf.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

--- a/fs/partitions/osf.c
+++ b/fs/partitions/osf.c
@@ -10,10 +10,13 @@
 #include "check.h"
 #include "osf.h"
 
+#define MAX_OSF_PARTITIONS 8
+
 int osf_partition(struct parsed_partitions *state, struct block_device *bdev)
 {
        int i;
        int slot = 1;
+       unsigned int npartitions;
        Sector sect;
        unsigned char *data;
        struct disklabel {
@@ -45,7 +48,7 @@ int osf_partition(struct parsed_partitio
                        u8  p_fstype;
                        u8  p_frag;
                        __le16 p_cpg;
-               } d_partitions[8];
+               } d_partitions[MAX_OSF_PARTITIONS];
        } * label;
        struct d_partition * partition;
 
@@ -63,7 +66,12 @@ int osf_partition(struct parsed_partitio
                put_dev_sector(sect);
                return 0;
        }
-       for (i = 0 ; i < le16_to_cpu(label->d_npartitions); i++, partition++) {
+       npartitions = le16_to_cpu(label->d_npartitions);
+       if (npartitions > MAX_OSF_PARTITIONS) {
+               put_dev_sector(sect);
+               return 0;
+       }
+       for (i = 0 ; i < npartitions; i++, partition++) {
                if (slot == state->limit)
                        break;
                if (le32_to_cpu(partition->p_size))


Patches currently in longterm-queue-2.6.32 which might be from 
[email protected] are

/home/gregkh/linux/longterm/longterm-queue-2.6.32/queue-2.6.32/fix-corrupted-osf-partition-table-parsing.patch
/home/gregkh/linux/longterm/longterm-queue-2.6.32/queue-2.6.32/fs-partitions-ldm.c-fix-oops-caused-by-corrupted-partition-table.patch

_______________________________________________
stable mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/stable

Reply via email to