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: <alpine.LSU.2.21.2010301008160.22360@pobox.suse.cz>
Date:   Fri, 30 Oct 2020 10:13:50 +0100 (CET)
From:   Miroslav Benes <mbenes@...e.cz>
To:     Steven Rostedt <rostedt@...dmis.org>
cc:     linux-kernel@...r.kernel.org,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>, nstange@...e.de
Subject: Re: [PATCH 1/9] ftrace: Move the recursion testing into global
 headers

Hi,

> +static __always_inline int trace_get_context_bit(void)
> +{
> +	int bit;
> +
> +	if (in_interrupt()) {
> +		if (in_nmi())
> +			bit = 0;
> +
> +		else if (in_irq())
> +			bit = 1;
> +		else
> +			bit = 2;
> +	} else
> +		bit = 3;
> +
> +	return bit;
> +}
> +
> +static __always_inline int trace_test_and_set_recursion(int start, int max)
> +{
> +	unsigned int val = current->trace_recursion;
> +	int bit;
> +
> +	/* A previous recursion check was made */
> +	if ((val & TRACE_CONTEXT_MASK) > max)
> +		return 0;
> +
> +	bit = trace_get_context_bit() + start;
> +	if (unlikely(val & (1 << bit)))
> +		return -1;
> +
> +	val |= 1 << bit;
> +	current->trace_recursion = val;
> +	barrier();
> +
> +	return bit;
> +}

how does this work in case of NMI? trace_get_context_bit() returns 0 (it 
does not change later in the patch set). "start" in 
trace_test_and_set_recursion() is 0 zero too as used later in the patch 
set by ftrace_test_recursion_trylock(). So trace_test_and_set_recursion() 
returns 0. That is perfectly sane, but then...

> +static __always_inline void trace_clear_recursion(int bit)
> +{
> +	unsigned int val = current->trace_recursion;
> +
> +	if (!bit)
> +		return;

... the bit is not cleared here.

> +	bit = 1 << bit;
> +	val &= ~bit;
> +
> +	barrier();
> +	current->trace_recursion = val;
> +}

Thanks
Miroslav

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ