diff options
author | Arnd Bergmann <arnd@arndb.de> | 2018-04-12 18:16:07 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-04-12 18:58:27 +0300 |
commit | 6038aa532a224da68c478f34f4dbce33c47169e6 (patch) | |
tree | ffb4f254e2d8a39ee400ea903e301a5b4aea269b /.cocciconfig | |
parent | 74c6c71530847808d4e3be7b205719270efee80c (diff) | |
download | linux-6038aa532a224da68c478f34f4dbce33c47169e6.tar.xz |
nvme: target: fix buffer overflow
nvmet_execute_get_disc_log_page() passes a fixed-length string into
nvmet_format_discovery_entry(), which then does a longer memcpy() on
it, as pointed out by gcc-8:
In function 'nvmet_format_discovery_entry',
inlined from 'nvmet_execute_get_disc_log_page' at drivers/nvme/target/discovery.c:126:4:
drivers/nvme/target/discovery.c:62:2: error: 'memcpy' forming offset [38, 223] is out of the bounds [0, 37] [-Werror=array-bounds]
memcpy(e->subnqn, subsys_nqn, NVMF_NQN_SIZE);
Using strncpy() will make this well-defined, filling the rest of the
buffer with zeroes, under the assumption that the input is either
a NUL-terminated string, or a byte sequence containing no zeroes.
If the input is a string that is longer than NVMF_NQN_SIZE, we
continue to have no NUL-termination in the output.
Fixes: a07b4970f464 ("nvmet: add a generic NVMe target")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to '.cocciconfig')
0 files changed, 0 insertions, 0 deletions