stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Ursula Braun <ubraun@linux.ibm.com>,
	"David S. Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.19 78/88] net/smc: postpone release of clcsock
Date: Wed, 15 Nov 2023 15:36:30 -0500	[thread overview]
Message-ID: <20231115191430.769764496@linuxfoundation.org> (raw)
In-Reply-To: <20231115191426.221330369@linuxfoundation.org>

4.19-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ursula Braun <ubraun@linux.ibm.com>

[ Upstream commit b03faa1fafc8018295401dc558bdc76362d860a4 ]

According to RFC7609 (http://www.rfc-editor.org/info/rfc7609)
first the SMC-R connection is shut down and then the normal TCP
connection FIN processing drives cleanup of the internal TCP connection.
The unconditional release of the clcsock during active socket closing
has to be postponed if the peer has not yet signalled socket closing.

Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Stable-dep-of: 5211c9729484 ("net/smc: fix dangling sock under state SMC_APPFINCLOSEWAIT")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/smc/af_smc.c    | 33 +++++++++++++++++----------------
 net/smc/smc_close.c |  7 ++++++-
 2 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index dcd00b514c3f9..6f342f6cc4876 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -143,32 +143,33 @@ static int smc_release(struct socket *sock)
 		rc = smc_close_active(smc);
 		sock_set_flag(sk, SOCK_DEAD);
 		sk->sk_shutdown |= SHUTDOWN_MASK;
-	}
-
-	sk->sk_prot->unhash(sk);
-
-	if (smc->clcsock) {
-		if (smc->use_fallback && sk->sk_state == SMC_LISTEN) {
+	} else {
+		if (sk->sk_state != SMC_LISTEN && sk->sk_state != SMC_INIT)
+			sock_put(sk); /* passive closing */
+		if (sk->sk_state == SMC_LISTEN) {
 			/* wake up clcsock accept */
 			rc = kernel_sock_shutdown(smc->clcsock, SHUT_RDWR);
 		}
-		mutex_lock(&smc->clcsock_release_lock);
-		sock_release(smc->clcsock);
-		smc->clcsock = NULL;
-		mutex_unlock(&smc->clcsock_release_lock);
-	}
-	if (smc->use_fallback) {
-		if (sk->sk_state != SMC_LISTEN && sk->sk_state != SMC_INIT)
-			sock_put(sk); /* passive closing */
 		sk->sk_state = SMC_CLOSED;
 		sk->sk_state_change(sk);
 	}
 
+	sk->sk_prot->unhash(sk);
+
+	if (sk->sk_state == SMC_CLOSED) {
+		if (smc->clcsock) {
+			mutex_lock(&smc->clcsock_release_lock);
+			sock_release(smc->clcsock);
+			smc->clcsock = NULL;
+			mutex_unlock(&smc->clcsock_release_lock);
+		}
+		if (!smc->use_fallback)
+			smc_conn_free(&smc->conn);
+	}
+
 	/* detach socket */
 	sock_orphan(sk);
 	sock->sk = NULL;
-	if (!smc->use_fallback && sk->sk_state == SMC_CLOSED)
-		smc_conn_free(&smc->conn);
 	release_sock(sk);
 
 	sock_put(sk); /* final sock_put */
diff --git a/net/smc/smc_close.c b/net/smc/smc_close.c
index 092696d738c00..3e7858793d485 100644
--- a/net/smc/smc_close.c
+++ b/net/smc/smc_close.c
@@ -415,8 +415,13 @@ static void smc_close_passive_work(struct work_struct *work)
 	if (old_state != sk->sk_state) {
 		sk->sk_state_change(sk);
 		if ((sk->sk_state == SMC_CLOSED) &&
-		    (sock_flag(sk, SOCK_DEAD) || !sk->sk_socket))
+		    (sock_flag(sk, SOCK_DEAD) || !sk->sk_socket)) {
 			smc_conn_free(conn);
+			if (smc->clcsock) {
+				sock_release(smc->clcsock);
+				smc->clcsock = NULL;
+			}
+		}
 	}
 	release_sock(sk);
 	sock_put(sk); /* sock_hold done by schedulers of close_work */
-- 
2.42.0




  parent reply	other threads:[~2023-11-15 20:46 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-15 20:35 [PATCH 4.19 00/88] 4.19.299-rc1 review Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 01/88] vfs: fix readahead(2) on block devices Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 02/88] genirq/matrix: Exclude managed interrupts in irq_matrix_allocated() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 03/88] i40e: fix potential memory leaks in i40e_remove() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 04/88] tcp_metrics: add missing barriers on delete Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 05/88] tcp_metrics: properly set tp->snd_ssthresh in tcp_init_metrics() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 06/88] tcp_metrics: do not create an entry from tcp_init_metrics() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 07/88] wifi: rtlwifi: fix EDCA limit set by BT coexistence Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 08/88] can: dev: move driver related infrastructure into separate subdir Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 09/88] can: dev: can_restart(): dont crash kernel if carrier is OK Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 10/88] can: dev: can_restart(): fix race condition between controller restart and netif_carrier_on() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 11/88] thermal: core: prevent potential string overflow Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 12/88] chtls: fix tp->rcv_tstamp initialization Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 13/88] ACPI: sysfs: Fix create_pnp_modalias() and create_of_modalias() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 14/88] ipv6: avoid atomic fragment on GSO packets Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 15/88] macsec: Fix traffic counters/statistics Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 16/88] macsec: use DEV_STATS_INC() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 17/88] net: add DEV_STATS_READ() helper Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 18/88] ipvlan: properly track tx_errors Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 19/88] regmap: debugfs: Fix a erroneous check after snprintf() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 20/88] clk: qcom: clk-rcg2: Fix clock rate overflow for high parent frequencies Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 21/88] clk: keystone: pll: fix a couple NULL vs IS_ERR() checks Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 22/88] clk: npcm7xx: Fix incorrect kfree Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 23/88] clk: mediatek: clk-mt6797: Add check for mtk_alloc_clk_data Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 24/88] clk: mediatek: clk-mt2701: " Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 25/88] platform/x86: wmi: Fix probe failure when failing to register WMI devices Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 26/88] platform/x86: wmi: remove unnecessary initializations Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 27/88] platform/x86: wmi: Fix opening of char device Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 28/88] hwmon: (coretemp) Fix potentially truncated sysfs attribute name Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 29/88] drm/rockchip: vop: Fix reset of state in duplicate state crtc funcs Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 30/88] drm/radeon: possible buffer overflow Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 31/88] drm/rockchip: cdn-dp: Fix some error handling paths in cdn_dp_probe() Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 32/88] ARM: dts: qcom: mdm9615: populate vsdcc fixed regulator Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 33/88] firmware: ti_sci: Mark driver as non removable Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 34/88] clk: scmi: Free scmi_clk allocated when the clocks with invalid info are skipped Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 35/88] hwrng: geode - fix accessing registers Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 36/88] sched/rt: Provide migrate_disable/enable() inlines Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 37/88] nd_btt: Make BTT lanes preemptible Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 38/88] HID: cp2112: Use irqchip template Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 39/88] hid: cp2112: Fix duplicate workqueue initialization Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 40/88] ARM: 9321/1: memset: cast the constant byte to unsigned char Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 41/88] ext4: move ix sanity check to corrent position Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 42/88] RDMA/hfi1: Workaround truncation compilation error Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 43/88] sh: bios: Revive earlyprintk support Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 44/88] ASoC: Intel: Skylake: Fix mem leak when parsing UUIDs fails Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 45/88] ASoC: ams-delta.c: use component after check Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 46/88] mfd: dln2: Fix double put in dln2_probe Greg Kroah-Hartman
2023-11-15 20:35 ` [PATCH 4.19 47/88] leds: pwm: simplify if condition Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 48/88] leds: pwm: convert to atomic PWM API Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 49/88] leds: pwm: Dont disable the PWM when the LED should be off Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 50/88] ledtrig-cpu: Limit to 8 CPUs Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 51/88] leds: trigger: ledtrig-cpu:: Fix output may be truncated issue for cpu Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 52/88] tty: tty_jobctrl: fix pid memleak in disassociate_ctty() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 53/88] usb: dwc2: fix possible NULL pointer dereference caused by driver concurrency Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 54/88] dmaengine: ti: edma: handle irq_of_parse_and_map() errors Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 55/88] misc: st_core: Do not call kfree_skb() under spin_lock_irqsave() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 56/88] tools: iio: privatize globals and functions in iio_generic_buffer.c file Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 57/88] tools: iio: iio_generic_buffer: Fix some integer type and calculation Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 58/88] tools: iio: iio_generic_buffer ensure alignment Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 59/88] USB: usbip: fix stub_dev hub disconnect Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 60/88] dmaengine: pxa_dma: Remove an erroneous BUG_ON() in pxad_free_desc() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 61/88] f2fs: fix to initialize map.m_pblk in f2fs_precache_extents() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 62/88] pcmcia: cs: fix possible hung task and memory leak pccardd() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 63/88] pcmcia: ds: fix refcount leak in pcmcia_device_add() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 64/88] pcmcia: ds: fix possible name leak in error path " Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 65/88] media: bttv: fix use after free error due to btv->timeout timer Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 66/88] media: s3c-camif: Avoid inappropriate kfree() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 67/88] media: dvb-usb-v2: af9035: fix missing unlock Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 68/88] pwm: sti: Avoid conditional gotos Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 69/88] pwm: sti: Reduce number of allocations and drop usage of chip_data Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 70/88] pwm: brcmstb: Utilize appropriate clock APIs in suspend/resume Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 71/88] Input: synaptics-rmi4 - fix use after free in rmi_unregister_function() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 72/88] llc: verify mac len before reading mac header Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 73/88] tipc: Change nla_policy for bearer-related names to NLA_NUL_STRING Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 74/88] dccp: Call security_inet_conn_request() after setting IPv4 addresses Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 75/88] dccp/tcp: Call security_inet_conn_request() after setting IPv6 addresses Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 76/88] r8169: improve rtl_set_rx_mode Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 77/88] net: r8169: Disable multicast filter for RTL8168H and RTL8107E Greg Kroah-Hartman
2023-11-15 20:36 ` Greg Kroah-Hartman [this message]
2023-11-15 20:36 ` [PATCH 4.19 79/88] net/smc: wait for pending work before clcsock release_sock Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 80/88] net/smc: fix dangling sock under state SMC_APPFINCLOSEWAIT Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 81/88] tg3: power down device only on SYSTEM_POWER_OFF Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 82/88] r8169: respect userspace disabling IFF_MULTICAST Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 83/88] netfilter: xt_recent: fix (increase) ipv6 literal buffer length Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 84/88] fbdev: imsttfb: Fix error path of imsttfb_probe() Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 85/88] fbdev: imsttfb: fix a resource leak in probe Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 86/88] fbdev: fsl-diu-fb: mark wr_reg_wa() static Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 87/88] Revert "mmc: core: Capture correct oemid-bits for eMMC cards" Greg Kroah-Hartman
2023-11-15 20:36 ` [PATCH 4.19 88/88] btrfs: use u64 for buffer sizes in the tree search ioctls Greg Kroah-Hartman
2023-11-16 11:13 ` [PATCH 4.19 00/88] 4.19.299-rc1 review Naresh Kamboju
2023-11-17  4:24 ` Guenter Roeck
2023-11-17 17:00 ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231115191430.769764496@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=patches@lists.linux.dev \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=ubraun@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).