Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp84208iof; Sun, 5 Jun 2022 21:53:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyw7opRzaqbOVb0xNwSsNrJyxW577C8AE/K5mj72wOwgVBhMZQOG7tzTQ35k+mNU+8xzy8M X-Received: by 2002:a17:902:8c93:b0:167:879d:6670 with SMTP id t19-20020a1709028c9300b00167879d6670mr833670plo.31.1654491180122; Sun, 05 Jun 2022 21:53:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654491180; cv=none; d=google.com; s=arc-20160816; b=ZWpL7Bu2cuhUMK/z5rlHVl3PoDv9ZvMt48JxOE42dcIA6h7XDfDrvrEesVM0cN32F0 WHWEA8kpQlztsw8mXm1DDMRDW7hQutyRHaChKfQ/J2KbZm+LXys8mL+XayqYJ+F5GitD di35kuSP0OOj1BoE9WbuK7NJcOv88bVpt/S+Hkk5ZwgiaEdgBv9DOWcZgIc7f4nd8117 lcAUpvuAHoEo0onEVDXThRt2lBMwaUle/6LQPn7lFWZt8kpLkuZq0rXs1jkMtEy+oXKB EXS/XF3GBvB0ozrotPlICwP24fVv8E5rwgQsXMK7BT5LtRSr8GVZ/k4JvoziU2mlKz0N jG+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=XL0red14pGxL6sCfZN8Z7IQ85QnVVwGdCx/2kOkLR0c=; b=zvF5gVGLUsqd62ruWSncV3hcaOXgFyn12Tw8olItXJ92PKe0QzNhVamu3AfTrI5Bs5 bAyzGrynTWbcSUR+Z4bjSkQ/J4I9ZgfB2EJdh8A+knUWEuC96UA6HGgG8J0tFHCnJYEF wQ3v0fkpNLq7/Rb/6eBVoqZ0NyuSHm5mSRuMx7Bg0T6JZtv2ODUj5mnxucMkehf398Hk ZRXjgTY5Kqt+tyFnFIPcCXW4424OSyY10oaLrxfNQp1/+AosT1ckXS5nXln+/TzrGBNJ eJopACFt1XhDezbzBLqjNZtRLRZOx+ypl7f+D8RY6fRRRYAfFyfcBb1p0wL9rj0dpKHI jR+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=OjrbsAM0; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f12-20020a63510c000000b003c67a4e3e22si18672573pgb.138.2022.06.05.21.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 21:53:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=OjrbsAM0; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3BDECB0D2F; Sun, 5 Jun 2022 21:07:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232350AbiFDD2s (ORCPT + 99 others); Fri, 3 Jun 2022 23:28:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232340AbiFDD2q (ORCPT ); Fri, 3 Jun 2022 23:28:46 -0400 Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1F32F245B2; Fri, 3 Jun 2022 20:28:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=XL0red14pGxL6sCfZN 8Z7IQ85QnVVwGdCx/2kOkLR0c=; b=OjrbsAM0XFEX76OcRz20q+j1/OZguFEYV1 gt78V4wV7FAX9uUi4FJXX3SCNSQ1WvnykSdFFq6gDIN7VAC/+MgLv+plu2uWYFlj tfccXu5D4/PxMuH/OKlr7nn1vfiEUBRRNrFun/9RdJhgdE6qwFyJMFt02FjUefHg Vs73GtrQ8= Received: from localhost.localdomain (unknown [202.112.113.212]) by smtp9 (Coremail) with SMTP id DcCowACXv+NL0ZpiGY58Gw--.4359S4; Sat, 04 Jun 2022 11:28:16 +0800 (CST) From: Xiaohui Zhang To: Xiaohui Zhang , Trond Myklebust , Anna Schumaker , "David S . Miller" , linux-nfs@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: hifoolno <553441439@qq.com> Subject: [PATCH 2/2] SUNRPC: Fix infinite looping in rpc_clnt_iterate_for_each_xprt Date: Sat, 4 Jun 2022 11:28:10 +0800 Message-Id: <20220604032810.12602-1-ruc_zhangxiaohui@163.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: DcCowACXv+NL0ZpiGY58Gw--.4359S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kr43ZFyDKFWxCFWkArWDJwb_yoW8Gry7p3 4UGryruF1kKF47tw1Iyr4kua1I9w4fGF1UGFWkC3s8Ar1DJFykJw1Ikr4jvrZ2kFs5Gr1a gry2kw45Aa4kAa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0p_eHqrUUUUU= X-Originating-IP: [202.112.113.212] X-CM-SenderInfo: puxfs6pkdqw5xldrx3rl6rljoofrz/1tbiTREWMFc7YPoNcAAAsx X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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-nfs@vger.kernel.org From: hifoolno <553441439@qq.com> If there were less than 2 entries in the multipath list, then xprt_iter_current_entry() would never advance beyond the first entry, which is correct for round robin behaviour, but not for the list iteration. The end result would be infinite looping in rpc_clnt_iterate_for_each_xprt() as we would never see the xprt == NULL condition fulfilled. Signed-off-by: hifoolno <553441439@qq.com> --- net/sunrpc/xprtmultipath.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/sunrpc/xprtmultipath.c b/net/sunrpc/xprtmultipath.c index 1693f81aae37..23c3aae1bb5b 100644 --- a/net/sunrpc/xprtmultipath.c +++ b/net/sunrpc/xprtmultipath.c @@ -278,14 +278,12 @@ static struct rpc_xprt *xprt_iter_current_entry(struct rpc_xprt_iter *xpi) { struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch); - struct list_head *head; if (xps == NULL) return NULL; - head = &xps->xps_xprt_list; - if (xpi->xpi_cursor == NULL || xps->xps_nxprts < 2) - return xprt_switch_find_first_entry(head); - return xprt_switch_find_current_entry(head, xpi->xpi_cursor); + return xprt_switch_set_next_cursor(&xps->xps_xprt_list, + &xpi->xpi_cursor, + find_next); } bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps, -- 2.17.1