RE: [PATCH] tty/sysrq: Make local variable 'killer' in sysrq_handle_crash() global

From: David Laight
Date: Tue Sep 18 2018 - 07:44:26 EST


From: Matthias Kaehlcke
> Sent: 17 September 2018 22:33
>
> sysrq_handle_crash() dereferences a NULL pointer on purpose to force
> an exception, the local variable 'killer' is assigned to NULL and
> dereferenced later. Clang detects the NULL pointer dereference at compile
> time and emits a BRK instruction (on arm64) instead of the expected NULL
> pointer exception. Change 'killer' to a global variable (and rename it
> to 'sysrq_killer' to avoid possible clashes) to prevent Clang from
> detecting the condition. By default global variables are initialized
> with zero/NULL in C, therefore an explicit initialization is not needed.

You need an explicit initialiser in order to make it global data
rather than a common section.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)