https://github.com/torvalds/linux
Revision d15dcd0f1a4753b57e66c64c8dc2a9779ff96aab authored by Dan Carpenter on 08 May 2024, 07:43:04 UTC, committed by Keith Busch on 08 May 2024, 13:10:32 UTC
The nsid value is a u32 that comes from nvmet_req_find_ns().  It's
endian data and we're on an error path and both of those raise red
flags.  So let's make this safer.

1) Make the buffer large enough for any u32.
2) Remove the unnecessary initialization.
3) Use snprintf() instead of sprintf() for even more safety.
4) The sprintf() function returns the number of bytes printed, not
   counting the NUL terminator. It is impossible for the return value to
   be <= 0 so delete that.

Fixes: 505363957fad ("nvmet: fix nvme status code when namespace is disabled")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 34cfb09
History
Tip revision: d15dcd0f1a4753b57e66c64c8dc2a9779ff96aab authored by Dan Carpenter on 08 May 2024, 07:43:04 UTC
nvmet: prevent sprintf() overflow in nvmet_subsys_nsid_exists()
Tip revision: d15dcd0
File Mode Size
Documentation
LICENSES
arch
block
certs
crypto
drivers
fs
include
init
io_uring
ipc
kernel
lib
mm
net
rust
samples
scripts
security
sound
tools
usr
virt
.clang-format -rw-r--r-- 21.7 KB
.cocciconfig -rw-r--r-- 59 bytes
.editorconfig -rw-r--r-- 672 bytes
.get_maintainer.ignore -rw-r--r-- 194 bytes
.gitattributes -rw-r--r-- 105 bytes
.gitignore -rw-r--r-- 2.0 KB
.mailmap -rw-r--r-- 38.0 KB
.rustfmt.toml -rw-r--r-- 369 bytes
COPYING -rw-r--r-- 496 bytes
CREDITS -rw-r--r-- 101.8 KB
Kbuild -rw-r--r-- 2.5 KB
Kconfig -rw-r--r-- 555 bytes
MAINTAINERS -rw-r--r-- 730.0 KB
Makefile -rw-r--r-- 66.2 KB
README -rw-r--r-- 726 bytes

README

back to top