Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3881154rwi; Sat, 22 Oct 2022 01:28:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4evqVslnInYWJkcio0zmrTcIQMUQLxm7FLt9yQcQbXuzj04IIMa3D8L3RORlygXH4NeotN X-Received: by 2002:a17:90b:3e82:b0:20d:2fa1:d08d with SMTP id rj2-20020a17090b3e8200b0020d2fa1d08dmr63818274pjb.162.1666427313626; Sat, 22 Oct 2022 01:28:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427313; cv=none; d=google.com; s=arc-20160816; b=y84chG7A38x6EWJIvK6ufPq2lUY2ZGtmGMRjlbCczIolXlUftvNld1bHTMq2ZIb199 i68sOeT/EgYEXgTkgDjUN6UJIprTQisQ8BLdgRWYlr4f20KBsNDmlHQjyoDfsVaxix+r zk7qqq+vwcCsv8BU/fdMnBbYIDSyrC+ulOwBDIZSRyWpjkHseHWQ1a75kTTzeNhmX1xw fH9IDJSDLp7mrmMnRaReqqZemivfKJD9f1709/ii7kRy/blWGqud86zQC8TJjlGS94fx NpJCGZA4P8U5tFyrSjGd4aMNzmE4H8W+VNcP//nX3Gz8dPW/UAF9IfK8fay0ZdnmCZuQ fFQA== 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=bmSwNScdnuDAdVnSD3RljFz695JStw1uXNv1SaPkWP3vfF+wbRgfPmUIaBwRn8p4XZ 3O3/ctArOG4ABUekNd0EtfMVANv/Ku2HNZpYQW3ibN0JGDe5GBgsPM4/kwfEQ3FXkFe/ gJnvAq7nXnWIcGVo5E42WFiIzBelvfo4VY14DshgjyeDncVptZSj7pwQHa456UY2uFhO Hapw76kv5saPh3K+nVAURZycDzBsU5EOYFz/E9L1TtBfjplLQN345NwfnxRGr/bm0c1j cwECIFMSN7T4t6TiYqx07vvZJxP3u6yGUSvtfp/y/BG7VLsDGVk0rpu0heu/Ce27RuyL HJjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PLEl43DJ; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 190-20020a6300c7000000b0045ec918ad31si26256441pga.544.2022.10.22.01.28.21; Sat, 22 Oct 2022 01:28:33 -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=PLEl43DJ; 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 S231738AbiJVHus (ORCPT + 99 others); Sat, 22 Oct 2022 03:50:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231703AbiJVHtB (ORCPT ); Sat, 22 Oct 2022 03:49:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED59A263F22; Sat, 22 Oct 2022 00:45:48 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 8B0C960AFD; Sat, 22 Oct 2022 07:42:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C49BC433C1; Sat, 22 Oct 2022 07:42:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424544; bh=93Mwl/CNPEa8olUJJ5MXG4cAm7nEoQMxsfLzscJcT+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PLEl43DJRz1tp4PyNsPW/EQ5TWIFjDGEdpp50autZqm1KM4Cx8ujaKTw6oWfSI6LF uAxUJmz19fcY1kPXaP1B4qh5rhBm7GFlMmBRtA2Go/+4nQB83V6AT2ZCMC0X2rvTqK KqZY4XLjAtsXGfLOUqRm6dO7uX1GHwVFWLVr8Luo= 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 5.19 185/717] erofs: fix order >= MAX_ORDER warning due to crafted negative i_size Date: Sat, 22 Oct 2022 09:21:04 +0200 Message-Id: <20221022072448.411194163@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.3 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 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; } -- 2.35.1