Squashfs: handle corruption of directory structure
authorPhillip Lougher <phillip@lougher.demon.co.uk>
Tue, 15 Mar 2011 22:09:55 +0000 (22:09 +0000)
committerAndi Kleen <ak@linux.intel.com>
Thu, 28 Apr 2011 15:21:00 +0000 (08:21 -0700)
commitf5228c7c5062d5257f881d2f9c6a355215ce79b2
tree7a1e3bf43dc3fae306f28656aafb5f5c944113fb
parent297a19bdbec76bbf4668abd4a8eb4bcf6b4019f8
Squashfs: handle corruption of directory structure

commit 44cff8a9ee8a974f9e931df910688e7fc1f0b0f9 upstream.

Handle the rare case where a directory metadata block is uncompressed and
corrupted, leading to a kernel oops in directory scanning (memcpy).
Normally corruption is detected at the decompression stage and dealt with
then, however, this will not happen if:

- metadata isn't compressed (users can optionally request no metadata
  compression), or
- the compressed metadata block was larger than the original, in which
  case the uncompressed version was used, or
- the data was corrupt after decompression

This patch fixes this by adding some sanity checks against known maximum
values.

Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
fs/squashfs/dir.c
fs/squashfs/namei.c