mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Greg KH" <gregkh@linuxfoundation.org>
Cc: "Yichong Chen" <chenyichong@uniontech.com>, <rafael@kernel.org>,
	<djakov@kernel.org>, <quic_mdtipton@quicinc.com>,
	<vkoul@kernel.org>, <yung-chuan.liao@linux.intel.com>,
	<pierre-louis.bossart@linux.dev>, <driver-core@lists.linux.dev>,
	<linux-kernel@vger.kernel.org>, <linux-pm@vger.kernel.org>,
	<linux-sound@vger.kernel.org>
Subject: Re: [PATCH v3 0/3] debugfs: make debugfs_create_str() read-only
Date: Thu, 01 Oct 2026 15:49:54 +0200	[thread overview]
Message-ID: <DLTJT271O5MJ.29DXT8VS9712I@kernel.org> (raw)
In-Reply-To: <2026100139-deviancy-direction-edea@gregkh>

On Thu Oct 1, 2026 at 3:19 PM CEST, Greg KH wrote:
> On Thu, Oct 01, 2026 at 03:10:45PM +0200, Danilo Krummrich wrote:
>> On Thu Oct 1, 2026 at 2:51 PM CEST, Greg KH wrote:
>> > On Fri, Aug 07, 2026 at 06:00:50PM +0800, Yichong Chen wrote:
>> >> debugfs_create_str() has a generic write implementation that replaces the
>> >> backing string.  Concurrent writers can race and free the same old string
>> >> twice.
>> >> 
>> >> Instead of adding more locking to the generic helper, convert the existing
>> >> writable in-tree users to local file operations and make
>> >> debugfs_create_str() read-only.
>> >> 
>> >> Changes since v2:
>> >> - Use scoped mutex guards in the interconnect and SoundWire conversions.
>> >> - Clarify why GFP_KERNEL is safe in the interconnect conversion after the
>> >>   RCU read-side critical section is removed.
>> >> - Drop the unnecessary firmware_file = NULL assignment in the SoundWire
>> >>   exit path.
>> >> - Use WARN() instead of WARN_ONCE() so each writable debugfs_create_str()
>> >>   caller can be reported.
>> >
>> > Sorry for the delay, now applied.
>> 
>> This series fell through the cracks on my end. I also reported this issue in [1]
>> and I agree making debugfs_create_str() read-only is the best fix for now.
>> 
>> However, it duplicates code and I think having a proper helper as suggested in
>> [1] would be nice follow-up.
>> 
>> [1] https://lore.kernel.org/driver-core/DLPDB44JJRGJ.3K6JNS746M7QC@kernel.org/
>
> Yes, that would be nice, but for read-only debugfs strings, let's keep
> writable ones away if at all possible :)

The two converted subsystems now have identical code that can easily be
generalized. And I think we have other users that open code this too.

For instance, soundwire would collapse to just:

In sdw_debugfs_init():

	/* Initialize struct debugfs_string */
	ret = debugfs_string_create(&firmware_file, "");

In sdw_debugfs_exit():

	/* Free struct debugfs_string */
	debugfs_string_free(&firmware_file);

In sdw_slave_debugfs_init():

	debugfs_create_str("firmware_file", 0600, d, &firmware_file);

In cmd_go():

	scoped_guard(debugfs_string, &firmware_file)
		ret = request_firmware(&fw,
				       debugfs_string_read_locked(&firmware_file),
				       &slave->dev);

Thanks,
Danilo

      reply	other threads:[~2026-10-01 13:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07 10:00 Yichong Chen
2026-08-07 10:00 ` [PATCH v3 1/3] interconnect: debugfs: replace writable string helper Yichong Chen
2026-08-07 10:00 ` [PATCH v3 2/3] soundwire: " Yichong Chen
2026-08-07 10:00 ` [PATCH v3 3/3] debugfs: make debugfs_create_str() read-only Yichong Chen
2026-10-01 12:51 ` [PATCH v3 0/3] " Greg KH
2026-10-01 13:10   ` Danilo Krummrich
2026-10-01 13:19     ` Greg KH
2026-10-01 13:49       ` Danilo Krummrich [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DLTJT271O5MJ.29DXT8VS9712I@kernel.org \
    --to=dakr@kernel.org \
    --cc=chenyichong@uniontech.com \
    --cc=djakov@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=quic_mdtipton@quicinc.com \
    --cc=rafael@kernel.org \
    --cc=vkoul@kernel.org \
    --cc=yung-chuan.liao@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®