From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 77EAB26AE5; Mon, 8 Jun 2026 21:31:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780954267; cv=none; b=Kvr5QEXuNvDrAR07Srj/kQUhqLsjbh5WHIT/tbDRoDnfXQwXMnlnWBZSfrPb05wV5Kv14Ro0FEcoUnXMqNWvTwiVrREKXySihxEiO/SdU50o7ya8TXaAT6hZapIUvf+UwK/MrC9qssfI6ewTcZEPnWfebhpqFr/lxPtAAPhyOvY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780954267; c=relaxed/simple; bh=X9OSzZe8q9NDMLj+Me6B8O65fYIfYSYHSQjZUs1Itzs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=oQblDrktsG/93DkQmH1i7xO4SFPVVv0D1jSXmAvCD/u1BEkAo9v3Xjmk8EFI8VsHfjx9QQOsiHkE3hU8ebpgfxmhX1sb0LqL+qTZBgfx4yvL0mrlYVffqJQW4ioHltVe/dKt2V35fWjJHWV2ZLQMquNITRRgN0jggtirqQgmUa0= 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=n0/DAp8B; arc=none smtp.client-ip=185.226.149.38 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="n0/DAp8B" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1wWhYi-00DJ52-1p; Mon, 08 Jun 2026 23:31:00 +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=NmiKciKHXv4C9xD9HOuVDqRWiEHYVQXSczgOsSWg0yc=; b=n0/DAp 8BDzh/OSrSSdhdRhuKkl+RzAHJ2wZedQgiod1Z/alKM50Rsie8euceqCEUFSNHEqNT0C3FXJqfhLH Q2SRwEq7hoUvMcq/vMH+7T4eMRSUb0b5Zsp8qJymAZgikrohXS5ZbB5ghIBG4SSAKyDHjLu8Nigl6 RAzHmDvVLYRw4TLPNVU3f4n3QDWxlyWFB8g50Jn/dlIB2/qgFKVU2yjt2uOM+d5lKamVcS4OMz0vp oAw73Y8U7WlXW6EvC5TXbVstywJZROLOUHPDg/DJNl2oLRi9WYmz6jfQG1eq1k5Im6D7HAATiULVs w57AwER9k6glU5t98AxvU6BbRrVg==; Received: from [10.9.9.73] (helo=submission02.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1wWhYh-0001RU-Hh; Mon, 08 Jun 2026 23:30:59 +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 1wWhYW-00BuhU-Bn; Mon, 08 Jun 2026 23:30:48 +0200 From: David Laight To: Kees Cook , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Arnd Bergmann , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Jay Vosburgh , Paolo Abeni , David Laight Subject: [PATCH v2 net-next] drivers/net/bonding: User strscpy() to copy device name Date: Mon, 8 Jun 2026 22:30:42 +0100 Message-Id: <20260608213042.25563-1-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 Replace the potentially unbounded strcpy() with the safer strscpy(). Signed-off-by: David Laight --- v2: Merge the patches for bond_main.c and bond_options together. 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/bonding/bond_main.c | 2 +- drivers/net/bonding/bond_options.c | 2 +- 2 files changed, 2 insertions(+), 2 deletion.(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index af82a3df2c5d..76ca61cad875 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1792,7 +1792,7 @@ static void bond_fill_ifbond(struct bonding *bond, struct ifbond *info) static void bond_fill_ifslave(struct slave *slave, struct ifslave *info) { - strcpy(info->slave_name, slave->dev->name); + strscpy(info->slave_name, slave->dev->name); info->link = slave->link; info->state = bond_slave_state(slave); info->link_failure_count = slave->link_failure_count; diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index 7380cc4ee75a..c57b7d6af043 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c @@ -1525,7 +1525,7 @@ static int bond_option_primary_set(struct bonding *bond, if (strncmp(slave->dev->name, primary, IFNAMSIZ) == 0) { slave_dbg(bond->dev, slave->dev, "Setting as primary slave\n"); rcu_assign_pointer(bond->primary_slave, slave); - strcpy(bond->params.primary, slave->dev->name); + strscpy(bond->params.primary, slave->dev->name); bond->force_primary = true; bond_select_active_slave(bond); goto out; -- 2.39.5