Commit Graph

7969 Commits

Author SHA1 Message Date
John Baldwin
6d3eca246c Remove Symbol.map entries for old AIO system calls for FreeBSD 6 compat.
These entries should have never been present since they only exist for
compat with FreeBSD 6.x (and older) binaries.  This was missed in r296572.
Technically this breaks the ABI by removing versioned symbols.  However,
no binaries should be linked against these symbols.  No release has
shipped with a header that contained a prototype for these functions.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D5615
2016-03-12 07:13:20 +00:00
Bryan Drewery
15c433351f DIRDEPS_BUILD: Connect MK_TESTS.
Sponsored by:	EMC / Isilon Storage Division
2016-03-09 22:46:01 +00:00
Bryan Drewery
30924962f4 Fix and connect setjmp test.
Sponsored by:	EMC / Isilon Storage Division
2016-03-09 22:45:04 +00:00
Edward Tomasz Napierala
62411b41c4 Fix spelling of MAXNAMLEN.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-03-09 13:45:03 +00:00
Ed Maste
142a37f3ad libc/{i386,amd64}: Do not export .cerror when building WITHOUT_SYMVER
Further to r240152 (i386) and r240178 (amd64), hide the .cerror symbol
so that it is not exported if symbol versioning is not in use.  Without
this change WITHOUT_SYMVER libc contains .text relocations for .cerror,
as described in LLVM PR 26813 (http://llvm.org/pr26813).

This is a no-op for the regular build as the symbol version script
already controls .cerror visibility.

PR:		207712
Submitted by:	Rafael Espíndola
Reviewed by:	jilles, kib
Differential Revision:	https://reviews.freebsd.org/D5571
2016-03-08 00:09:34 +00:00
Jilles Tjoelker
ee3147b53a libc: Add some tests for memcmp(). 2016-03-06 18:41:48 +00:00
Kurt Lidl
06feb971e7 Allow O_CLOEXEC to be used in dbopen() flags
There is also a small portability crutch, also present in NetBSD,
to allow compiling on a system that doesn't define O_CLOEXEC.

Approved by:	rpaulo (mentor)
Obtained from:	NetBSD (r1.17, r1.18)
Differential Revision:	https://reviews.freebsd.org/D5549
2016-03-06 04:38:08 +00:00
Pedro F. Giffuni
09426b3d88 Stray tabs and spaces.
No functional change.
2016-03-05 01:17:23 +00:00
Pedro F. Giffuni
ef2c4fae74 Work around aliasing issues detected in modern GCC.
Avoid casting gymnastics that lead to pointer aliasing by introducing an
inline function as done in NetBSD (but without #if0'd WIP code).

Obtained from:	NetBSD (CVS Rev. 1.24, 1.25)
2016-03-04 15:30:41 +00:00
Pedro F. Giffuni
45256214eb mbtowc(3): set errno to EILSEQ if an incomplete character is passed.
According to POSIX, The mbtowc() function shall fail if:
[EILSEQ] An invalid character sequence is detected.

Reviewed by:		bapt
Differential Revision:	https://reviews.freebsd.org/D5496

Obtained from:	OpenBSD (Ingo Schwarze)
MFC after:	1 month
2016-03-01 19:15:34 +00:00
Jason Evans
df0d881d94 Update jemalloc to 4.1.0.
Add missing Symbol.map entry for __aligned_alloc.

Add weak-->strong symbol binding for
{malloc_stats_print,mallctl,mallctlnametomib,mallctlbymib} -->
{__malloc_stats_print,__mallctl,__mallctlnametomib,__mallctlbymib}.  These
bindings complete the set necessary to allow applications to replace all
malloc-related symbols.
2016-02-29 19:10:32 +00:00
Edward Tomasz Napierala
0ca11f9ded kenv(8) -> kenv(1)
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-29 17:22:34 +00:00
Edward Tomasz Napierala
406e4bde38 sysconf(2) -> sysconf(3)
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-29 17:20:04 +00:00
Edward Tomasz Napierala
a561a028dd sendmsg(3) -> sendmsg(2)
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-29 17:19:15 +00:00
Edward Tomasz Napierala
de19f22681 Fix typos in .Xrs.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-29 16:52:06 +00:00
Pedro F. Giffuni
283970e873 RPC: update the getrpcbyname() definition to include a const qualifier.
Add const qualifier making getrpcbyname() and getrpcbyname_r()
prototypes match those used in latest Sun RPC code (TI-RPC 2.3).

Obtained from:	NetBSD
2016-02-26 23:25:21 +00:00
Bryan Drewery
ffc534f75b Make it clear that the "size" argument is for the dst string.
The rest of the manpage already referenced 'dstsize' but did not rename
the variable in the prototype in r257646.

MFC after:	3 days
Sponsored by:	EMC / Isilon Storage Division
2016-02-26 22:14:19 +00:00
Nathan Whitehorn
97a5390e6d Make unions in PowerPC libc endian-safe. 2016-02-26 20:38:23 +00:00
Pedro F. Giffuni
a6221f7b51 rpc: fix failure to clear string by passing the wrong size to memset.
Noted by NetBSD's PR/21014

Obtained from:	NetBSD (CVS Rev. 1.24, 1.25)
MFC after:	1 month
2016-02-26 14:39:39 +00:00
Mariusz Zaborski
c501d73c7e Convert casperd(8) daemon to the libcasper.
After calling the cap_init(3) function Casper will fork from it's original
process, using pdfork(2). Forking from a process has a lot of advantages:
1. We have the same cwd as the original process.
2. The same uid, gid and groups.
3. The same MAC labels.
4. The same descriptor table.
5. The same routing table.
6. The same umask.
7. The same cpuset(1).
From now services are also in form of libraries.
We also removed libcapsicum at all and converts existing program using Casper
to new architecture.

Discussed with:		pjd, jonathan, ed, drysdale@google.com, emaste
Partially reviewed by:	drysdale@google.com, bdrewery
Approved by:		pjd (mentor)
Differential Revision:	https://reviews.freebsd.org/D4277
2016-02-25 18:23:40 +00:00
Bryan Drewery
bd18fd57db DIRDEPS_BUILD: Regenerate without local dependencies.
These are no longer needed after the recent 'beforebuild: depend' changes
and hooking DIRDEPS_BUILD into a subset of FAST_DEPEND which supports
skipping 'make depend'.

Sponsored by:	EMC / Isilon Storage Division
2016-02-24 17:20:11 +00:00
Pedro F. Giffuni
e1ea782729 db(3): Fix aliasing warnings from modern GCC.
While here also drop a malloc cast.

Obtained from:	NetBSD (CVS Rev. 1.18 - 1.20)
2016-02-24 17:14:11 +00:00
Pedro F. Giffuni
3579f3d9ea db(3): Fix aliasing warnings from modern GCC.
Obtained from:	NetBSD (CVS Rev. 1.20)
2016-02-24 16:52:03 +00:00
David Malone
efb7dae251 If we close or sync a hash-based db file, make sure to call fsync to
make sure the changes are on disk. The people at pfSense noticed that
it didn't always make it to the disk soon enough with soft updates.

Differential Revision:	https://reviews.freebsd.org/D5186
Reviewed by:	garga, vangyzen, bapt, se
MFC after:	1 week
2016-02-23 15:21:13 +00:00
Kevin Lo
3ef58843aa Remove sys/types.h 2016-02-19 06:50:00 +00:00
Benjamin Kaduk
24183025a5 Bump .Dd for r295764
Also fix a spelling and grammar nit while here.
2016-02-18 18:50:03 +00:00
Maxim Sobolev
a050ef0997 Right now, the "virtual hole" API feature of lseek(2) is very vaguely
documented and easy to miss.

At the same time, it's pretty important for anyone who is trying to use
SEEK_HOLE/SEEK_DATA in real app. Try to bridge that gap by making that
description more pronounced and also document how it affects failure codes.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D5162
2016-02-18 18:41:40 +00:00
Ed Maste
796a99fc5c Remove dd xfer stats emitted during buildworld
They result in gratuitous differences when comparing build log output.
2016-02-18 14:17:28 +00:00
Bryan Drewery
52d66ba6ae Fix build race after r295643.
Sponsored by:	EMC / Isilon Storage Division
2016-02-17 18:41:55 +00:00
Pedro F. Giffuni
179a5a39a8 fputs: Return the number of bytes written.
Fix r295631: wrong value.

Pointy hat:	pfg (me)
Pointed out by:	bde
2016-02-15 21:18:52 +00:00
Pedro F. Giffuni
20055d7691 getln: We cannot expand the buffer beyond INT_MAX.
In such cases return ENOMEM. This is a limitation of our
implementation, alternatively you may consider getline(3).

Differential Revision:	https://reviews.freebsd.org/D442 (Partial)
Obtained from:	Apple Inc. (Libc 997.90.3)
Relnotes:	yes
2016-02-15 18:14:21 +00:00
Pedro F. Giffuni
2082bf26c8 fputs: Return the number of bytes written.
POSIX.1-2008 requires that successful completion simply return a
non-negative integer. We have regularly returned a constant value.
Another, equally valid, implementation convention implies returning
the number of bytes written.

Adopt this last convention to be in line with what Apple's libc
does. POSIX also explicitly notes:

Note that this implementation convention cannot be adhered to for strings
longer than {INT_MAX} bytes as the value would not be representable in the
return type of the function. For backwards-compatibility, implementations
can return the number of bytes for strings of up to {INT_MAX} bytes, and
return {INT_MAX} for all longer strings.

Developers shouldn't depend specifically on either convention but
the change may help port software from Apple.

Differential Revision:  https://reviews.freebsd.org/D442 (Partial)
Obtained from:  Apple Inc. (Libc 997.90.3 with changes)
Relnotes:	yes
2016-02-15 18:13:33 +00:00
Jamie Gritton
e94b881ba1 Remove man page references to rndassociates.com, which has been taken over
by a domain squatter.
2016-02-10 14:48:49 +00:00
Mark Johnston
c5dd49afec Fix the gcc build after r295407.
X-MFC-With:	r295407
2016-02-08 22:02:56 +00:00
Konstantin Belousov
bd43f0691c If libthr.so is dlopened without RTLD_GLOBAL flag, the libthr symbols
do not participate in the global symbols namespace, but rtld locks are
still replaced and functions are interposed.  In particular,
__pthread_map_stacks_exec is resolved to the libc version.  If a
library is loaded later, which requires adjustment of the stack
protection mode, rtld calls into libc __pthread_map_stacks_exec due to
the symbols scope.  The libc version might recurse into binder and
recursively acquire rtld bind lock, causing the hang.

Make libc __pthread_map_stacks_exec() interposed, which synchronizes
rtld locks and version of the stack exec hook when libthr loaded,
regardless of the symbol scope control or symbol resolution order.

The __pthread_map_stacks_exec() symbol is removed from the private
version in libthr since libc symbol now operates correctly in presence
of libthr.

Reported and tested by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2016-02-08 19:24:13 +00:00
Jilles Tjoelker
9ef7a36255 semget(2): Add missing [EINVAL] conditions.
PR:		206927
2016-02-07 21:25:08 +00:00
Jason Helfman
74f9cea2d3 - connect(2) Clarify namelen
PR:		206838
Submitted by:	t@tobik.me
Approved by:	bcr (mentor)
MFH:		after 1 week
Differential Revision:	https://reviews.freebsd.org/D5194
2016-02-04 18:03:06 +00:00
Bryan Drewery
b231dc0a9f Move logic to destroy a struct catentry to its own function.
This will be used later for memory leak handling.

Obtained from:	OneFS
Sponsored by:	EMC / Isilon Storage Division
2016-02-02 23:33:58 +00:00
Maxim Sobolev
7fd852f860 This seems like a very trivial bug that should have been squashed a long
time ago, but for some reason it was not. Basically, without this change
dlopen(3)'ing an empty .so file would just cause application to dump core
with SIGSEGV.

Make sure the file has enough data for at least the ELF header before
mmap'ing it.

Add a test case to check that dlopen an empty file return an error.

There were a separate discussion as to whether it should be SIGBUS
instead when you try to access region mapped from an empty file,
but it's definitely SIGSEGV now, so if anyone want to check that please
be my guest.
Reviewed by:	mjg, cem
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D5112
2016-01-30 04:16:05 +00:00
Konstantin Belousov
bf420ace0a Add implementations of sendmmsg(3) and recvmmsg(3) functions which
wraps sendmsg(2) and recvmsg(2) into batch send and receive operation.
The goal of this implementation is only to provide API compatibility
with Linux.

The cancellation behaviour of the functions is not quite right, but
due to relative rare use of cancellation it is considered acceptable
comparing with the complexity of the correct implementation.  If
functions are reimplemented as syscalls, the fix would come almost
trivial.  The direct use of the syscall trampolines instead of libc
wrappers for sendmsg(2) and recvmsg(2) is to avoid data loss on
cancellation.

Submitted by:	Boris Astardzhiev <boris.astardzhiev@gmail.com>
Discussed with:	jilles (cancellation behaviour)
MFC after:	1 month
2016-01-29 14:12:12 +00:00
Brooks Davis
45308eec4a Use intptr_t note ptrdiff_t when storing flags in the bottom bits of
pointers.

Obtained from:	CheriBSD (e3a69027cc)
Sponsored by:	DARPA, AFRL
2016-01-29 01:22:12 +00:00
Bryan Drewery
545d341d77 Replace nslexer.l->nslexer.c custom rule with a -D CFLAG.
This avoids reproducing the lex logic which had dependencies set wrong
and used an intermediate file for modifying the YY_BUF_SIZE.

This has only been possible since flex 2.5.37 was imported in r250873,
which uses #ifndef YY_BUF_SIZE.

MFC after:	2 weeks
Sponsored by:	EMC / Isilon Storage Division
2016-01-27 01:33:23 +00:00
Bryan Drewery
bde5c8997e nslexer.c does not depend on nsparser.h.
nslexer.o depends on nsparser.h, which is already added by bsd.lib.mk
and .depend.

This reverts r237402.

MFC after:	2 weeks
Sponsored by:	EMC / Isilon Storage Division
2016-01-27 01:33:19 +00:00
Bryan Drewery
2027d8784f Remove excess whitespace 2016-01-27 00:24:24 +00:00
Konstantin Belousov
88d74d64d7 Restore flushing of output for revoke(2) again. Document revoke()'s
intended behaviour in its man page.  Simplify tty_drain() to match.
Don't call ttydevsw methods in tty_flush() if the device is gone
since we now sometimes call it then.

The flushing was supposed to be implemented by passing the FNONBLOCK
flag to VOP_CLOSE() for revoke().  The tty driver is one of the few
that can block in close and was one of the fewer that knew about this.

This almost worked in FreeBSD-1 and similarly in Net/2.  These
versions only almost worked because there was and is considerable
confusion between IO_NDELAY and FNONBLOCK (aka O_NONBLOCK).  IO_NDELAY
is only valid for VOP_READ() and VOP_WRITE().  For other VOPs it has
the same value as O_SHLOCK.  But since vfs_subr.c and tty.c
consistently used the wrong flag and the O_SHLOCK flag is rarely set,
this mostly worked.  It also gave the feature than applications could
get the non-blocking close by abusing O_SHLOCK.

This was first broken then fixed in 1995.  I changed only the tty
driver to use FNONBLOCK, as a hack to get non-blocking via the normal
flag FNONBLOCK for last closes.  I didn't know about revoke()'s use
of IO_NDELAY or change it to be consistent, so revoke() was broken.
Then I changed revoke() to match.

This was next broken in 1997 then fixed in 1998.  Importing Lite2 made
the flags inconsistent again by undoing the fix only in vfs_subr.c.

This was next broken in 2008 by replacing everything in tty.c and not
checking any flags in last close.  Other bugs in draining limited the
resulting unbounded waits to drain in some cases.

It is now possible to fix this better using the new FREVOKE flag.
Just restore flushing for revoke() for now.  Don't restore or undo any
hacks for ordinary last closes yet.  But remove dead code in the
1-second relative timeout (r272789).  This did extra work to extend
the buggy draining for revoke() for as long as possible.  The 1-second
timeout made this not very long by usually flushing after 1 second.

Submitted by:	bde
MFC after:	2 weeks
2016-01-26 07:57:44 +00:00
Bryan Drewery
dfdb6cf4c1 Replace .CURDIR with SRCTOP to respect LIBC_SRCTOP feature. 2016-01-25 19:11:34 +00:00
Michael Tuexen
32d0a77de1 sctp_sendx() needs to provide the assoc_id back.
MFC after: 3 days
2016-01-24 22:31:34 +00:00
Maxim Sobolev
18a2ccd22d Fix bug in the readpassphrase(3) function, which can be exposed
by application closing its stdin (i.e. STDIN_FILENO) prior to
calling readpassphrase WITHOUT setting RPP_STDIN. What happens
then is that the readpassphrase would open /dev/tty, and since
file descriptors are reused, the call would return first unused
fd, which is 0 which is also STDIN_FILENO. Then due to the usage
of "input != STDIN_FILENO" in the code to do its logic, that
would result in noecho flags not set on that file descriptor,
which was original issue I've been trying to fix.

In addition to that, the readpassphrase() would leak file
descriptor on its way out, so fix that one as well.

This problem can be tested with:

 $ ssh-add - < /tmp/myprivate.key

The password will not be hidden as it should and ktrace will
show:

 53326 ssh-add  CALL  open(0x80142443c,0x100002<O_RDWR|O_CLOEXEC>,<unused>0x165f030)
 53326 ssh-add  NAMI  "/dev/tty"
 53326 ssh-add  RET   open 0
 53326 ssh-add  CALL  sigprocmask(SIG_SETMASK,0x802eb1324,0x7fffffffd5e0)
 53326 ssh-add  RET   sigprocmask 0
 53326 ssh-add  CALL  sigaction(SIGALRM,0x7fffffffd630,0x7fffffffd610)

Instead of:

 57690 ssh-add  CALL  open(0x80142443c,0x100002<O_RDWR|O_CLOEXEC>,<unused>0x165f030)
 57690 ssh-add  NAMI  "/dev/tty"
 57690 ssh-add  RET   open 4
 57690 ssh-add  CALL  ioctl(0x4,TIOCGETA,0x7fffffffd860)
 57690 ssh-add  RET   ioctl 0
 57690 ssh-add  CALL  ioctl(0x4,TIOCSETAF,0x7fffffffd680)
 57690 ssh-add  RET   ioctl 0
 57690 ssh-add  CALL  sigprocmask(SIG_SETMASK,0x802eb1324,0x7fffffffd620)
 57690 ssh-add  RET   sigprocmask 0
 57690 ssh-add  CALL  sigaction(SIGALRM,0x7fffffffd670,0x7fffffffd650)

For the case when the key is read from the file.

Technically this can also be workaround'ed at the application side
by not closing the STDIN_FILENO in the first place, but readpassphrase(3)
doesn't need to make any assumptions about that. Plus the file descriptor
leak confirms that this is an oversight, rather than a deliberate behaviour.

MFC after:	1 week
2016-01-24 22:20:13 +00:00
Michael Tuexen
c7f6ce2800 sctp_sendv() needs to fill in the association id on return.
MFC after: 3 days
2016-01-24 22:08:15 +00:00
Warren Block
c18d8171a6 Add a standards compliance note for strtok_r as suggested by cpercival.
Reviewed by:	cpercival
MFC after:	1 week
2016-01-22 20:36:03 +00:00