Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1410456rwn; Thu, 8 Sep 2022 20:01:39 -0700 (PDT) X-Google-Smtp-Source: AA6agR4wZMARvnmRqovb3/i8KkcLhL1Kh7DsGR/LMVE/43cQAoNGnogCG2eEPKAAyXlF1CjOVBPe X-Received: by 2002:a2e:b6d3:0:b0:26b:ddd7:919 with SMTP id m19-20020a2eb6d3000000b0026bddd70919mr1144901ljo.491.1662692499067; Thu, 08 Sep 2022 20:01:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662692499; cv=none; d=google.com; s=arc-20160816; b=dLF4V42ZnOBgGf2nI2KrgORUm140NG8v+lAe/OT8+SyhiKznPxoDc18Tb559r9DjAN zW9ZzGoJTDmSFvYLW0giSgZwV3ShwVE1WbW6Bt4sw6YjmourXk34xrNDw0gttlIhzAkx Pjqwjrbbeupvv+FsnK5tcNqhIwkIwBYD+KL+puJmBc0d5LUfHJ6egC+2denhhhunryt2 DEEUtm8uy5LAWH/2cuRT7SCr3Weqqjx1bWL9HAH4XF8LL6XRlm4D65J68YvnVLraDUiE mBacF3GOvUflHwFG1v/0IlHqDVbIcxPNIb9sZ08o+/8D6ETbBw3evnANFv53oSDkE+Tf LXMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jeBeeHajn6AHNeLGNwOnJYNipW3M3hCkieZOidGSyhk=; b=HEY7UPpPqW6mRuI1ltZzLK6IdsNp8/rSzMzsiti7LY1Fo8NjT0YMEPMViLZiESBopJ tSqhhE9zVgc5thQaNLgsBF4XQyNL6Y8f3bMdDDyxioKttMCFyNWt1zN0W5V21kGZAtJ1 ToWsl/WUA9VP9C5Tw+jznsV0K6WqYOqBbVaBnEOeP6JDpWCdwYxFhM8Sm/by7mOWJ9sJ RI93x5/6G89avxqaKoIL/FmHoDycckyagXfVgoe2+Gl44kBX1SD9/g/wslWh0LTkmZSQ Grk8wDjGUBt32aiD0UdVeEjyVqFSlZtOxVRrdaxPS0huz1TN0TDaRghFRMCbDuGpFvex v4mA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x36-20020a056512132400b00498fc04fb05si63860lfu.622.2022.09.08.20.01.09; Thu, 08 Sep 2022 20:01:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229973AbiIICkS (ORCPT + 99 others); Thu, 8 Sep 2022 22:40:18 -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: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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, /* if it cannot be handled with fast symlink scheme */ if (vi->datalayout != EROFS_INODE_FLAT_INLINE || - inode->i_size >= EROFS_BLKSIZ) { + inode->i_size >= EROFS_BLKSIZ || inode->i_size < 0) { inode->i_op = &erofs_symlink_iops; return 0; } -- 2.24.4