diff options
author | Gustavo A. R. Silva <gustavo@embeddedor.com> | 2018-03-16 08:21:08 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-03-16 15:40:19 +0100 |
commit | 225b3dc92da1a3198cf687b13435fef952757a8f (patch) | |
tree | afea7f22d030ab0a6dead88cbb22fdc5d2b1019c /drivers/usb/host/xhci-plat.c | |
parent | 7bb9aedac66cc768b255e60f97a137935dd818d8 (diff) | |
download | linux-225b3dc92da1a3198cf687b13435fef952757a8f.tar.gz linux-225b3dc92da1a3198cf687b13435fef952757a8f.tar.bz2 linux-225b3dc92da1a3198cf687b13435fef952757a8f.zip |
USB: wusbcore: crypto: Remove VLA usage
In preparation to enabling -Wvla, remove VLA and replace it
with dynamic memory allocation instead.
The use of stack Variable Length Arrays needs to be avoided, as they
can be a vector for stack exhaustion, which can be both a runtime bug
or a security flaw. Also, in general, as code evolves it is easy to
lose track of how big a VLA can get. Thus, we can end up having runtime
failures that are hard to debug.
Also, fixed as part of the directive to remove all VLAs from
the kernel: https://lkml.org/lkml/2018/3/7/621
Notice that in this particular case, an alternative to kzalloc is kcalloc,
in which case the code would look as follows instead:
iv = kcalloc(crypto_skcipher_ivsize(tfm_cbc), sizeof(*iv), GFP_KERNEL);
but if the data type of _iv_ never changes, or the type size is always one
byte, kzalloc is good enough.
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host/xhci-plat.c')
0 files changed, 0 insertions, 0 deletions