linux/scripts/kconfig/tests
Leizhen Zhang a8f72a75b3
kconfig: use the value argument in sym_get_near_range_bound()
sym_get_near_range_bound() is meant to check whether the given value is
outside of the active range of an int/hex symbol, and is called with the
symbol's current value from sym_calc_value() and with the default value
from sym_get_string_default().

Since commit 9b8719973e ("kconfig: use unsigned integers for hex range
checks") it ignores its value argument and uses the current value of the
symbol (via sym_get_range_val()) instead. As a result, an out-of-range
default is no longer clamped in sym_get_string_default(), and
savedefconfig writes out values that are equal to the effective default
again, for example CONFIG_A=4 for:

  config A
  	int "a"
  	range 1 4
  	default 8

The existing savedefconfig_range test did not catch this because it only
covers symbols without a prompt.

Parse the value argument again, and add a test case for a symbol with a
prompt.

Found while fuzzing Kconfig input with ASan/UBSan.

Fixes: 9b8719973e ("kconfig: use unsigned integers for hex range checks")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Leizhen Zhang <lzsx618@gmail.com>
Tested-by: Julian Braha <julianbraha@gmail.com>
Reviewed-by: Julian Braha <julianbraha@gmail.com>
Link: https://patch.msgid.link/20261008164540.3686383-1-lzsx618@gmail.com
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2026-10-09 22:31:53 +02:00
..
auto_submenu kconfig: convert to SPDX License Identifier 2018-12-28 22:22:28 +09:00
choice kconfig: remove tristate choice support 2024-07-16 01:08:36 +09:00
choice_randomize kconfig: tests: add a test for randconfig with dependent choices 2024-03-21 02:39:55 +09:00
choice_randomize2 kconfig: tests: test dependency after shuffling choices 2024-03-21 02:40:39 +09:00
conditional_dep kconfig: Support conditional deps using "depends on X if Y" 2026-01-06 14:57:15 -07:00
def_type kconfig: Add "def_string", "def_int" and "def_hex" 2026-09-24 11:37:05 -04:00
err_num_bounds kconfig: prevent out-of-bounds user input for numeric options 2026-09-17 16:31:00 -07:00
err_num_mismatch kconfig: check for hex and int mismatches 2026-09-17 16:31:00 -07:00
err_num_non_numeric_ref kconfig: check for out-of-bounds numeric constants 2026-09-17 16:31:00 -07:00
err_recursive_dep kconfig: error out for recursive range 2026-08-31 16:56:48 -07:00
err_recursive_inc kconfig: tests: fix recursive inclusion unit test 2019-06-05 02:33:10 +09:00
err_repeated_inc kconfig: Fix repeated include selftest expectation 2026-06-05 19:24:49 +02:00
err_transitional kconfig: Add transitional symbol attribute for migration support 2025-09-24 14:23:35 -07:00
new_choice_with_dep kconfig: convert to SPDX License Identifier 2018-12-28 22:22:28 +09:00
no_write_if_dep_unmet kconfig: tests: fix typo in comment 2026-06-09 16:28:46 -07:00
preprocess kconfig: test: add Kconfig macro language tests 2018-05-29 03:31:19 +09:00
randconfig_probability kconfig: warn about malformed KCONFIG_PROBABILITY values 2026-09-24 11:30:42 -04:00
savedefconfig_range kconfig: use the value argument in sym_get_near_range_bound() 2026-10-09 22:31:53 +02:00
transitional kconfig: Avoid prompting for transitional symbols 2025-10-07 08:21:23 -07:00
warn_changed_input kconfig: tests: {old,save}defconfig: Forward dynamic keyword arguments 2026-09-30 15:45:29 +02:00
warn_num_bounds kconfig: prevent out-of-bounds user input for numeric options 2026-09-17 16:31:00 -07:00
conftest.py kconfig: tests: {old,save}defconfig: Forward dynamic keyword arguments 2026-09-30 15:45:29 +02:00
pytest.ini