From nobody Mon Apr 6 08:05:41 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E743CC6FA83 for ; Fri, 9 Sep 2022 02:40:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229604AbiIICkT (ORCPT ); Thu, 8 Sep 2022 22:40:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229913AbiIICkL (ORCPT ); Thu, 8 Sep 2022 22:40:11 -0400 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B2C7E7FAF for ; Thu, 8 Sep 2022 19:40:03 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0VP7M4tU_1662691196; Received: from e18g06460.et15sqa.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VP7M4tU_1662691196) by smtp.aliyun-inc.com; Fri, 09 Sep 2022 10:40:01 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: LKML , syzkaller-bugs , Gao Xiang , syzbot+f966c13b1b4fc0403b19@syzkaller.appspotmail.com Subject: [PATCH] erofs: fix order >= MAX_ORDER warning due to crafted nagative i_size Date: Fri, 9 Sep 2022 10:39:48 +0800 Message-Id: <20220909023948.28925-1-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.24.4 In-Reply-To: <000000000000ac8efa05e7feaa1f@google.com> References: <000000000000ac8efa05e7feaa1f@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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") Signed-off-by: Gao Xiang Reviewed-by: Yue Hu --- 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 95a403720e8c..16cf9a283557 100644 --- a/fs/erofs/inode.c +++ b/fs/erofs/inode.c @@ -214,7 +214,7 @@ static int erofs_fill_symlink(struct inode *inode, void= *kaddr, =20 /* if it cannot be handled with fast symlink scheme */ if (vi->datalayout !=3D EROFS_INODE_FLAT_INLINE || - inode->i_size >=3D EROFS_BLKSIZ) { + inode->i_size >=3D EROFS_BLKSIZ || inode->i_size < 0) { inode->i_op =3D &erofs_symlink_iops; return 0; } --=20 2.24.4