lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Ym+WqKStCg/EHfh3@alley>
Date:   Mon, 2 May 2022 10:30:32 +0200
From:   Petr Mladek <pmladek@...e.com>
To:     Marco Elver <elver@...gle.com>
Cc:     John Ogness <john.ogness@...utronix.de>,
        Naresh Kamboju <naresh.kamboju@...aro.org>,
        Linux-Next Mailing List <linux-next@...r.kernel.org>,
        open list <linux-kernel@...r.kernel.org>,
        lkft-triage@...ts.linaro.org, linux-mm <linux-mm@...ck.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Alexander Potapenko <glider@...gle.com>,
        Dmitry Vyukov <dvyukov@...gle.com>,
        Stephen Rothwell <sfr@...b.auug.org.au>,
        Anders Roxell <anders.roxell@...aro.org>,
        Andrey Konovalov <andreyknvl@...il.com>,
        Andrey Ryabinin <ryabinin.a.a@...il.com>,
        Catalin Marinas <catalin.marinas@....com>,
        Evgenii Stepanov <eugenis@...gle.com>,
        Mark Rutland <mark.rutland@....com>,
        Peter Collingbourne <pcc@...gle.com>,
        Vincenzo Frascino <vincenzo.frascino@....com>,
        Will Deacon <will@...nel.org>
Subject: Re: [next] i386: kunit: ASSERTION FAILED at
 mm/kfence/kfence_test.c:547

On Mon 2022-05-02 09:51:46, Marco Elver wrote:
> On Sat, Apr 30, 2022 at 11:14PM +0206, John Ogness wrote:
> [...]
> > I am not familiar with how this works. Is the tracepoint getting set on
> > call_console_drivers()? Or on call_console_driver()?
> 
> It's at the start of call_console_drivers(). See trace_console_rcuidle()
> call.
> 
> > If so, there are a couple problems with that. First off, the prototype
> > for that function has changed. Second, that function is called when text
> > is printed, but this is not when the text was created. With the
> > kthreads, the printing can be significantly delayed.
> > 
> > Since printk() is now lockless and console printing is delayed, it
> > becomes a bit tricky to parse the records in the existing code using a
> > tracepoint.
> > 
> > I wonder if creating a NOP function for the kfence probe to attach to
> > would be more appropriate. In printk_sprint() we get the text after
> > space has been reserved, but before the text is committed to the
> > ringbuffer. This is guaranteed to be called from within the printk()
> > context.
> 
> I think we just need to fix the existing tracepoint, since it has
> changed its semantics vs. what it was intended to be:
> 
>  | commit 95100358491abaa2e9a5483811370059bbca4645
>  | Author: Johannes Berg <johannes.berg@...el.com>
>  | Date:   Thu Nov 24 20:03:08 2011 +0100
>  |
>  |     printk/tracing: Add console output tracing
>  |
>  |     Add a printk.console trace point to record any printk
>  |     messages into the trace, regardless of the current
>  |     console loglevel. This can help correlate (existing)
>  |     printk debugging with other tracing.
>  |
>  |     Link: http://lkml.kernel.org/r/1322161388.5366.54.camel@jlt3.sipsolutions.net
>  |
>  |     Acked-by: Frederic Weisbecker <fweisbec@...il.com>
>  |     Cc: Christoph Hellwig <hch@...radead.org>
>  |     Cc: Ingo Molnar <mingo@...hat.com>
>  |     Acked-by: Peter Zijlstra <a.p.zijlstra@...llo.nl>
>  |     Acked-by: Thomas Gleixner <tglx@...utronix.de>
>  |     Signed-off-by: Johannes Berg <johannes.berg@...el.com>
>  |     Signed-off-by: Steven Rostedt <rostedt@...dmis.org>
> 
> Specifically using it to "correlate (existing) printk debugging with
> other tracing" is now broken.

It is pity that it was done in the console code in the first place.

printk() always used console_trylock() and the message was flushed
to the console only when the trylock succeeded. And it was always
deferred in NMI or when printed via printk_deferred().

> My proposal would be to fix the tracepoint like so:
> 
>  | --- a/kernel/printk/printk.c
>  | +++ b/kernel/printk/printk.c
>  | @@ -2002,8 +2002,6 @@ static void call_console_driver(struct console *con, const char *text, size_t le
>  |  {
>  |  	size_t dropped_len;
>  |  
>  | -	trace_console_rcuidle(text, len);
>  | -
>  |  	if (con->dropped && dropped_text) {
>  |  		dropped_len = snprintf(dropped_text, DROPPED_TEXT_MAX,
>  |  				       "** %lu printk messages dropped **\n",
>  | @@ -2178,6 +2176,8 @@ static u16 printk_sprint(char *text, u16 size, int facility,
>  |  		}
>  |  	}
>  |  
>  | +	trace_console_rcuidle(text, text_len);
>  | +
>  |  	return text_len;
>  |  }
> 
> This fixes the KFENCE and KCSAN tests.
> 
> Unless I hear objections, I'll prepare a patch explaining why we need to
> fix the tracepoint.

It makes perfect sense to me.

Note that there is one difference. The original tracepoint stored the
string with the console header (loglevel + timestamp), see
info_print_prefix(). The new code will store "only" the plain message.

But the new code should be more user friendly. The printk() message
will be sorted with the other tracing messages out of box. Users will
not longer need to use the printk timestamp to find when it was
actually printed.

Best Regards,
Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ