erofs: fix order >= MAX_ORDER warning due to crafted negative i_size
authorGao Xiang <hsiangkao@linux.alibaba.com>
Fri, 9 Sep 2022 02:39:48 +0000 (10:39 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 8 Dec 2022 10:28:37 +0000 (11:28 +0100)
commitacc2f40b980c61a9178b72cdedd150b829064997
tree7101e073ddaff306635edf524bd67f8c82fdb101
parentca9f27448af0ba9e25a6d963b9722e2c0420647d
erofs: fix order >= MAX_ORDER warning due to crafted negative i_size

[ Upstream commit 1dd73601a1cba37a0ed5f89a8662c90191df5873 ]

As syzbot reported [1], the root cause is that i_size field is a
signed type, and negative i_size is also less than EROFS_BLKSIZ.
As a consequence, it's handled as fast symlink unexpectedly.

Let's fall back to the generic path to deal with such unusual i_size.

[1] https://lore.kernel.org/r/000000000000ac8efa05e7feaa1f@google.com

Reported-by: syzbot+f966c13b1b4fc0403b19@syzkaller.appspotmail.com
Fixes: 431339ba9042 ("staging: erofs: add inode operations")
Reviewed-by: Yue Hu <huyue2@coolpad.com>
Link: https://lore.kernel.org/r/20220909023948.28925-1-hsiangkao@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/erofs/inode.c