From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) (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 7AEFC285C89 for ; Fri, 17 Apr 2026 14:04:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776434688; cv=none; b=uOoLYdTvJdofThtFEnN4/04fN79B3Q6gkV3cfDlKGs04IuahtfcRmVd9any59DD5a6cgZGIwebTc6vGFCY508GfKwiUX7JL6TNiH0uFtZM5GHUT1GmJiTZqw0sCeu/TWAkluE9B038hbRCImHx3NU8VIZpQrqyp4dcCk9UBJwVc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776434688; c=relaxed/simple; bh=IIQ6nEXJhz2Z1aKBTiSV2PJwfhNHrGNa987GO/xBBuQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Pieom2Tp/KI9ymgW2+DpGbuyWvG/MvbjvRwuuoZ/VurnsTD08PClzlS002u1PiB6lHhLRzmsxaQEuwp+QC7ZNl5SeLjdAtpFLZ6v/G28eOWgUOt73PL13SBA9q7+6396UruQOnz5vwHZnYLtvSde9fv67bR78o6/p/2q92jMp0w= 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=rVlsWchv; arc=none smtp.client-ip=95.215.58.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="rVlsWchv" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1776434683; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3GhlHA2ESSNJUFTnm+3/sML/ou4ajVzcsjUumgk/VcU=; b=rVlsWchvZeguS/ZqRXug18qPGsdyTK/5b1kqb5SZYt5F4b0I/8OSJSKvgDRkM7lD5MUM62 X8zfvWumbiPKnv28YjOVJQelt9XSHmrW98+iD4zalD3MgjKmGrt+hUyCPRwyPAJibdgyI8 YTT5pC7JH4BbUoHUJM4hA5R6wr1Vcu4= From: Thorsten Blum To: Kees Cook Cc: Thorsten Blum , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] gdrom: use strscpy in probe_gdrom_{setupcd,setupdisk} Date: Fri, 17 Apr 2026 16:03:49 +0200 Message-ID: <20260417140349.554098-3-thorsten.blum@linux.dev> 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=UTF-8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1751; i=thorsten.blum@linux.dev; h=from:subject; bh=IIQ6nEXJhz2Z1aKBTiSV2PJwfhNHrGNa987GO/xBBuQ=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDJmPbI/unBTkFXbxYRbPEZFsgY2KpxaatWY0OilLHw3Zd ypZ/wV/RykLgxgXg6yYIsuDWT9m+JbWVG4yidgJM4eVCWQIAxenAExk8S+GfwpX3pgyui8RCz83 4/F2I/kgf7WMyHW82RkT0gy637jMWcrw3/V22aTy6ZlSkzQfFPkILJbv+TTladV58ce661d9ZZr 1mgcA X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT strcpy() has been deprecated¹ because it performs no bounds checking on the destination buffer, which can lead to buffer overflows. While the current code works correctly, replace strcpy() with the safer strscpy() to follow secure coding best practices. ¹ https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy Signed-off-by: Thorsten Blum --- Compile-tested only. Adding arch/sh/ maintainers since that's the only platform where this driver can be used. Cc: Yoshinori Sato Cc: Rich Felker Cc: John Paul Adrian Glaubitz Cc: linux-sh@vger.kernel.org --- drivers/cdrom/gdrom.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c index 4ba4dd06cbf4..5768dc1aebc0 100644 --- a/drivers/cdrom/gdrom.c +++ b/drivers/cdrom/gdrom.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -708,7 +709,7 @@ static void probe_gdrom_setupcd(void) { gd.cd_info->ops = &gdrom_ops; gd.cd_info->capacity = 1; - strcpy(gd.cd_info->name, GDROM_DEV_NAME); + strscpy(gd.cd_info->name, GDROM_DEV_NAME); gd.cd_info->mask = CDC_CLOSE_TRAY|CDC_OPEN_TRAY|CDC_LOCK| CDC_SELECT_DISC; } @@ -719,7 +720,7 @@ static void probe_gdrom_setupdisk(void) gd.disk->first_minor = 1; gd.disk->minors = 1; gd.disk->flags |= GENHD_FL_NO_PART; - strcpy(gd.disk->disk_name, GDROM_DEV_NAME); + strscpy(gd.disk->disk_name, GDROM_DEV_NAME); } static int probe_gdrom_setupqueue(void)