From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.72 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795963877; b=P86AoiVGmCfv5/AR57nYdsC2x8ol7EtAX+6Wq0p91rYzSWl89ZLflQDU2umlKM8PTOZr EnCPMGxGs7yfCDsiysyf7aR37FCRZ2cTRy0wca+i0m7Z62zfQEA9efulOumr4Jdwsh3dI N4nZ9U90nxJqZ22fOYGxejSenRpVt8Mh/r9CPWbLh+bdOpPMdeBhMzxIDZdJWQF6GEocx 42JwUG1JXo7hYImOjeaqj2cHWAkUu+4evXGzbDOE3V/aNqQMFBtcjTJjah1RXuIl95Ynd qN+BwgOKwCfJaj+g/u1e7xiMa2gKtPSCJ6skVDTXDAOlzGQ8ZfxykD2If5vYTfIqiwA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795963877; 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=qZYW1FCRFUPysnpQTTKg+SLdQobzNt7xJ/O2ZQdbtQN0hAOvePqTr1+rjuumsQlucqOz rSyq4D9B5cyG6MGFGoRKQYGtUp3wTlbynVMxrBL5ah1Ni2PBUTyaQTRZzAA8HD4KQp3B8 db3x8xDZUonl1/KY/bGdWsfu9QUIiGHx5vvbA3k/pHF+bVGZsK4y1Uki+fFVapXfAWw/j 6iL9gAfYglZmX06ALEL1vOBzaPhc8O6j15z2Z6HQptCbLueam3bAw9Zh2lXx9O0PLtAGH akr7vx0RgUYiGDJZIKEbhkqI+PVLKgLJ1HFHMRT4a4jTHn61s6mXAD/IxS7yPHvySuA== 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.72 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (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 EFFC2606A337 for ; Sun, 29 Nov 2026 14:51:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EFFC2606A337 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-f72.google.com with SMTP id 6a1803df08f44-92125ff2d08so102177316d6.2 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=KljKoPWO0NxtLJb6Wcux8YU9QwD3qyUzPssm1fIgTbD/Rc6bDLFbZTkPfkayx1A3bK 3nUhmVN7PW7d8wn9iwsvD9nG49sdOvICVPlVUuCc9d6hWm9JrQmobSAEgqmL7fL+n3L1 IBqYawfKHjz0AZTVuT5ZDFz/EaTlF+CFEv2XLGcaFeoYC6zmVVP594Y78Xq3k+h7Z1v2 awNhab7vt2qT0VdJ2z7mfheAOzxTApBaN1HS2MmoQ/Ly1qEzdn4s4TU4dZISn4y6y2ze O4JmTbbcLEcz70I/90C+RrwPFV9LbRmofrGMu3SYSQNsSyKiHJFpEw/VdrX6mJwJCTB1 +EQw== X-Forwarded-Encrypted: i=1; AL+hErGPMWFZ9NJIZ6FiRh5LBVEXsR+PKgPEPoDKI0gKRHo3UoI52bP5keFvuM/yh2OlwykJdNOFrIrgP4lk@vger.kernel.org X-Gm-Message-State: APuU4Z9X6sHM/hGiMIcRf0u4O8i8M8g5jtAfQ7bgYeoS5E0BKrgzV5Vu LnIokJXosARLXza+V/1CbOwGYfmKkIJ9kuE7JGD74ZXnYWhqQWmU45C82mwejQjrF3yITUybdBK gKoitB/pqhQ== 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: linux-s390@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