From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796409781; b=FyQgkIckIg5Hbpu5ic+43drOnxeZjsIyo5o08GC8RTLlvmDeiq3Zut76k7IPXC4TU1cz 3DtTO9mk7A/C3ayihCEZjeeilBC0h8VWoOqScbWhDcpsYtw+9sOETSMHpjKLitLSsjzB9 pnJYkWRuTsZz04g6ycvOt8WBISWAXkM1Aq1YMnc3KhNtbrtlsgXt3dXMUTE8k5R18Aym8 CuZmYFQYah7h4BzV/xOq2uL4sdjgTwvTCgFvmCRlsJ2LPgr72bDfXad5ZKareUEK90TxK O7GAkf37mqZZO4axhutJdNQN8XRSyrjNWjojySEYSWLEQd8jAg2zxtjFpmfWCKfeTGg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796409781; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=6/ZDVtEy4DJ7cDuAVy+6RzLINk1FwDTcvxKe3dBzAkE=; b=jjyw4uovIabJqOw0vVY8gzLDeYNXPGLp6bvur1tAt9AV1MXTD/Ud/m8+8ld1s7WCBffK ATU6w1Jpsno4kFmiLypedGVBXnJljEh+F1nsvAdkahke47Qs0N95PXXA3jd6HWNdhUQzO J/JGDhxWEgwp3jJM+Qo7mHD8qeB4BPZv2dy7OpEEZso+uCAij98p/Izg9omIZgj0h7Stv 7gFQYk4pyE+MtcUbaac78SsvL53p6I+6h9d5DmSKtfCkiBK8eik9g/CQdKyAqGONDiGIE /7rEqi+squUgGkHwgSP/OTBIujCfi33ccZQZT/p3xWO2yST53LLmwKPg0zOPWmzyFHw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=stellman-greene.com; spf=none smtp.mailfrom=stellman-greene.com; dkim=pass header.d=stellman-greene-com.20260707.gappssmtp.com header.i=@stellman-greene-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=P8UxTbji; arc=none smtp.remote-ip=209.85.219.47 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 16E5E606A335 for ; Fri, 4 Dec 2026 18:43:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 16E5E606A335 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=stellman-greene.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=stellman-greene.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=stellman-greene-com.20260707.gappssmtp.com header.i=@stellman-greene-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=P8UxTbji Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-921d2f3d65dso13772066d6.2 for ; Fri, 04 Dec 2026 10:43:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stellman-greene-com.20260707.gappssmtp.com; s=20260707; t=1796409780; x=1797014580; 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:content-type; bh=6/ZDVtEy4DJ7cDuAVy+6RzLINk1FwDTcvxKe3dBzAkE=; b=P8UxTbjii6Mv43ecd+gRdEW2NHeFitWEuf4/Rg7g+tYFOKG6xmATqpMhNgVPIGh8px Po8igAsy7umIzzBRWlONsokZkigFYCYTltEPkLa8TR1Cwq/OqT4H7jyQKthwR/o4ujEa vJMRgjsdTwkxEVh3vZ/oIFDumYPrC+RU8tZwRlpT39zdFPWNYDWjF6SiAjs2Z6pEGi1w Ji12Kv48odqRaAxjHPbJOVGB1eFjnd7jEAp4QyAiFuLCQN5PKFtwYVyUxvDjJywM64f6 inYgdk4YVaj2Jw0L1umJNKkAb4iBdEy6a+qCCxulDhmKZinf7Ie276NwarKlgV1l+uSt d2cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796409780; x=1797014580; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=6/ZDVtEy4DJ7cDuAVy+6RzLINk1FwDTcvxKe3dBzAkE=; b=f67PKOPXgebqLkvrUP9tS4vyudtwNtQ4yo8P8w6nxl/FR2afnFVJEJ41UNkqJ/qIqR v7LkICfpjiFf8LBJZtLD5NuYsVKwhkjJjFg7KMbE/AOxBZjtFznzjUX5PEPfKTsIGdJm Km9dAR6b7ILEkwS+c4RycKnBPqFSe08BrNVvfkBB7NiaN+pk6UxL+qywDMreA5R9+5mN t+W7Gr0PVRCQWt01txHDviznTQ8vggM8g+1FS1WZETmSU564+t6rLZ2aoCCFvsLh61/i FwGk9ZkInwOg98oA4ne0YajchDMimGdIF+vJ8n4DdV7OYL0V+cf4oGO/BZgkeNoVSsCN rjjQ== X-Forwarded-Encrypted: i=1; AL+hErHn6P+jejL9y8bvHYL6NeK1hpX1hBcQWb9KfZzo/xzRoH5KOseRzfgzWEegESvbms6gCeW+Mm4=@vger.kernel.org X-Gm-Message-State: AB4q+uGFFMQmQXZFpFu1Tz0N2NjM+0Oh/l2IKsKNPn2yZkOCOQ1n/9pa vZoMJQ8np5gtxZ/di6L3A7U49HccA+3mzCLDj29IKqAJ/6wHy2oyJTNNux3gIiZq+QM= X-Gm-Gg: AZFdTZfjkDc/yMx2uNUiF2txii5nUDltnJjx9OCuNpEWGtn9ApS5HKX+nKExlS5XGQj wwZmLz/BfBsxOnR9w+FJPROWvhuXh1IT1iw+JXrF3peBZ+zfo5ek7Nm4IG5UiUvi0UqFqJFATd5 qxLMKyfEq+8m9srAu/rcelcgQKZSqcNpfpKl3+pGhlwx4h7fxslHmcO323ahh8kBytJA/1sNxh+ HBcH3Kkd8laIurAYwfYK7/5RcxIhUepRtQmrR4RnOjYljCd0hr3uanJmkuLMB+sxIAYkrj7OUKZ W4KpCbWj5yTa5jN5cyVuacCUrkNXCOvpr+lb3Yynzu8vaYo2A/CBAYhuyvVeCrBhT2V8sLyUzih oZPfM5H1VuWxFhVSBP0K+57kldnU/L46Ex+bl0iqSaC95NyoQ4ujbQt8vQXXuXolW71Mph2L+t0 G/zLewiwZZu0bzgXD1r/Zbha2t11loP9mDzkM2YQKADNRPwdEoUQoEnB75AVRzM6+utB0Nu9pCJ FJ1FSapScM4x8bhjoL4K5w6YutHP3fUyj9LPO6aC3exNHPXBdKnI/zKpZ0+xmthJTiNpkAJoFlN KeOOMumarGIWHxh64oK65xWf0kvvl6SbYbMSRV5i3GpgCb6JXYJRfy1I0PJig+LYKD6qTNJjEz0 YfP1EEsOabfjLzQ6jPsh2 X-Received: by 2002:a05:6214:5a06:b0:921:d8a9:84ce with SMTP id 6a1803df08f44-921e26a362emr46657666d6.55.1796409780029; Fri, 04 Dec 2026 10:43:00 -0800 (PST) Received: from Mac.mynetworksettings.com ([2600:4041:5c28:200:62:766c:1c4a:276e]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-921e05801f1sm28228006d6.23.2026.12.04.10.42.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 04 Dec 2026 10:42:59 -0800 (PST) From: Andrew Stellman To: Jeremy Kerr , Matt Johnston Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v2 1/2] net: mctp: don't hold a zero-refcount socket in mctp_key_alloc() Date: Fri, 4 Dec 2026 13:42:57 -0500 Message-ID: <20261204184258.70828-2-bugs@stellman-greene.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261204184258.70828-1-bugs@stellman-greene.com> References: <20261204184258.70828-1-bugs@stellman-greene.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 Content-Transfer-Encoding: 8bit From: Andrew Stellman mctp_dst_input() finds the bound socket with mctp_lookup_bind() under RCU only, without holding a reference. If a concurrent close drops the last reference after that lookup, mctp_key_alloc() calls sock_hold() on a zero refcount, which saturates it and warns, and mctp_key_unref() later underflows it. Take the reference with refcount_inc_not_zero() and fail the key allocation if the socket is already at zero. The issue was found by Claude Opus 5.5 and Claude Fable 5.2 running Quality Playbook, an LLM-driven code review tool: https://github.com/andrewstellman/quality-playbook The fix and this changelog were drafted with OpenAI GPT-6 (Codex) and reviewed by me. Fixes: de8a6b15d965 ("net: mctp: add an explicit reference from a mctp_sk_key to sock") Reviewed-by: Jeremy Kerr Signed-off-by: Andrew Stellman --- v2: no code change; add Jeremy Kerr's Reviewed-by. v1: https://lore.kernel.org/netdev/20261202164958.49945-1-bugs@stellman-greene.com/ Tested on net 3c8881ee9806 (7.4.0-rc5) in arm64 QEMU with KASAN, using the KUnit case in 2/2, which sets a zero sk_refcnt on a bound socket (the close race itself wasn't reproduced): it hit the "addition on 0" and "underflow" refcount warnings without this fix and passed with it. net/mctp/route.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/mctp/route.c b/net/mctp/route.c index 96fd75ea7..5bc3a8e09 100644 --- a/net/mctp/route.c +++ b/net/mctp/route.c @@ -239,7 +239,10 @@ static struct mctp_sk_key *mctp_key_alloc(struct mctp_sock *msk, key->valid = true; spin_lock_init(&key->lock); refcount_set(&key->refs, 1); - sock_hold(key->sk); + if (!refcount_inc_not_zero(&msk->sk.sk_refcnt)) { + kfree(key); + return NULL; + } return key; } -- 2.53.0