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=1795963877; b=W10RFLmg+E6leHVx4GG3WhuzetxV1O0IpG4Tghc1OH4LbievMuI0N7OvauB4/Xcxzkri VvjTVbdGrZc+FwsrxSfaqHUD1HYLffLrcu8GkTtjf4rZZmfyS7Ofuo+4dq4GTX1tZQj5m whNGsTagHETvZLdIpaXjiciKWt+qz49wM5nsbokTIxg1QaikHuZNKckaiF1BMR74U+nhT mSn86b2oshF1rG/kWxUozKzfpj3i0MRCRLsMcisgnlNUb+6qF+UNejK3z9BVZe4XT7G2K JY17upnHk5TyPhKUYK5wK5KYr3BXUeS8Tm3PNrBzDSKhhrLo4pLJDd+Lfa3V6hNGuPw== 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=3e4+KpoBTzRlV7CkQp/ucjbTN2pUTVFUmvvKNriu2rMDoXR12Kv+WLUcfiOWwCyDsvpy yLG4pf78hFVIclJXhnSJw6W8w1YOyBU//M7SNorWt8sWwaJDw7S+1eRe141Y6H1X5GqMb qFzDwCaI9Bpp5b/NT1rAOL0Phqv+tW2uZyBK+OoE9vEw/6oDiqqfmM2aTNfhfRWBJjWuF btEm4wtD++m1E3xteyRlP0RC1YURxnl5QsJgbvVUqfk2ERnBCUBc8A9BM05RfxR0eYVgU mU2vak9Gcye/JBUsWCciuHeunSEnC1cXeSTAW/MgfZL3oNdHFXGED9SlBw4i7lfYGAA== 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 ED54F606A331 for ; Sun, 29 Nov 2026 14:51:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org ED54F606A331 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-92125ff2d08so102177346d6.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=CROo5AYvVGp/Ucd/OczWm47HQ5pPO+oUFkuGxNuiswwmoE5nnU9cEpnuzeF9FvoQJF wbueYpZlSCpz27zfew5up+CjvlL2IbYpr/GyswlhNHwJxlvzx3xIAlFp9JaPxmJxk/Ix cxGlqM9k/Gch6sKFcYDf8vQYQS6O9Y6wVaMcyQwxE6YLgFVzl6XLSn9cA3XT4Xp8bpDW p48qWWSuge7xbydqMzh2Fdc/JKaOJ1B8clGHSaCZxAqIlapZEGvehFMHLmF09lYfpwcW SlrFTOxEpT3wDTW4XonevvRFIg+VtZyJ11pQ1xGP/1+iToD1YPPQ5MKUdBCpgGoTweL7 kx8A== X-Forwarded-Encrypted: i=1; AL+hErH0z0oIsSe0ff5ICCWn7hc7FY9cI7SfCFI/JqoYjUcZGt8CDgcWO3YAHWtbKMza3DlWFUEIhA0X/l//@vger.kernel.org X-Gm-Message-State: APuU4Z9aVSzTZ3FwUPgmCM7Eo4vLjadEjZi6P0DhZwngMcrP3CJZ7Qvc 94+N8odDu2MAGMX72FUrXpp/HK5jj9TYnC27qOPRq6atbZBT9hXwFqKM8EvcmzJ/0w0VwtkT0XG hkBYsxuBd1g== 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-rdma@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