From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 217924A6CD1; Tue, 15 Sep 2026 18:30:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789497023; cv=none; b=UrbuLHUZ/DWUitNC2KlhDW+TWonkBWZFuB2UDs3s3+1mnqscNoa7FBlWmzUqxW4iYlL/WVVsD8uarFny6RJLhosVi5veBMEZK5s1O61LPjAFODZA8E1xLuZzOHQbi/2x+veueZs/6Z7zvAk5n0zEmOKrcqB0xCGBjR0g+0xhhgA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789497023; c=relaxed/simple; bh=pKH8xO25YwnfpC2mXfUbhQkwTcYQqjJEajFuWg/A4u8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nQ+nuCzFOZKDcvdE/W2DtkdCK07ZQ9EOB7PXALXokMT9HzIlJBXxT/IyCvPHxHCEEiNXsM7hCCDg1Pw9IYFKz0ONc5yTNZFh/LYBT6qVQkKe7LblnsNkXqdFHd9pgXj/loAgW2Uyum8X98wS2Q9A6j3bQ7M6PiqnDWKBSnqn5Lc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FtG1AIAh; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FtG1AIAh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE75C1F00898; Tue, 15 Sep 2026 18:30:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789497021; bh=zCJx1lMoPaoDeiIN5oezRLV8MqYpA3JhuUg8Z+dhoag=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=FtG1AIAh8Ifu90TvPASnvJLKq/3hHoybYyG8CBtKd2A3Tko5EoQZmhxlykHybSWCY H6+cZEX9BUB3VzICpj+OZxPJ673u94nnolr9H+SDA6dBcoGGYAc9yHJcjV+Ep8BP0l el5biVBlyvnMpvBBdnmFKteUXHpcuI8Bb8Pu3nE8NtDNIpu6JJu8fFsiOvrLa3Qrgq NkHBRSaDsJkBM6eE9SQ++npMsQoPqmrvJCP6/7TZu7tvF19A4a5+2+kwcqpI8v/iuX YN51bg9WV0sHN4tZ47tD/7Vxl/N2tA6azTTrtrat6edEQApqlwzt/pVbGgznFVhGNY okL3wnYQoU9Ng== Date: Tue, 15 Sep 2026 11:30:21 -0700 From: Kees Cook To: Bill Wendling Cc: linux-kernel@vger.kernel.org, codemender-patching+linux@google.com, Russell King , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Ian Abbott , H Hartley Sweeten , Tony Luck , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Matthew Brost , Thomas =?iso-8859-1?Q?Hellstr=F6m?= , Rodrigo Vivi , Dmitry Torokhov , Matthias Schwarzott , Mauro Carvalho Chehab , Tony Nguyen , Przemek Kitszel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Arend van Spriel , Rob Herring , Saravana Kannan , Krzysztof Kozlowski , Sylwester Nawrocki , Peter Griffin , Alim Akhtar , Linus Walleij , Anil Gurumurthy , Sudarsana Kalluru , "Martin K. Petersen" , Trond Myklebust , Anna Schumaker , Mike Marshall , Martin Brandenburg , Jiri Pirko , Simon Horman , Chuck Lever , Jeff Layton , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jaroslav Kysela , Takashi Iwai , Andrew Morton , "Mike Rapoport (Microsoft)" , Kanglong Wang , Tiezhu Yang , Qiang Ma , Randy Dunlap , Pengpeng Hou , Ard Biesheuvel , Breno Leitao , Thorsten Blum , Harshit Mogalapalli , Greg Kroah-Hartman , Lyude Paul , Ashutosh Desai , Imre Deak , Dmitry Baryshkov , Johan Hovold , Johannes Berg , Miri Korenblit , Alexander Stein , Cryolitia PukNgae , Jiaming Zhang , Will Porter , Cen Zhang , =?iso-8859-1?Q?C=E1ssio?= Gabriel , Rong Zhang , Arun Raghavan , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-edac@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, brcm80211@lists.linux.dev, brcm80211-dev-list.pdl@broadcom.com, devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-gpio@vger.kernel.org, linux-scsi@vger.kernel.org, linux-nfs@vger.kernel.org, devel@lists.orangefs.org, linux-hardening@vger.kernel.org, linux-sound@vger.kernel.org Subject: Re: [PATCH 28/28] drm/xe/pf: Refactor strlcat() to seq_buf in sched_group_engines_read() Message-ID: <202609151126.29464A5E1@keescook> References: <20260915081910.4142719-1-morbo@google.com> <20260915081910.4142719-29-morbo@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260915081910.4142719-29-morbo@google.com> On Tue, Sep 15, 2026 at 08:18:45AM +0000, Bill Wendling wrote: > 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/ 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 > 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. > 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