Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

m68k: Avoid VLA use in mangle_kernel_stack()

With gcc 7.3.0:

arch/m68k/kernel/signal.c: In function ‘mangle_kernel_stack’:
arch/m68k/kernel/signal.c:654:3: warning: ISO C90 forbids variable length array ‘buf’ [-Wvla]
unsigned long buf[fsize / 2]; /* yes, twice as much */
^~~~~~~~

Replace the variable size by the upper limit, which is 168 bytes.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>

+2 -1
+2 -1
arch/m68k/kernel/signal.c
··· 651 651 regs->vector = formatvec & 0xfff; 652 652 } else { 653 653 struct switch_stack *sw = (struct switch_stack *)regs - 1; 654 - unsigned long buf[fsize / 2]; /* yes, twice as much */ 654 + /* yes, twice as much as max(sizeof(frame.un.fmt<x>)) */ 655 + unsigned long buf[sizeof(((struct frame *)0)->un) / 2]; 655 656 656 657 /* that'll make sure that expansion won't crap over data */ 657 658 if (copy_from_user(buf + fsize / 4, fp, fsize))