]> git.ipfire.org Git - thirdparty/util-linux.git/commit
fsck.minix: Verify more fields in super-block.
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 29 May 2016 16:56:58 +0000 (18:56 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 31 May 2016 11:18:06 +0000 (13:18 +0200)
commit8f35b3a998cc4ca5a9030692a5bbffbbf3449765
tree311d665d92a56e983b15f4ece53a03ca0c715a60
parent1eb16fd78065dd6485731c4fb70924bc9b69df3a
fsck.minix: Verify more fields in super-block.

The field s_ninodes in super-block is used for memory allocation and
division without verifications. The memory allocation increments the
unchecked value by 1, making it vulnerable to an integer overflow
on 32 bit systems with minix 3 file systems. I did not find a (good)
way to exploit this by crafting a malicious file system, so I consider
it as a reliability issue. If it's 0, a division by zero occurs when
"-v" has been used. A filesystem without any inodes is definitely
wrong, because it means that there's not even the root inode, which is
accessed unchecked later on.

The field s_firstdatazone has to be checked against s_(n)zones. If it
is larger than the highest allowed index, the file system is definitely
corrupted -- hard to say which value is wrong though, therefore I
decided to simply call die(). A maliciously created file system could
do more harm in this way: single bits inside the memory area could be
flipped because range checks would fail. Hard to consider it as a
security issue though, because these addresses are not arbitrarily
accessible without very careful crafting (if at all possible).

[kzak@redhat.com: - fix compiler warning (cast get_nzones()) [-Wsign-compare]]

Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/fsck.minix.c