]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
erofs: fix order >= MAX_ORDER warning due to crafted negative i_size
authorGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 18 Dec 2024 07:36:25 +0000 (15:36 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jan 2025 12:24:51 +0000 (13:24 +0100)
commit 1dd73601a1cba37a0ed5f89a8662c90191df5873 upstream.

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

index 0a94a52a119fbcb89f2d8a1e8662ee362dc2a0a9..93a4ed665d939de5ef3308619b5048b8c1cbb976 100644 (file)
@@ -202,7 +202,7 @@ static int erofs_fill_symlink(struct inode *inode, void *data,
 
        /* if it cannot be handled with fast symlink scheme */
        if (vi->datalayout != EROFS_INODE_FLAT_INLINE ||
-           inode->i_size >= PAGE_SIZE) {
+           inode->i_size >= PAGE_SIZE || inode->i_size < 0) {
                inode->i_op = &erofs_symlink_iops;
                return 0;
        }