nfs: Avoid overrun when copying client IP address string
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): 1254662749.2395.68.camel@localhost
Quoted 13 lines · Ben Hutchings
As seen in <http://bugs.debian.org/549002>,
nfs4_init_client()can overrun the source string when copying the client IP address fromnfs_parsed_mount_data::client_addresstonfs_client::cl_ipaddr. Since these are both treated as null-terminated strings elsewhere, the copy should be done withstrlcpy()notmemcpy().Signed-off-by Ben Hutchings <[email protected]>---
fs/nfs/client.c +0
-0
fs/nfs/client.c static int nfs4_init_client(struct nfs_client *clp, · line 1079
Quoted 8 lines
fs/nfs/client.c +1
-1@@ -1073,7 +1073,7 @@ static int nfs4_init_client(struct nfs_client *clp, 1, flags & NFS_MOUNT_NORESVPORT);if (error <0 ) goto error; -memcpy (clp->cl_ipaddr, ip_addr,sizeof (clp->cl_ipaddr)); +strlcpy (clp->cl_ipaddr, ip_addr,sizeof (clp->cl_ipaddr)); error =nfs_idmap_new (clp);if (error <0 ) {
It looks good, so I'll push it upstream. I assume the bug report also applies to [email protected]?
Thanks!
Trond
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
A message that is not in the archive (sent off-list or not yet received): 1254695596.30515.75.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org
Re: Bug#549002: [PATCH] nfs: Avoid overrun when copying client IP address string
Quoted 20 lines · Trond Myklebust
Quoted 19 lines · Ben Hutchings
As seen in <http://bugs.debian.org/549002>,
nfs4_init_client()can overrun the source string when copying the client IP address fromnfs_parsed_mount_data::client_addresstonfs_client::cl_ipaddr. Since these are both treated as null-terminated strings elsewhere, the copy should be done withstrlcpy()notmemcpy().Signed-off-by Ben Hutchings <[email protected]>---
fs/nfs/client.c +1
-1@@ -1073,7 +1073,7 @@ static int nfs4_init_client(struct nfs_client *clp, 1, flags & NFS_MOUNT_NORESVPORT);if (error <0 ) goto error; -memcpy (clp->cl_ipaddr, ip_addr,sizeof (clp->cl_ipaddr)); +strlcpy (clp->cl_ipaddr, ip_addr,sizeof (clp->cl_ipaddr));
Quoted 5 lines
fs/nfs/client.c static int nfs4_init_client(struct nfs_client *clp, · line 1079
Quoted 2 lines
fs/nfs/client.c +0
-0error =nfs_idmap_new (clp);if (error <0 ) {It looks good, so I'll push it upstream. I assume the bug report also applies to [email protected]?
This bug appears to have been present "forever", though I think it has become a practical problem since nfs_client::cl_ipaddr was enlarged to 48 bytes in v2.6.25. So yes, the bug and fix are applicable to every stable series.
Ben.
Signature · 2 lines
Ben Hutchings I say we take off; nuke the site from orbit. It's the only way to be sure.