Commit d64d11b7 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'replace-deprecated-strcpy-with-strscpy'

Hongbo Li says:

====================
replace deprecated strcpy with strscpy

The deprecated helper strcpy() performs no bounds checking on the
destination buffer. This could result in linear overflows beyond
the end of the buffer, leading to all kinds of misbehaviors.
The safe replacement is strscpy() [1].

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
====================

Link: https://patch.msgid.link/20240828123224.3697672-1-lihongbo22@huawei.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 3cbd2090 82183b03
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -11143,7 +11143,7 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
	if (!dev->ethtool)
		goto free_all;

	strcpy(dev->name, name);
	strscpy(dev->name, name);
	dev->name_assign_type = name_assign_type;
	dev->group = INIT_NETDEV_GROUP;
	if (!dev->ethtool_ops)
+1 −1
Original line number Diff line number Diff line
@@ -1326,7 +1326,7 @@ int ip_tunnel_init(struct net_device *dev)

	tunnel->dev = dev;
	tunnel->net = dev_net(dev);
	strcpy(tunnel->parms.name, dev->name);
	strscpy(tunnel->parms.name, dev->name);
	iph->version		= 4;
	iph->ihl		= 5;

+1 −1
Original line number Diff line number Diff line
@@ -826,7 +826,7 @@ static int get_info(struct net *net, void __user *user, const int *len)
		       sizeof(info.underflow));
		info.num_entries = private->number;
		info.size = private->size;
		strcpy(info.name, name);
		strscpy(info.name, name);

		if (copy_to_user(user, &info, *len) != 0)
			ret = -EFAULT;
+1 −1
Original line number Diff line number Diff line
@@ -981,7 +981,7 @@ static int get_info(struct net *net, void __user *user, const int *len)
		       sizeof(info.underflow));
		info.num_entries = private->number;
		info.size = private->size;
		strcpy(info.name, name);
		strscpy(info.name, name);

		if (copy_to_user(user, &info, *len) != 0)
			ret = -EFAULT;
+1 −1
Original line number Diff line number Diff line
@@ -1944,7 +1944,7 @@ static void ndisc_warn_deprecated_sysctl(const struct ctl_table *ctl,
	static char warncomm[TASK_COMM_LEN];
	static int warned;
	if (strcmp(warncomm, current->comm) && warned < 5) {
		strcpy(warncomm, current->comm);
		strscpy(warncomm, current->comm);
		pr_warn("process `%s' is using deprecated sysctl (%s) net.ipv6.neigh.%s.%s - use net.ipv6.neigh.%s.%s_ms instead\n",
			warncomm, func,
			dev_name, ctl->procname,
Loading