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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <871pwbnj8k.ffs@tglx>
Date: Thu, 06 Feb 2025 17:14:19 +0100
From: Thomas Gleixner <tglx@...utronix.de>
To: Waiman Long <llong@...hat.com>, Ingo Molnar <mingo@...hat.com>, Borislav
 Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>, Peter
 Zijlstra <peterz@...radead.org>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org, "H. Peter Anvin"
 <hpa@...or.com>, Rik van Riel <riel@...riel.com>
Subject: Re: [PATCH v4] x86/nmi: Add an emergency handler in nmi_desc & use
 it in nmi_shootdown_cpus()

On Wed, Feb 05 2025 at 21:46, Waiman Long wrote:
> On 2/5/25 4:20 AM, Thomas Gleixner wrote:
>>> +int set_emergency_nmi_handler(unsigned int type, nmi_handler_t handler)
>>> +{
>>> +	struct nmi_desc *desc = nmi_to_desc(type);
>>> +	nmi_handler_t orig = NULL;
>>> +
>>> +	if (!handler) {
>>> +		orig = READ_ONCE(desc->emerg_handler);
>>> +		WARN_ON_ONCE(!orig);
>>> +	}
>>> +
>>> +	if (try_cmpxchg(&desc->emerg_handler, &orig, handler))
>>> +		return 0;
>> What's the point of this cmpxchg()? What's the concurrency problem this
>> tries to address?
> It is because I am not sure if there can only be one instance of 
> nmi_shootdown_cpus() at any time. If there can't be more than one 
> instance, I can remove the atomic instruction.

There are two ways to get there:

  1) crash(), which installs a handler

  2) emergency_reboot(), which sets the handler to NULL

If they interfere, then the callback is the least of your
worries. That's already broken today in so many other ways.

> I do remove the smp_wmb() in nmi_shootdown_cpus(). If I don't use an
> atomic instruction, I will have to add it smp_wmb() here.

Right.

Thanks,

        tglx

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ