Thread (60 messages) 60 messages, 5 authors, 2021-12-30

Re: [PATCH mm v4 35/39] kasan: add kasan.vmalloc command line flag

From: Andrey Konovalov <andreyknvl@gmail.com>
Date: 2021-12-30 19:11:55
Also in: linux-arm-kernel, lkml

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!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help