[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aSWPH51A8NvoD9cm@infradead.org>
Date: Tue, 25 Nov 2025 03:12:31 -0800
From: Christoph Hellwig <hch@...radead.org>
To: Huiwen He <hehuiwen@...inos.cn>
Cc: Jens Axboe <axboe@...nel.dk>, Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH] blk-trace: Fix potential buffer overflow in
blk_trace_setup()
On Tue, Nov 25, 2025 at 04:24:20PM +0800, Huiwen He wrote:
> The legacy struct blk_user_trace_setup has a 32-byte name field,
> while buts2->name is a 64-byte buffer (BLKTRACE_BDEV_SIZE2).
>
> Since commit 113cbd62824a ("blktrace: pass blk_user_trace2 to setup
> functions"), blk_trace_setup() copied buts2->name into buts->name
> using strcpy(). strcpy() performs no bounds checking on the destination
> buffer, which can overflow if the source string exceeds 31 characters.
>
> Replace deprecated [1] strcpy() with strscpy() to ensure proper bounds
> checking and prevent potential buffer overflow.
At this point all this has been checked as part of the setup. If you
hatr strcpy with passing, just doing a memcpy of BLKTRACE_BDEV_SIZE2
is the saner alternative.
Powered by blists - more mailing lists