On Tue, Dec 21, 2021 at 3:43 PM Alexander Potapenko [off-list ref] wrote:
quoted
+ switch (kasan_arg_vmalloc) {
+ case KASAN_ARG_VMALLOC_DEFAULT:
+ /* Default to enabling vmalloc tagging. */
+ fallthrough;
+ case KASAN_ARG_VMALLOC_ON:
+ static_branch_enable(&kasan_flag_vmalloc);
+ break;
+ case KASAN_ARG_VMALLOC_OFF:
+ /* Do nothing, kasan_flag_vmalloc keeps its default value. */
+ break;
+ }
I think we should be setting the default when defining the static key
(e.g. in this case it should be DEFINE_STATIC_KEY_TRUE), so that:
- the _DEFAULT case is always empty;
- the _ON case explicitly enables the static branch
- the _OFF case explicitly disables the branch
This way we'll only need to change DEFINE_STATIC_KEY_TRUE to
DEFINE_STATIC_KEY_FALSE if we want to change the default, but we don't
have to mess up with the rest of the code.
Right now the switch statement is confusing, because the _OFF case
refers to some "default" value, whereas the _DEFAULT one actively
changes the state.
I see that this code is copied from kasan_flag_stacktrace
implementation, and my comment also applies there (but I don't insist
on fixing that one right now).
Will do in v5. Thanks!