summaryrefslogtreecommitdiffstats
path: root/fs/nfs/dns_resolve.h
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2022-10-16 21:36:50 -0700
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2022-10-27 15:52:10 -0400
commitcf0d7e7f4520814f45e1313872ad5777ed504004 (patch)
treee5bdb30c9297ff31dcd7ea93925008864763d8d2 /fs/nfs/dns_resolve.h
parent121affdf8a940555ceef6ab10a709030e52a4f91 (diff)
downloadlinux-cf0d7e7f4520814f45e1313872ad5777ed504004.tar.bz2
NFS: Avoid memcpy() run-time warning for struct sockaddr overflows
The 'nfs_server' and 'mount_server' structures include a union of 'struct sockaddr' (with the older 16 bytes max address size) and 'struct sockaddr_storage' which is large enough to hold all the supported sa_family types (128 bytes max size). The runtime memcpy() buffer overflow checker is seeing attempts to write beyond the 16 bytes as an overflow, but the actual expected size is that of 'struct sockaddr_storage'. Plumb the use of 'struct sockaddr_storage' more completely through-out NFS, which results in adjusting the memcpy() buffers to the correct union members. Avoids this false positive run-time warning under CONFIG_FORTIFY_SOURCE: memcpy: detected field-spanning write (size 28) of single field "&ctx->nfs_server.address" at fs/nfs/namespace.c:178 (size 16) Reported-by: kernel test robot <yujie.liu@intel.com> Link: https://lore.kernel.org/all/202210110948.26b43120-yujie.liu@intel.com Cc: Trond Myklebust <trond.myklebust@hammerspace.com> Cc: Anna Schumaker <anna@kernel.org> Cc: linux-nfs@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'fs/nfs/dns_resolve.h')
-rw-r--r--fs/nfs/dns_resolve.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/nfs/dns_resolve.h b/fs/nfs/dns_resolve.h
index 576ff4b54c82..fe3b172c4de1 100644
--- a/fs/nfs/dns_resolve.h
+++ b/fs/nfs/dns_resolve.h
@@ -32,6 +32,6 @@ extern void nfs_dns_resolver_cache_destroy(struct net *net);
#endif
extern ssize_t nfs_dns_resolve_name(struct net *net, char *name,
- size_t namelen, struct sockaddr *sa, size_t salen);
+ size_t namelen, struct sockaddr_storage *sa, size_t salen);
#endif