From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A27973C1D58 for ; Fri, 14 Aug 2026 14:46:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786718824; cv=none; b=FRW8sxX8UOjkEx78bIclhOK3Ga2JUeWBjViVYAdadpfjdqR480UG18rT2u6R+lAEJtxeGhhN0zDEBdqVGLqn6XGaW/NTUhAZlhQs6S4KdYt5q3SoZU1ZirtevwMWcxS1gKysqz5txWxnwQGglDN4tYR/h0oFsIEM9UB58zjCBT8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786718824; c=relaxed/simple; bh=6Ju9cxsbKIzu4nS8o05SDUO/qtHPRUYljZsU/spdKGQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=X7m0ebgsC9Q+s07HtHWO6dc+dB48HrWuPqgWW0yUyzwZP/5mVGMGj2wJqrBqyboMOqByLOYgDpbhQxrcVCOZmWRIx48VF/adXaNLi5h6ZGtNJLI0pHnEaZDLEsvbdK5kXJhV6kK5JsLVbGVO7Fmest4q2mSwohXYtNDOvl9oPQE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Kvz21zVA; arc=none smtp.client-ip=91.218.175.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Kvz21zVA" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=6Ju9cxsbKIzu4nS8o05SDUO/qtHPRUYljZsU/spdKGQ=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1786718817; v=1; x=1787323617; b=Kvz21zVA7Wns+Y7BglWgOzVIYdQYVqp5HfF4nYB8F+fT+DkuIZ93rTiV5oi3nVZ3Rmk1jDSU ALo10Dsqre83qrpY0hCv2siRUnC/nnKMDRftDzGlqMeEjjDJ9FYR+LblSNFdMlAG224m2mMswIR ZFDwNLUOUaHgFrspAno9sNnQ= X-Envelope-To: linux-kernel@vger.kernel.org Received: from linux.dev (62.216.208.217) by mta11.migadu.com with ESMTPS id 0a40309b412adbeb; Fri, 14 Aug 2026 14:46:57 +0000 X-Migadu-Flow: FLOW_OUT Date: Fri, 14 Aug 2026 16:46:51 +0200 From: Thorsten Blum To: "Christophe Leroy (CS GROUP)" Cc: Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Kees Cook , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] powerpc: fsl_rio: Use snprintf() in fsl_rio_setup() Message-ID: References: <20260630144951.692473-2-thorsten.blum@linux.dev> <44f93c64-55e9-4240-bc2c-be49280219f9@kernel.org> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <44f93c64-55e9-4240-bc2c-be49280219f9@kernel.org> On Fri, Aug 14, 2026 at 02:26:24PM +0200, Christophe Leroy (CS GROUP) wrote: > Le 30/06/2026 à 16:49, Thorsten Blum a écrit : > > While the current code works correctly, replace the unbounded sprintf() > > with the safer snprintf() in fsl_rio_setup() to follow secure coding > > best practices. > > > > Signed-off-by: Thorsten Blum > > --- > > arch/powerpc/sysdev/fsl_rio.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c > > index eb55dabb4748..077c03cd93e4 100644 > > --- a/arch/powerpc/sysdev/fsl_rio.c > > +++ b/arch/powerpc/sysdev/fsl_rio.c > > @@ -612,7 +612,7 @@ static int fsl_rio_setup(struct platform_device *dev) > > kfree(port); > > continue; > > } > > - sprintf(port->name, "RIO mport %d", i); > > + snprintf(port->name, sizeof(port->name), "RIO mport %d", i); > > Are you sure it is correct ? > > Shouldn't it be sizeof(port->name) - 1 ? snprintf() takes the destination buffer size (including the NUL) as its second argument, so sizeof(port->name) should be correct.