Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp134901lqb; Tue, 28 May 2024 10:50:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXz2xd9T7WlQMPbjpSMSCNkz/bIUQxelHEHyRN10Abvmro6p8qU/nPpseD+9zglluCj1fnkB1wb6oVC07K1lJpxmmlc8HFCgqt+TGra/A== X-Google-Smtp-Source: AGHT+IF/pFGb7z4BnWrNnkyfX8DNK0rUGd0nCPlAkvqHpFnZxZCOSU1izLdyiqcWP6ltzYKj/yLy X-Received: by 2002:a05:6a00:2c94:b0:6ed:d5f5:85e with SMTP id d2e1a72fcca58-6f8f2c74a8dmr13325721b3a.3.1716918649556; Tue, 28 May 2024 10:50:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716918649; cv=pass; d=google.com; s=arc-20160816; b=GU/6EJAuDuL+IEFFktVfkM9TduoAsD2k0hwpH4LBQljfawdq33eFH/2l+MPKk2B/1a 7cwQVKVD2Mhx3qlgzbA7UkkDJVHRlpIVZqccZK7xcW4W6J8/i9CEGp8EYG1/xqBk35u/ NTYb3JRd0rQfc1/tbYNhDnm5V7OzRq0U9va5KqLoOBc9sf+Qd7QFJtPHRH3a1v6CCRyl vUezUD+P3AheYYCUX2qIAeELC1w/k17tc0CVeD0fJWmJL4Ylx+LIaVBe9pwgFSR9TjOo CASm0wDE6Q7MkE8KAbDw+qaWJnXf1mX58QSvgxdetTyc121z4j3Iss0BlJ1JH8gr7meQ 0XAA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:organization:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=gtoURNCOY74CD9zYdt8tnhryGeHT9SETThJoT+djOVI=; fh=/HnMYbuiY0TAOuyQrceiR+aizJ4dNsgfmWEzLMtnEAw=; b=PQL0YPN79YJe33UR0TjYeJNVyi/dt9g8yubjkDkz+dehVaPgKjy93rxPmaXK2yFZ88 GNtrA6zP1ppOn+yaFcqsslyiP6M6jvc6pgGVjuJC3HuwPz7mtzhaWRdJgw0nckJLpj0q YC+mKQ3uvXJwnmejwJXWvvlD+RoNHdPIR1+tu3il3ZE23wDKygTfYPwJJLk77knq3urb TxR4fbaGqPWJxbLpOv/BBMfmmW5ops8KKGEKhVRhwpPhzzb1GXsBjJx2crBSwcxROpZ9 dDcvHQOg6f+QeDfdEgThyrmJ2UmfplAWru18evfBpzh3Irwus1ZJldi4Sei9n8TGyTtR /raA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QSwLXPAv; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-192565-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192565-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f8fd4cc234si8326850b3a.226.2024.05.28.10.50.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 10:50:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192565-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QSwLXPAv; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-192565-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192565-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A0237284708 for ; Tue, 28 May 2024 14:46:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DBB5E107A0; Tue, 28 May 2024 14:46:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QSwLXPAv" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 A8DDC16D4D0 for ; Tue, 28 May 2024 14:46:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716907571; cv=none; b=UEPC0aMiX/uHo/C7mpnE+O6AYlPT67xcr2W2Hvd/sev/d2nRoV/pvbwjMUCSbPmQzMtXoasno6PvOZEDOIz+ShIkXZMAtaXBbWKXGNsOBhDWYM18Z+7V7fup1C4s2xNHLaUhvS1v2AMHHw5XNSVJfdvZjXcwiT00QQO3tXSN3SQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716907571; c=relaxed/simple; bh=WM1Ru3mLX4zWI02W0VPy8yVNN3HZVq5joCnDe1A1HyA=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=tfi7MagrY7uJRTdnpy30BPyQCLsj35m92scyp940c1V7RCT25FVUQ4jfTR7n5GH32ZY/62egIPyi0hMlf9gWjLt85+q4utdh4zdDgSJSkzgnZMRWSCx3u9FHBOqyDMPzi7wKpeWdbqtJmpEXSYHrIVLY+wNRkfjQBZTBPzweuMI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=QSwLXPAv; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716907570; x=1748443570; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=WM1Ru3mLX4zWI02W0VPy8yVNN3HZVq5joCnDe1A1HyA=; b=QSwLXPAvJeO0VBUuxOUE04Wx2KSvcXFWC2LUamm+rtwVyGVg0zj3rIuJ hof3OdS3VoMvtFpHScvKyhucMgqm+3+diM+j25DcUjeac/qn5qdXmJlYU HZi7iXGkOR8XpEZYe3tenPSFrq0W1wS1Ai/Mv0Nj2h+r5Z3iBizNrzQdg PZxbPtxc5jCvXqffeL0/3nynGB8nQqFkly9efUVUEnnnmq3NRNuTwGG/l nD/mHz3dCP5pLyB18v1GDQrQmV6sAr6UO7BhSp5/KJsrWXowiofUOBVXV qaVEDVligAO607jMOXFXHRPR0jBb5YtIVeMuYC/WaeJ+ryHkKl3U/E1wS w==; X-CSE-ConnectionGUID: qzlRbtbDRWavt+DrElT7oA== X-CSE-MsgGUID: B3qIWBhGRMChL5+nZ9O9Xw== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13385506" X-IronPort-AV: E=Sophos;i="6.08,195,1712646000"; d="scan'208";a="13385506" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 07:46:09 -0700 X-CSE-ConnectionGUID: xGs5gK3MRcO4NYbEnddi9A== X-CSE-MsgGUID: OXNqiTS6TfG+Z+wOQgedAg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,195,1712646000"; d="scan'208";a="35116733" Received: from maurocar-mobl2.ger.corp.intel.com (HELO [10.245.244.233]) ([10.245.244.233]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 07:46:05 -0700 Message-ID: <706e63abf12b9cf76d43cf67999cbb7baa06ebb0.camel@linux.intel.com> Subject: Re: [PATCH] drm/xe: replace format-less snprintf() with strscpy() From: Thomas =?ISO-8859-1?Q?Hellstr=F6m?= To: Arnd Bergmann , Lucas De Marchi , Oded Gabbay Cc: Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rodrigo Vivi , =?ISO-8859-1?Q?Jos=E9?= Roberto de Souza , Matthew Brost , Francois Dugast , Himal Prasad Ghimiray , intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Date: Tue, 28 May 2024 16:46:02 +0200 In-Reply-To: <20240528133251.2310868-1-arnd@kernel.org> References: <20240528133251.2310868-1-arnd@kernel.org> Autocrypt: addr=thomas.hellstrom@linux.intel.com; prefer-encrypt=mutual; keydata=mDMEZaWU6xYJKwYBBAHaRw8BAQdAj/We1UBCIrAm9H5t5Z7+elYJowdlhiYE8zUXgxcFz360SFRob21hcyBIZWxsc3Ryw7ZtIChJbnRlbCBMaW51eCBlbWFpbCkgPHRob21hcy5oZWxsc3Ryb21AbGludXguaW50ZWwuY29tPoiTBBMWCgA7FiEEbJFDO8NaBua8diGTuBaTVQrGBr8FAmWllOsCGwMFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgkQuBaTVQrGBr/yQAD/Z1B+Kzy2JTuIy9LsKfC9FJmt1K/4qgaVeZMIKCAxf2UBAJhmZ5jmkDIf6YghfINZlYq6ixyWnOkWMuSLmELwOsgPuDgEZaWU6xIKKwYBBAGXVQEFAQEHQF9v/LNGegctctMWGHvmV/6oKOWWf/vd4MeqoSYTxVBTAwEIB4h4BBgWCgAgFiEEbJFDO8NaBua8diGTuBaTVQrGBr8FAmWllOsCGwwACgkQuBaTVQrGBr/P2QD9Gts6Ee91w3SzOelNjsus/DcCTBb3fRugJoqcfxjKU0gBAKIFVMvVUGbhlEi6EFTZmBZ0QIZEIzOOVfkaIgWelFEH Organization: Intel Sweden AB, Registration Number: 556189-6027 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.4 (3.50.4-1.fc39) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Tue, 2024-05-28 at 15:32 +0200, Arnd Bergmann wrote: > From: Arnd Bergmann >=20 > Using snprintf() with a format string from task->comm is a bit > dangerous since the string may be controlled by unprivileged > userspace: >=20 > drivers/gpu/drm/xe/xe_devcoredump.c: In function > 'devcoredump_snapshot': > drivers/gpu/drm/xe/xe_devcoredump.c:184:9: error: format not a string > literal and no format arguments [-Werror=3Dformat-security] > =C2=A0 184 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 snprintf(ss-= >process_name, sizeof(ss->process_name), > process_name); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 ^~~~~~~~ >=20 > In this case there is no reason for an snprintf(), so use a simpler > string copy. >=20 > Fixes: b10d0c5e9df7 ("drm/xe: Add process name to devcoredump") > Signed-off-by: Arnd Bergmann Reviewed-by: Thomas Hellstr=C3=B6m Thanks, Will pick up and apply as soon as our CI is fit for fight. /Thomas > --- > =C2=A0drivers/gpu/drm/xe/xe_devcoredump.c | 2 +- > =C2=A01 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/drivers/gpu/drm/xe/xe_devcoredump.c > b/drivers/gpu/drm/xe/xe_devcoredump.c > index 1643d44f8bc4..1973bfaece40 100644 > --- a/drivers/gpu/drm/xe/xe_devcoredump.c > +++ b/drivers/gpu/drm/xe/xe_devcoredump.c > @@ -181,7 +181,7 @@ static void devcoredump_snapshot(struct > xe_devcoredump *coredump, > =C2=A0 if (task) > =C2=A0 process_name =3D task->comm; > =C2=A0 } > - snprintf(ss->process_name, sizeof(ss->process_name), > process_name); > + strscpy(ss->process_name, process_name); > =C2=A0 if (task) > =C2=A0 put_task_struct(task); > =C2=A0