Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2647394lqb; Tue, 28 May 2024 06:33:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVoyxYAljAz+qsvHtY7ZyTik8xbXvCouu+nilaYQwPHmjnlrUPnG3IWK4RtUq8SLWY/1EMEqea81DYyIN1mdFuaPTc9GSNqa0iO9suBtg== X-Google-Smtp-Source: AGHT+IEAgTeq9R5eDFSBH4WvbpC9Qt6vACVSGX7TIdfNHctd2/pKzr6rFAlXhTyvkiPNdm2EL4BY X-Received: by 2002:a05:6a00:330b:b0:6f3:ea8a:f974 with SMTP id d2e1a72fcca58-6f8f2b484c2mr12777462b3a.1.1716903228336; Tue, 28 May 2024 06:33:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716903228; cv=pass; d=google.com; s=arc-20160816; b=yhShmZbYA5RkVuzDpPDXkbrk8u5p2TTuwjL18UaX5ctbPztxb5VOla6WIZH9Fx9boG PxgfnkNTZ42dOx0BxPLiIh1BGgaiQ9EHdmz3+6LNa6NJOSPANRZBdo6xgjsNYBcunsN6 x0Vtb0APEYxSvjCcYXYTOszOR8tN+8XnQ+UpafmbLTl0EuTLDsI+CpDtaUOvXXNmaSCX vUs9YY+QyYB5nWaxZNPydKeONe5XHBTcCG3XaxZTIl79fFa1HYklVzlNiV2lqtF00Azm 3dY/4DLG4RTlOY86MI0lQaPNYAJnyKQ6n0S5tHyt7xdCn32B72MvDEE3S52z6G3Vpn2Z Klfg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=DafjiN3uB/4vo5bDpx4rBWEHd+hif5b605/ehWqJvSg=; fh=jdBZlkxSIAhVzu1PeZw6rswJHl6pDHounYqy+HHxLD4=; b=F0aIyS00O2SKbkl9qyQhcUMy1Pejm8cBUKRkjddqeHyOqQeiIJKWhE6wk1bmcKeCyo VDYZy3A3JmJPz/9mzv8djSBhQznD6XUh+IRxIhoCbBGLOpg9FiIDjvSP74VEQpvwjs8F qwg3pT8bglZu0p28RNjbIWR1D8dBsGlsNo/78DD+6lTcyB3xdTGyIvBd0FPmjwUNPHun UgS9yE1F+YmoYIWAhrJMj2DU89DLbV6TA4Ngm+8wL8PmZjWcpkLj0RUfLqou7Fzw9MZ1 Z8W80AeRm03EXuHdZwlmfuGPsOw2gi61gnisMzmOIy2uDiRnaWDTAwdA+YteW7fFJmPr ObXA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Tyc6h+vy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-192423-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192423-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f8fcfdee7bsi8179035b3a.221.2024.05.28.06.33.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 06:33:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192423-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=@kernel.org header.s=k20201202 header.b=Tyc6h+vy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-192423-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192423-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 E579E287034 for ; Tue, 28 May 2024 13:33:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F0F1116F830; Tue, 28 May 2024 13:32:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Tyc6h+vy" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2894A17C7F for ; Tue, 28 May 2024 13:32:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716903178; cv=none; b=H77ZkDz05O7C3zf5yVEF8IQ7zI+m73UZM+1+NdjQhd0q33C6bDw6RquBU9IqogYu0CAR+NN/q+qzvP6DhdKhu/+cA+IrD8j6lMSy/ggGmiGMWTTmn9qDL1qTu9/G+62tuIimuSr2jAILbjZkSBjYvzK1fwbHwyE5LFSt2cdKzkc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716903178; c=relaxed/simple; bh=Dz+CC+JZWQtuG8vRgbBmaJAyi+jOVLXABQMl0q6O1kM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Sg7kmU0Pi3QJoH4hhc9aj7i4/VqaKRYORoGibWbS3n2z5iw9iAKPDQ/KRkiHcW3QBL1wcLvo2hToYRbEBR86O0t8p+eUohLV2rQLVL61g4LqJHW8CmBl1PGjtmVtB8j7U1fwjVNXJuc2zWet4hpB4B7kzgvMKWTWv9BiaEqw/LY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Tyc6h+vy; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E656C3277B; Tue, 28 May 2024 13:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716903177; bh=Dz+CC+JZWQtuG8vRgbBmaJAyi+jOVLXABQMl0q6O1kM=; h=From:To:Cc:Subject:Date:From; b=Tyc6h+vyN/0ZtgmqlBVQivGgvzaHDwhnURTNTqAzCNT1CAUF4+XoAWWP9zIVozyWh JaEUiYWPKRClmYh7/hg8fx0BhqsyfmzRPFKrsIlNebfX4kyQkuA7VP1suJrYUwfiuq FcB2RZi/cn6mo1q8HsxG5a3nOV89f6WZN6sQpi1HI2LOy+ifhc8MWSrxO/X90ljkgR DRKZuzwiwHV3WpPXA4HWBW720Xyhrk/4Nmw+tB/JG4BNOGbFmsuo7HSMYxoN1j3tjG CjQgVM3G606etOfuHQc1B+i8n96rmS5SmhLVIR596pmD4YIGfOrWwc0cUs5Y2BclbN ujPRZU2Cl+dEQ== From: Arnd Bergmann To: Lucas De Marchi , Oded Gabbay , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= Cc: Arnd Bergmann , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rodrigo Vivi , =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= , Matthew Brost , Francois Dugast , Himal Prasad Ghimiray , intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/xe: replace format-less snprintf() with strscpy() Date: Tue, 28 May 2024 15:32:36 +0200 Message-Id: <20240528133251.2310868-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann Using snprintf() with a format string from task->comm is a bit dangerous since the string may be controlled by unprivileged userspace: 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=format-security] 184 | snprintf(ss->process_name, sizeof(ss->process_name), process_name); | ^~~~~~~~ In this case there is no reason for an snprintf(), so use a simpler string copy. Fixes: b10d0c5e9df7 ("drm/xe: Add process name to devcoredump") Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/xe/xe_devcoredump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, if (task) process_name = task->comm; } - snprintf(ss->process_name, sizeof(ss->process_name), process_name); + strscpy(ss->process_name, process_name); if (task) put_task_struct(task); -- 2.39.2