]> Git Repo - J-linux.git/commitdiff
stackleak: Use a copy of the ctl_table argument
authorThomas Weißschuh <[email protected]>
Fri, 3 May 2024 13:44:09 +0000 (15:44 +0200)
committerKees Cook <[email protected]>
Fri, 3 May 2024 19:35:12 +0000 (12:35 -0700)
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]>
kernel/stackleak.c

index 34c9d81eea9409410fb289f19108bb7fb8488810..59cdfaf5118e8c22a207f87b00bec20a881b2391 100644 (file)
@@ -27,10 +27,10 @@ static int stack_erasing_sysctl(struct ctl_table *table, int write,
        int ret = 0;
        int state = !static_branch_unlikely(&stack_erasing_bypass);
        int prev_state = state;
+       struct ctl_table table_copy = *table;
 
-       table->data = &state;
-       table->maxlen = sizeof(int);
-       ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
+       table_copy.data = &state;
+       ret = proc_dointvec_minmax(&table_copy, write, buffer, lenp, ppos);
        state = !!state;
        if (ret || !write || state == prev_state)
                return ret;
This page took 0.049764 seconds and 4 git commands to generate.