Re: mmotm 2020-03-03-22-28 uploaded (warning: objtool:)

From: Peter Zijlstra
Date: Thu Mar 05 2020 - 03:18:52 EST


On Thu, Mar 05, 2020 at 09:17:17AM +0100, Peter Zijlstra wrote:
> On Wed, Mar 04, 2020 at 09:34:49AM -0800, Randy Dunlap wrote:

> > mm/kasan/common.o: warning: objtool: kasan_report()+0x13: call to report_enabled() with UACCESS enabled
>
> I used next/master instead, and found the below broken commit
> responsible for this.

> @@ -634,12 +637,20 @@ void kasan_free_shadow(const struct vm_struct *vm)
> #endif
>
> extern void __kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip);
> +extern bool report_enabled(void);
>
> -void kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip)
> +bool kasan_report(unsigned long addr, size_t size, bool is_write, unsigned long ip)
> {
> - unsigned long flags = user_access_save();
> + unsigned long flags;
> +
> + if (likely(!report_enabled()))
> + return false;

This adds an explicit call before the user_access_save() and that is a
straight on bug.

> +
> + flags = user_access_save();
> __kasan_report(addr, size, is_write, ip);
> user_access_restore(flags);
> +
> + return true;
> }