* [PATCH net-next v2] net: tipc: replace deprecated strcpy with strscpy
@ 2026-08-12 13:22 Ajith P V
0 siblings, 0 replies; 2+ messages in thread
From: Ajith P V @ 2026-08-12 13:22 UTC (permalink / raw)
To: tung.quang.nguyen, jmaloy, davem, edumazet, kuba, pabeni, horms
Cc: netdev, tipc-discussion, linux-kernel, Ajith P V
The `strcpy()` function is deprecated and moving towards code-tree
elimination. Replacing it with `strscpy()` fixes potential buffer
overflow vectors by ensuring safe NULL-termination based on the
destination buffer size limit [1][2].
In `tipc_bearer_get_name()`, the 'name' parameter decays into a pointer,
meaning `sizeof()` cannot capture the underlying array bounds directly.
However, all parent callers allocate this buffer using the
TIPC_MAX_BEARER_NAME macro.
Replace strcpy() with strscpy() using TIPC_MAX_BEARER_NAME as the
explicit destination bound length.
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
Link: https://github.com/KSPP/linux/issues/88 [2]
Signed-off-by: Ajith P V <ajithpv.linux@gmail.com>
---
v2:
- Target net-next tree instead of standard net tree as requested by Tung Quang Nguyen.
- No code changes from v1.
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 05dcd2f9e887..951bb474c7d4 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -209,7 +209,7 @@ int tipc_bearer_get_name(struct net *net, char *name, u32 bearer_id)
if (!b)
return -EINVAL;
- strcpy(name, b->name);
+ strscpy(name, b->name, TIPC_MAX_BEARER_NAME);
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [PATCH] net: tipc: replace deprecated strcpy with strscpy
@ 2026-08-12 7:47 Tung Quang Nguyen
2026-08-12 13:12 ` [PATCH net-next v2] " Ajith P V
0 siblings, 1 reply; 2+ messages in thread
From: Tung Quang Nguyen @ 2026-08-12 7:47 UTC (permalink / raw)
To: Ajith P V
Cc: netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org, jmaloy@redhat.com,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org
>Subject: [PATCH] net: tipc: replace deprecated strcpy with strscpy
Please fix the target tree name.
Since this patch is just an improvement, the tree name should be "[PATCH net-next]".
>
>The `strcpy()` function is deprecated and moving towards code-tree
>elimination. Replacing it with `strscpy()` fixes potential buffer overflow vectors
>by ensuring safe NULL-termination based on the destination buffer size limit
>[1][2].
>
>In `tipc_bearer_get_name()`, the 'name' parameter decays into a pointer,
>meaning `sizeof()` cannot capture the underlying array bounds directly.
>However, all parent callers allocate this buffer using the
>TIPC_MAX_BEARER_NAME macro.
>
>Replace strcpy() with strscpy() using TIPC_MAX_BEARER_NAME as the explicit
>destination bound length.
>
>Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
>[1]
>Link: https://github.com/KSPP/linux/issues/88 [2]
>
>Signed-off-by: Ajith P V <ajithpv.linux@gmail.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
>05dcd2f9e887..951bb474c7d4 100644
>--- a/net/tipc/bearer.c
>+++ b/net/tipc/bearer.c
>@@ -209,7 +209,7 @@ int tipc_bearer_get_name(struct net *net, char *name,
>u32 bearer_id)
> if (!b)
> return -EINVAL;
>
>- strcpy(name, b->name);
>+ strscpy(name, b->name, TIPC_MAX_BEARER_NAME);
> return 0;
> }
>
>--
>2.43.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH net-next v2] net: tipc: replace deprecated strcpy with strscpy
2026-08-12 7:47 [PATCH] " Tung Quang Nguyen
@ 2026-08-12 13:12 ` Ajith P V
0 siblings, 0 replies; 2+ messages in thread
From: Ajith P V @ 2026-08-12 13:12 UTC (permalink / raw)
To: tung.quang.nguyen, jmaloy, davem, edumazet, kuba, pabeni, horms
Cc: netdev, tipc-discussion, linux-kernel, Ajith P V
The `strcpy()` function is deprecated and moving towards code-tree
elimination. Replacing it with `strscpy()` fixes potential buffer
overflow vectors by ensuring safe NULL-termination based on the
destination buffer size limit [1][2].
In `tipc_bearer_get_name()`, the 'name' parameter decays into a pointer,
meaning `sizeof()` cannot capture the underlying array bounds directly.
However, all parent callers allocate this buffer using the
TIPC_MAX_BEARER_NAME macro.
Replace strcpy() with strscpy() using TIPC_MAX_BEARER_NAME as the
explicit destination bound length.
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
Link: https://github.com/KSPP/linux/issues/88 [2]
Signed-off-by: Ajith P V <ajithpv.linux@gmail.com>
---
v2:
- Target net-next tree instead of standard net tree as requested by Tung Quang Nguyen.
- No code changes from v1.
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 05dcd2f9e887..951bb474c7d4 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -209,7 +209,7 @@ int tipc_bearer_get_name(struct net *net, char *name, u32 bearer_id)
if (!b)
return -EINVAL;
- strcpy(name, b->name);
+ strscpy(name, b->name, TIPC_MAX_BEARER_NAME);
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-12 13:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-12 13:22 [PATCH net-next v2] net: tipc: replace deprecated strcpy with strscpy Ajith P V
-- strict thread matches above, loose matches on Subject: below --
2026-08-12 7:47 [PATCH] " Tung Quang Nguyen
2026-08-12 13:12 ` [PATCH net-next v2] " Ajith P V
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox