RE: [PATCH] x86/mce/dev-mcelog: Fix potential memory access error

From: Luck, Tony
Date: Mon Mar 29 2021 - 12:13:18 EST


- set_bit(MCE_OVERFLOW, (unsigned long *)&mcelog->flags);
+ mcelog->flags |= BIT(MCE_OVERFLOW);

set_bit() is an atomic operation because it might race with the code to
get and clear this bit:

do {
flags = mcelog->flags;
} while (cmpxchg(&mcelog->flags, flags, 0) != flags);

Originally this was needed because mcelog could be called from #MC
context.

That's all changed now and the machine check notifier chain routines are
called in a kernel thread. So some other locking (mutex?) could be used
to protect access to mcelog->flags.

-Tony