Re: [PATCH RESEND v2 23/30] dyndbg: let procfs copy in writes to /proc/dynamic_debug/control

From
sashiko-bot@kernel.org
Date
2026-11-05 19:58:29
Also in
dri-devel, kexec, linux-ext4, linux-hwmon, linux-input, linux-m68k, linux-mm, linux-pci, linux-raid, linux-s390, linux-scsi, linux-serial, linux-sound, linux-usb, sparclinux
Reply to
Christian Brauner, 2026-11-04
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] dyndbg: split declaration and assignment of __free() in ddebug_proc_write()
--

commit 1bfaabab91de2989a4d10ae03eef349ab77809d6
Author: Christian Brauner [off-list ref]

dyndbg: let procfs copy in writes to /proc/dynamic_debug/control

This commit factors the query execution logic out of ddebug_proc_write() into
ddebug_proc_write_buf() and switches proc_fops to use .proc_write_buf and
.proc_write_size so procfs copies in the user buffer before pinning the entry.
quoted hunk ↗ jump to hunk
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 64a2112908725..1d6012c9eb41f 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -1002,11 +1002,28 @@ __setup("dyndbg=", dyndbg_setup);
[ ... ]
quoted hunk ↗ jump to hunk
 static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf,
 				  size_t len, loff_t *offp)
 {
-	char *tmpbuf;
-	int ret;
+	char *tmpbuf __free(kfree) = NULL;
 
 	if (len == 0)
 		return 0;
@@ -1017,15 +1034,7 @@ static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf,
 	tmpbuf = memdup_user_nul(ubuf, len);
 	if (IS_ERR(tmpbuf))
 		return PTR_ERR(tmpbuf);
-	v2pr_info("read %zu bytes from userspace\n", len);
-
-	ret = ddebug_exec_queries(tmpbuf, NULL);
-	kfree(tmpbuf);
-	if (ret < 0)
-		return ret;
-
-	*offp += len;
-	return len;
+	return ddebug_proc_write_buf(file, tmpbuf, len, offp);
 }
[Severity: Low]
In ddebug_proc_write(), tmpbuf is declared with __free(kfree) = NULL at the
top of the function before the early length checks and then assigned later via
memdup_user_nul().

Per the cleanup.h guidelines, could tmpbuf be defined and initialized in a
single statement at the allocation site instead:

	char *tmpbuf __free(kfree) = memdup_user_nul(ubuf, len);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261104-work-procfs-fs-v2-0-319e0f9a8aae@kernel.org?part=23
Thread (209 messages) 209 messages, 9 authors, last reply 23d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help