From nobody Wed Aug 27 07:56:17 2025 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cBcKs1FRGz65tPJ for ; Wed, 27 Aug 2025 07:56:17 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cBcKs0YMjz49Sl for ; Wed, 27 Aug 2025 07:56:17 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756281377; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oZ79yrmNiqkIbd2a/B+6CcIWeR5KjfXFF59Jm8M0tN4=; b=p9slQOAMMH1Lt6GG1sC698BWrz64HttSoek9z6/Fu9LZvgGHjxTHRCVzqwBjYOBBHBSY/S gnm9DSpeoVwy0juLTy77OT0YtCNS0q1SLrUr1TpFX8kOblbvz0FEbx/iMCDSYYXX6aR0Xv dmUdQbNGVHGPuYqt6pJmMsF0BZ4HEhvgdIyhsLLsyqCEZCfI4xZkofjjp6VsNM7hV/kbXV +SmIZfuQ1BaWxAQBwEweDndufdmBfWvpsA3SpK5y+/rDa4EdZc2cJvdiabh79wpVRDo8II vmRChNX4U6Xak1FY3CIV1X6La5Su1I8Ot/CLddnJBgD/n6hMKulvStFDFCRMhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756281377; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oZ79yrmNiqkIbd2a/B+6CcIWeR5KjfXFF59Jm8M0tN4=; b=HuqMUtWUl8qtIyUvwuLK3NUj9EvPJe2zgjVl9Fwhk1i2ctJW4Q5O0rFyHJs5f5o9NrZRdA y2XZ9ZQ8lJP2IqSkTu3rN62L/QQjI9RIdh7KuWYayfA7bYza4Mk7j9tuQ0UPDIQwaTZuNF j754nTHtsSBYFm7VfkvWDyAi5QxGV8D+3yfMNho9ivKFlJSi0HXnIocHIecw27/su3wdl7 vxpMDVofRiDV9rL+t/EFk0UYKwP3qM0Q3j+ACg9Gxtbx55L87y+aGX8iE9ro91XGGEwb5Y QDcCkybwVlEZNhXypW+XVMRvjTag2eiBcclXj6o0fUKt15LJcC6CnyAEVoJsYA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1756281377; a=rsa-sha256; cv=none; b=aqhmrsWb/PbDDxOP3qc6dGs9f+eUfXTlWlQqwpoWny3zXHRXAh9fzzGhB20Rvb1RzZmAdQ hQdF5EaHQGT3hLtHYYXRMrZbzXib4wVN84o33vW0MP0JqVmME8rZp07WpApMD5qXGDQ7Wh x3Hw7H+TchvRg+UJZUpqVGZ3joklGbonvpyv4bdN+DrxCV2ub++bdiC00+3cX9+L5+SJm3 jRcUW5+Udcjb6cMlud736QmrQb94wzE/L2eWkxNvXl9l6Yq1Jf7rQLeV6OStqKvdnRyYh8 90ajaIPUZLBgTHQ1oao8VPsmomifoave6Oih4REPQwCvNZFIMx9JfJIxyaZfng== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cBcKr6zbVz1Cw3 for ; Wed, 27 Aug 2025 07:56:16 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 57R7uG4I033925 for ; Wed, 27 Aug 2025 07:56:16 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 57R7uG69033924 for bugs@FreeBSD.org; Wed, 27 Aug 2025 07:56:16 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 289121] A time-of-check to time-of-use race exists in sysctl_requested_fec() of the cxgbe subsystem Date: Wed, 27 Aug 2025 07:56:17 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 14.3-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: chenqiuji666@gmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@FreeBSD.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D289121 Bug ID: 289121 Summary: A time-of-check to time-of-use race exists in sysctl_requested_fec() of the cxgbe subsystem Product: Base System Version: 14.3-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: chenqiuji666@gmail.com Summary In sysctl_requested_fec(), the output string is chosen via a ternary that r= eads lc->requested_fec twice without synchronization: lc->requested_fec =3D=3D FEC_AUTO ? -1 : (lc->requested_fec & (M_FW_PORT_CAP32_FEC | FEC_MODULE)) Because lc->requested_fec may change between the check and the use, the =E2=80=9Clc->requested_fec =3D=3D FEC_AUTO=E2=80=9D test can pass/fail on a= stale value, and the masked use can observe a concurrent FEC_AUTO, yielding 0 (since FEC_AUTO & (M_FW_PORT_CAP32_FEC | FEC_MODULE) =3D=3D 0). The result =E2=80=9C0=E2=80= =9D is then handed to sysctl_handle_string() as the old value. However, under the allowed mask no real FEC combination produces 0; real FECs live in bit0..2 (FEC_RS=3D1<<0, FEC_BASER_RS=3D1<<1, FEC_NONE=3D1<<2), while pseudo FECs start at bit5 (FEC_AUTO=3D1<<5, FEC_MODULE=3D1<<6). AUTO should be serialized as =E2=80= =9C-1=E2=80=9D, not =E2=80=9C0=E2=80=9D. Impact =E2=80=A2 Wrong interface semantics: the old value reported to user space c= an become =E2=80=9C0=E2=80=9D, which encodes neither AUTO (-1) nor any valid real-FEC= bitset, misleading management tools and scripts and causing faulty decisions. Suggested fix Snapshot lc->requested_fec once into local variables and compute from that single snapshot, instead of repeatedly reading shared fields. --=20 You are receiving this mail because: You are the assignee for the bug.=