mirror of
https://github.com/torvalds/linux.git
synced 2024-11-01 13:03:25 +01:00
cf0d7e7f45
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>
37 lines
859 B
C
37 lines
859 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Resolve DNS hostnames into valid ip addresses
|
|
*/
|
|
#ifndef __LINUX_FS_NFS_DNS_RESOLVE_H
|
|
#define __LINUX_FS_NFS_DNS_RESOLVE_H
|
|
|
|
#define NFS_DNS_HOSTNAME_MAXLEN (128)
|
|
|
|
|
|
#ifdef CONFIG_NFS_USE_KERNEL_DNS
|
|
static inline int nfs_dns_resolver_init(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void nfs_dns_resolver_destroy(void)
|
|
{}
|
|
|
|
static inline int nfs_dns_resolver_cache_init(struct net *net)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void nfs_dns_resolver_cache_destroy(struct net *net)
|
|
{}
|
|
#else
|
|
extern int nfs_dns_resolver_init(void);
|
|
extern void nfs_dns_resolver_destroy(void);
|
|
extern int nfs_dns_resolver_cache_init(struct net *net);
|
|
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_storage *sa, size_t salen);
|
|
|
|
#endif
|