From 45888b40d2a6221d46bb69959e2600ddba71cc1f Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Sun, 22 Apr 2018 18:23:55 +0200 Subject: rslib: Allocate decoder buffers to avoid VLAs To get rid of the variable length arrays on stack in the RS decoder it's necessary to allocate the decoder buffers per control structure instance. All usage sites have been checked for potential parallel decoder usage and fixed where necessary. Kees confirmed that the pstore decoding is strictly single threaded so there should be no surprises. Allocate them in the rs control structure sized depending on the number of roots for the chosen codec and adapt the decoder code to make use of them. Document the fact that decode operations based on a particular rs control instance cannot run in parallel and the caller has to ensure that as it's not possible to provide a proper locking construct which fits all use cases. Signed-off-by: Thomas Gleixner Acked-by: Kees Cook Cc: Boris Brezillon Cc: Tony Luck Cc: Segher Boessenkool Cc: Kernel Hardening Cc: Richard Weinberger Cc: Mike Snitzer Cc: Anton Vorontsov Cc: Colin Cross Cc: Andrew Morton Cc: David Woodhouse Cc: Alasdair Kergon Signed-off-by: Kees Cook --- include/linux/rslib.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/linux/rslib.h') diff --git a/include/linux/rslib.h b/include/linux/rslib.h index 6703311beea3..5974cedd008c 100644 --- a/include/linux/rslib.h +++ b/include/linux/rslib.h @@ -50,9 +50,11 @@ struct rs_codec { /** * struct rs_control - rs control structure per instance * @codec: The codec used for this instance + * @buffers: Internal scratch buffers used in calls to decode_rs() */ struct rs_control { struct rs_codec *codec; + uint16_t buffers[0]; }; /* General purpose RS codec, 8-bit data width, symbol width 1-15 bit */ -- cgit v1.2.3-71-gd317