Re: [PATCH 15/18] lib/stacktrace, kasan, kmsan: rework extra_bits interface

From: Alexander Potapenko
Date: Thu Feb 02 2023 - 05:04:36 EST


> This change also fixes a minor issue in the old code: __stack_depot_save
> does not return NULL if saving stack trace fails and extra_bits is used.

Good catch!


> + *
> + * Stack depot handles have a few unused bits, which can be used for storing
> + * user-specific information. These bits are transparent to the stack depot.
> + */
> +depot_stack_handle_t stack_depot_set_extra_bits(depot_stack_handle_t handle,
> + unsigned int extra_bits)
> +{
> + union handle_parts parts = { .handle = handle };
> +
> + parts.extra = extra_bits;
> + return parts.handle;
> +}
> +EXPORT_SYMBOL(stack_depot_set_extra_bits);

You'd need to check for handle==NULL here, otherwise we're in the same
situation when __stack_depot_save returns NULL and we are happily
applying extra bits on top of it.