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] [day] [month] [year] [list]
Message-ID: <20251215202244.GK3195@twin.jikos.cz>
Date: Mon, 15 Dec 2025 21:22:44 +0100
From: David Sterba <dsterba@...e.cz>
To: David Sterba <dsterba@...e.cz>
Cc: david laight <david.laight@...box.com>,
	Thorsten Blum <thorsten.blum@...ux.dev>, Chris Mason <clm@...com>,
	David Sterba <dsterba@...e.com>, linux-btrfs@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] btrfs: Replace memcpy + NUL termination in _btrfs_printk

On Wed, Dec 03, 2025 at 02:45:58PM +0100, David Sterba wrote:
> On Sun, Nov 30, 2025 at 11:06:40AM +0000, david laight wrote:
> > On Sun, 30 Nov 2025 01:55:17 +0100
> > Thorsten Blum <thorsten.blum@...ux.dev> wrote:
> > 
> > > Use strscpy() to copy the NUL-terminated source string 'fmt' to the
> > > destination buffer 'lvl' instead of using memcpy() followed by a manual
> > > NUL termination.  No functional changes.
> > 
> > Why?
> > The code has just got the length of part of the format string, it wants
> > a copy of it with a '\0' terminator.
> > So memcpy() is correct and strscpy() just expensive.
> > The code is actually strange (and strangely written), but 'size' is always 2.
> > 
> > One might question why btrfs has to invent its own 'printk' scheme...
> 
> The first code of the printk helper was added in 2012 as 4da35113426d
> ("btrfs: add varargs to btrfs_error") and since then it evolved a lot
> and I'm not sure we still need it.
> 
> Own helpers for messages insert the filesystem identification in front
> of the message. There's per-level ratelimit which needs the parsing
> added in commit 35f4e5e6f198 ("btrfs: Add ratelimit to btrfs printing").
> This can be possibly removed as we can ratelimit specific messages if
> they're known to be noisy.

For the record the level parsing is now gone
https://lore.kernel.org/linux-btrfs/f884e72071839aeb0f8b77e79a6ae2d0bc8adf78.1765299883.git.dsterba@suse.com/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ