The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH net-next v3] tipc: replace deprecated strcpy with strscpy in tipc_bearer_get_name()
@ 2026-08-13 10:22 Ajith P V
  2026-08-14  9:00 ` Tung Quang Nguyen
  0 siblings, 1 reply; 5+ messages in thread
From: Ajith P V @ 2026-08-13 10: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>
---
v3:
  - Fix patch title as suggested by Tung Quang Nguyen.
  - No code changes from v2.
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] 5+ messages in thread

* Re: [PATCH net-next v3] tipc: replace deprecated strcpy with strscpy in tipc_bearer_get_name()
  2026-08-13 10:22 [PATCH net-next v3] tipc: replace deprecated strcpy with strscpy in tipc_bearer_get_name() Ajith P V
@ 2026-08-14  9:00 ` Tung Quang Nguyen
  2026-08-14 12:55   ` Ajith P V
  0 siblings, 1 reply; 5+ messages in thread
From: Tung Quang Nguyen @ 2026-08-14  9:00 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-next v3] tipc: replace deprecated strcpy with strscpy in tipc_bearer_get_name()
It seems your patch is not based on net-next tree:
"Conflicts with pending/net patches (net-next-2026-08-13--12-00): error: patch failed: net/tipc/bearer.c:209 error: net/tipc/bearer.c: patch does not apply"

Could you please apply your patch to net-next tree and resubmit ?



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v3] tipc: replace deprecated strcpy with strscpy in tipc_bearer_get_name()
  2026-08-14  9:00 ` Tung Quang Nguyen
@ 2026-08-14 12:55   ` Ajith P V
  2026-08-14 13:03     ` Tung Quang Nguyen
  0 siblings, 1 reply; 5+ messages in thread
From: Ajith P V @ 2026-08-14 12:55 UTC (permalink / raw)
  To: tung.quang.nguyen, jmaloy, davem, edumazet, kuba, pabeni, horms
  Cc: netdev, tipc-discussion, linux-kernel

> It seems your patch is not based on net-next tree:
> "Conflicts with pending/net patches (net-next-2026-08-13--12-00): error: patch failed: net/tipc/bearer.c:209 error: net/tipc/bearer.c: patch does not apply"

> Could you please apply your patch to net-next tree and resubmit ?

First time net contributor and I'm a bit confused here. When I cloned the net-next, it applied the same patch without the error as shown below:
<path of the linux tree >net-next$ ls
arch   certs    CREDITS  Documentation  fs       init      ipc     Kconfig  lib       MAINTAINERS  mm   README  samples  security  tools  virt
block  COPYING  crypto   drivers        include  io_uring  Kbuild  kernel   LICENSES  Makefile     net  rust    scripts  sound     usr
<path of the linux tree/net-next$ git remote -v
origin	https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git (fetch)
origin	https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git (push)
<path of the linux tree/net-next$ git branch
* main
<path of the linux tree/net-next$ git am ../../patches/v3-0001-tipc-replace-deprecated-strcpy-with-strscpy-in-ti.patch
Applying: tipc: replace deprecated strcpy with strscpy in tipc_bearer_get_name()
<path of the linux tree/net-next$

May I know the correct way of getting the latest net-next so that I can reproduce the same error and patch on top of it?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v3] tipc: replace deprecated strcpy with strscpy in tipc_bearer_get_name()
  2026-08-14 12:55   ` Ajith P V
@ 2026-08-14 13:03     ` Tung Quang Nguyen
  2026-08-14 16:08       ` Ajith P V
  0 siblings, 1 reply; 5+ messages in thread
From: Tung Quang Nguyen @ 2026-08-14 13:03 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

> May I know the correct way of getting the latest net-next so that I can reproduce the same error and patch on top of it?
net tree: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git
net-next tree: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v3] tipc: replace deprecated strcpy with strscpy in tipc_bearer_get_name()
  2026-08-14 13:03     ` Tung Quang Nguyen
@ 2026-08-14 16:08       ` Ajith P V
  0 siblings, 0 replies; 5+ messages in thread
From: Ajith P V @ 2026-08-14 16:08 UTC (permalink / raw)
  To: tung.quang.nguyen, jmaloy, davem, edumazet, kuba, pabeni, horms
  Cc: netdev, tipc-discussion, linux-kernel

> net tree: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git
> net-next tree: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git

Thank you. I tried the correct net-next tree. The same patch applied successfully here also as shown below.

<path of the linux tree>/net-next$ ls
arch   certs    CREDITS  Documentation  fs       init      ipc     Kconfig  lib       MAINTAINERS  mm   README  samples  security  tools  virt
block  COPYING  crypto   drivers        include  io_uring  Kbuild  kernel   LICENSES  Makefile     net  rust    scripts  sound     usr
<path of the linux tree>/net-next$ git remote -v
origin	https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git (fetch)
origin	https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git (push)
<path of the linux tree>/net-next$ git am ../../patches/v3-0001-tipc-replace-deprecated-strcpy-with-strscpy-in-ti.patch
Applying: tipc: replace deprecated strcpy with strscpy in tipc_bearer_get_name()
<path of the linux tree>/net-next$ git branch
* main
<path of the linux tree>/net-next$

Am I missing something?

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-14 16:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13 10:22 [PATCH net-next v3] tipc: replace deprecated strcpy with strscpy in tipc_bearer_get_name() Ajith P V
2026-08-14  9:00 ` Tung Quang Nguyen
2026-08-14 12:55   ` Ajith P V
2026-08-14 13:03     ` Tung Quang Nguyen
2026-08-14 16:08       ` 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