From patchwork Thu Jun 1 09:42:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravanan Vajravel X-Patchwork-Id: 13263241 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38C4BC77B7E for ; Thu, 1 Jun 2023 09:43:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231690AbjFAJnG (ORCPT ); Thu, 1 Jun 2023 05:43:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232297AbjFAJnE (ORCPT ); Thu, 1 Jun 2023 05:43:04 -0400 Received: from mail-oo1-xc30.google.com (mail-oo1-xc30.google.com [IPv6:2607:f8b0:4864:20::c30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EDB1E62 for ; Thu, 1 Jun 2023 02:42:47 -0700 (PDT) Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-5555765c6d3so518280eaf.1 for ; Thu, 01 Jun 2023 02:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1685612566; x=1688204566; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=mJ5zBVvByf2yO78KESoPlYAeCNrqepIQbuqjnGer02c=; b=Dx6DRjFWcTAXM2OiWu3rS4bBStC/fiFvsxYdz0jhB1u6xQsCTWxrItifs1HhqcSGFo 5oP5GgNyiRM3x2eYwulBjo48/G6fBEtF3ieu/cgS1CAdCtlui88bOHuNrIKKEdoQNa0Y f3uEgSotMw7kmaxY803fErkpewISfDQTUh8zc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685612566; x=1688204566; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mJ5zBVvByf2yO78KESoPlYAeCNrqepIQbuqjnGer02c=; b=Rm3SLGFBkePU5hsGXK5XOynUg2nJ4NCoRAlLgGNwbHGwmaXtztKyKqasIbFPMGdK6b Kj8eHtsl47s/gLAfBbDZWvGBUfYLEZ/waoIdw0PD2U3EfI46zAZwgHamZoe7oFojVFhZ McZ4R6Yxeiax7D6kcrXrsKY9Myi0jwKQb92TueL6m/zxvVqmurezvTGwwkHBQFZBYhBG i0etvPI1KYYiaHtK/naemcivSQscC84GLH85sz7aGeSj3vdXdH6PFmeR9tom4naI53Xt QHd03y43w3Ky/2LOM3hgmma+/ORvHNSgPR7FkdfN5hp8sEp3CFPA2cxha4hNf/38ahnc c/Zg== X-Gm-Message-State: AC+VfDzBp2jjBcqHej9bnoK/KefVxQla9X18PbDaFqlvAJSws6WJ+E/N YHfGlRCR6X8lmt88U0eB1ji+Cw== X-Google-Smtp-Source: ACHHUZ5xeXOjpJsPf3JyNp/fePU3MWxW2mkmgK3q7CzdoNH2fj3Vcga2dcfdiONqhd0GpYGP0EgDFQ== X-Received: by 2002:a05:6358:9218:b0:125:80a4:4733 with SMTP id d24-20020a056358921800b0012580a44733mr6110251rwb.10.1685612566302; Thu, 01 Jun 2023 02:42:46 -0700 (PDT) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id e12-20020a63ee0c000000b00502e7115cbdsm2744960pgi.51.2023.06.01.02.42.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 02:42:46 -0700 (PDT) From: Saravanan Vajravel To: selvin.xavier@broadcom.com, jgg@ziepe.ca, leon@kernel.org, sagi@grimberg.me Cc: linux-rdma@vger.kernel.org, Saravanan Vajravel Subject: [PATCH for-rc 3/3] IB/isert: Fix incorrect release of isert connextion Date: Thu, 1 Jun 2023 02:42:20 -0700 Message-Id: <20230601094220.64810-4-saravanan.vajravel@broadcom.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230601094220.64810-1-saravanan.vajravel@broadcom.com> References: <20230601094220.64810-1-saravanan.vajravel@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org The ib_isert module is releasing the isert connection both in isert_wait_conn() handler as well as isert_free_conn() handler. In isert_wait_conn() handler, it is expected to wait for iSCSI session logout operation to complete. It should free the isert connection only in isert_free_conn() handler. When a bunch of iSER target is cleared, this issue can lead to use-after-free memory issue as isert conn is twice released Signed-off-by: Saravanan Vajravel Signed-off-by: Selvin Xavier Reviewed-by: Sagi Grimberg --- drivers/infiniband/ulp/isert/ib_isert.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index 64af8d966adf..873c8cbaaa5f 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c @@ -2570,8 +2570,6 @@ static void isert_wait_conn(struct iscsit_conn *conn) isert_put_unsol_pending_cmds(conn); isert_wait4cmds(conn); isert_wait4logout(isert_conn); - - queue_work(isert_release_wq, &isert_conn->release_work); } static void isert_free_conn(struct iscsit_conn *conn)