Sun Jan 7 15:28:34 2018 UTC ()
Revert namespacing of atoi(3)

Sanitizers can handle recursive interceptions in some / most cases, if they
will cause damage the problem will be not workaroundable without libc
changes - I will be back to it.

Keep namespace of asctime() as this can be a cancellation point according
to POSIX. Right now it's not implemented on NetBSD. Defer it for later.

Keep weak symbols and namespace for wait6(2) as this could be a
cancellation point as well. Defer this for later.

Sanitizers's [recursive] interceptors are a hack and moving one way or
another can cause new sets of problems. Recursive ones can be useful and
cause problems (on Linux there are known with with signal handlers).

Sponsored by <The NetBSD Foundation>


(kamil)
diff -r1.193 -r1.194 src/lib/libc/include/namespace.h
diff -r1.13 -r1.14 src/lib/libc/stdlib/atoi.c
diff -r1.2 -r1.3 src/sys/external/bsd/compiler_rt/dist/lib/profile/InstrProfilingFile.c

cvs diff -r1.193 -r1.194 src/lib/libc/include/namespace.h (expand / switch to unified diff)

--- src/lib/libc/include/namespace.h 2018/01/05 20:30:51 1.193
+++ src/lib/libc/include/namespace.h 2018/01/07 15:28:33 1.194
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: namespace.h,v 1.193 2018/01/05 20:30:51 kamil Exp $ */ 1/* $NetBSD: namespace.h,v 1.194 2018/01/07 15:28:33 kamil Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1997-2004 The NetBSD Foundation, Inc. 4 * Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -207,27 +207,26 @@ @@ -207,27 +207,26 @@
207#define allocaddrinfo _allocaddrinfo 207#define allocaddrinfo _allocaddrinfo
208#define alphasort _alphasort 208#define alphasort _alphasort
209#define arc4random _arc4random 209#define arc4random _arc4random
210#define arc4random_addrandom _arc4random_addrandom 210#define arc4random_addrandom _arc4random_addrandom
211#define arc4random_buf _arc4random_buf 211#define arc4random_buf _arc4random_buf
212#define arc4random_stir _arc4random_stir 212#define arc4random_stir _arc4random_stir
213#define arc4random_uniform _arc4random_uniform 213#define arc4random_uniform _arc4random_uniform
214#define asctime _asctime 214#define asctime _asctime
215#define asctime_r _asctime_r 215#define asctime_r _asctime_r
216#define asprintf _asprintf 216#define asprintf _asprintf
217#define asprintf_l _asprintf_l 217#define asprintf_l _asprintf_l
218#define asysctl _asysctl 218#define asysctl _asysctl
219#define asysctlbyname _asysctlbyname 219#define asysctlbyname _asysctlbyname
220#define atoi _atoi 
221#define atoll _atoll 220#define atoll _atoll
222#define authnone_create _authnone_create 221#define authnone_create _authnone_create
223#define authunix_create _authunix_create 222#define authunix_create _authunix_create
224#define authunix_create_default _authunix_create_default 223#define authunix_create_default _authunix_create_default
225#define basename _basename 224#define basename _basename
226#define bindresvport _bindresvport 225#define bindresvport _bindresvport
227#define bindresvport_sa _bindresvport_sa 226#define bindresvport_sa _bindresvport_sa
228#define bm_comp _bm_comp 227#define bm_comp _bm_comp
229#define bm_exec _bm_exec 228#define bm_exec _bm_exec
230#define bm_free _bm_free 229#define bm_free _bm_free
231#define callrpc _callrpc 230#define callrpc _callrpc
232#define cdbr_close _cdbr_close 231#define cdbr_close _cdbr_close
233#define cdbr_find _cdbr_find 232#define cdbr_find _cdbr_find

cvs diff -r1.13 -r1.14 src/lib/libc/stdlib/atoi.c (expand / switch to unified diff)

--- src/lib/libc/stdlib/atoi.c 2018/01/05 20:30:51 1.13
+++ src/lib/libc/stdlib/atoi.c 2018/01/07 15:28:33 1.14
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: atoi.c,v 1.13 2018/01/05 20:30:51 kamil Exp $ */ 1/* $NetBSD: atoi.c,v 1.14 2018/01/07 15:28:33 kamil Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1993 4 * Copyright (c) 1988, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,33 +24,27 @@ @@ -24,33 +24,27 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#if defined(LIBC_SCCS) && !defined(lint) 33#if defined(LIBC_SCCS) && !defined(lint)
34#if 0 34#if 0
35static char sccsid[] = "@(#)atoi.c 8.1 (Berkeley) 6/4/93"; 35static char sccsid[] = "@(#)atoi.c 8.1 (Berkeley) 6/4/93";
36#else 36#else
37__RCSID("$NetBSD: atoi.c,v 1.13 2018/01/05 20:30:51 kamil Exp $"); 37__RCSID("$NetBSD: atoi.c,v 1.14 2018/01/07 15:28:33 kamil Exp $");
38#endif 38#endif
39#endif /* LIBC_SCCS and not lint */ 39#endif /* LIBC_SCCS and not lint */
40 40
41#include "namespace.h" 
42 
43#include <assert.h> 41#include <assert.h>
44#include <stdlib.h> 42#include <stdlib.h>
45 43
46#ifdef __weak_alias 
47__weak_alias(atoi,_atoi) 
48#endif 
49 
50int 44int
51atoi(const char *str) 45atoi(const char *str)
52{ 46{
53 _DIAGASSERT(str != NULL); 47 _DIAGASSERT(str != NULL);
54 48
55 return((int)strtol(str, (char **)NULL, 10)); 49 return((int)strtol(str, (char **)NULL, 10));
56} 50}

cvs diff -r1.2 -r1.3 src/sys/external/bsd/compiler_rt/dist/lib/profile/InstrProfilingFile.c (expand / switch to unified diff)

--- src/sys/external/bsd/compiler_rt/dist/lib/profile/InstrProfilingFile.c 2018/01/05 20:30:51 1.2
+++ src/sys/external/bsd/compiler_rt/dist/lib/profile/InstrProfilingFile.c 2018/01/07 15:28:34 1.3
@@ -1,26 +1,22 @@ @@ -1,26 +1,22 @@
1/*===- InstrProfilingFile.c - Write instrumentation to a file -------------===*\ 1/*===- InstrProfilingFile.c - Write instrumentation to a file -------------===*\
2|* 2|*
3|* The LLVM Compiler Infrastructure 3|* The LLVM Compiler Infrastructure
4|* 4|*
5|* This file is distributed under the University of Illinois Open Source 5|* This file is distributed under the University of Illinois Open Source
6|* License. See LICENSE.TXT for details. 6|* License. See LICENSE.TXT for details.
7|* 7|*
8\*===----------------------------------------------------------------------===*/ 8\*===----------------------------------------------------------------------===*/
9 9
10#ifdef _LIBC 
11#include "namespace.h" 
12#endif 
13 
14#include "InstrProfiling.h" 10#include "InstrProfiling.h"
15#include "InstrProfilingInternal.h" 11#include "InstrProfilingInternal.h"
16#include "InstrProfilingUtil.h" 12#include "InstrProfilingUtil.h"
17#include <errno.h> 13#include <errno.h>
18#include <stdio.h> 14#include <stdio.h>
19#include <stdlib.h> 15#include <stdlib.h>
20#include <string.h> 16#include <string.h>
21 17
22#define UNCONST(ptr) ((void *)(uintptr_t)(ptr)) 18#define UNCONST(ptr) ((void *)(uintptr_t)(ptr))
23 19
24/* Return 1 if there is an error, otherwise return 0. */ 20/* Return 1 if there is an error, otherwise return 0. */
25static uint32_t fileWriter(ProfDataIOVec *IOVecs, uint32_t NumIOVecs, 21static uint32_t fileWriter(ProfDataIOVec *IOVecs, uint32_t NumIOVecs,
26 void **WriterCtx) { 22 void **WriterCtx) {