Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/sysctl sysctl: Add indirection of symbols to remove cla...



details:   https://anonhg.NetBSD.org/src/rev/2088ceec5c06
branches:  trunk
changeset: 964798:2088ceec5c06
user:      kamil <kamil%NetBSD.org@localhost>
date:      Sun Aug 18 04:10:22 2019 +0000

description:
sysctl: Add indirection of symbols to remove clash with sanitizers

Add indirection and symbol renaming under MKSANITIZER for the linked in
version of sysctlbyname and sysctlgetmibinfo.

diffstat:

 sbin/sysctl/Makefile         |   6 +++++-
 sbin/sysctl/prog_ops.h       |  16 +++++++++++++++-
 sbin/sysctl/sysctl.c         |  16 ++++++++--------
 sbin/sysctl/sysctl_hostops.c |   8 ++++++--
 sbin/sysctl/sysctl_rumpops.c |   8 ++++++--
 5 files changed, 40 insertions(+), 14 deletions(-)

diffs (187 lines):

diff -r d3b00ab37ee4 -r 2088ceec5c06 sbin/sysctl/Makefile
--- a/sbin/sysctl/Makefile      Sun Aug 18 02:42:40 2019 +0000
+++ b/sbin/sysctl/Makefile      Sun Aug 18 04:10:22 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.21 2012/11/29 02:05:38 christos Exp $
+#      $NetBSD: Makefile,v 1.22 2019/08/18 04:10:22 kamil Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/6/93
 
 .include <bsd.own.mk>
@@ -13,4 +13,8 @@
 CPPFLAGS+= -DRUMP_ACTION
 RUMPSRCS+= sysctlbyname.c sysctlgetmibinfo.c
 
+SANITIZER_RENAME_CLASSES+=     rump
+SANITIZER_RENAME_FILES.rump+=  ${PROG}_rumpops.c ${RUMPSRCS}
+SANITIZER_RENAME_SYMBOL.rump+= sysctlbyname sysctlgetmibinfo
+
 .include <bsd.prog.mk>
diff -r d3b00ab37ee4 -r 2088ceec5c06 sbin/sysctl/prog_ops.h
--- a/sbin/sysctl/prog_ops.h    Sun Aug 18 02:42:40 2019 +0000
+++ b/sbin/sysctl/prog_ops.h    Sun Aug 18 04:10:22 2019 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: prog_ops.h,v 1.2 2010/12/13 21:48:01 pooka Exp $      */
+/*      $NetBSD: prog_ops.h,v 1.3 2019/08/18 04:10:22 kamil Exp $      */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -32,19 +32,33 @@
 #include <sys/types.h>
 
 #ifndef CRUNCHOPS
+struct sysctlnode;
+
 struct prog_ops {
        int (*op_init)(void);
 
        int (*op_sysctl)(const int *, u_int, void *, size_t *,
                         const void *, size_t);
+
+       /* Indirection needed for sanitizers. */
+
+       int (*op_sysctlbyname)(const char *, void *, size_t *,
+                        const void *, size_t);
+
+       int (*op_sysctlgetmibinfo)(const char *, int *, u_int *, char *,
+                        size_t *, struct sysctlnode **, int);
 };
 extern const struct prog_ops prog_ops;
 
 #define prog_init prog_ops.op_init
 #define prog_sysctl prog_ops.op_sysctl
+#define prog_sysctlbyname prog_ops.op_sysctlbyname
+#define prog_sysctlgetmibinfo prog_ops.op_sysctlgetmibinfo
 #else
 #define prog_init ((int (*)(void))NULL)
 #define prog_sysctl sysctl
+#define prog_sysctlbyname sysctlbyname
+#define prog_sysctlgetmibinfo sysctlgetmibinfo
 #endif
 
 #endif /* _PROG_OPS_H_ */
diff -r d3b00ab37ee4 -r 2088ceec5c06 sbin/sysctl/sysctl.c
--- a/sbin/sysctl/sysctl.c      Sun Aug 18 02:42:40 2019 +0000
+++ b/sbin/sysctl/sysctl.c      Sun Aug 18 04:10:22 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysctl.c,v 1.161 2018/10/30 19:41:21 kre Exp $ */
+/*     $NetBSD: sysctl.c,v 1.162 2019/08/18 04:10:22 kamil Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
 #if 0
 static char sccsid[] = "@(#)sysctl.c   8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: sysctl.c,v 1.161 2018/10/30 19:41:21 kre Exp $");
+__RCSID("$NetBSD: sysctl.c,v 1.162 2019/08/18 04:10:22 kamil Exp $");
 #endif
 #endif /* not lint */
 
@@ -896,7 +896,7 @@
        namelen = CTL_MAXNAME;
        sz = sizeof(gsname);
 
-       if (sysctlgetmibinfo(key, &name[0], &namelen, gsname, &sz, &node,
+       if (prog_sysctlgetmibinfo(key, &name[0], &namelen, gsname, &sz, &node,
                             SYSCTL_VERSION) == -1) {
                if (optional)
                        return;
@@ -1441,7 +1441,7 @@
                namelen = sizeof(name) / sizeof(name[0]);
                sz = sizeof(gsname);
                *t = '\0';
-               rc = sysctlgetmibinfo(nname, &name[0], &namelen,
+               rc = prog_sysctlgetmibinfo(nname, &name[0], &namelen,
                                      gsname, &sz, NULL, SYSCTL_VERSION);
                *t = sep[0];
                if (rc == -1) {
@@ -1489,7 +1489,7 @@
        memset(name, 0, sizeof(name));
        namelen = sizeof(name) / sizeof(name[0]);
        sz = sizeof(gsname);
-       rc = sysctlgetmibinfo(l, &name[0], &namelen, gsname, &sz, NULL,
+       rc = prog_sysctlgetmibinfo(l, &name[0], &namelen, gsname, &sz, NULL,
                              SYSCTL_VERSION);
        if (rc == -1) {
                sysctlparseerror(namelen, l);
@@ -1538,7 +1538,7 @@
        memset(name, 0, sizeof(name));
        namelen = sizeof(name) / sizeof(name[0]);
        sz = sizeof(gsname);
-       rc = sysctlgetmibinfo(l, &name[0], &namelen, gsname, &sz, NULL,
+       rc = prog_sysctlgetmibinfo(l, &name[0], &namelen, gsname, &sz, NULL,
                              SYSCTL_VERSION);
        if (rc == -1) {
                sysctlparseerror(namelen, l);
@@ -2266,7 +2266,7 @@
 
        if (namelen == 2 && Aflag) {
                sz = sizeof(n);
-               rc = sysctlbyname("hw.ncpu", &n, &sz, NULL, 0);
+               rc = prog_sysctlbyname("hw.ncpu", &n, &sz, NULL, 0);
                if (rc != 0)
                        return; /* XXX print an error, eh? */
                n++; /* Add on space for the sum. */
@@ -2414,7 +2414,7 @@
 
        if (namelen == 2) {
                sz = sizeof(n);
-               rc = sysctlbyname("hw.ncpu", &n, &sz, NULL, 0);
+               rc = prog_sysctlbyname("hw.ncpu", &n, &sz, NULL, 0);
                if (rc != 0)
                        return; /* XXX print an error, eh? */
                sz = n * sizeof(u_int64_t);
diff -r d3b00ab37ee4 -r 2088ceec5c06 sbin/sysctl/sysctl_hostops.c
--- a/sbin/sysctl/sysctl_hostops.c      Sun Aug 18 02:42:40 2019 +0000
+++ b/sbin/sysctl/sysctl_hostops.c      Sun Aug 18 04:10:22 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysctl_hostops.c,v 1.1 2010/12/13 17:47:40 pooka Exp $ */
+/*     $NetBSD: sysctl_hostops.c,v 1.2 2019/08/18 04:10:22 kamil Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: sysctl_hostops.c,v 1.1 2010/12/13 17:47:40 pooka Exp $");
+__RCSID("$NetBSD: sysctl_hostops.c,v 1.2 2019/08/18 04:10:22 kamil Exp $");
 #endif /* !lint */
 
 #include <sys/types.h>
@@ -38,4 +38,8 @@
 
 const struct prog_ops prog_ops = {
        .op_sysctl = sysctl,
+
+       .op_sysctlbyname = sysctlbyname,
+
+       .op_sysctlgetmibinfo = sysctlgetmibinfo,
 };
diff -r d3b00ab37ee4 -r 2088ceec5c06 sbin/sysctl/sysctl_rumpops.c
--- a/sbin/sysctl/sysctl_rumpops.c      Sun Aug 18 02:42:40 2019 +0000
+++ b/sbin/sysctl/sysctl_rumpops.c      Sun Aug 18 04:10:22 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysctl_rumpops.c,v 1.1 2010/12/13 17:47:40 pooka Exp $ */
+/*     $NetBSD: sysctl_rumpops.c,v 1.2 2019/08/18 04:10:22 kamil Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: sysctl_rumpops.c,v 1.1 2010/12/13 17:47:40 pooka Exp $");
+__RCSID("$NetBSD: sysctl_rumpops.c,v 1.2 2019/08/18 04:10:22 kamil Exp $");
 #endif /* !lint */
 
 #include <sys/types.h>
@@ -44,4 +44,8 @@
        .op_init =      rumpclient_init,
 
        .op_sysctl =    rump_sys___sysctl,
+
+       .op_sysctlbyname = sysctlbyname,
+
+       .op_sysctlgetmibinfo = sysctlgetmibinfo,
 };



Home | Main Index | Thread Index | Old Index