From nobody Mon Sep 28 22:28:42 2026 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD2C218B0A for ; Sun, 16 Aug 2026 21:54:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786917250; cv=none; b=cun8ooI+dQt/VF6HbNFJVthscbdS4/8vf663fNQTrdPWeL6gB3tweMsbH/We4q7xtktBCO5EIn6d/TtMIrQqStiPxTF3kQr/QR3FSHJC8hjgLkBbOMN1WVM9vul0t4qOy3XVd5oJXhuwVlm2ECBCsNlwUWFHHtu/VoldJEHWJag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786917250; c=relaxed/simple; bh=R1Ocnxy5s4ML8UfdoZ1jafHArHGdF3fkqDWYKWsXZVc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=mYVt+T78GbQya6LOQlZLK2tjuawrNX+B+3hLR1QZznZuDy8e/iOsZl+GKLmDemJeZlIme/a3duOnFar0PbaBlZm00Cjt3+JvqqbCdbo04AqExxkRAaWhf0IqH8CqWNkwOS0kUicn6sp32Gri4al1TsEFQVh8wghg+aPQUiDNkvI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ap7hC5ej; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ap7hC5ej" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-49800c6a846so31787565e9.3 for ; Sun, 16 Aug 2026 14:54:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786917247; x=1787522047; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to :content-type; bh=cKSHWQgwdR30Bs+BMpgTKUy/VKU4EsEuaszA/Toc6Fc=; b=ap7hC5ej+SAl76pc5gShNxXaeY4Y/lKvTveU5mx2JROBOxWFUnZlREtzhmgcaXnT/6 1h34J1mfTlutYmm0YRchkLlhp+a7ZlZCGRpyV91E+ix7AbWQvb4/VOMgmu+6E/z77CsC dEtu7/jBlhhleQTSgnB8TnLyulkC05dmIfSdJNNZtr8R+SHw6BxAWxzv00hWo1JRX/SE y8/JHIfSBVtTFQRYZ9GS5bBWaynPqGJ+J7TgIMja8tc2oWmXdA6Qmi7T923RFw8/AruN eHY7VBFeDiMjij8KYNC49gq7CphiVyuK6QBYFDszzNDPQGAYywJ7lw8Vy3J37lMhq3qM 0k2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786917247; x=1787522047; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=cKSHWQgwdR30Bs+BMpgTKUy/VKU4EsEuaszA/Toc6Fc=; b=oZeYXaLEkTmpUs93BWmsMWveZZ2IYmDUJducz7qnr0LuLOVL8OhFvScuEhbVnBDq1y xChvQwyhHKTGzh1R79HVkiJKRvybOZtwBwgaMh2IIsOlO6r/BWSkrYQ6prtmzi+9JNUr v+N+YqCA6GY8BE5zf8VxroYwPXrRZhywy6uByyM0zzfckPQ6R9AxVl1zaqrl2dr4UE34 6YlvzIr/rPrKLi8zWCygZLOB4VTwNfk5lHdGlj9SdPGgppOqscQ/3KtR/9fD58MvZ+Rh VPZ7tWb+pHILPkTWUcT5oFhznwjv8Oe2MWeZRyh78uh4Aux+F+JAIcP6iV0RtN1qN3ao T6vw== X-Forwarded-Encrypted: i=1; AHgh+RpIE+Tq930lMv6n98437qxeiPHM4o5KJVtQw0SDktWgl570A0v6QOcDEIU8o8dlMorLGYzq2nubbmI5jqg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw8hzGnNJsvGnl7DfWVXrVQs+DoYbaNiudpjgmdY+omrMStHNN6 PF2KPx4sS4KSpmP6OevhifJDCGcIac7Ja7heDUynU8znCWp4BDSzZYgt X-Gm-Gg: AR+sD106x8GitHXzlGskyvdtHQdZNrdxaG7kh6F7YxXynlidDQUZDPkIl9Boe9z9E23 apIHtCWQuWwAxiB6n6qJaUyaD+xpq0E0w7HOKXjkGMaHcB7hGQoJd+W72SAbttq6kH401h4/9Gx MuMD8E2eSIQ+J3YC4WtDltNr/yTbFxatbSdJg2tn3ExUqFK499IjtzHo5eXgx4ea1aKg7q0Unqz RN20ru7b40kkYBVHAMPdZaljWeLw8cfShVCZAFWjjiruRM7XqIhpEXSGCJXCERtTKv8SkIkzx1i 9LOQZkFRrJrF/J0dYpR94bS5qVIAatDT+UWSpPVyppSObOLe2JAxsN2gadfQ2SeeX8FoCGX3Bt7 W5To8t3ZYkljC94h1NyojYEgkMG80/q66f8DOzJ1jdPSjM02EC6fz3JzD7v1B8beRYMzkb4geoS VYYwCFkFmheHBZ9Pta4iJsHRZBDEHxkHKnlptvvZ4a32/BvtublZJwgdP09mLye1rBKls32deuA kIwkk85+w/GTozcfrMueSfyMNwSUtWhbOVZHrrv56RJJuXatPXl X-Received: by 2002:a05:600c:37ca:b0:499:858e:de42 with SMTP id 5b1f17b1804b1-49987935039mr306469345e9.6.1786917246843; Sun, 16 Aug 2026 14:54:06 -0700 (PDT) Received: from nixos-office (195-23-151-163.net.novis.pt. [195.23.151.163]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4999610e18fsm68307625e9.8.2026.08.16.14.54.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Aug 2026 14:54:06 -0700 (PDT) Sender: Julian Braha From: Julian Braha To: nathan@kernel.org, nsc@kernel.org Cc: kees@kernel.org, vegard.nossum@oracle.com, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Julian Braha Subject: [PATCH] kconfig: error out for recursive range Date: Sun, 16 Aug 2026 22:53:54 +0100 Message-ID: <20260816215354.1499059-1-julianbraha@gmail.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, it is possible to create recursive ranges with Kconfig, such as: config C int "Enable C" default 1 range A B config A int "Enable A" default 2 range B C config B int "Enable B" default 3 range A C The current outcome of this example above, is that all 3 options are set to= 2. There is currently no warning or error if a user attempts this. Several attributes are already checked for recursion, including 'depends on= ', 'select', and 'imply', and we can extend this to 'range' for numeric options (int and hex types). Recursive ranges are currently not used anywhere in the tree, so it is alre= ady safe to make this a hard error. Assisted-by: Codex:gpt-5.6-sol Signed-off-by: Julian Braha --- scripts/kconfig/symbol.c | 5 +++- .../kconfig/tests/err_recursive_dep/Kconfig | 24 +++++++++++++++++++ .../tests/err_recursive_dep/expected_stderr | 13 ++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 7e81b3676ee9..e82f330fb8ee 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -1196,6 +1196,7 @@ static struct symbol *sym_check_expr_deps(const struc= t expr *e) case E_GTH: case E_LEQ: case E_LTH: + case E_RANGE: case E_UNEQUAL: sym =3D sym_check_deps(e->left.sym); if (sym) @@ -1243,7 +1244,9 @@ static struct symbol *sym_check_sym_deps(struct symbo= l *sym) sym2 =3D sym_check_expr_deps(prop->visible.expr); if (sym2) break; - if (prop->type !=3D P_DEFAULT || sym_is_choice(sym)) + if (sym_is_choice(sym)) + continue; + if (prop->type !=3D P_DEFAULT && prop->type !=3D P_RANGE) continue; stack.expr =3D &prop->expr; sym2 =3D sym_check_expr_deps(prop->expr); diff --git a/scripts/kconfig/tests/err_recursive_dep/Kconfig b/scripts/kcon= fig/tests/err_recursive_dep/Kconfig index ebdb3ffd8717..bd1ff92bcab2 100644 --- a/scripts/kconfig/tests/err_recursive_dep/Kconfig +++ b/scripts/kconfig/tests/err_recursive_dep/Kconfig @@ -61,3 +61,27 @@ config G bool "G" =20 endmenu + +# depends on and range + +config H1 + int + depends on H2 < H3 + +config H2 + int + range H3 H1 + +config H3 + int + range H1 H2 + +# range + +config I1 + int + range I2 I2 + +config I2 + int + range I1 I1 diff --git a/scripts/kconfig/tests/err_recursive_dep/expected_stderr b/scri= pts/kconfig/tests/err_recursive_dep/expected_stderr index fc2e860af082..08f843087678 100644 --- a/scripts/kconfig/tests/err_recursive_dep/expected_stderr +++ b/scripts/kconfig/tests/err_recursive_dep/expected_stderr @@ -36,3 +36,16 @@ error: recursive dependency detected! symbol G depends on G For a resolution refer to Documentation/kbuild/kconfig-language.rst subsection "Kconfig recursive dependency limitations" + +error: recursive dependency detected! + symbol H1 depends on H2 + symbol H2 range value contains H3 + symbol H3 range value contains H1 +For a resolution refer to Documentation/kbuild/kconfig-language.rst +subsection "Kconfig recursive dependency limitations" + +error: recursive dependency detected! + symbol I1 range value contains I2 + symbol I2 range value contains I1 +For a resolution refer to Documentation/kbuild/kconfig-language.rst +subsection "Kconfig recursive dependency limitations" --=20 2.55.0