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/[email protected]

Reported-by: [email protected]
Fixes: 431339ba9042 ("staging: erofs: add inode operations")
Reviewed-by: Yue Hu <[email protected]>
Link: 
https://lore.kernel.org/r/[email protected]
Signed-off-by: Gao Xiang <[email protected]>
---
 fs/erofs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index 0a94a52a119f..93a4ed665d93 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -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;
        }
-- 
2.43.5

Reply via email to