lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 08 Apr 2024 20:05:12 +0200
From: "Arnd Bergmann" <arnd@...db.de>
To: "Steven Rostedt" <rostedt@...dmis.org>, "Arnd Bergmann" <arnd@...nel.org>
Cc: linux-kernel@...r.kernel.org, "Jens Axboe" <axboe@...nel.dk>,
 "Masami Hiramatsu" <mhiramat@...nel.org>,
 "Mathieu Desnoyers" <mathieu.desnoyers@...icios.com>,
 linux-block@...r.kernel.org, linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH 08/11] blktrace: convert strncpy() to strscpy_pad()

On Thu, Mar 28, 2024, at 15:14, Steven Rostedt wrote:
> On Thu, 28 Mar 2024 15:04:52 +0100
>> 
>> diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
>> index d5d94510afd3..95a00160d465 100644
>> --- a/kernel/trace/blktrace.c
>> +++ b/kernel/trace/blktrace.c
>> @@ -524,8 +524,7 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
>>  	if (!buts->buf_size || !buts->buf_nr)
>>  		return -EINVAL;
>>  
>> -	strncpy(buts->name, name, BLKTRACE_BDEV_SIZE);
>> -	buts->name[BLKTRACE_BDEV_SIZE - 1] = '\0';
>> +	strscpy(buts->name, name, BLKTRACE_BDEV_SIZE);
>
> The commit message says "Using strscpy_pad()" but it doesn't do so in the
> patch.
>
> Rule 12 of debugging: "When the comment and the code do not match, they are
>                        probably both wrong"

Thanks for double-checking this, I had a hard time deciding which
one to use here and ended up with an obviously inconsistent version.

I've changed it now to strscpy_pad() for v2, which is the slightly
safer choice here. The non-padding version would still not leak
kernel data but would write back user-provided data after the
padding instead of always zeroing it.

    Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ