Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28889495rwd; Wed, 5 Jul 2023 04:23:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlHk7SIX241zEDYnRE1pxtkCNho5taV3Iuf2l7cWpfrGjFnL27IQSFPo2OZ8oEO4aT9JW0+z X-Received: by 2002:a17:90a:51a1:b0:263:6d18:a2d4 with SMTP id u30-20020a17090a51a100b002636d18a2d4mr11036022pjh.41.1688556183696; Wed, 05 Jul 2023 04:23:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688556183; cv=none; d=google.com; s=arc-20160816; b=B2hVifBYX0vcfw4nHJaI9HQSKnhSN+YVHnk//ecVME1ag8egMtRSEruYp5cz5aedGI 2A3veqs45o/V3nh9ti8fVsctZQPqPupGPgYchP8kCWK4Ch2bb9ysSwmfg39NJDOp/NQw 946ipGq4KwsUOv3T5SQXUg4VkqcjJGgDu0vlxFSBhem8xI7KwTHcCGA3KpbfroYXJUz9 aXxrwBYLe10wpi2eaB8LNEsGTY2APJ8Fj53Tgs9b0i01yEAVHK+CPLIRQ/vT+lJeEb2L Zbu2ra4aU9YtPYqt7DMerG0ewXrIxExNEM5blhUECrwsaeJW3AgdHK0wKIBWIvOdHndD UuAQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=0sv39E7nfdwapshv40sFh2SHTzZz3df2EWwfVLd65zI=; fh=rzZhFHjAHo+PVbuFgujNfPBK80koABfj1qcj4LTMTxM=; b=nRTmD6E+8IwMVJzXMyrCyJCKklhAFEULZB/pI5xciKfKGX7TjeiNBeIOYbeGZuCTws dBxGeHFrL8EJ/sp6zBsKPNmNLXPvFXJCZOphEC5DosvUJhk8ifd6NI6Oc5k6GkAV8bCN 7mtwfozxXLr8YOph7NHsXXA95kK1XN/UpzgH5gNWBBZvNgLYCpakeKtgJh8ZaS3l4i56 rirZKJ30MYSRbt+hkmitLSYQgNNPJyBn3CiphhC3YcpeO2BiQMF/TLwoUgdqEe+WoymF OWdS3wJRDrlW/SNFGbVv4X9pBtEswTxFZl1zBvh7Ok2cKpJRVHQv+9y9T9MQSDD092Hn fsig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jwDCNLft; 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 t1-20020a17090a3e4100b00263dee6d04dsi1442462pjm.126.2023.07.05.04.22.47; Wed, 05 Jul 2023 04:23:03 -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=jwDCNLft; 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 S231970AbjGEKg4 (ORCPT + 99 others); Wed, 5 Jul 2023 06:36:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230285AbjGEKgz (ORCPT ); Wed, 5 Jul 2023 06:36:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A07D0DD; Wed, 5 Jul 2023 03:36:50 -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) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1898A614EA; Wed, 5 Jul 2023 10:36:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E759CC433C9; Wed, 5 Jul 2023 10:36:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688553409; bh=F4rFG36YSdtp+ECeALfuw2X8+DlTe4GxNPIo0OWn5BE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jwDCNLftMGMRa9noO9SpEbclCC5GgTVOy79ADkxYvO3d34pNhkkfK+xU/CSxkgWou pEZAc2XFXFbGpKtgaSTm8jBN3YdEM/ZOTSVqFiF78JbtVHG15ua+VDNVs13uDiMkrg +GVGHgLEVgaq/oJ/udOnEfcIVAU1V9LO1R2C4pxPllfHj6ICdZZiwZBRzIs8KE8PxL dhOWDnP7Ij9AZqD8fuGRY4gX2RmvRgzEbqaJokpMeYzbo5IFEfpXveYRCxJJ0QA76L kwc6e7aIzzMLa0lrc4mMhCwbBiKsfcKJ7igRTobPYDrlVi6w5LMbBVCMpCKVcsW10u 1bj0AFDLHzeGA== Date: Wed, 5 Jul 2023 13:36:44 +0300 From: Leon Romanovsky To: Rock =?utf-8?B?TGko5p2O5a6P5LyfKQ==?= 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: <20230705103644.GL6455@unreal> References: <45c68d6835964dcbae8fbd983696064b@inspur.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <45c68d6835964dcbae8fbd983696064b@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 Wed, Jul 05, 2023 at 09:22:08AM +0000, Rock Li(李宏伟) wrote: > > > 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 > > Hi Leon, > Thanks for your reply:) In case iscsi_stop_conn was executed cocurrently or > after iscsi_iser_cleanup_task, above issue would happen. > I've confirmed the values in iscsi_cls_conn and iscsi_conn instances from > vmcore: > > iscsi_stop_conn > ... > WRITE_ONCE(conn->state, ISCSI_CONN_FAILED); --- confirmed > ... > conn->transport->stop_conn => iscsi_iser_conn_stop > iscsi_conn_stop > ... > conn->c_stage = ISCSI_CONN_STOPPED; --- confirmed > conn->dd_data = NULL; --- confirmed > > The crash scene tells us that iscsi_stop_conn was executed before > iscsi_iser_cleanup_task start, the iser_conn instance was already released. It is by chance, it will be better to provide a fix which is race free. Thanks > > > > > > + device = iser_conn->ib_conn.device; > > > > > > /* DEVICE_REMOVAL event might have already released the device */ > > > if (!device) > > > -- > > > 2.27.0 > > >