Fix corrupted OSF partition table parsing
commit473ef924e5994fa4c0943897300c53e116eb9e42
authorTimo Warns <Warns@pre-sense.de>
Mon, 14 Mar 2011 13:59:33 +0000 (14 14:59 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 9 May 2011 22:55:14 +0000 (9 15:55 -0700)
treebaf8166025438971809f7fe8e173daf5a0825054
parent9aa01fe50360df5e502e1098c9446cbdf51c9672
Fix corrupted OSF partition table parsing

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 <warns@pre-sense.de>
Cc: stable@kernel.org
[ 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 <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/partitions/osf.c