Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp196018lqb; Thu, 23 May 2024 15:23:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXsVcC0N4B9/6AoRP6R7XcpIzNLkwDzjgjPUPumIfS7ImV6zRSIc9Tf9mT9+8TY1tEGg1nWI5XA5IX7jhNG7L56bvwzSykQO4LTkKlGtg== X-Google-Smtp-Source: AGHT+IHDGXk6j/KUJyYob+TCSq1ya8VuWeSRCQ3NrCYmfzSq2G+0Wv22oknTUKpRBYZX9RJh2bq8 X-Received: by 2002:a05:622a:486:b0:43d:e60a:f20a with SMTP id d75a77b69052e-43fb0e8f029mr4785271cf.35.1716503021039; Thu, 23 May 2024 15:23:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716503021; cv=pass; d=google.com; s=arc-20160816; b=QJZX6fXTW9CezsCfeB5YWrs9s5PgQPivhB7G5nSBQUKXWQkiqsbHbr2yKXMyOsiIm6 lE49jZeBd0YC2IslFTef/EGtnWje69WItWO2vAXZdIeM1EkNTlhOuUs1JAPGaofhXikE 47C3d9W3fImJsMhIqDgMD7v0RyicvXlKGhPxCEzm9J8k7uVrtIEAUDsCAIx0ZrBvIRlj 44CN0tw4bKz/ayPr3AS97FZhsc87oYbpK/RE1rn4QszqcxVFhu9a7ekGr1QCjWT0xIKU slh0I9skPlxvD0acTwFXOYunq0cLgD6deudHJfEmjEpD5XIMX2vi/0DVxtDd0IDit5VS RkTg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7hlo/0USYgm45RKgbQV7mEAT0VdxfPiKQOpjReznKyw=; fh=wh3i58MPtA6ne8E/6v2EhOIfQLCAyaJcMjyvG69M/1Q=; b=wmmn1k/rwhpHCUEATC0aWc5sbVhVm3Mz+m5PrvJ4LB28Z2Z4s7ngMzrPd7VrxlAIDa QQyiRmgoCjev4HcH34HsZpQoqvrDoSCHu9u31cWZq8jLAV9xtLO0ATiC2kK/99+uhuCP JlMuMRWuNY/0ntLWxs8CBZkIJO3vWXguxWwj5VhVWInNYaroIyJEjiV8m/6YoAIg+RwE 1pXZv/qfVjqp5hZFYTwJsgW2IWigIw5ObLtj1pV+3WD5Q9Yin9Ovq4akTPyvpg0WZr7m Lqalt+SSHLwg5U0gCJF1moPCl/HydZ8f2PTVMW0N1r3jja0tDC3HOfcn8/5PROS7R8U8 xCXg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aPZhhoXs; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-188071-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188071-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43fb18a8094si3054161cf.243.2024.05.23.15.23.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 15:23:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-188071-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aPZhhoXs; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-188071-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188071-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A91611C24646 for ; Thu, 23 May 2024 22:23:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 723D112880D; Thu, 23 May 2024 22:23:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="aPZhhoXs" Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3363512838A for ; Thu, 23 May 2024 22:23:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716502987; cv=none; b=WoOzfdwk+OdWWRSEE2Y7YNPxTtPsrDb99nMDaZh1mBSlt6hh1jpzPzeD9yPJB6dzwEEGcMAeKQHtZaMKmKV9H7YKG4uibdArdN+rjEys2KD/600SL0EMpczkjBETSyOdqYW5NnOZP69xU/tHPNzJL6307CJuaaiqXbzbAgvN2VI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716502987; c=relaxed/simple; bh=Yw893T+VjD34w4x4yV0pVt0ig1FaascDQOJmlsUUHNg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UAT2hIMVL7R9Jf1LvyhMkpbhYg98+WAKDj9cgcAVkH+/3eTo4L5yvON3vSpOMh9mVkhIti+KMUj1m4j79l9y4eq8dB2B0+aDd43tfx0qmBswIaTmx6exKlOUf8YG4+FrJU1WiMV7wTKYYyU5QoqvYoCF8MoMbDb5+n6eMesJIY4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=aPZhhoXs; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1f44b45d6abso1708635ad.0 for ; Thu, 23 May 2024 15:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1716502985; x=1717107785; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7hlo/0USYgm45RKgbQV7mEAT0VdxfPiKQOpjReznKyw=; b=aPZhhoXsm0SxwtGla0KDtTur4S6A2NK90ijrFgZkvz3iafftzIyCxlUt+A9k/z/oSs NaDMSx+MJVE4zs7x5KAt5bj1BQE1Hz2WoPiCMa05Tw0/4k69LXeMwIsUUd/QkSG6i6s2 jcoRHWjnZWAectaHvKKggBFQmfIwNpDgpGy1g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716502985; x=1717107785; h=content-transfer-encoding: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=7hlo/0USYgm45RKgbQV7mEAT0VdxfPiKQOpjReznKyw=; b=eMphTcf+T12JR6FtvCRZf/gsdAwKK1jQWWk5nzb73oMldkDW4JY/6P6vHHAw+J0lVi dIKN7T5mna7TAsHYnx5DRTSYkwxe6jQwx6fPYESQc4WfEy5pK/LdzcFAABkdC5G4Kv2n /2fjafJV8l3UaMYvWtzEwZMLmhgkaEa2QQkYP41KgZ8yx0ok6FUSEPYvd0H7a20dZKSv CxV4urCKprn8PxSgEbOy0/v/l22BhU5BT+3VZPtYm+SUeAZz+B/pcX04IMr4YSkHF7h5 iCzPGh4t2t8MhZgbCwkQoe+qCHmHt+GTlqs7lewlzyfOXoMYhq0dcTa22uOiRxx8pVZI FF+A== X-Forwarded-Encrypted: i=1; AJvYcCV6YChNS7nJoLerLcex+9hsz80wgtH20rIZ+kqrQDmmaBhhA8nFwIrwymUAM+rA/uZpaovXESEGdKrPfRoGq8v9XHP2zcxdiYLQbI3F X-Gm-Message-State: AOJu0YyUuWV26XV7LcXW8UY0M9d6S4/iiTSSrwHYrgj9PKof6NSjIg9q vcaYHnDCXGp3N3D0pLHD3ocmHWQxPFN2n5ZQDv3WyLTWGTiQ+nFAfLnXIoY0lA== X-Received: by 2002:a17:902:ea11:b0:1f3:4d44:7000 with SMTP id d9443c01a7336-1f448a36c0amr6257655ad.41.1716502985499; Thu, 23 May 2024 15:23:05 -0700 (PDT) Received: from khazhy-linux.svl.corp.google.com ([2620:15c:2a3:200:6f10:db2c:e2ea:44ad]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f44c7c59ebsm819125ad.105.2024.05.23.15.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 15:23:05 -0700 (PDT) From: Khazhismel Kumykov X-Google-Original-From: Khazhismel Kumykov To: Lee Duncan , Chris Leech , Mike Christie Cc: "James E.J. Bottomley" , "Martin K. Petersen" , open-iscsi@googlegroups.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Khazhismel Kumykov Subject: [PATCH v2 2/2] libiscsi: disallow binding an already-bound connection Date: Thu, 23 May 2024 15:21:28 -0700 Message-ID: <20240523222128.786137-2-khazhy@google.com> X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog In-Reply-To: <20240523222128.786137-1-khazhy@google.com> References: <20240523222128.786137-1-khazhy@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This fixes issue where misbehaving userspace initiator could bind the same connection multiple times, which would leak the old connection socket without cleaning it up. For iscsi_tcp, it calls iscsi_suspend_tx directly in stop_conn. Update this to iscsi_conn_unbind, which matches the lifecycle of other drivers, and clears the CONN_FLAG_BOUND. Suggested-by: Mike Christie Signed-off-by: Khazhismel Kumykov --- drivers/scsi/iscsi_tcp.c | 2 +- drivers/scsi/libiscsi.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index deb9252e02e6..1d93404515ae 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -696,7 +696,7 @@ static void iscsi_sw_tcp_conn_stop(struct iscsi_cls_conn *cls_conn, int flag) wake_up_interruptible(sk_sleep(sock->sk)); /* stop xmit side */ - iscsi_suspend_tx(conn); + iscsi_conn_unbind(cls_conn, true); /* stop recv side and release socket */ iscsi_sw_tcp_release_conn(conn); diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 0fda8905eabd..0fb98eb53584 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -3453,6 +3453,12 @@ int iscsi_conn_bind(struct iscsi_cls_session *cls_session, struct iscsi_conn *conn = cls_conn->dd_data; spin_lock_bh(&session->frwd_lock); + if (test_bit(ISCSI_CONN_FLAG_BOUND, &conn->flags)) { + spin_unlock_bh(&session->frwd_lock); + return -EBUSY; + } + + if (is_leading) session->leadconn = conn; -- 2.45.1.288.g0e0cd299f1-goog