Skip to content

Commit ee4784a

Browse files
morbidrsaaxboe
authored andcommitted
block: don't use strcpy to copy blockdev name
0-day bot flagged the use of strcpy() in blk_trace_setup(), because the source buffer can theoretically be bigger than the destination buffer. While none of the current callers pass a string bigger than BLKTRACE_BDEV_SIZE, use strscpy() to prevent eventual future misuse and silence the checker warnings. Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/r/202602020718.GUEIRyG9-lkp@intel.com/ Fixes: 113cbd6 ("blktrace: pass blk_user_trace2 to setup functions") Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 65d466b commit ee4784a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

kernel/trace/blktrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ int blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
793793
return PTR_ERR(bt);
794794
}
795795
blk_trace_setup_finalize(q, name, 1, bt, &buts2);
796-
strcpy(buts.name, buts2.name);
796+
strscpy(buts.name, buts2.name, BLKTRACE_BDEV_SIZE);
797797
mutex_unlock(&q->debugfs_mutex);
798798

799799
if (copy_to_user(arg, &buts, sizeof(buts))) {

0 commit comments

Comments
 (0)