Skip to content

Commit 0e148d3

Browse files
t-8chkees
authored andcommitted
stackleak: Use a copy of the ctl_table argument
Sysctl handlers are not supposed to modify the ctl_table passed to them. Adapt the logic to work with a temporary variable, similar to how it is done in other parts of the kernel. This is also a prerequisite to enforce the immutability of the argument through the callbacks. Reviewed-by: Luis Chamberlain <[email protected]> Signed-off-by: Thomas Weißschuh <[email protected]> Reviewed-by: Tycho Andersen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 7d78a77 commit 0e148d3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/stackleak.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ static int stack_erasing_sysctl(struct ctl_table *table, int write,
2727
int ret = 0;
2828
int state = !static_branch_unlikely(&stack_erasing_bypass);
2929
int prev_state = state;
30+
struct ctl_table table_copy = *table;
3031

31-
table->data = &state;
32-
table->maxlen = sizeof(int);
33-
ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
32+
table_copy.data = &state;
33+
ret = proc_dointvec_minmax(&table_copy, write, buffer, lenp, ppos);
3434
state = !!state;
3535
if (ret || !write || state == prev_state)
3636
return ret;

0 commit comments

Comments
 (0)