summaryrefslogtreecommitdiff
path: root/lib/libc/include/namespace.h
AgeCommit message (Collapse)Author
2022-05-31libc: Reintroduce getentropy.riastradh
This was introduced two years ago when the getrandom/getentropy API question was still open, and removed because the discussion was ongoing. Now getentropy is more widely adopted and soon to be in POSIX. So reintroduce the symbol into libc since we'll be keeping it anyway. Discussion of details of the semantics, as interpreted by NetBSD, is ongoing, but the symbol needs to get in before the netbsd-10 branch. The draft POSIX text is (https://www.opengroup.org/austin/docs/austin_1110.pdf): SYNOPSIS #include <unistd.h> int getentropy(void *buffer, size_t length); DESCRIPTION The getentropy() function shall write length bytes of data starting at the location pointed to by buffer. The output shall be unpredictable high quality random data, generated by a cryptographically secure pseudo-random number generator. The maximum permitted value for the length argument is given by the {GETENTROPY_MAX} symbolic constant defined in <limits.h>. RETURN VALUES Upon successful completion, getentropy() shall return 0; otherwise, -1 shall be retunred and errno set to indicate the error. ERRORS The getentropy() function shall fail if: [EINVAL] The value of length is greater than {GETENTROPY_MAX}. The getentropy() function may fail if: [ENOSYS] The system does not provide the necessary source of entropy. RATIONALE The getentropy() function is not a cancellation point. Minor changes from the previous introduction of getentropy into libc: - Return EINVAL, not EIO, on buflen > 256. - Define GETENTROPY_MAX in limits.h. The declaration of getentropy in unistd.h and definition of GETENTROPY_MAX in limits.h are currently conditional on _NETBSD_SOURCE. When the next revision of POSIX is finalized, we can expose them also under _POSIX_C_SOURCE > 20yymmL as usual -- and this can be done as a pullup without breaking existing compiled programs.
2021-09-11Add missing double p and d for stopped and overriden accordingly.andvar
Fix few more typos along the way, mainly in copy-pasted comments.
2021-07-04libc: remove special handling for lintrillig
In namespace.h 1.102 from 2005-07-16, the #ifndef was added to fix the broken lint2 pass. Somewhere between 2005 and now, lint has been changed so that it does not need this workaround anymore. After usr.bin/xlint/lint1/tree.c 1.303 from 2021-06-30, the #ifndef in namespace.h caused the only warning about an implicit function declaration in the whole NetBSD tree, in lib/libc/gen/sysconf.c:149, where _getpagesize was not defined, but only getpagesize.
2020-09-22remove getentropy bitsnia
2020-05-06Add getentropy() to libc - a simple wrapper to access the kernel CSPRNG.nia
Posted to tech-userlevel@ a week ago and reviewed by riastradh@. GETENTROPY(3) Library Functions Manual GETENTROPY(3) NAME getentropy - fill a buffer with high quality random data LIBRARY Standard C Library (libc, -lc) SYNOPSIS #include <unistd.h> int getentropy(void *buf, size_t buflen); DESCRIPTION The getentropy() function fills a buffer with high quality random data, suitable for seeding cryptographically secure psuedorandom number generators. getentropy() is only intended for seeding random number generators and is not intended for use by regular code which simply needs secure random data. For this purpose, please use arc4random(3). The maximum value for buflen is 256 bytes. IMPLEMENTATION NOTES getentropy() reads from the sysctl(7) variable kern.arandom. RETURN VALUES The getentropy() function returns 0 on success, and -1 if an error occurred. ERRORS getentropy() will succeed unless: [EFAULT] The buf argument points to an invalid memory address. [EIO] Too many bytes were requested. SEE ALSO arc4random(3), rnd(4) STANDARDS The getentropy() function is non-standard. HISTORY The getentropy() function first appeared in OpenBSD 5.6, then in FreeBSD 12.0, and NetBSD 10.
2020-04-18Rename "syscall" to "_syscall" and provide "syscall" as a weak alias.thorpej
2019-09-22Add a new member to struct vfsstat and grow the unused memberschristos
The new member is caled f_mntfromlabel and it is the dkw_wname of the corresponding wedge. This is now used by df -W to display the mountpoint name as NAME=
2018-01-17Revert to commits as they broke few rump testskamil
"Include namespace.h in a few of libc source files [...] This change finishes elimination of usage of the global name of the following symbols: - close -> _close - execve -> _execve - fcntl -> _fcntl - setcontext -> _setcontext - wait6 -> _wait6 - write -> _write - writev -> _writev" "Register more syscalls in namespace.h (of libc) Add weak symbols for: - fcntl - close - execve - setcontext - wait6 - write - writev" These changes broke: fs/nfs/t_rquotad:get_nfs_be_1_both fs/nfs/t_rquotad:get_nfs_be_1_group fs/nfs/t_rquotad:get_nfs_be_1_user fs/nfs/t_rquotad:get_nfs_le_1_both fs/nfs/t_rquotad:get_nfs_le_1_group fs/nfs/t_rquotad:get_nfs_le_1_user lib/librumphijack/t_config:fdoff lib/librumphijack/t_tcpip:http lib/librumphijack/t_tcpip:nfs lib/librumphijack/t_vfs:cpcopy lib/librumphijack/t_vfs:mv_x lib/librumphijack/t_vfs:paxcopy net/net/t_forwarding:ipforwarding_fastforward_v4 net/net/t_forwarding:ipforwarding_fastforward_v6 net/net/t_forwarding:ipforwarding_fragment_v4 net/net/t_forwarding:ipforwarding_misc net/net/t_mtudisc6:mtudisc6_basic This revert fixes the failures, except lib/librumphijack/t_vfs. The original changes were added in order to facilitate a usage of sanitizers against programs linked with NetBSD's libc. It is no longer needed, so abandon these changes. Sponsored by <The NetBSD Foundation>
2018-01-07Revert asctime() namespacingkamil
asctime() is optionally a cancellation point in the POSIX spec. It's not true for NetBSD. Requested by <joerg>
2018-01-07Revert namespacing of atoi(3)kamil
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>
2018-01-05Register new weak symbol in libc for internal usage: atoikamil
The NetBSD Standard C Library uses internally some of its functions with a mangled symbol name, usually "_symbol". The internal functions shall not use the global (public) symbols. Add atoi to namespace.h. Register a new __weak_alias() entry for atoi() in atoi.c. atoi() is used internally in getrpcent(), rresvport_af(), ftok(), err(), __llvm_profile_write_file(), llvm_gcda_start_file(), citrus_iconv_open(), getprotoent_r(), __rpc_uaddr2taddr_af(), __res_nopt_rdata() and servent_parseline(). This revision switches the internal usage to the internal symbol. Sponsored by <The NetBSD Foundation>
2018-01-05Register new weak symbol in libc for internal usage: asctimekamil
The NetBSD Standard C Library uses internally some of its functions with a mangled symbol name, usually "_symbol". The internal functions shall not use the global (public) symbols. Add asctime to namespace.h. Register a new __weak_alias() entry for asctime() in asctime.c. acstime() is used internally in ctime and __ctime50. This revision switches the internal usage to the internal symbol. Sponsored by <The NetBSD Foundation>
2018-01-05Register dl_iterate_phdr in the libc's namespace.hkamil
The NetBSD Standard C Library uses internally some of its functions with a mangled symbol name, usually "_symbol". The internal functions shall not use the global (public) symbols. Stop using the public global name of dl_iterate_phdr in tls/tls.c: __libc_static_tls_setup(). Follow the approach with other dlopen(3)-like functions with the namespace.h in the dl_iterate_phdr() case. Use internally a weak symbol: __dl_iterate_phdr instead of dl_iterate_phdr. Sponsored by <The NetBSD Foundation>
2018-01-05Register more syscalls in namespace.h (of libc)kamil
Add weak symbols for: - fcntl - close - execve - setcontext - wait6 - write - writev These syscalls are already marked as WEAKASM, generating weak references. Sponsored by <The NetBSD Foundation>
2017-11-30Import SHA-3 code into libc and libkern.riastradh
No new public symbols in libc, but publishing the symbols is a simple matter if/when we decide to do so. Proposed on tech-kern and tech-userlevel with no objections: https://mail-index.NetBSD.org/tech-kern/2017/11/11/msg022581.html https://mail-index.NetBSD.org/tech-userlevel/2017/11/11/msg010968.html
2017-10-22xref libc/READMEriastradh
2017-10-22Add an explanation of how namespace.h works.christos
2017-02-08Make paccept a weak symbol in preparation for using it in another functionmaya
2017-01-13allow overriding snprintf/vsnprintfchristos
2017-01-12undo SSP damage from -Wsystem-headerschristos
2017-01-12Add strerror_ss_r to be used by syslog_sschristos
2016-09-24remove mpool_getfchristos
2016-09-24bump for the flags version of db routineschristos
2016-04-03userland bits for wait6/waitid.christos
2015-09-10namespace protect allocaddrinfochristos
2015-05-01- new test for strtoichristos
- namespace protection for strto{i,u} - separate manpages for strto{i,u} from the ones for strto{u,}l From: Kamil Rytarowski
2015-02-17Introduce reallocarr(3) for easy (re)allocation of memory with overflowjoerg
checks. Compared to OpenBSD's reallocarray, makes it easier to avoid memory leaks on allocation failures and it doesn't depend on malloc(0) != NULL for correct error checking. Compared to plain realloc, it also avoids the problem of intermediate integer overflows. The trade-off is the use of void * to side step C type system with regard to generic pointer to pointer.
2014-09-26add execvpe, execlpe (reviewed by phone)christos
2014-09-25Fix argument paddiing for posix_fallocate and fdiscard with gcc 1.xmanu
2014-06-13Add asysctl(3) and asysctlbyname(3) wrappers for the common idiom ofjoerg
fetching dynamically sized data via sysctl.
2014-01-16remove dupschristos
2014-01-16namespace protection for the new err functionschristos
2014-01-16Fix (v)errc/(v)warnc.joerg
2013-12-05Add cdbr_open_mem.joerg
2013-08-28Publish explicit_memset and consttime_memequal in userland libc.riastradh
Remove the double-underscore from the userland versions, and do the weak alias dance instead, now that these are public parts of libc. As discussed on tech-userlevel: https://mail-index.netbsd.org/tech-userlevel/2013/06/24/msg007843.html (option 3)
2013-08-19Add strerror_l.joerg
2013-08-19Add nl_langinfo_l, catopen_l and wcsftime_l.joerg
2013-04-30Make that to process PATH_LOCALE the first time _find_category isjoerg
called. Use this to implement newlocale and provide duplocale/freelocale as well. Based on patches by Takehiko Nozaki with simplications and fix for the init order by myself.
2013-04-21Store time-specific locale data directly in the locale.joerg
Ad dstrftime_l, strftime_lz and strptime_l.
2013-04-19Add scanf_l and wscanf_l families.joerg
2013-04-19Add dummy strcoll_l and strxfrm_l.joerg
2013-04-19Add explicit locale versions for the printf family. Replace asprintf,joerg
snprintf and sprintf with simple wrappers around the corresponding va_list functions to reduce code duplication.
2013-04-18Add wcscoll_l, wcsxfrm_l, wcsncasecmp_l, wcscasecmp_l, btowc_l,joerg
mbrlen_l, mbsinit_l, mbsrtowcs_l, wcrtomb_l, wcsrtombs_l and wctob_l.
2013-04-18Add wcstof_l, wcstod_l and wcstold_l.joerg
2013-04-18Add strtof_l, strtod_l and strtold_l.joerg
2013-04-16Add strtol_l and friends. Switch _citrus_bcs_strtol to use plainjoerg
strtol_l unless in tools mode. Add note to retire the BCS code on the next libc major bump.
2013-04-16Add wcwidth_l, wcswidth_l and the wctype.h family of *_l functions.joerg
2012-08-20I'm fairly sure the libc rules require that arc4random_addrandom,dsl
arc4random_buf, arc4random_stir and arc4random_uniform be weak.
2012-07-09Add weak symbol for murmurhash2.rmind
2012-06-03Switch device database to cdb(5). Rework ttyname(3) and ttyname_r(3) tojoerg
depend on new devname_r(3) as heart. Add /dev/pts magic directly to devname(3). While it can lead to returning non-existing paths, the behavior is more consistent that way. Drop caching layer in devname(3), it doesn't buy anything for the common case of having access to the database. Teach devname(3) proper fallback behavior of scanning /dev. Create both old-style and new-style database for now in /etc/rc.d/sysdb.