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]
Message-ID: <fdd5c1c2-41f2-4d74-a5e0-444c1d2a0a81@sirena.org.uk>
Date: Tue, 4 Mar 2025 14:35:34 +0000
From: Mark Brown <broonie@...nel.org>
To: Zxyan Zhu <zxyan20@....com>
Cc: gregkh@...uxfoundation.org, rafael@...nel.org, dakr@...nel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] regmap: debugfs: Fix name collision without atomic
 operations

On Tue, Mar 04, 2025 at 10:24:52PM +0800, Zxyan Zhu wrote:

> Changes since v1:
> - Replaced atomic_read + atomic_inc with atomic_inc_return.
> - Added atomic_dec in the error path to maintain index consistency.
> - Updated the commit message to clarify the fix.
> 
> Signed-off-by: Zxyan Zhu <zxyan20@....com>
> ---

As covered in submitting-patches.rst the inter-version changelog should
be after the ---.

> -		map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d",
> -						dummy_index);
> -		if (!map->debugfs_name)
> +		index = atomic_inc_return(&dummy_index);
> +		map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d", index);
> +		if (!map->debugfs_name) {
> +			atomic_dec(&dummy_index);

Adding the decrement seems racy, we could increment again between
getting index and kasprintf() failing so might not get back to the
starting point.  It'd be a little messy to skip a number but it doesn't
really matter, and if we're under that much memory pressure probably
nobody's even going to look, so I don't see any reason to decrement.

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ