From patchwork Wed Oct 19 08:24:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5096 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp249954wrs; Wed, 19 Oct 2022 03:47:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM57o3MVRgpDehtYXNsKN7Qp01Cb5ma1UHozM3piVjucnt+0eVhMUPD9y0OcSWDNRD++R2i7 X-Received: by 2002:a17:907:6da3:b0:78e:2a5f:5aaf with SMTP id sb35-20020a1709076da300b0078e2a5f5aafmr6096998ejc.554.1666176459160; Wed, 19 Oct 2022 03:47:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666176459; cv=none; d=google.com; s=arc-20160816; b=zny8r48WzSI3H3o4UMibyrtQ5u49FayEcf7LWUAe4ArmWSgJr22RTe0M0T2sYeSjRk F91f9cjykzbQ2SlKzF5+BkQa5zXr9IS2ZJAQFGpoerSIXAo5as7QvToTQnZVU8/El1Do 1t8VMw3xR1HPdpdX8IZUkJef2D7NAigNNRBURZruzonypIZuUZT2zOGJYhr83OSoiykF ngTHchuDFJCR6oHS9iobR1RPfZgObH2hiMijl66jCPkN0yo9BwcDqvkW9Me+H6NuG0oU zJKDmZEOxZkkoyTULhpgbBfuAVkNPKCATV7tSjlVEJDUT2H62jPZZf8fdv9+96H/Ll3P GB/w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=160xUj7FoYlNJDDaH0QkShc2p2Wp6ZmDJbKBrEcSaEQ=; b=ydngQra1hSdmoALH2JRnb0f3d2x1/RnffTpdq3NwYJYCOA0OmxA2pJsOkAcZYh3EYg 33J0Von7dncqR4WsuL8yGK00y8zPNksEGQGHsmdZAGrPqqil7dEcXpFgf7HZxNPCsL/L Ki217db7l0i5BlzC1FoK9bCFq4ByVqZ9jXyhVgFGLL8KLVWs3cBPbxki5UST2XbyyPMe D/YVvQz7ci4Rjrp8D+bqPyumg9EEq8QhPtm6s8ramiv9375sUjDLwOVW74UczNk9w946 NGbW4GjRdktsYO3ZKO2X11Wxeo/njtBYqxEbSI1Q2ds1HoD5S/E3hAePVan+gNeXrJUx IWCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bKNzwgB9; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cx18-20020a05640222b200b0045ca9f57186si12184059edb.288.2022.10.19.03.47.13; Wed, 19 Oct 2022 03:47: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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bKNzwgB9; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233451AbiJSKq5 (ORCPT + 99 others); Wed, 19 Oct 2022 06:46:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230507AbiJSKom (ORCPT ); Wed, 19 Oct 2022 06:44:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C9ADA2879; Wed, 19 Oct 2022 03:21:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8D470B8231F; Wed, 19 Oct 2022 08:47:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBE97C433D6; Wed, 19 Oct 2022 08:47:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169260; bh=93Mwl/CNPEa8olUJJ5MXG4cAm7nEoQMxsfLzscJcT+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bKNzwgB9bCRUdOtwTy96tCLtjBX3LXNlYdrQQZbyjmphOQAXyOhL5csTS7SjiruQJ MAfB0WTZdKFVbFYNke/FL4UW7nQ/voOt9Vu6rh4Y4FkJAzwxJQtPgtGZi2kT0jxjuO uFlJaECiKSeVW5BN1QS1EK+ca3yQYi/Srhrseuqs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+f966c13b1b4fc0403b19@syzkaller.appspotmail.com, Yue Hu , Gao Xiang , Sasha Levin Subject: [PATCH 6.0 212/862] erofs: fix order >= MAX_ORDER warning due to crafted negative i_size Date: Wed, 19 Oct 2022 10:24:59 +0200 Message-Id: <20221019083259.396157131@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747112646712159672?= X-GMAIL-MSGID: =?utf-8?q?1747112646712159672?= From: Gao Xiang [ 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 Link: https://lore.kernel.org/r/20220909023948.28925-1-hsiangkao@linux.alibaba.com Signed-off-by: Gao Xiang Signed-off-by: Sasha Levin --- 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; }