erofs: reject inodes with negative i_size
authorGao Xiang <hsiangkao@linux.alibaba.com>
Thu, 12 Sep 2024 08:35:38 +0000 (16:35 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Thu, 12 Sep 2024 15:00:09 +0000 (23:00 +0800)
commit025497e1d176a9e063d1e60699527e2f3a871935
treeeb633c6a9f65806a38c208e5b1947bc7e4b98df0
parent7c3ca1838a7831855cbf2e6927a10e0e4723edf6
erofs: reject inodes with negative i_size

Negative i_size is never supported, although crafted images with inodes
having negative i_size will NOT lead to security issues in our current
codebase:

The following image can verify this (gzip+base64 encoded):

H4sICCmk4mYAA3Rlc3QuaW1nAGNgGAWjYBSMVPDo4dcH3jP2aTED2TwMKgxMUHHNJY/SQDQX
LxcDIw3tZwXit44MDNpQ/n8gQJZ/vxjijosPuSyZ0DUDgQqcZoKzVYFsDShbHeh6PT29ktTi
Eqz2g/y2pBFiLxDMh4lhs5+W4TAKRsEoGAWjYBSMglEwCkYBPQAAS2DbowAQAAA=

Mark as bad inodes for such corrupted inodes explicitly.

Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240912083538.3011860-1-hsiangkao@linux.alibaba.com
fs/erofs/inode.c