From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.198 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796146690; b=MN9gpsKizeHpuIlXwnOOWwhRZ7W4bjOHWuHcoUN725WSjsR4hJ1NcsV0GAnVIBTSxKX/ dILfJy0Z3dkwYtvV71OM0007OXenQgfFDt2wVbG0HgNgpi2P14+KBYNUiIVeatT7Zgm/Q QTERERd3csCFHvildY+bTmg7EvBlLoBWxZxyEklLiJ5jcfTZ/gCWATUf9QQXISkWaqrxr AFQSS16PXBglxmBTFCSwrh2cpFVtqgoEhwqnx+6uilGao5Wksq8/i5a8VbsevIXyPoXLO GIaA0JCnJxGZOGBNgyVoz4GLxv4EGoGROskN/9f6K6SjaVAJH70I8HI8iHqNT9XhJ4g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796146690; 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:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=0AL6ZQCUH/L2jkVoV52AoYh+4rhxJBENMyCAlZbVPBs=; b=nJXvzV0ONMQm8d7wUvpgZbEsZDmuJHQcYgbK6Mq2JprMFtbeyaZ93cmwjpHqDX5YYF1A ctAlfsxAK3tlp4c8GzUu4uR6HiLZUZlCyDB85O2jl0A+xoc4EqHIBRQmGDL1fMkbWbMmP ajZmivka9iaABZFNrntarwjyewaYKtG9I261ZyKVsZ2ebigeJzkujZO6gIuuxkqlDrcAA aMh46NJcHmW3vglFMlGkmL8Qs0CFrStAcUQP8zpnLJQFV1qdXhDRLqqfsYPGFJKSGF5rj YNTkO6ke4V0eJ7gwiG57Q3mWLkSdttIC/1+kRg65a+XSDc0LHDEOFWKrGkd39gS5TDA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b="oKRV/YhK"; arc=none smtp.remote-ip=74.125.82.198 Received: from mail-dy1-f198.google.com (mail-dy1-f198.google.com [74.125.82.198]) (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 96FF0606A335 for ; Tue, 1 Dec 2026 17:38:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 96FF0606A335 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--irogers.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=oKRV/YhK Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-3846d5f54c1so13076874eec.1 for ; Tue, 01 Dec 2026 09:38:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796146690; x=1796751490; 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=0AL6ZQCUH/L2jkVoV52AoYh+4rhxJBENMyCAlZbVPBs=; b=oKRV/YhKQuWlf5eTa9MK40ysosqnwvKOWEPcjMUGKqgEgROctoBigmeUUPDtRsJPWl COwSlZAzea6kmMPWlTTa3CQ8fX76KQA5DeQkKfwz95SNsD4Wghl0e+kB+Pz5TPj2cOFx oaWPtqHEz5KUKkVHSyh+al5QoJvgJiLKY9PkRmNA+qdPSBNZrQ8ZqvjNb2CUU7W8n0ZU iNy1AOmz+QNgBbsBwrPRYZbp5+ZUz+M/GOgrP8DyTU0XoP7TVLtCqcYtz89+w3c4/RzU b40W/vN8TuAwycnwaIySc8XsESl89Q2DOly4q9ANngbJh1EZeA8PBmWn2qrd7gKheDo9 uXVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796146690; x=1796751490; 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=0AL6ZQCUH/L2jkVoV52AoYh+4rhxJBENMyCAlZbVPBs=; b=DVMVuGq0LhFTVpmHv+8RpAZObuPmH+RV4gBZ40OSHFO/IZKzDGZ7HIh0Mjn6iY69Cl my19KKn+CE7vBzc3FWFzsbECbqPILSu/n6ibK5mhaigafjjUDPS1cVfPCpaD2l8wIji7 27WyeXyx3ArU+J3bIhN5ga1PRpUd1y9uZaXzn0i3iXceZ2cb/6X3uj+yR2MZY2psz9Ce aowZVfVeLECYXdyeps9PjlekR9fOPZP9t6N5+4zopNCBBAfMUwD4mFKlIPeDA8A+gb/p tkNUHdzsI4ycJUptgl8iY1RoSHoXLhNraDP5ROYnydGlmQm5H1fJn4CsslM1lMnUeBdN MEbQ== X-Forwarded-Encrypted: i=1; AL+hErHSQx9uI8YVJGB84iJAkXA0/XLMttZ/gnM9p67ac7p1vCtugXyGmdYegHYNd3PZk/zKvQMsIcw=@vger.kernel.org X-Gm-Message-State: APuU4Z+Mfr96z4jTFYmeMF5qDR1YyMthSsICFaBS0tSVuu/PJyHJJKfU la4AjjjFepXiMw++mbKPplm+GqLLgS/scMcvneSGZoCnKatoAqILbIj9k/O57eXTG6BAD5SPdd3 otKemNf+7Cg== X-Received: from dyjk39.prod.google.com ([2002:a05:7300:2727:b0:386:f19c:18bb]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:693c:69d4:b0:386:5adb:ac25 with SMTP id 5a478bee46e88-3865adbb1d2mr29745323eec.22.1796146689394; Tue, 01 Dec 2026 09:38:09 -0800 (PST) Date: Tue, 1 Dec 2026 09:38:07 -0800 In-Reply-To: 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: <20261119170342.1508789-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog Message-ID: <20261201173807.1423448-1-irogers@google.com> Subject: Re: [PATCH net] sctp: initialize new_value in custom proc_dointvec sysctl handlers From: Ian Rogers To: Xin Long Cc: willemb@google.com, Marcelo Ricardo Leitner , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-sctp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Elkin Cruz , Ian Rogers Content-Type: text/plain; charset="UTF-8" On Thu, Nov 26, 2026 at 2:17 PM Xin Long wrote: > > On Wed, Nov 25, 2026 at 8:43 PM wrote: > > > > Returning early on reads (`if (!write) return proc_dointvec(ctl, write, > > buffer, lenp, ppos);`), initializing `old_value = READ_ONCE(...)` / > > `new_value = old_value` unconditionally on the write path (keeping Clang's > > -Wconditional-uninitialized happy), and gating the commit block on > > `new_value != old_value` with WRITE_ONCE() avoids both the data race and > > stale writebacks on ignored writes. > Right. > > I think you can replace proc_sctp_do_rto_min() and proc_sctp_do_rto_max() > with proc_dointvec_minmax(). > > Then apply Willem's suggestion only to proc_sctp_do_auth() and > proc_sctp_do_probe_interval(). [...] > With sctp_sysctl_mutex, we don't need the extra old_value variable, unlike > in proc_sctp_do_auth() and proc_sctp_do_probe_interval() above. Thanks both for the thorough review! I've updated the patch to replace proc_sctp_do_rto_min() and proc_sctp_do_rto_max() with proc_dointvec_minmax(), apply the early !write return + READ_ONCE() / WRITE_ONCE() + new_value != old_value check to proc_sctp_do_auth() and proc_sctp_do_probe_interval(), and hold sctp_sysctl_mutex across new_value initialization and proc_dointvec() in proc_sctp_do_udp_port(). I also reproduced the unpatched stack corruption/-EINVAL in QEMU with CONFIG_INIT_STACK_NONE=y and verified the fix under CONFIG_KCSAN_STRICT=y, CONFIG_PROVE_LOCKING=y, and tools/testing/selftests/net/sctp_vrf.sh. I'll send v2 shortly. Thanks, Ian pw-bot: cr