Skip to content

Commit a8cdf51

Browse files
committed
Merge tag 'hardening-fix1-v6.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull hardening fixes from Kees Cook: - tools headers: rename missed CONFIG_CFI_CLANG in merge (Carlos Llamas) - kconfig: Avoid prompting for transitional symbols * tag 'hardening-fix1-v6.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: tools headers: kcfi: rename missed CONFIG_CFI_CLANG kconfig: Avoid prompting for transitional symbols
2 parents 16d1ba7 + b157dd2 commit a8cdf51

7 files changed

Lines changed: 62 additions & 2 deletions

File tree

scripts/kconfig/symbol.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ bool sym_dep_errors(void)
411411
void sym_calc_value(struct symbol *sym)
412412
{
413413
struct symbol_value newval, oldval;
414-
struct property *prop;
414+
struct property *prop = NULL;
415415
struct menu *choice_menu;
416416

417417
if (!sym)
@@ -520,6 +520,19 @@ void sym_calc_value(struct symbol *sym)
520520
;
521521
}
522522

523+
/*
524+
* If the symbol lacks a user value but its value comes from a
525+
* single transitional symbol with an existing user value, mark
526+
* this symbol as having a user value to avoid prompting.
527+
*/
528+
if (prop && !sym_has_value(sym)) {
529+
struct symbol *ds = prop_get_symbol(prop);
530+
if (ds && (ds->flags & SYMBOL_TRANS) && sym_has_value(ds)) {
531+
sym->def[S_DEF_USER] = newval;
532+
sym->flags |= SYMBOL_DEF_USER;
533+
}
534+
}
535+
523536
sym->curr = newval;
524537
sym_validate_range(sym);
525538

scripts/kconfig/tests/transitional/Kconfig

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,37 @@ config OLD_WITH_HELP
9696
help
9797
This transitional symbol has a help section to validate that help is allowed.
9898

99+
# Test that we can set something to =n via transitional symbol
100+
config NEW_DISABLED
101+
tristate "Check for setting to disabled"
102+
default OLD_DISABLED
103+
104+
config OLD_DISABLED
105+
tristate
106+
transitional
107+
108+
# Test that a potential new value disappears if it lacks a prompt
109+
config NEW_DISABLED_UNSAVED
110+
tristate
111+
default OLD_DISABLED
112+
113+
config OLD_DISABLED_UNSAVED
114+
tristate
115+
transitional
116+
117+
# Test conditional default: transitional value should not prevent prompting
118+
# when default visibility makes the expression evaluate to 'no'
119+
config DEPENDENCY_TEST
120+
bool "Dependency for testing"
121+
default n
122+
123+
config NEW_CONDITIONAL_DEFAULT
124+
bool "New option with conditional default"
125+
default OLD_CONDITIONAL_DEFAULT if DEPENDENCY_TEST
126+
127+
config OLD_CONDITIONAL_DEFAULT
128+
bool
129+
transitional
130+
99131
config REGULAR_OPTION
100132
bool "Regular option"

scripts/kconfig/tests/transitional/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- OLD_* options in existing .config cause NEW_* options to be set
77
- OLD_* options are not written to the new .config file
88
- NEW_* options appear in the new .config file with correct values
9+
- NEW_* options with defaults from transitional symbols are not prompted
910
- All Kconfig types work correctly: bool, tristate, string, hex, int
1011
- User-set NEW values take precedence over conflicting OLD transitional values
1112
"""
@@ -16,3 +17,9 @@ def test(conf):
1617

1718
# Check that the configuration matches expected output
1819
assert conf.config_contains('expected_config')
20+
21+
# Test oldconfig to ensure symbols with transitional defaults are not prompted
22+
assert conf.oldconfig(dot_config='initial_config', in_keys='n\n') == 0
23+
24+
# Except for when conditional default evaluates to 'no'
25+
assert conf.stdout_contains('expected_stdout')

scripts/kconfig/tests/transitional/expected_config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ CONFIG_NEW_STRING_PRECEDENCE="user value"
99
CONFIG_NEW_TRISTATE_PRECEDENCE=y
1010
CONFIG_NEW_HEX_PRECEDENCE=0xABCD
1111
CONFIG_NEW_INT_PRECEDENCE=100
12+
# CONFIG_NEW_DISABLED is not set
13+
# CONFIG_DEPENDENCY_TEST is not set
14+
# CONFIG_NEW_CONDITIONAL_DEFAULT is not set
1215
# CONFIG_REGULAR_OPTION is not set
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
New option with conditional default (NEW_CONDITIONAL_DEFAULT) [N/y/?] (NEW) n

scripts/kconfig/tests/transitional/initial_config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ CONFIG_NEW_HEX_PRECEDENCE=0xABCD
1414
CONFIG_OLD_HEX_PRECEDENCE=0x5678
1515
CONFIG_NEW_INT_PRECEDENCE=100
1616
CONFIG_OLD_INT_PRECEDENCE=200
17+
# CONFIG_OLD_DISABLED is not set
18+
# CONFIG_OLD_DISABLED_UNSAVED is not set
19+
# CONFIG_DEPENDENCY_TEST is not set
20+
CONFIG_OLD_CONDITIONAL_DEFAULT=y

tools/include/linux/cfi_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
#else /* __ASSEMBLY__ */
4545

46-
#ifdef CONFIG_CFI_CLANG
46+
#ifdef CONFIG_CFI
4747
#define DEFINE_CFI_TYPE(name, func) \
4848
/* \
4949
* Force a reference to the function so the compiler generates \

0 commit comments

Comments
 (0)