[RFC PATCH 1/5] bug: Core support for suppressing warning backtraces
Guenter Roeck
linux at roeck-us.net
Tue Mar 5 20:17:55 UTC 2024
On 3/5/24 11:54, Kees Cook wrote:
> On Tue, Mar 05, 2024 at 10:40:29AM -0800, Guenter Roeck wrote:
>> [...]
>> warning = (bug->flags & BUGFLAG_WARNING) != 0;
>> once = (bug->flags & BUGFLAG_ONCE) != 0;
>> done = (bug->flags & BUGFLAG_DONE) != 0;
>>
>> + if (warning && IS_SUPPRESSED_WARNING(function))
>> + return BUG_TRAP_TYPE_WARN;
>> +
>
> I had to re-read __report_bug() more carefully, but yes, this works --
> it's basically leaving early, like "once" does.
>
> This looks like a reasonable approach!
>
> Something very similar to this is checking that a warning happens. i.e.
> you talk about drm selftests checking function return values, but I've
> got a bunch of tests (LKDTM) that live outside of KUnit because I haven't
> had a clean way to check for specific warnings/bugs. I feel like future
> changes built on top of this series could add counters or something that
> KUnit could examine. E.g. I did this manually for some fortify tests:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?h=for-next/hardening&id=4ce615e798a752d4431fcc52960478906dec2f0e
>
Sounds like a good idea. It should be straightforward to add a counter
to struct __suppressed_warning. This way the calling code could easily
check if an expected warning backtrace actually happened.
Thanks,
Guenter
More information about the dri-devel
mailing list