diff options
author | Arnd Bergmann <arnd@arndb.de> | 2018-10-11 13:06:17 +0200 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@bootlin.com> | 2018-10-12 09:17:46 +0200 |
commit | f0fe77f601c3d6a821198f88f7adb0a05b8fe03e (patch) | |
tree | 39bf89a0fa0faad1bfc759e5bf3cd4ef4765ca0d /lib/test_module.c | |
parent | 0238df646e6224016a45505d2c111a24669ebe21 (diff) | |
download | op-kernel-dev-f0fe77f601c3d6a821198f88f7adb0a05b8fe03e.zip op-kernel-dev-f0fe77f601c3d6a821198f88f7adb0a05b8fe03e.tar.gz |
lib/bch: fix possible stack overrun
The previous patch introduced very large kernel stack usage and a Makefile
change to hide the warning about it.
From what I can tell, a number of things went wrong here:
- The BCH_MAX_T constant was set to the maximum value for 'n',
not the maximum for 't', which is much smaller.
- The stack usage is actually larger than the entire kernel stack
on some architectures that can use 4KB stacks (m68k, sh, c6x), which
leads to an immediate overrun.
- The justification in the patch description claimed that nothing
changed, however that is not the case even without the two points above:
the configuration is machine specific, and most boards never use the
maximum BCH_ECC_WORDS() length but instead have something much smaller.
That maximum would only apply to machines that use both the maximum
block size and the maximum ECC strength.
The largest value for 't' that I could find is '32', which in turn leads
to a 60 byte array instead of 2048 bytes. Making it '64' for future
extension seems also worthwhile, with 120 bytes for the array. Anything
larger won't fit into the OOB area on NAND flash.
With that changed, the warning can be enabled again.
Only linux-4.19+ contains the breakage, so this is only needed
as a stable backport if it does not make it into the release.
Fixes: 02361bc77888 ("lib/bch: Remove VLA usage")
Reported-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: stable@vger.kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Diffstat (limited to 'lib/test_module.c')
0 files changed, 0 insertions, 0 deletions