Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28711816rwd; Wed, 5 Jul 2023 01:17:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlF62sgngHrwXiFLjs6coUftpU4ryG8SFWft6ygpoVlJtikQ6GIdOATeBAJoTZLOb4Zc+sw5 X-Received: by 2002:a17:90a:db87:b0:262:df58:2411 with SMTP id h7-20020a17090adb8700b00262df582411mr8430486pjv.18.1688545074206; Wed, 05 Jul 2023 01:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688545074; cv=none; d=google.com; s=arc-20160816; b=JJGcKpjPIIugvImyf4epbnremmNQ7/DYGFqXQBSZKsyW5ILjNJ9iKKEvFQA+s/asrb 25xEg+6ny+gI03u9j3V5kMJNGzksTflcRrvcczx+K8D0YE+mqhUsou7VBIn8XLsKJj9s FwoV4LWa3+uC3Ek6W1qZWUs9NLK/Pk2zwgBhru7QQW8ryfPj7Nnbi9tUEnPT2iTh7U3/ 2NccLk5YI0pv0JQ9Kcq3MYjF/KiG3M61Wcc0DonPRrIQ2zj1RvZgmWnrLvGAzQSdBsQY LtU2twOQSSDW0M8XUOCq1xXoB6ORz2M9JjGVe/WYWYHMmCtx4iy94JaXeIiHW3GLogrt 7szQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9cFmzkEJG2Hg/Ep9hyklTre7VRuPTjMtDisrUnKsLIQ=; fh=0Zq1Af7A2tTXgtBd/P2hI/B5JQtXhEhBQ0mL8osAbrI=; b=rHM8PZFS8ZFFPCGOd2sLMbQn/Wt9sSNdg/3VqgBh910gaTexbgHA1gg3Gmtl1bKqi3 It2Oi06Qi8SYpGLxvlSlFlz/QxbzQ4pt9K/uWRbjNxVipbqO4ELsc7QHWYOsgvpP6ZLx XdI7stkDo/8oA2ezQPZ+p10RBUQVPl8s3Qz+DTjnELW/FtqaMUmYkB+4KDQFSCfpTLKD 7WKn3FO3OUvhX1sSHV0gWGZxg5zdIrbZILHC5KxOT1dRGXrnnSHFgD1BR3JlAxhaSfkt mXSKf8EFwpt9K4pNDd6ApcsN/arwOiAR15rbUBHmPNlJbb8hhIZOIGv0mdaJJZcZN0kq 7jfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U4HXUcmV; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f12-20020a17090ac28c00b0026301cd4644si1107876pjt.183.2023.07.05.01.17.41; Wed, 05 Jul 2023 01:17:54 -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=@kernel.org header.s=k20201202 header.b=U4HXUcmV; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231488AbjGEHyL (ORCPT + 99 others); Wed, 5 Jul 2023 03:54:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229700AbjGEHyJ (ORCPT ); Wed, 5 Jul 2023 03:54:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF766E2; Wed, 5 Jul 2023 00:54:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6D60961408; Wed, 5 Jul 2023 07:54:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FF3EC433C8; Wed, 5 Jul 2023 07:54:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688543647; bh=YWfxi/xZnE3bJaiOHq81mY4QNBuZCJ6nAJGjGfLnkhs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=U4HXUcmVzNBi7NvgetIMhOEL+Cvbn6Dz90QrbEWiojEgZM1rVHFxLuNmcw3eTzHm2 4P1VTVqZ/z37S/RHNVfolcI7c8GcHuFMmWJXmDX/6jD/Bd8McbppLMggZ3ixd4PsTp X1vuO5BN1O4Wy5QG6JPSDihiewPtEGHUZzxiL+8UIMgyQ4azrMY2LEvW0XMdsyfWQD vrn+5/WOO99AGX7Va3qYIJEAuQuR2dFxrzUwgzTyK4rRbAxazY5k4IBOfV7fNvy2bx hNvW3BSoJ/4JSkASK6kmGfVQ5QSsnbHru1MfpYoy0Do/MgIAI+bPHWDyLLMjazzqoI xGhiLo2Ja9utw== Date: Wed, 5 Jul 2023 10:54:03 +0300 From: Leon Romanovsky To: lihongweizz Cc: sagi@grimberg.me, mgurtovoy@nvidia.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] IB/iser: Protect tasks cleanup in case iser connection was stopped Message-ID: <20230705075403.GI6455@unreal> References: <20230704005144.1172-1-lihongweizz@inspur.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230704005144.1172-1-lihongweizz@inspur.com> X-Spam-Status: No, score=-7.1 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,T_SCC_BODY_TEXT_LINE 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 On Tue, Jul 04, 2023 at 08:51:44AM +0800, lihongweizz wrote: > From: Rock Li > > We met a crash issue as below: > ... > #7 [ff61b991f6f63d10] page_fault at ffffffffab80111e > [exception RIP: iscsi_iser_cleanup_task+13] > RIP: ffffffffc046c04d RSP: ff61b991f6f63dc0 RFLAGS: 00010246 > RAX: 0000000000000000 RBX: ff4bd0aalf7a5610 RCX: ff61b991f6f63dc8 > RDX: ff61b991f6f63d68 RSI: ff61b991f6f63d58 RDI: ff4bd0aalf6cdc00 > RBP: 0000000000000005 R8: 0000000000000073 R9: 0000000000000005 > R10: 0000000000000000 R11: 00000ccde3e0f5c0 R12: ff4bd08c0e0631f8 > R13: ff4bd0a95ffd3c78 R14: ff4bd0a95ffd3c78 R15: ff4bd0aalf6cdc00 > ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018 > #8 [ff616991f6f63dc0] __iscsi_put_task at ffffffffc0bd3652 [libiscsi] > #9 [ff61b991f6f63e00] iscsi_put_task at ffffffffc0bd36e9 [libiscsi] > ... > > After analysing the vmcore, we find that the iser connection was already > stopped before abort handler running. The iser_conn is already unbindded > and released. So we add iser connection validation check inside cleanup > task to fix this corner case. > > Signed-off-by: Rock Li > --- > drivers/infiniband/ulp/iser/iscsi_iser.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c > index bb9aaff92ca3..35dfbf41fc40 100644 > --- a/drivers/infiniband/ulp/iser/iscsi_iser.c > +++ b/drivers/infiniband/ulp/iser/iscsi_iser.c > @@ -366,7 +366,12 @@ static void iscsi_iser_cleanup_task(struct iscsi_task *task) > struct iscsi_iser_task *iser_task = task->dd_data; > struct iser_tx_desc *tx_desc = &iser_task->desc; > struct iser_conn *iser_conn = task->conn->dd_data; > - struct iser_device *device = iser_conn->ib_conn.device; > + struct iser_device *device; > + > + /* stop connection might happens before iser cleanup work */ > + if (!iser_conn) > + return; And what prevents from iser_conn being not valid here? For example, in the flow: 1. Start iscsi_iser_cleanup_task 2. Get valid task->conn->dd_data 3. Pass this if (..) check 4. Context switch and release connection 5. iser_conn now points to released memory. Thanks > + device = iser_conn->ib_conn.device; > > /* DEVICE_REMOVAL event might have already released the device */ > if (!device) > -- > 2.27.0 >