Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3688077lfo; Mon, 23 May 2022 11:28:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1ZCh5cA6Av8ycRVS/BQYEN7H91beVoklU1dhbYwnlEk8FMGB891Dmq4isK8iXQj6aKVxG X-Received: by 2002:a05:6a00:1941:b0:50d:807d:530b with SMTP id s1-20020a056a00194100b0050d807d530bmr25013852pfk.17.1653330539334; Mon, 23 May 2022 11:28:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653330539; cv=none; d=google.com; s=arc-20160816; b=MSzWBqxaVSFfKJpenPQNYSlGJD+maDmSP/LEioP1feMxfPEzLYF2GNY5NiT2wBmaoq XW9gMju1R6pOxo4LJRVSbEhOsZmfFjY9rs57UAM0DwkKtNi9UzodEEN6VKo4xKkBtpU4 CwnpH5Rg1cj4igntWQyj7CjCEH9Wq3UA16BGPFXUJ/ccFKItxY05CiiKPnAbhOjBCW+H 6xMjRuN5dmuUyRj1Xw63N0n/HMz4RFhLG5jnoODdAsZfRGpy+9vVgTOWlhT3YrblOzRH GbQcExMZPQaC6qM6NWJ/btA2kKi3yDFFhoWG46MfG1OOXyzghP/1QZQoB2Sq96i7rTrR Pj5A== 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=EIws8fJTwnjr1cCch6r01Obnv/kEHPUpjaKv8Xc2ZL8=; b=hkLaNB7tHzXikK9sm5eZQ56OTIl+celsbbck6IUxhsJzYTFu1ptdA76Od2rPa9ux0C zc87CgMdlmYCSoRFjV83ubY8XlPTW7gAYdj0vIOjtqMKQABGgRC9SK/lWs9K7Xxx51yi TAE/xuOAarpLcD9Rzn8R1zWBH204V4N0yUhMUSZk1tvdSa4Ugwh3f/32iOro7rIrXAqI UXtFRwc8u3Tq3uOEJsLYfcbPSf8VVNm9wNq2lBGHSRbkVPePjAOGEZph1BWW4/IdlhoL JWcNY1mDBhWzGHaGglskKcD84nbvK9eD70FIfMllMfONZ/zYzeA6ipWSNuA9GhyE3FDy Q3wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jItNr2b2; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id f11-20020a6547cb000000b003db7de734bdsi10193602pgs.747.2022.05.23.11.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 11:28:59 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jItNr2b2; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B1AF31269B5; Mon, 23 May 2022 11:28:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242449AbiEWRsl (ORCPT + 99 others); Mon, 23 May 2022 13:48:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239859AbiEWR2S (ORCPT ); Mon, 23 May 2022 13:28:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDF0F8FD45; Mon, 23 May 2022 10:25:22 -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 852F0608C0; Mon, 23 May 2022 17:25:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D82FC385A9; Mon, 23 May 2022 17:25:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653326722; bh=zeyKZE8740RxC0fLVa0ngmzOPV4kdSKGulQZT2SyRhU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jItNr2b2p/ps/LItmqJ9mwe+dKXfXHBLOGyiwQxVAYlmF+I4UJU8VloyowLyO1q+S wBeDjdDlAA+FK2QpQDBPZLW6kvkoYAnzxL9Tjjwu8t8VHFXMSCc0NFgJjc67wGPGqW L/1q87Ysg4ZDLRo6zKnmdgjuzUeKdQZl6m6MEaes= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Guo Xuenan , Christoph Hellwig , "Darrick J. Wong" , Sasha Levin Subject: [PATCH 5.17 039/158] fs: fix an infinite loop in iomap_fiemap Date: Mon, 23 May 2022 19:03:16 +0200 Message-Id: <20220523165836.959872332@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165830.581652127@linuxfoundation.org> References: <20220523165830.581652127@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Guo Xuenan [ Upstream commit 49df34221804cfd6384135b28b03c9461a31d024 ] when get fiemap starting from MAX_LFS_FILESIZE, (maxbytes - *len) < start will always true , then *len set zero. because of start offset is beyond file size, for erofs filesystem it will always return iomap.length with zero,iomap iterate will enter infinite loop. it is necessary cover this corner case to avoid this situation. ------------[ cut here ]------------ WARNING: CPU: 7 PID: 905 at fs/iomap/iter.c:35 iomap_iter+0x97f/0xc70 Modules linked in: xfs erofs CPU: 7 PID: 905 Comm: iomap Tainted: G W 5.17.0-rc8 #27 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 RIP: 0010:iomap_iter+0x97f/0xc70 Code: 85 a1 fc ff ff e8 71 be 9c ff 0f 1f 44 00 00 e9 92 fc ff ff e8 62 be 9c ff 0f 0b b8 fb ff ff ff e9 fc f8 ff ff e8 51 be 9c ff <0f> 0b e9 2b fc ff ff e8 45 be 9c ff 0f 0b e9 e1 fb ff ff e8 39 be RSP: 0018:ffff888060a37ab0 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffff888060a37bb0 RCX: 0000000000000000 RDX: ffff88807e19a900 RSI: ffffffff81a7da7f RDI: ffff888060a37be0 RBP: 7fffffffffffffff R08: 0000000000000000 R09: ffff888060a37c20 R10: ffff888060a37c67 R11: ffffed100c146f8c R12: 7fffffffffffffff R13: 0000000000000000 R14: ffff888060a37bd8 R15: ffff888060a37c20 FS: 00007fd3cca01540(0000) GS:ffff888108780000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020010820 CR3: 0000000054b92000 CR4: 00000000000006e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: iomap_fiemap+0x1c9/0x2f0 erofs_fiemap+0x64/0x90 [erofs] do_vfs_ioctl+0x40d/0x12e0 __x64_sys_ioctl+0xaa/0x1c0 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x44/0xae ---[ end trace 0000000000000000 ]--- watchdog: BUG: soft lockup - CPU#7 stuck for 26s! [iomap:905] Reported-by: Hulk Robot Signed-off-by: Guo Xuenan Reviewed-by: Christoph Hellwig [djwong: fix some typos] Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Sasha Levin --- fs/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ioctl.c b/fs/ioctl.c index 1ed097e94af2..85f7e4ee6924 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -173,7 +173,7 @@ int fiemap_prep(struct inode *inode, struct fiemap_extent_info *fieinfo, if (*len == 0) return -EINVAL; - if (start > maxbytes) + if (start >= maxbytes) return -EFBIG; /* -- 2.35.1