Commit ee4784a8 authored by Johannes Thumshirn's avatar Johannes Thumshirn Committed by Jens Axboe
Browse files

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: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202602020718.GUEIRyG9-lkp@intel.com/


Fixes: 113cbd62 ("blktrace: pass blk_user_trace2 to setup functions")
Signed-off-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 65d466b6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -793,7 +793,7 @@ int blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
		return PTR_ERR(bt);
	}
	blk_trace_setup_finalize(q, name, 1, bt, &buts2);
	strcpy(buts.name, buts2.name);
	strscpy(buts.name, buts2.name, BLKTRACE_BDEV_SIZE);
	mutex_unlock(&q->debugfs_mutex);

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