* [PATCH net-next v2 0/6] replace deprecated strcpy with strscpy
@ 2024-08-28 12:32 Hongbo Li
2024-08-28 12:32 ` [PATCH net-next v2 1/6] net: prefer strscpy over strcpy Hongbo Li
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Hongbo Li @ 2024-08-28 12:32 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, dsahern, ralf, jmaloy, ying.xue,
dan.carpenter
Cc: netdev, linux-hams, netfilter-devel, lihongbo22
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]
Hongbo Li (6):
net: prefer strscpy over strcpy
net/ipv6: replace deprecated strcpy with strscpy
net/netrom: prefer strscpy over strcpy
net/netfilter: replace deprecated strcpy with strscpy
net/tipc: replace deprecated strcpy with strscpy
net/ipv4: net: prefer strscpy over strcpy
net/core/dev.c | 2 +-
net/ipv4/ip_tunnel.c | 2 +-
net/ipv4/netfilter/arp_tables.c | 2 +-
net/ipv4/netfilter/ip_tables.c | 2 +-
net/ipv6/ndisc.c | 2 +-
net/netfilter/xt_recent.c | 2 +-
net/netrom/nr_route.c | 4 ++--
net/tipc/bearer.c | 2 +-
8 files changed, 9 insertions(+), 9 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net-next v2 1/6] net: prefer strscpy over strcpy
2024-08-28 12:32 [PATCH net-next v2 0/6] replace deprecated strcpy with strscpy Hongbo Li
@ 2024-08-28 12:32 ` Hongbo Li
2024-08-28 12:32 ` [PATCH net-next v2 2/6] net/ipv6: replace deprecated strcpy with strscpy Hongbo Li
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Hongbo Li @ 2024-08-28 12:32 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, dsahern, ralf, jmaloy, ying.xue,
dan.carpenter
Cc: netdev, linux-hams, netfilter-devel, lihongbo22
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]
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
net/core/dev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 0d0b983a6c21..b2ee944867e7 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -11121,7 +11121,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)
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next v2 2/6] net/ipv6: replace deprecated strcpy with strscpy
2024-08-28 12:32 [PATCH net-next v2 0/6] replace deprecated strcpy with strscpy Hongbo Li
2024-08-28 12:32 ` [PATCH net-next v2 1/6] net: prefer strscpy over strcpy Hongbo Li
@ 2024-08-28 12:32 ` Hongbo Li
2024-08-28 12:32 ` [PATCH net-next v2 3/6] net/netrom: prefer strscpy over strcpy Hongbo Li
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Hongbo Li @ 2024-08-28 12:32 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, dsahern, ralf, jmaloy, ying.xue,
dan.carpenter
Cc: netdev, linux-hams, netfilter-devel, lihongbo22
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]
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
net/ipv6/ndisc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 1e42e40fb379..aba94a348673 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -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,
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next v2 3/6] net/netrom: prefer strscpy over strcpy
2024-08-28 12:32 [PATCH net-next v2 0/6] replace deprecated strcpy with strscpy Hongbo Li
2024-08-28 12:32 ` [PATCH net-next v2 1/6] net: prefer strscpy over strcpy Hongbo Li
2024-08-28 12:32 ` [PATCH net-next v2 2/6] net/ipv6: replace deprecated strcpy with strscpy Hongbo Li
@ 2024-08-28 12:32 ` Hongbo Li
2024-08-28 12:32 ` [PATCH net-next v2 4/6] net/netfilter: replace deprecated strcpy with strscpy Hongbo Li
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Hongbo Li @ 2024-08-28 12:32 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, dsahern, ralf, jmaloy, ying.xue,
dan.carpenter
Cc: netdev, linux-hams, netfilter-devel, lihongbo22
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]
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
net/netrom/nr_route.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c
index bd2b17b219ae..2b5e246b8d9a 100644
--- a/net/netrom/nr_route.c
+++ b/net/netrom/nr_route.c
@@ -189,7 +189,7 @@ static int __must_check nr_add_node(ax25_address *nr, const char *mnemonic,
}
nr_node->callsign = *nr;
- strcpy(nr_node->mnemonic, mnemonic);
+ strscpy(nr_node->mnemonic, mnemonic);
nr_node->which = 0;
nr_node->count = 1;
@@ -214,7 +214,7 @@ static int __must_check nr_add_node(ax25_address *nr, const char *mnemonic,
nr_node_lock(nr_node);
if (quality != 0)
- strcpy(nr_node->mnemonic, mnemonic);
+ strscpy(nr_node->mnemonic, mnemonic);
for (found = 0, i = 0; i < nr_node->count; i++) {
if (nr_node->routes[i].neighbour == nr_neigh) {
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next v2 4/6] net/netfilter: replace deprecated strcpy with strscpy
2024-08-28 12:32 [PATCH net-next v2 0/6] replace deprecated strcpy with strscpy Hongbo Li
` (2 preceding siblings ...)
2024-08-28 12:32 ` [PATCH net-next v2 3/6] net/netrom: prefer strscpy over strcpy Hongbo Li
@ 2024-08-28 12:32 ` Hongbo Li
2024-08-28 12:32 ` [PATCH net-next v2 5/6] net/tipc: " Hongbo Li
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Hongbo Li @ 2024-08-28 12:32 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, dsahern, ralf, jmaloy, ying.xue,
dan.carpenter
Cc: netdev, linux-hams, netfilter-devel, lihongbo22
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]
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
net/netfilter/xt_recent.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
index 588a5e6ad899..6b7d6978713f 100644
--- a/net/netfilter/xt_recent.c
+++ b/net/netfilter/xt_recent.c
@@ -400,7 +400,7 @@ static int recent_mt_check(const struct xt_mtchk_param *par,
t->nstamps_max_mask = nstamp_mask;
memcpy(&t->mask, &info->mask, sizeof(t->mask));
- strcpy(t->name, info->name);
+ strscpy(t->name, info->name);
INIT_LIST_HEAD(&t->lru_list);
for (i = 0; i < ip_list_hash_size; i++)
INIT_LIST_HEAD(&t->iphash[i]);
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next v2 5/6] net/tipc: replace deprecated strcpy with strscpy
2024-08-28 12:32 [PATCH net-next v2 0/6] replace deprecated strcpy with strscpy Hongbo Li
` (3 preceding siblings ...)
2024-08-28 12:32 ` [PATCH net-next v2 4/6] net/netfilter: replace deprecated strcpy with strscpy Hongbo Li
@ 2024-08-28 12:32 ` Hongbo Li
2024-08-28 12:32 ` [PATCH net-next v2 6/6] net/ipv4: net: prefer strscpy over strcpy Hongbo Li
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Hongbo Li @ 2024-08-28 12:32 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, dsahern, ralf, jmaloy, ying.xue,
dan.carpenter
Cc: netdev, linux-hams, netfilter-devel, lihongbo22
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]
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
net/tipc/bearer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 3c9e25f6a1d2..ae1ddbf71853 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -326,7 +326,7 @@ static int tipc_enable_bearer(struct net *net, const char *name,
if (!b)
return -ENOMEM;
- strcpy(b->name, name);
+ strscpy(b->name, name);
b->media = m;
res = m->enable_media(net, b, attr);
if (res) {
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next v2 6/6] net/ipv4: net: prefer strscpy over strcpy
2024-08-28 12:32 [PATCH net-next v2 0/6] replace deprecated strcpy with strscpy Hongbo Li
` (4 preceding siblings ...)
2024-08-28 12:32 ` [PATCH net-next v2 5/6] net/tipc: " Hongbo Li
@ 2024-08-28 12:32 ` Hongbo Li
2024-08-29 19:36 ` [PATCH net-next v2 0/6] replace deprecated strcpy with strscpy Jakub Kicinski
2024-08-29 19:50 ` patchwork-bot+netdevbpf
7 siblings, 0 replies; 9+ messages in thread
From: Hongbo Li @ 2024-08-28 12:32 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, dsahern, ralf, jmaloy, ying.xue,
dan.carpenter
Cc: netdev, linux-hams, netfilter-devel, lihongbo22
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]
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
net/ipv4/ip_tunnel.c | 2 +-
net/ipv4/netfilter/arp_tables.c | 2 +-
net/ipv4/netfilter/ip_tables.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 5cffad42fe8c..0cd2f3de100c 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -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;
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index 14365b20f1c5..42c34e8952da 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -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;
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index fe89a056eb06..97e754ddc155 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -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;
--
2.34.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net-next v2 0/6] replace deprecated strcpy with strscpy
2024-08-28 12:32 [PATCH net-next v2 0/6] replace deprecated strcpy with strscpy Hongbo Li
` (5 preceding siblings ...)
2024-08-28 12:32 ` [PATCH net-next v2 6/6] net/ipv4: net: prefer strscpy over strcpy Hongbo Li
@ 2024-08-29 19:36 ` Jakub Kicinski
2024-08-29 19:50 ` patchwork-bot+netdevbpf
7 siblings, 0 replies; 9+ messages in thread
From: Jakub Kicinski @ 2024-08-29 19:36 UTC (permalink / raw)
To: Hongbo Li
Cc: davem, edumazet, pabeni, dsahern, ralf, jmaloy, ying.xue,
dan.carpenter, netdev, linux-hams, netfilter-devel
On Wed, 28 Aug 2024 20:32:18 +0800 Hongbo Li wrote:
> 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].
What's you plan? Are you going to send 200 patches like this
just for networking?
$ git grep strcpy -- net/ drivers/net/ | wc -l
199
Please don't. I'll look thru this series but it feels like such
a waste of time.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next v2 0/6] replace deprecated strcpy with strscpy
2024-08-28 12:32 [PATCH net-next v2 0/6] replace deprecated strcpy with strscpy Hongbo Li
` (6 preceding siblings ...)
2024-08-29 19:36 ` [PATCH net-next v2 0/6] replace deprecated strcpy with strscpy Jakub Kicinski
@ 2024-08-29 19:50 ` patchwork-bot+netdevbpf
7 siblings, 0 replies; 9+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-08-29 19:50 UTC (permalink / raw)
To: Hongbo Li
Cc: davem, edumazet, kuba, pabeni, dsahern, ralf, jmaloy, ying.xue,
dan.carpenter, netdev, linux-hams, netfilter-devel
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 28 Aug 2024 20:32:18 +0800 you wrote:
> 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]
>
> [...]
Here is the summary with links:
- [net-next,v2,1/6] net: prefer strscpy over strcpy
https://git.kernel.org/netdev/net-next/c/68016b997222
- [net-next,v2,2/6] net/ipv6: replace deprecated strcpy with strscpy
https://git.kernel.org/netdev/net-next/c/b19f69a95830
- [net-next,v2,3/6] net/netrom: prefer strscpy over strcpy
https://git.kernel.org/netdev/net-next/c/597be7bd17c3
- [net-next,v2,4/6] net/netfilter: replace deprecated strcpy with strscpy
(no matching commit)
- [net-next,v2,5/6] net/tipc: replace deprecated strcpy with strscpy
https://git.kernel.org/netdev/net-next/c/af1052fd49cc
- [net-next,v2,6/6] net/ipv4: net: prefer strscpy over strcpy
https://git.kernel.org/netdev/net-next/c/82183b03de5f
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-08-29 19:50 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-28 12:32 [PATCH net-next v2 0/6] replace deprecated strcpy with strscpy Hongbo Li
2024-08-28 12:32 ` [PATCH net-next v2 1/6] net: prefer strscpy over strcpy Hongbo Li
2024-08-28 12:32 ` [PATCH net-next v2 2/6] net/ipv6: replace deprecated strcpy with strscpy Hongbo Li
2024-08-28 12:32 ` [PATCH net-next v2 3/6] net/netrom: prefer strscpy over strcpy Hongbo Li
2024-08-28 12:32 ` [PATCH net-next v2 4/6] net/netfilter: replace deprecated strcpy with strscpy Hongbo Li
2024-08-28 12:32 ` [PATCH net-next v2 5/6] net/tipc: " Hongbo Li
2024-08-28 12:32 ` [PATCH net-next v2 6/6] net/ipv4: net: prefer strscpy over strcpy Hongbo Li
2024-08-29 19:36 ` [PATCH net-next v2 0/6] replace deprecated strcpy with strscpy Jakub Kicinski
2024-08-29 19:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).