From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 84EBD3AB283 for ; Mon, 8 Jun 2026 09:55:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780912535; cv=none; b=hLAM9yGGxcqVpQHGx50FDguBi5OsPK72K6tOYJHEnkil4/RVc+4HrJlCe6xdjAY4Q7gHX++VOgGn3cA5wv1YL0JjMNfDslrYkt8H4zGAsqoGXWCczyJ8cQIR+YzuWYtf7iq7kWhXz6B5qYusPBL3yfuogha7nRJTYlwQOIm9Iyk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780912535; c=relaxed/simple; bh=kjgzlGkCqp1NC5w51WcCRLvPiI8hJDKE74lYbf8SGl0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=D+k6CZ4LL+tb75IP/7SxD1b04gQ/9n44ut8S+XOF1GaTT58AwKnJ60OTV6U5LYLxd1UEz9G/WYMDZOEe7jseEGgDvyhA7lj9md35/gJVhVA2W2D1mgz833McYjKS2VpmzhjQb/VI28OrspKfWyRI9BvEZAENr9W8F/2CCgphf0Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=tX4WCsF6; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="tX4WCsF6" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1wWWha-00BRun-Uq; Mon, 08 Jun 2026 11:55:26 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date: Subject:Cc:To:From; bh=ph85ZDRTWov53bumdN4BhGhFsj9VkRRexE10g5yL/6o=; b=tX4WCs F66HH9Bh7fiprOEtpdwojmDpEB9IBYKVPLZaJ5xMKldw73K3oeFov+5ggDN30O3e3ZGHfzNBaO/ca vkRrpOaFLZ0cH3APoGF7q6xpsQyHtnWLt9yRTYWKFRu61ErDi52RcBJs6H2j6ugvQp++iBYnwCBnM OUlUFU7y07RJJYNNa9ubJ6AWtbqSPzYktH/do4lC8Y7lRpm6Cb4h+6tQOnX+RLPgz3OjL8c58YQl+ dsd6gwjP+2pMjw0dYQZM2VCuV0cGYUiQh437xgcSKzaSWJ281/yVj/AQYUkKfnomt0vx+fC/0tbf9 Yt6HhJubm2xflL3ACP38CLi51tcg==; Received: from [10.9.9.73] (helo=submission02.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1wWWhQ-0003ZK-7j; Mon, 08 Jun 2026 11:55:16 +0200 Received: by submission02.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.95) id 1wWWhG-00Afz8-0J; Mon, 08 Jun 2026 11:55:06 +0200 From: david.laight.linux@gmail.com To: Kees Cook , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Arnd Bergmann , Ajit Khaparde , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Sriharsha Basavapatna , David Laight Subject: [PATCH net-next] drivers/net/ethernet/emulex/benet: Use strscpy() to copy strings into arrays Date: Mon, 8 Jun 2026 10:54:59 +0100 Message-Id: <20260608095500.2567-4-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: David Laight Replacing strcpy() with strscpy() ensures that overflow of the target buffer cannot happen. Signed-off-by: David Laight --- This is one of a group of patches that remove potentially unbounded strcpy() calls. They are mostly replaced by strscpy() or, when strlen() has just been called, with memcpy() (usually including the '\0'). Calls with copy string literals into arrays are left unchanged. They are safe and easily detected as such. The changes were made by getting the compiler to detect the calls and then fixing the code by hand. Note that all the changes are only compile tested. Some Makefiles were changed to allow files to contain strcpy(). As well as 'difficult to fix' files, this included 'show' functions as they really need to use sysfs_emit() or seq_printf(). All the patches are being sent individually to avoid very long cc lists. Apologies for the terse commit messages and likely unexpected tags. (There are about 100 patches in total.) drivers/net/ethernet/emulex/benet/be_cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index eab81e073e1e..230c91559322 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c @@ -2508,7 +2508,7 @@ int lancer_cmd_read_object(struct be_adapter *adapter, struct be_dma_mem *cmd, req->desired_read_len = cpu_to_le32(data_size); req->read_offset = cpu_to_le32(data_offset); - strcpy(req->object_name, obj_name); + strscpy(req->object_name, obj_name); req->descriptor_count = cpu_to_le32(1); req->buf_len = cpu_to_le32(data_size); req->addr_low = cpu_to_le32((cmd->dma & 0xFFFFFFFF)); -- 2.39.5