[SCM] Samba Shared Repository - branch master updated
Samuel Cabrero
scabrero at samba.org
Mon Apr 6 17:35:02 UTC 2020
The branch, master has been updated
via c012f924382 third_party: Update nss_wrapper to version 1.1.11
from 53324c35d13 selftest: add two more nbt.dgram flapping tests
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit c012f924382bc694d3ddcc2946bb2c1d92742aff
Author: Andreas Schneider <asn at samba.org>
Date: Thu Apr 2 13:43:44 2020 +0200
third_party: Update nss_wrapper to version 1.1.11
This fixes strict aliasing which leads to segfaults on certain
architectures, e.g. armv7hl.
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Samuel Cabrero <scabrero at samba.org>
Autobuild-User(master): Samuel Cabrero <scabrero at samba.org>
Autobuild-Date(master): Mon Apr 6 17:34:53 UTC 2020 on sn-devel-184
-----------------------------------------------------------------------
Summary of changes:
buildtools/wafsamba/samba_third_party.py | 2 +-
third_party/nss_wrapper/nss_wrapper.c | 878 +++++++++++++++++++------------
third_party/nss_wrapper/wscript | 2 +-
3 files changed, 554 insertions(+), 328 deletions(-)
Changeset truncated at 500 lines:
diff --git a/buildtools/wafsamba/samba_third_party.py b/buildtools/wafsamba/samba_third_party.py
index 181d0b352a5..fae9029002d 100644
--- a/buildtools/wafsamba/samba_third_party.py
+++ b/buildtools/wafsamba/samba_third_party.py
@@ -29,7 +29,7 @@ Build.BuildContext.CHECK_SOCKET_WRAPPER = CHECK_SOCKET_WRAPPER
@conf
def CHECK_NSS_WRAPPER(conf):
- return conf.CHECK_BUNDLED_SYSTEM_PKG('nss_wrapper', minversion='1.1.10')
+ return conf.CHECK_BUNDLED_SYSTEM_PKG('nss_wrapper', minversion='1.1.11')
Build.BuildContext.CHECK_NSS_WRAPPER = CHECK_NSS_WRAPPER
@conf
diff --git a/third_party/nss_wrapper/nss_wrapper.c b/third_party/nss_wrapper/nss_wrapper.c
index d90264c6d24..17c87321d4d 100644
--- a/third_party/nss_wrapper/nss_wrapper.c
+++ b/third_party/nss_wrapper/nss_wrapper.c
@@ -185,6 +185,8 @@ typedef nss_status_t NSS_STATUS;
pthread_mutex_unlock(&( m ## _mutex)); \
} while(0)
+static pthread_mutex_t libc_symbol_binding_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t nss_module_symbol_binding_mutex = PTHREAD_MUTEX_INITIALIZER;
static bool nwrap_initialized = false;
static pthread_mutex_t nwrap_initialized_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -201,6 +203,8 @@ static pthread_mutex_t nwrap_sp_global_mutex = PTHREAD_MUTEX_INITIALIZER;
* nwrap_init() function.
*/
# define NWRAP_LOCK_ALL do { \
+ NWRAP_LOCK(libc_symbol_binding); \
+ NWRAP_LOCK(nss_module_symbol_binding); \
NWRAP_LOCK(nwrap_initialized); \
NWRAP_LOCK(nwrap_global); \
NWRAP_LOCK(nwrap_gr_global); \
@@ -216,6 +220,8 @@ static pthread_mutex_t nwrap_sp_global_mutex = PTHREAD_MUTEX_INITIALIZER;
NWRAP_UNLOCK(nwrap_gr_global); \
NWRAP_UNLOCK(nwrap_global); \
NWRAP_UNLOCK(nwrap_initialized); \
+ NWRAP_UNLOCK(nss_module_symbol_binding); \
+ NWRAP_UNLOCK(libc_symbol_binding); \
} while (0);
static void nwrap_init(void);
@@ -311,107 +317,278 @@ static void nwrap_log(enum nwrap_dbglvl_e dbglvl,
buffer);
}
-struct nwrap_libc_fns {
- struct passwd *(*_libc_getpwnam)(const char *name);
- int (*_libc_getpwnam_r)(const char *name, struct passwd *pwd,
- char *buf, size_t buflen, struct passwd **result);
- struct passwd *(*_libc_getpwuid)(uid_t uid);
- int (*_libc_getpwuid_r)(uid_t uid, struct passwd *pwd, char *buf, size_t buflen, struct passwd **result);
- void (*_libc_setpwent)(void);
- struct passwd *(*_libc_getpwent)(void);
+/*****************
+ * LIBC
+ *****************/
+
+#define LIBC_NAME "libc.so"
+
+typedef struct passwd *(*__libc_getpwnam)(const char *name);
+
+typedef int (*__libc_getpwnam_r)(const char *name,
+ struct passwd *pwd,
+ char *buf,
+ size_t buflen,
+ struct passwd **result);
+
+typedef struct passwd *(*__libc_getpwuid)(uid_t uid);
+
+typedef int (*__libc_getpwuid_r)(uid_t uid,
+ struct passwd *pwd,
+ char *buf,
+ size_t buflen,
+ struct passwd **result);
+
+typedef void (*__libc_setpwent)(void);
+
+typedef struct passwd *(*__libc_getpwent)(void);
+
#ifdef HAVE_GETPWENT_R
-# ifdef HAVE_SOLARIS_GETPWENT_R
- struct passwd *(*_libc_getpwent_r)(struct passwd *pwbuf, char *buf, size_t buflen);
-# else /* HAVE_SOLARIS_GETPWENT_R */
- int (*_libc_getpwent_r)(struct passwd *pwbuf, char *buf, size_t buflen, struct passwd **pwbufp);
-# endif /* HAVE_SOLARIS_GETPWENT_R */
+# ifdef HAVE_SOLARIS_GETPWENT_R
+typedef struct passwd *(*__libc_getpwent_r)(struct passwd *pwbuf,
+ char *buf,
+ size_t buflen);
+# else /* HAVE_SOLARIS_GETPWENT_R */
+typedef int (*__libc_getpwent_r)(struct passwd *pwbuf,
+ char *buf,
+ size_t buflen,
+ struct passwd **pwbufp);
+# endif /* HAVE_SOLARIS_GETPWENT_R */
#endif /* HAVE_GETPWENT_R */
- void (*_libc_endpwent)(void);
- int (*_libc_initgroups)(const char *user, gid_t gid);
- struct group *(*_libc_getgrnam)(const char *name);
- int (*_libc_getgrnam_r)(const char *name, struct group *grp, char *buf, size_t buflen, struct group **result);
- struct group *(*_libc_getgrgid)(gid_t gid);
- int (*_libc_getgrgid_r)(gid_t gid, struct group *grp, char *buf, size_t buflen, struct group **result);
- void (*_libc_setgrent)(void);
- struct group *(*_libc_getgrent)(void);
+
+typedef void (*__libc_endpwent)(void);
+
+typedef int (*__libc_initgroups)(const char *user, gid_t gid);
+
+typedef struct group *(*__libc_getgrnam)(const char *name);
+
+typedef int (*__libc_getgrnam_r)(const char *name,
+ struct group *grp,
+ char *buf,
+ size_t buflen,
+ struct group **result);
+
+typedef struct group *(*__libc_getgrgid)(gid_t gid);
+
+typedef int (*__libc_getgrgid_r)(gid_t gid,
+ struct group *grp,
+ char *buf,
+ size_t buflen,
+ struct group **result);
+
+typedef void (*__libc_setgrent)(void);
+
+typedef struct group *(*__libc_getgrent)(void);
+
#ifdef HAVE_GETGRENT_R
-# ifdef HAVE_SOLARIS_GETGRENT_R
- struct group *(*_libc_getgrent_r)(struct group *group, char *buf, size_t buflen);
-# else /* HAVE_SOLARIS_GETGRENT_R */
- int (*_libc_getgrent_r)(struct group *group, char *buf, size_t buflen, struct group **result);
-# endif /* HAVE_SOLARIS_GETGRENT_R */
+# ifdef HAVE_SOLARIS_GETGRENT_R
+typedef struct group *(*__libc_getgrent_r)(struct group *group,
+ char *buf,
+ size_t buflen);
+# else /* HAVE_SOLARIS_GETGRENT_R */
+typedef int (*__libc_getgrent_r)(struct group *group,
+ char *buf,
+ size_t buflen,
+ struct group **result);
+# endif /* HAVE_SOLARIS_GETGRENT_R */
#endif /* HAVE_GETGRENT_R */
- void (*_libc_endgrent)(void);
- int (*_libc_getgrouplist)(const char *user, gid_t group, gid_t *groups, int *ngroups);
- void (*_libc_sethostent)(int stayopen);
- struct hostent *(*_libc_gethostent)(void);
- void (*_libc_endhostent)(void);
+typedef void (*__libc_endgrent)(void);
+
+typedef int (*__libc_getgrouplist)(const char *user,
+ gid_t group,
+ gid_t *groups,
+ int *ngroups);
+
+typedef void (*__libc_sethostent)(int stayopen);
+
+typedef struct hostent *(*__libc_gethostent)(void);
+
+typedef void (*__libc_endhostent)(void);
+
+typedef struct hostent *(*__libc_gethostbyname)(const char *name);
- struct hostent *(*_libc_gethostbyname)(const char *name);
#ifdef HAVE_GETHOSTBYNAME2 /* GNU extension */
- struct hostent *(*_libc_gethostbyname2)(const char *name, int af);
+typedef struct hostent *(*__libc_gethostbyname2)(const char *name, int af);
#endif
+
#ifdef HAVE_GETHOSTBYNAME2_R /* GNU extension */
- int (*_libc_gethostbyname2_r)(const char *name,
- int af,
+typedef int (*__libc_gethostbyname2_r)(const char *name,
+ int af,
+ struct hostent *ret,
+ char *buf,
+ size_t buflen,
+ struct hostent **result,
+ int *h_errnop);
+#endif
+
+typedef struct hostent *(*__libc_gethostbyaddr)(const void *addr,
+ socklen_t len,
+ int type);
+
+typedef int (*__libc_getaddrinfo)(const char *node,
+ const char *service,
+ const struct addrinfo *hints,
+ struct addrinfo **res);
+typedef int (*__libc_getnameinfo)(const struct sockaddr *sa,
+ socklen_t salen,
+ char *host,
+ size_t hostlen,
+ char *serv,
+ size_t servlen,
+ int flags);
+
+typedef int (*__libc_gethostname)(char *name, size_t len);
+
+#ifdef HAVE_GETHOSTBYNAME_R
+typedef int (*__libc_gethostbyname_r)(const char *name,
+ struct hostent *ret,
+ char *buf, size_t buflen,
+ struct hostent **result, int *h_errnop);
+#endif
+
+#ifdef HAVE_GETHOSTBYADDR_R
+typedef int (*__libc_gethostbyaddr_r)(const void *addr,
+ socklen_t len,
+ int type,
struct hostent *ret,
char *buf,
size_t buflen,
struct hostent **result,
int *h_errnop);
#endif
- struct hostent *(*_libc_gethostbyaddr)(const void *addr, socklen_t len, int type);
-
- int (*_libc_getaddrinfo)(const char *node, const char *service,
- const struct addrinfo *hints,
- struct addrinfo **res);
- int (*_libc_getnameinfo)(const struct sockaddr *sa, socklen_t salen,
- char *host, size_t hostlen,
- char *serv, size_t servlen,
- int flags);
- int (*_libc_gethostname)(char *name, size_t len);
+
+#define NWRAP_SYMBOL_ENTRY(i) \
+ union { \
+ __libc_##i f; \
+ void *obj; \
+ } _libc_##i
+
+struct nwrap_libc_symbols {
+ NWRAP_SYMBOL_ENTRY(getpwnam);
+ NWRAP_SYMBOL_ENTRY(getpwnam_r);
+ NWRAP_SYMBOL_ENTRY(getpwuid);
+ NWRAP_SYMBOL_ENTRY(getpwuid_r);
+ NWRAP_SYMBOL_ENTRY(setpwent);
+ NWRAP_SYMBOL_ENTRY(getpwent);
+#ifdef HAVE_GETPWENT_R
+ NWRAP_SYMBOL_ENTRY(getpwent_r);
+#endif
+ NWRAP_SYMBOL_ENTRY(endpwent);
+
+ NWRAP_SYMBOL_ENTRY(initgroups);
+ NWRAP_SYMBOL_ENTRY(getgrnam);
+ NWRAP_SYMBOL_ENTRY(getgrnam_r);
+ NWRAP_SYMBOL_ENTRY(getgrgid);
+ NWRAP_SYMBOL_ENTRY(getgrgid_r);
+ NWRAP_SYMBOL_ENTRY(setgrent);
+ NWRAP_SYMBOL_ENTRY(getgrent);
+#ifdef HAVE_GETGRENT_R
+ NWRAP_SYMBOL_ENTRY(getgrent_r);
+#endif
+ NWRAP_SYMBOL_ENTRY(endgrent);
+ NWRAP_SYMBOL_ENTRY(getgrouplist);
+
+ NWRAP_SYMBOL_ENTRY(sethostent);
+ NWRAP_SYMBOL_ENTRY(gethostent);
+ NWRAP_SYMBOL_ENTRY(endhostent);
+ NWRAP_SYMBOL_ENTRY(gethostbyname);
#ifdef HAVE_GETHOSTBYNAME_R
- int (*_libc_gethostbyname_r)(const char *name,
- struct hostent *ret,
- char *buf, size_t buflen,
- struct hostent **result, int *h_errnop);
+ NWRAP_SYMBOL_ENTRY(gethostbyname_r);
+#endif
+#ifdef HAVE_GETHOSTBYNAME2
+ NWRAP_SYMBOL_ENTRY(gethostbyname2);
#endif
+#ifdef HAVE_GETHOSTBYNAME2_R
+ NWRAP_SYMBOL_ENTRY(gethostbyname2_r);
+#endif
+ NWRAP_SYMBOL_ENTRY(gethostbyaddr);
#ifdef HAVE_GETHOSTBYADDR_R
- int (*_libc_gethostbyaddr_r)(const void *addr, socklen_t len, int type,
- struct hostent *ret,
- char *buf, size_t buflen,
- struct hostent **result, int *h_errnop);
+ NWRAP_SYMBOL_ENTRY(gethostbyaddr_r);
#endif
+ NWRAP_SYMBOL_ENTRY(getaddrinfo);
+ NWRAP_SYMBOL_ENTRY(getnameinfo);
+ NWRAP_SYMBOL_ENTRY(gethostname);
};
-
-struct nwrap_module_nss_fns {
- NSS_STATUS (*_nss_getpwnam_r)(const char *name, struct passwd *result, char *buffer,
- size_t buflen, int *errnop);
- NSS_STATUS (*_nss_getpwuid_r)(uid_t uid, struct passwd *result, char *buffer,
- size_t buflen, int *errnop);
- NSS_STATUS (*_nss_setpwent)(void);
- NSS_STATUS (*_nss_getpwent_r)(struct passwd *result, char *buffer,
- size_t buflen, int *errnop);
- NSS_STATUS (*_nss_endpwent)(void);
- NSS_STATUS (*_nss_initgroups)(const char *user, gid_t group, long int *start,
- long int *size, gid_t **groups, long int limit, int *errnop);
- NSS_STATUS (*_nss_getgrnam_r)(const char *name, struct group *result, char *buffer,
- size_t buflen, int *errnop);
- NSS_STATUS (*_nss_getgrgid_r)(gid_t gid, struct group *result, char *buffer,
- size_t buflen, int *errnop);
- NSS_STATUS (*_nss_setgrent)(void);
- NSS_STATUS (*_nss_getgrent_r)(struct group *result, char *buffer,
- size_t buflen, int *errnop);
- NSS_STATUS (*_nss_endgrent)(void);
- NSS_STATUS (*_nss_gethostbyaddr_r)(const void *addr, socklen_t addrlen,
- int af, struct hostent *result,
- char *buffer, size_t buflen,
- int *errnop, int *h_errnop);
- NSS_STATUS (*_nss_gethostbyname2_r)(const char *name, int af,
+#undef NWRAP_SYMBOL_ENTRY
+
+typedef NSS_STATUS (*__nss_getpwnam_r)(const char *name,
+ struct passwd *result,
+ char *buffer,
+ size_t buflen,
+ int *errnop);
+typedef NSS_STATUS (*__nss_getpwuid_r)(uid_t uid,
+ struct passwd *result,
+ char *buffer,
+ size_t buflen,
+ int *errnop);
+typedef NSS_STATUS (*__nss_setpwent)(void);
+typedef NSS_STATUS (*__nss_getpwent_r)(struct passwd *result,
+ char *buffer,
+ size_t buflen,
+ int *errnop);
+typedef NSS_STATUS (*__nss_endpwent)(void);
+typedef NSS_STATUS (*__nss_initgroups)(const char *user,
+ gid_t group,
+ long int *start,
+ long int *size,
+ gid_t **groups,
+ long int limit,
+ int *errnop);
+typedef NSS_STATUS (*__nss_getgrnam_r)(const char *name,
+ struct group *result,
+ char *buffer,
+ size_t buflen,
+ int *errnop);
+typedef NSS_STATUS (*__nss_getgrgid_r)(gid_t gid,
+ struct group *result,
+ char *buffer,
+ size_t buflen,
+ int *errnop);
+typedef NSS_STATUS (*__nss_setgrent)(void);
+typedef NSS_STATUS (*__nss_getgrent_r)(struct group *result,
+ char *buffer,
+ size_t buflen,
+ int *errnop);
+typedef NSS_STATUS (*__nss_endgrent)(void);
+typedef NSS_STATUS (*__nss_gethostbyaddr_r)(const void *addr,
+ socklen_t addrlen,
+ int af,
struct hostent *result,
- char *buffer, size_t buflen,
- int *errnop, int *h_errnop);
+ char *buffer,
+ size_t buflen,
+ int *errnop,
+ int *h_errnop);
+typedef NSS_STATUS (*__nss_gethostbyname2_r)(const char *name,
+ int af,
+ struct hostent *result,
+ char *buffer,
+ size_t buflen,
+ int *errnop,
+ int *h_errnop);
+
+#define NWRAP_NSS_MODULE_SYMBOL_ENTRY(i) \
+ union { \
+ __nss_##i f; \
+ void *obj; \
+ } _nss_##i
+
+struct nwrap_nss_module_symbols {
+ NWRAP_NSS_MODULE_SYMBOL_ENTRY(getpwnam_r);
+ NWRAP_NSS_MODULE_SYMBOL_ENTRY(getpwuid_r);
+ NWRAP_NSS_MODULE_SYMBOL_ENTRY(setpwent);
+ NWRAP_NSS_MODULE_SYMBOL_ENTRY(getpwent_r);
+ NWRAP_NSS_MODULE_SYMBOL_ENTRY(endpwent);
+
+ NWRAP_NSS_MODULE_SYMBOL_ENTRY(initgroups);
+ NWRAP_NSS_MODULE_SYMBOL_ENTRY(getgrnam_r);
+ NWRAP_NSS_MODULE_SYMBOL_ENTRY(getgrgid_r);
+ NWRAP_NSS_MODULE_SYMBOL_ENTRY(setgrent);
+ NWRAP_NSS_MODULE_SYMBOL_ENTRY(getgrent_r);
+ NWRAP_NSS_MODULE_SYMBOL_ENTRY(endgrent);
+
+ NWRAP_NSS_MODULE_SYMBOL_ENTRY(gethostbyaddr_r);
+ NWRAP_NSS_MODULE_SYMBOL_ENTRY(gethostbyname2_r);
};
struct nwrap_backend {
@@ -419,7 +596,7 @@ struct nwrap_backend {
const char *so_path;
void *so_handle;
struct nwrap_ops *ops;
- struct nwrap_module_nss_fns *fns;
+ struct nwrap_nss_module_symbols *symbols;
};
struct nwrap_vector;
@@ -634,7 +811,7 @@ struct nwrap_libc {
void *handle;
void *nsl_handle;
void *sock_handle;
- struct nwrap_libc_fns *fns;
+ struct nwrap_libc_symbols symbols;
};
struct nwrap_main {
@@ -1023,7 +1200,7 @@ static void *nwrap_load_lib_handle(enum nwrap_lib lib)
return handle;
}
-static void *_nwrap_load_lib_function(enum nwrap_lib lib, const char *fn_name)
+static void *_nwrap_bind_symbol(enum nwrap_lib lib, const char *fn_name)
{
void *handle;
void *func;
@@ -1046,11 +1223,37 @@ static void *_nwrap_load_lib_function(enum nwrap_lib lib, const char *fn_name)
return func;
}
-#define nwrap_load_lib_function(lib, fn_name) \
- if (nwrap_main_global->libc->fns->_libc_##fn_name == NULL) { \
- *(void **) (&nwrap_main_global->libc->fns->_libc_##fn_name) = \
- _nwrap_load_lib_function(lib, #fn_name); \
- }
+#define nwrap_bind_symbol_libc(sym_name) \
+ NWRAP_LOCK(libc_symbol_binding); \
+ if (nwrap_main_global->libc->symbols._libc_##sym_name.obj == NULL) { \
+ nwrap_main_global->libc->symbols._libc_##sym_name.obj = \
+ _nwrap_bind_symbol(NWRAP_LIBC, #sym_name); \
+ } \
+ NWRAP_UNLOCK(libc_symbol_binding)
+
+#define nwrap_bind_symbol_libc_posix(sym_name) \
+ NWRAP_LOCK(libc_symbol_binding); \
+ if (nwrap_main_global->libc->symbols._libc_##sym_name.obj == NULL) { \
+ nwrap_main_global->libc->symbols._libc_##sym_name.obj = \
+ _nwrap_bind_symbol(NWRAP_LIBC, "__posix_" #sym_name); \
+ } \
+ NWRAP_UNLOCK(libc_symbol_binding)
+
+#define nwrap_bind_symbol_libnsl(sym_name) \
+ NWRAP_LOCK(libc_symbol_binding); \
+ if (nwrap_main_global->libc->symbols._libc_##sym_name.obj == NULL) { \
+ nwrap_main_global->libc->symbols._libc_##sym_name.obj = \
+ _nwrap_bind_symbol(NWRAP_LIBNSL, #sym_name); \
+ } \
+ NWRAP_UNLOCK(libc_symbol_binding)
+
+#define nwrap_bind_symbol_libsocket(sym_name) \
+ NWRAP_LOCK(libc_symbol_binding); \
+ if (nwrap_main_global->libc->symbols._libc_##sym_name.obj == NULL) { \
+ nwrap_main_global->libc->symbols._libc_##sym_name.obj = \
+ _nwrap_bind_symbol(NWRAP_LIBSOCKET, #sym_name); \
+ } \
+ NWRAP_UNLOCK(libc_symbol_binding)
/* INTERNAL HELPER FUNCTIONS */
static void nwrap_lines_unload(struct nwrap_cache *const nwrap)
@@ -1075,9 +1278,9 @@ static void nwrap_lines_unload(struct nwrap_cache *const nwrap)
*/
static struct passwd *libc_getpwnam(const char *name)
{
- nwrap_load_lib_function(NWRAP_LIBC, getpwnam);
+ nwrap_bind_symbol_libc(getpwnam);
- return nwrap_main_global->libc->fns->_libc_getpwnam(name);
+ return nwrap_main_global->libc->symbols._libc_getpwnam.f(name);
}
#ifdef HAVE_GETPWNAM_R
@@ -1088,27 +1291,24 @@ static int libc_getpwnam_r(const char *name,
struct passwd **result)
{
#ifdef HAVE___POSIX_GETPWNAM_R
- if (nwrap_main_global->libc->fns->_libc_getpwnam_r == NULL) {
- *(void **) (&nwrap_main_global->libc->fns->_libc_getpwnam_r) =
- _nwrap_load_lib_function(NWRAP_LIBC, "__posix_getpwnam_r");
- }
+ nwrap_bind_symbol_libc_posix(getpwnam_r);
#else
- nwrap_load_lib_function(NWRAP_LIBC, getpwnam_r);
+ nwrap_bind_symbol_libc(getpwnam_r);
#endif
- return nwrap_main_global->libc->fns->_libc_getpwnam_r(name,
--
Samba Shared Repository
More information about the samba-cvs
mailing list