public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 05/14] NFSD: move from strlcpy with unused retval to strscpy
       [not found] <20220818210123.7637-1-wsa+renesas@sang-engineering.com>
@ 2022-08-18 21:01 ` Wolfram Sang
  2022-08-18 21:08   ` Chuck Lever III
  2022-08-18 21:01 ` [PATCH 06/14] NFS: " Wolfram Sang
  2022-08-18 21:01 ` [PATCH 07/14] lockd: " Wolfram Sang
  2 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2022-08-18 21:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: Wolfram Sang, Chuck Lever, Jeff Layton, linux-nfs

Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 fs/nfsd/nfs4idmap.c | 8 ++++----
 fs/nfsd/nfs4proc.c  | 2 +-
 fs/nfsd/nfssvc.c    | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
index f92161ce1f97..e70a1a2999b7 100644
--- a/fs/nfsd/nfs4idmap.c
+++ b/fs/nfsd/nfs4idmap.c
@@ -82,8 +82,8 @@ ent_init(struct cache_head *cnew, struct cache_head *citm)
 	new->id = itm->id;
 	new->type = itm->type;
 
-	strlcpy(new->name, itm->name, sizeof(new->name));
-	strlcpy(new->authname, itm->authname, sizeof(new->authname));
+	strscpy(new->name, itm->name, sizeof(new->name));
+	strscpy(new->authname, itm->authname, sizeof(new->authname));
 }
 
 static void
@@ -548,7 +548,7 @@ idmap_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen
 		return nfserr_badowner;
 	memcpy(key.name, name, namelen);
 	key.name[namelen] = '\0';
-	strlcpy(key.authname, rqst_authname(rqstp), sizeof(key.authname));
+	strscpy(key.authname, rqst_authname(rqstp), sizeof(key.authname));
 	ret = idmap_lookup(rqstp, nametoid_lookup, &key, nn->nametoid_cache, &item);
 	if (ret == -ENOENT)
 		return nfserr_badowner;
@@ -584,7 +584,7 @@ static __be32 idmap_id_to_name(struct xdr_stream *xdr,
 	int ret;
 	struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
 
-	strlcpy(key.authname, rqst_authname(rqstp), sizeof(key.authname));
+	strscpy(key.authname, rqst_authname(rqstp), sizeof(key.authname));
 	ret = idmap_lookup(rqstp, idtoname_lookup, &key, nn->idtoname_cache, &item);
 	if (ret == -ENOENT)
 		return encode_ascii_id(xdr, id);
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index a72ab97f77ef..0437210b9898 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1343,7 +1343,7 @@ static __be32 nfsd4_ssc_setup_dul(struct nfsd_net *nn, char *ipaddr,
 		return 0;
 	}
 	if (work) {
-		strlcpy(work->nsui_ipaddr, ipaddr, sizeof(work->nsui_ipaddr) - 1);
+		strscpy(work->nsui_ipaddr, ipaddr, sizeof(work->nsui_ipaddr) - 1);
 		refcount_set(&work->nsui_refcnt, 2);
 		work->nsui_busy = true;
 		list_add_tail(&work->nsui_list, &nn->nfsd_ssc_mount_list);
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index 4bb5baa17040..bfbd9f672f59 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -799,7 +799,7 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred)
 	if (nrservs == 0 && nn->nfsd_serv == NULL)
 		goto out;
 
-	strlcpy(nn->nfsd_name, utsname()->nodename,
+	strscpy(nn->nfsd_name, utsname()->nodename,
 		sizeof(nn->nfsd_name));
 
 	error = nfsd_create_serv(net);
-- 
2.35.1


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

* [PATCH 06/14] NFS: move from strlcpy with unused retval to strscpy
       [not found] <20220818210123.7637-1-wsa+renesas@sang-engineering.com>
  2022-08-18 21:01 ` [PATCH 05/14] NFSD: move from strlcpy with unused retval to strscpy Wolfram Sang
@ 2022-08-18 21:01 ` Wolfram Sang
  2022-08-18 21:01 ` [PATCH 07/14] lockd: " Wolfram Sang
  2 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2022-08-18 21:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: Wolfram Sang, Trond Myklebust, Anna Schumaker, linux-nfs

Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 fs/nfs/nfs4client.c | 2 +-
 fs/nfs/nfsroot.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index 3c5678aec006..7a5162afa5c0 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -254,7 +254,7 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
 			goto error;
 		ip_addr = (const char *)buf;
 	}
-	strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
+	strscpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
 
 	err = nfs_idmap_new(clp);
 	if (err < 0) {
diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c
index fa148308822c..620329b7e6ae 100644
--- a/fs/nfs/nfsroot.c
+++ b/fs/nfs/nfsroot.c
@@ -139,7 +139,7 @@ static int __init nfs_root_setup(char *line)
 	ROOT_DEV = Root_NFS;
 
 	if (line[0] == '/' || line[0] == ',' || (line[0] >= '0' && line[0] <= '9')) {
-		strlcpy(nfs_root_parms, line, sizeof(nfs_root_parms));
+		strscpy(nfs_root_parms, line, sizeof(nfs_root_parms));
 	} else {
 		size_t n = strlen(line) + sizeof(NFS_ROOT) - 1;
 		if (n >= sizeof(nfs_root_parms))
-- 
2.35.1


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

* [PATCH 07/14] lockd: move from strlcpy with unused retval to strscpy
       [not found] <20220818210123.7637-1-wsa+renesas@sang-engineering.com>
  2022-08-18 21:01 ` [PATCH 05/14] NFSD: move from strlcpy with unused retval to strscpy Wolfram Sang
  2022-08-18 21:01 ` [PATCH 06/14] NFS: " Wolfram Sang
@ 2022-08-18 21:01 ` Wolfram Sang
  2 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2022-08-18 21:01 UTC (permalink / raw)
  To: linux-kernel
  Cc: Wolfram Sang, Trond Myklebust, Anna Schumaker, Chuck Lever,
	Jeff Layton, linux-nfs

Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 fs/lockd/host.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index f802223e71ab..cdc8e12cdac4 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -164,7 +164,7 @@ static struct nlm_host *nlm_alloc_host(struct nlm_lookup_host_info *ni,
 	host->h_addrbuf    = nsm->sm_addrbuf;
 	host->net	   = ni->net;
 	host->h_cred	   = get_cred(ni->cred);
-	strlcpy(host->nodename, utsname()->nodename, sizeof(host->nodename));
+	strscpy(host->nodename, utsname()->nodename, sizeof(host->nodename));
 
 out:
 	return host;
-- 
2.35.1


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

* Re: [PATCH 05/14] NFSD: move from strlcpy with unused retval to strscpy
  2022-08-18 21:01 ` [PATCH 05/14] NFSD: move from strlcpy with unused retval to strscpy Wolfram Sang
@ 2022-08-18 21:08   ` Chuck Lever III
  2022-08-19  5:41     ` Wolfram Sang
  0 siblings, 1 reply; 5+ messages in thread
From: Chuck Lever III @ 2022-08-18 21:08 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Linux Kernel Mailing List, Jeff Layton, Linux NFS Mailing List



> On Aug 18, 2022, at 5:01 PM, Wolfram Sang <wsa+renesas@sang-engineering.com> wrote:
> 
> Follow the advice of the below link and prefer 'strscpy' in this
> subsystem. Conversion is 1:1 because the return value is not used.
> Generated by a coccinelle script.
> 
> Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Makes sense.

I think I would like to carry 05 and 07 in the NFSD tree so they
can get some exposure to our test workloads before they are merged.
Is that OK with you?


> ---
> fs/nfsd/nfs4idmap.c | 8 ++++----
> fs/nfsd/nfs4proc.c  | 2 +-
> fs/nfsd/nfssvc.c    | 2 +-
> 3 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
> index f92161ce1f97..e70a1a2999b7 100644
> --- a/fs/nfsd/nfs4idmap.c
> +++ b/fs/nfsd/nfs4idmap.c
> @@ -82,8 +82,8 @@ ent_init(struct cache_head *cnew, struct cache_head *citm)
> 	new->id = itm->id;
> 	new->type = itm->type;
> 
> -	strlcpy(new->name, itm->name, sizeof(new->name));
> -	strlcpy(new->authname, itm->authname, sizeof(new->authname));
> +	strscpy(new->name, itm->name, sizeof(new->name));
> +	strscpy(new->authname, itm->authname, sizeof(new->authname));
> }
> 
> static void
> @@ -548,7 +548,7 @@ idmap_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen
> 		return nfserr_badowner;
> 	memcpy(key.name, name, namelen);
> 	key.name[namelen] = '\0';
> -	strlcpy(key.authname, rqst_authname(rqstp), sizeof(key.authname));
> +	strscpy(key.authname, rqst_authname(rqstp), sizeof(key.authname));
> 	ret = idmap_lookup(rqstp, nametoid_lookup, &key, nn->nametoid_cache, &item);
> 	if (ret == -ENOENT)
> 		return nfserr_badowner;
> @@ -584,7 +584,7 @@ static __be32 idmap_id_to_name(struct xdr_stream *xdr,
> 	int ret;
> 	struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
> 
> -	strlcpy(key.authname, rqst_authname(rqstp), sizeof(key.authname));
> +	strscpy(key.authname, rqst_authname(rqstp), sizeof(key.authname));
> 	ret = idmap_lookup(rqstp, idtoname_lookup, &key, nn->idtoname_cache, &item);
> 	if (ret == -ENOENT)
> 		return encode_ascii_id(xdr, id);
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index a72ab97f77ef..0437210b9898 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -1343,7 +1343,7 @@ static __be32 nfsd4_ssc_setup_dul(struct nfsd_net *nn, char *ipaddr,
> 		return 0;
> 	}
> 	if (work) {
> -		strlcpy(work->nsui_ipaddr, ipaddr, sizeof(work->nsui_ipaddr) - 1);
> +		strscpy(work->nsui_ipaddr, ipaddr, sizeof(work->nsui_ipaddr) - 1);
> 		refcount_set(&work->nsui_refcnt, 2);
> 		work->nsui_busy = true;
> 		list_add_tail(&work->nsui_list, &nn->nfsd_ssc_mount_list);
> diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
> index 4bb5baa17040..bfbd9f672f59 100644
> --- a/fs/nfsd/nfssvc.c
> +++ b/fs/nfsd/nfssvc.c
> @@ -799,7 +799,7 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred)
> 	if (nrservs == 0 && nn->nfsd_serv == NULL)
> 		goto out;
> 
> -	strlcpy(nn->nfsd_name, utsname()->nodename,
> +	strscpy(nn->nfsd_name, utsname()->nodename,
> 		sizeof(nn->nfsd_name));
> 
> 	error = nfsd_create_serv(net);
> -- 
> 2.35.1
> 

--
Chuck Lever




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

* Re: [PATCH 05/14] NFSD: move from strlcpy with unused retval to strscpy
  2022-08-18 21:08   ` Chuck Lever III
@ 2022-08-19  5:41     ` Wolfram Sang
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2022-08-19  5:41 UTC (permalink / raw)
  To: Chuck Lever III
  Cc: Linux Kernel Mailing List, Jeff Layton, Linux NFS Mailing List

[-- Attachment #1: Type: text/plain, Size: 579 bytes --]


> > Follow the advice of the below link and prefer 'strscpy' in this
> > subsystem. Conversion is 1:1 because the return value is not used.
> > Generated by a coccinelle script.
> > 
> > Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
> > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> 
> Makes sense.
> 
> I think I would like to carry 05 and 07 in the NFSD tree so they
> can get some exposure to our test workloads before they are merged.
> Is that OK with you?

Of course!

Thank you.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2022-08-19  5:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20220818210123.7637-1-wsa+renesas@sang-engineering.com>
2022-08-18 21:01 ` [PATCH 05/14] NFSD: move from strlcpy with unused retval to strscpy Wolfram Sang
2022-08-18 21:08   ` Chuck Lever III
2022-08-19  5:41     ` Wolfram Sang
2022-08-18 21:01 ` [PATCH 06/14] NFS: " Wolfram Sang
2022-08-18 21:01 ` [PATCH 07/14] lockd: " Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox