]> git.karo-electronics.de Git - karo-tx-linux.git/commit
jffs2: validate symlink size in jffs2_do_read_inode_internal()
authorXi Wang <xi.wang@gmail.com>
Wed, 25 Apr 2012 18:45:22 +0000 (14:45 -0400)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Sun, 29 Apr 2012 15:33:33 +0000 (18:33 +0300)
commit804121253d30300689744757f36ccb0a2f1959c4
tree316c07df91a2771d2e6b774f9d495ab3fa768214
parent16d7c6f7d4b37d9f8bc21a8a742766c32c560b77
jffs2: validate symlink size in jffs2_do_read_inode_internal()

`csize' is read from disk and thus needs validation.  Otherwise a bogus
value 0xffffffff would turn the subsequent kmalloc(csize + 1, ...) into
kmalloc(0, ...), leading to out-of-bounds write.

This patch limits `csize' to JFFS2_MAX_NAME_LEN, which is also used
in jffs2_symlink().

Artem: we actually validate csize by checking CRC, so this 0xFFs cannot
come from empty flash region. But I guess an attacker could feed JFFS2
an image with random csize value, including 0xFFs.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
fs/jffs2/readinode.c