Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 113cbd62824a ("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>

authored by

Johannes Thumshirn and committed by
Jens Axboe
ee4784a8 65d466b6

+1 -1
+1 -1
kernel/trace/blktrace.c
··· 793 793 return PTR_ERR(bt); 794 794 } 795 795 blk_trace_setup_finalize(q, name, 1, bt, &buts2); 796 - strcpy(buts.name, buts2.name); 796 + strscpy(buts.name, buts2.name, BLKTRACE_BDEV_SIZE); 797 797 mutex_unlock(&q->debugfs_mutex); 798 798 799 799 if (copy_to_user(arg, &buts, sizeof(buts))) {