From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7953DC88E5C for ; Wed, 16 Sep 2026 07:36:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8EAD710E7E6; Wed, 16 Sep 2026 07:35:22 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="FtG1AIAh"; dkim-atps=neutral Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 07F9910E28E; Tue, 15 Sep 2026 18:30:23 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 2728C600CB; Tue, 15 Sep 2026 18:30:22 +0000 (UTC) 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260915081910.4142719-29-morbo@google.com> X-Mailman-Approved-At: Wed, 16 Sep 2026 07:35:16 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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