Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796409781; b=XF+21OlaY+kDiYhxJmDqs0pgi3uMZ+pVl+JoNJKZY91Xmr92lw0HeX19QSJs5i/Fw9gJ Od1bfy6WKOwVE7IVUAAyfx7qEbj9BcaI2S5kNG5sV+mX/NA61bRinfrSzFX0xCKk/Hu/K ZRLr9Yaym30nJ8QrEAwxqbRxvQI9PQ9qos2zPY0EO6uJA2Ue7lhGyrdtTeQMd4IFBe1Te oKGkjAEFj3YIaz7/QBDxB5SY+T/3Q87ZBPOczLkDdyDPm1h2xs+ugCnzIyvoohDK6nyEg 9pYoMR0/NBWWh0/oBafVndqW54UTeJJDFu6CduCSFYDZ8je9blgo4HrVRewNBjfpPLw== 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=zNpBpu7b43f/+Ba/s57GeeGSV80PeUs2zmwo0WTtiZx0i/0MicwPrW5bvWrBeaMyHBO5 LajjJeSLjrD4tQP20V2MPhGfYQGC1zTURKh5K9+q7Y174I9pAjG+tzXp65ipVw31jg2e2 1XIowmJCtR48VEumL4uUxpUTl32zS8UOQF5JDqnokQi4Zr3aZ5bhEmjYDrQJC7b/NHhFk kCf5EG+pp/HBo1XRRVnJ3uWtPFeiIQH2nflcsZI9lrgNq7KJMXnWVm3Duh3eWB8m/D/zR Dky6o4X9xATrDi4tEd9+g9zcNALWYhJhlwTzgCFPu6LE8K653pwWdB1//7lMMbpBSUw== 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.48 Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (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 1BC11606A336 for ; Fri, 4 Dec 2026 18:43:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1BC11606A336 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-f48.google.com with SMTP id 6a1803df08f44-921d2f3d65dso13772076d6.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=j2ZbTGMqQUFPNmx0m0p4aDMErsjdSoXpQ6+vZu7jOUy9VcOwQDuzGJTWw8qLTrJEt1 XwQXbcNEVimmSula6vuAaw4MNO72gxNyIiWCjm2w/1lw+d9ZB3aBp79OxLqSwhkj1rmo RgjjiOt45DR+l+ohaKwoZXq2qCEfritw9NpErh/Cqdxe821E2T0YxZB4+Balj51brzyc nNEOJajp0PbIspcAjxX20SAd4MubO6odOS5/Tu5SGCJ/5PuNozZfHPD2wLulnnlkoA+4 P7maWGhVcejhF2LNKK3R6E1T1iKPEMYFuXKcg151RPaBMlN5Jxdb3okELIldlFYsqg91 KGZg== X-Forwarded-Encrypted: i=1; AL+hErGtbCtNH/1DlDjdd0h2szOqBZV0bOa4i06pkEFKDo0hu1mM1A5C9z2BQy0kM+YfL91T5BtX5V+WrHOv0jQ=@vger.kernel.org X-Gm-Message-State: AB4q+uHp5hUo3g3PNeP9MKd2DyBDJLzoV+zLXpfQTx2HCCRyWzQl0H89 nlFEQF+hs8QDBQefXz5ST+qxe8c/Y72LWVJu60TfFdkOmtkqc0D2K98vHZP/583CPxQ= X-Gm-Gg: AZFdTZdzl5v59J5zeE5WtL+pEorV0jpEmZoA4W2cFzC1WSCX2zHu0A/hJWz3LHSZtnV DEJHNJ38JKXybppTOZi7COfwhLpzJQy5sgIXzOteirkLTBR3aKBWW+GkeeJuMp0hChUCu8BvMvn 5KsC5O4ODXAv+BIB6/zXoOlttvpvy3sKlGjjMvWkQWngqIEInF6+etBg4MFIWM9plCYi/80Bj1x +DkLKvkFffpoe56P5lmh/EU4QhjW7Kg8mBe5UgLgS27X5r5DGqNJ0lkrbGJpgxY8wYc81aIzLo5 xzEoKnP+DKFLlvF9SyRlF2sb2YgGEW0HgLILD+T3Mw4rloPTSqlW0PN7FEPdxM54D4A4beXYamZ 2QocGRHIueMXgAxAcfy6q2bFIgABti3dF9WSq0oJVSDMb7poXcwzjv3WMrO9TtcKcEYTVxni/cS IikxUa/KcNorpM0w5f3dJ2NXNA+6v3g+rkO7m6h1lElowILqodAe6TkmiTMVlQBTHDM7IzkWqqJ BIvmVTlkXupat2JZiVGrRgf5dBrfS0B/bmZMZVG+SEyhsM9hrdagpY5Ss860CxSWqDfBI38ypcN TMzggWNXSr4CIu2oLFFnBiQKjDwkLfARRLB0Dr1GNNsfgAoNV2ZtYhEmm9sVZlzfyLRx2H5Gm0T +SLSeiE/MzhiCKcPofUJ2 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: linux-kernel@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