Thread (47 messages) 47 messages, 8 authors, 13d ago

Re: [PATCH 28/28] drm/xe/pf: Refactor strlcat() to seq_buf in sched_group_engines_read()

From: Kees Cook <kees@kernel.org>
Date: 2026-09-15 18:30:27
Also in: dri-devel, intel-wired-lan, intel-xe, linux-devicetree, linux-edac, linux-gpio, linux-hardening, linux-input, linux-media, linux-mips, linux-nfs, linux-samsung-soc, linux-scsi, linux-sound, linux-wireless, lkml, loongarch

On Tue, Sep 15, 2026 at 08:18:45AM +0000, Bill Wendling wrote:
quoted hunk ↗ jump to hunk
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c
This is the same file touched as
https://lore.kernel.org/all/20260915081910.4142719-28-morbo@google.com/ (local)
and doing the same thing, roughly? I think it'd be best to combine
these, especially since one depends on the other's addition of seq_buf.h
quoted hunk ↗ jump to hunk
index 5db7fc067c4d..548a50f74422 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c
@@ -377,8 +377,10 @@ static ssize_t sched_group_engines_read(struct file *file, char __user *buf,
 	struct xe_hw_engine *hwe;
 	enum xe_hw_engine_id id;
 	char engines[128];
+	struct seq_buf s;
+	const char *s_str;
 
-	engines[0] = '\0';
+	seq_buf_init(&s, engines, sizeof(engines));
As with the others, DECLARE_SEQ_BUF should be used.
quoted hunk ↗ jump to hunk
 	if (group < num_groups) {
 		for_each_hw_engine(hwe, gt, id) {
@@ -386,15 +388,14 @@ static ssize_t sched_group_engines_read(struct file *file, char __user *buf,
 			u16 guc_logical_instance = xe_hwe_guc_logical_instance(hwe);
 			u32 mask = groups[group].engines[guc_class];
 
-			if (mask & BIT(guc_logical_instance)) {
-				strlcat(engines, hwe->name, sizeof(engines));
-				strlcat(engines, " ", sizeof(engines));
-			}
+			if (mask & BIT(guc_logical_instance))
+				seq_buf_printf(&s, "%s ", hwe->name);
 		}
-		strlcat(engines, "\n", sizeof(engines));
+		seq_buf_puts(&s, "\n");
 	}
 
-	return simple_read_from_buffer(buf, count, ppos, engines, strlen(engines));
+	s_str = seq_buf_str(&s);
+	return simple_read_from_buffer(buf, count, ppos, s_str, strlen(s_str));
While this is the correct length, it does illustrate why I think we need
a new seq_buf helper to get the strlen result detected from NUL
termination like seq_buf_str().

-Kees

-- 
Kees Cook
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help