Skip to content

Commit 107a231

Browse files
jpoimboeIngo Molnar
authored andcommitted
objtool, nvmet: Fix out-of-bounds stack access in nvmet_ctrl_state_show()
The csts_state_names[] array only has six sparse entries, but the iteration code in nvmet_ctrl_state_show() iterates seven, resulting in a potential out-of-bounds stack read. Fix that. Fixes the following warning with an UBSAN kernel: vmlinux.o: warning: objtool: .text.nvmet_ctrl_state_show: unexpected end of section Fixes: 649fd41 ("nvmet: add debugfs support") Reported-by: kernel test robot <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Sagi Grimberg <[email protected]> Cc: Chaitanya Kulkarni <[email protected]> Cc: Linus Torvalds <[email protected]> Link: https://lore.kernel.org/r/f1f60858ee7a941863dc7f5506c540cb9f97b5f6.1742852847.git.jpoimboe@kernel.org Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
1 parent 76e51db commit 107a231

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/nvme/target/debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static int nvmet_ctrl_state_show(struct seq_file *m, void *p)
7878
bool sep = false;
7979
int i;
8080

81-
for (i = 0; i < 7; i++) {
81+
for (i = 0; i < ARRAY_SIZE(csts_state_names); i++) {
8282
int state = BIT(i);
8383

8484
if (!(ctrl->csts & state))

0 commit comments

Comments
 (0)