From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795963878; b=WWJuPidxL4six0s4L5Za9QyDogdvpvAibgJp917R176i2JMhNwOGJILcnvx4za/qhIY8 u1W045WihQjf8MLE62/dwmHWJHGbSpZk2h2tU/TMhe2i56SFt5nDDc5GI3hblzT1X+ut1 KBLWkTqWwukR4ITg4w2HIKHhEvlgh3gaZZ1zMncWdsxGaxlkvk26+4JyPRmq2rLwEIdZk xmK+0G400mMLswPcDgNrFd+qGADYE0wEkB3oOJa/vYqXRt0iu0B6RqB4BM3EferRt0MSb G2uqn1ICRi0JYumfTFWow1FJVwGvm3HADFHOoedT2TKG2584loM9Nfmw6kT5my4a8Sw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795963878; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type; bh=jZZ5vQQELcsBhemoDQ52zSZ5Zzc3cGO5DHFbEhHCROM=; b=B7jjMuCSF8t4f11W/0l4VWiu30mMSU7iJzHfz2hCTuRc7uJ+2eDjptCCeZAALtH5rVek FX8g9mG0mVYC8hLCa7btsUo3nd9VADgYzJZYbLA23rsNR1i3KKYj/5232x+XguiGx0h4h 1LhAK8/xiaAZtR66P+GZ6sxkt7uEXjRG8QdVjSfNAFk1FzqRrIqEHOSpuxUSA7Qw/GD2u BzWSpvbmnegfpd17X5EfVt/66JAo1mMdGI4f6ZDlxzAOm+Rn/1bGvtEUDNrd4/43PUJWF 0JxdTA7qDClDahYxQ3PIoqBspjJHvNvAtQykr88dIDPHbz0sNeMnNRbb30LJYKbWV7w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=TvOmqg8Z; arc=none smtp.remote-ip=209.85.219.70 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED4B5606A32D for ; Sun, 29 Nov 2026 14:51:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org ED4B5606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=TvOmqg8Z Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-9213c7a506fso113625836d6.1 for ; Sun, 29 Nov 2026 06:51:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795963876; x=1796568676; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=jZZ5vQQELcsBhemoDQ52zSZ5Zzc3cGO5DHFbEhHCROM=; b=TvOmqg8ZbQM6+KbL1rxzDq9+am8C/ygrEXHzRWh/Thzn1d1CJ5yZC3EIChbJy65XxF P0G1ZXXWM4rO2hf5vACTan6b6Vffc4ZPZp3PUAWADOwTMLQzDVXQarCRsHcIHt+k8Inr osGPnPxvGD+1jJVQqJBe5Jv9Z/RPNHnybC/qDZvXsfO74/MrJeKdM0pOoo4vx8fmzadY qxqy8+8AwHVzFMfyctTNSY6ceoh3+oEYGUHZ01HRhKbfzoYGqKmuTHHXDhObw+r+wWZA 8K8oVssPy0MXWfs/spEIISXcqHmwz4SwvOkair2qHOrEF0ZA2LdRPoNUwoTHt44VKKbp /HJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795963876; x=1796568676; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=jZZ5vQQELcsBhemoDQ52zSZ5Zzc3cGO5DHFbEhHCROM=; b=Sn3JE2T3cEPUeKS7hJ/S9keyQBD45LgwRIChlUMEZkvsiI9JZ5D2g99zLUF9ApT3U0 VT+UY5r8CfXv5R8K+UwnnviP5zMq7tBys/UO28atNe5Ycgkdcjavn2MHxCWprwBf1Fgb A9mZEaSyhQAiPNmCeAKYdyyb5ghPRa+BxHMavwE+ojBq2wKvxE9j8sQifZr3JywzQKDf 2jQm2cqlJffTrylxhfQJuC884ubQIbeJ+L1rEDAgHXaViOR7GUO1j5sQOb0LZMikvCnC L5sppnvv2Kl2rX4bblG/ctciEwz+VgjcmcACXZBCSioy+RZUJx9/i6ptRHEjJQXbNy9j ofLA== X-Forwarded-Encrypted: i=1; AL+hErGs6wc4o2L/RbbxRA/6uaDIfE7IgjemQPjietbvq4iNSDicvY5a7675RFLQSfdiA8jefMojDNo=@vger.kernel.org X-Gm-Message-State: APuU4Z+HC+uVzedm0pePQX96gyzwof/S5G+zJgCYZUqnWYrzR6L2C3Zs Ey4rrvy+6N2YU7Hnv/eHCjxDpmMK6p2WsjlmSnFsmGexGOX7UCm0ghN+yK07V16+CutUsevJSxz 9TL4eM4ctnQ== X-Received: from qvnt18.prod.google.com ([2002:a0c:f992:0:b0:91e:9cba:4fe9]) (user=willemb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6214:53c9:b0:921:890c:442a with SMTP id 6a1803df08f44-921890c48c7mr245488636d6.46.1795963875663; Sun, 29 Nov 2026 06:51:15 -0800 (PST) Date: Sun, 29 Nov 2026 09:51:14 -0500 In-Reply-To: <20261124074927.3622245-1-mjambigi@linux.ibm.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261124074927.3622245-1-mjambigi@linux.ibm.com> Message-ID: Subject: Re: [PATCH net-next v2 0/3] net/smc: fix clcsock lifetime vs asynchronous paths From: willemb@google.com To: Mahanta Jambigi , andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, alibuda@linux.alibaba.com, dust.li@linux.alibaba.com, sidraya@linux.ibm.com Cc: hidayath@linux.ibm.com, pasic@linux.ibm.com, horms@kernel.org, tonylu@linux.alibaba.com, guwen@linux.alibaba.com, netdev@vger.kernel.org, linux-s390@vger.kernel.org, linux-rdma@vger.kernel.org, Mahanta Jambigi Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes Mahanta Jambigi wrote: > The internal TCP socket (clcsock) of an SMC socket is freed by > asynchronous paths: link group termination reaches > smc_close_active_abort() and peer close reaches > smc_close_passive_work(), and both can run while the SMC socket is still > referenced by an open file descriptor. A task that uses the fd at that > moment, for example getsockopt() or a socket diag dump, then operates on > a released socket. > Free the clcsock only when no socket file can reference it: from the > socket release paths, after the socket has been unhashed, and from the > abnormal close paths once the socket has no file left. The decision is > made under the socket lock, and the accept path holds the same lock > across the accept-queue state check and sock_graft(), so a connection > that is being accepted cannot lose its clcsock to an asynchronous close. > The clcsock_release_lock is no longer needed: a socket operation on a > file is serialized with smc_release() by the file reference, and the > listen work is covered by flush_work() and cancel_work_sync() in > smc_clcsock_release(). > Trade-off: with an open file, a clcsock now stays allocated after an > abnormal close until the application closes the SMC fd. The SMC > connection is already torn down and its TCP connection has been reset or > shut down; only the local TCP socket remains allocated until then. > Patch 1 makes the lifetime change and is self-contained. Patch 2 removes > the lock and the checks it made necessary, and serializes the accept > path with the asynchronous close. Patch 3 documents the invariant and > adds a destructor warning for it. The diag dump keeps its NULL check: a > socket is hashed in smc_sk_init(), before its clcsock is created. > This is hardening found by code walk, not a fix for a reported > regression, so the series targets net-next and carries no Fixes: tag. > --- > Changes in v2: > - Rebased onto net-next (eb6d6c80d354) instead of the torvalds tree > (7e1392a42ea2). The patch content is unchanged; the only differences > are unrelated net-next context: patch 2 now shows the READ_ONCE() > around limit_smc_hs, and hunk labels were re-derived. > - Patch 1: clarify the commit message to say the issue was found by code > inspection rather than from a reported regression, and to describe the > conn->freed rationale more precisely. > - No functional change to the series. > Mahanta Jambigi (3): > net/smc: keep clcsock until socket release > net/smc: remove the clcsock release lock > net/smc: document the clcsock lifetime > net/smc/af_smc.c | 123 +++++++++++++++++--------------------------- > net/smc/smc.h | 8 ++- > net/smc/smc_close.c | 35 +++++++++---- > net/smc/smc_diag.c | 3 ++ > net/smc/smc_inet.c | 9 ++-- > 5 files changed, 82 insertions(+), 96 deletions(-) > base-commit: eb6d6c80d35449c27471b1874f13066c09a8964d This series no longer applies cleanly to current net-next (conflict in net/smc/af_smc.c reported by NIPA contest). Please rebase onto current net-next and repost v3. -- pw-bot: cr