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

2021-03-29 Thread Luck, Tony
- 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;

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

2021-03-29 Thread Yang Li
Using set_bit() to set a bit in an integer is not a good idea, since the function expects an unsigned long as argument, which can be 64bit wide. Coverity reports this problem as High:Out-of-bounds access(INCOMPATIBLE_CAST) CWE119: Out-of-bounds access to a scalar Pointer "&mcelog->flags" points to