Re: [PATCH v7 00/43] Add KernelMemorySanitizer infrastructure

Andrew Morton
2022-09-15T21:07:57Z

On Thu, 15 Sep 2022 14:05:51 -0700 Andrew Morton <akpm@linux-foundation.org> wrote:

>
> For "kmsan: add KMSAN runtime core":
>
> ...
>
> @@ -219,23 +212,22 @@ depot_stack_handle_t kmsan_internal_chai
> * Make sure we have enough spare bits in @id to hold the UAF bit and
> * the chain depth.
> */
> - BUILD_BUG_ON((1 << STACK_DEPOT_EXTRA_BITS) <= (MAX_CHAIN_DEPTH << 1));
> + BUILD_BUG_ON(
> + (1 << STACK_DEPOT_EXTRA_BITS) <= (KMSAN_MAX_ORIGIN_DEPTH << 1));
>
> extra_bits = stack_depot_get_extra_bits(id);
> depth = kmsan_depth_from_eb(extra_bits);
> uaf = kmsan_uaf_from_eb(extra_bits);
>
> - if (depth >= MAX_CHAIN_DEPTH) {
> - static atomic_long_t kmsan_skipped_origins;
> - long skipped = atomic_long_inc_return(&kmsan_skipped_origins);
> -
> - if (skipped % NUM_SKIPPED_TO_WARN == 0) {
> - pr_warn("not chained %ld origins\n", skipped);
> - dump_stack();
> - kmsan_print_origin(id);
> - }

Wouldn't it be neat if printk_ratelimited() returned true if it printed
something.

But you deleted this user of that neatness anyway ;)