Commit Graph

17176 Commits

Author SHA1 Message Date
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
Ed Maste
c1da297433 Add libpe for elfcopy(1) PE/COFF support
Sponsored by:	The FreeBSD Foundation
2016-02-12 21:12:47 +00:00
Ed Maste
839529caa9 Update ELF Tool Chain to upstream rev 3400
Some notable improvements include:

readelf:
- Add AArch64 relocation definitions.
- Report value of unknown relocation types.

elfcopy:
- Consider symbols with STB_GNU_UNIQUE binding as global symbols.
- Fixed support for VMA adjustment for loadable sections found
  in relocatable objects.
- Handle nameless global symbols.
- Improve wildcard matching for !-prefixed symbols.
- Add PE/COFF support.

elfdump:
- Improve section type reporting.
- Add MIPS-specific section types.

This update also includes a significant number of bug fixes.

PR:		207091 [exp-run]
Sponsored by:	The FreeBSD Foundation
2016-02-12 20:54:02 +00:00
Dag-Erling Smørgrav
a982c4c7f5 Fix double-free error: r289419 moved all error handling in http_connect()
to the end of the function, but did not remove a fetch_close() call which
was made redundant by the one in the shared error-handling code.

PR:		206774
Submitted by:	Christian Heckendorf <heckendorfc@gmail.com>
MFC after:	3 days
2016-02-11 17:48:15 +00:00
Dag-Erling Smørgrav
0de4f1bf64 Use the new insecure-lan-zones option instead of listing each AS112 zone
separately.

MFC after:	3 days
2016-02-11 17:37:02 +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
Gleb Smirnoff
b28cc462ad Include sys/_task.h into uma_int.h, so that taskqueue.h isn't a
requirement for uma_int.h.

Suggested by:	jhb
2016-02-09 20:22:35 +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
Pedro F. Giffuni
56f42903b1 MFV r295360
Sync our libedit with NetBSD's libedit 2016-01-16

Obtained from:	NetBSD
2016-02-07 15:26:21 +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
Gleb Smirnoff
9508a0e1fe Fix build. 2016-02-04 00:23:21 +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
John Baldwin
0fd00e0caa - Note that devctl(8) will appear in 10.3 first.
- Add missing devctl_set_driver entry to namelist in devlist(3).
- Fix sorting of function prototypes in devlist(3).

MFC after:	3 days
2016-02-02 22:55:03 +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
John Baldwin
5842bd683f Add a SYSDECODE_ABI_ prefix to the ABI enums to avoid potential collisions.
Suggested by:	jmallett
Reviewed by:	bdrewery, jmallett
Differential Revision:	https://reviews.freebsd.org/D5123
2016-01-30 01:00:54 +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
Brooks Davis
34fe534bcf Declare bt_devenum() to match the definition.
Obtained from:	CheriBSD (1c1dad87ef)
MFC after:	1 week
Sponsored by:	DARPA, AFRL
2016-01-29 00:59:48 +00:00
Devin Teske
116cc28a35 Fix fatal warn when compiling under GCC 5.2.0
GCC 5.2.0 generates the following [fatal] warning:
dialog_util.c:270:23: error:
zero-length gnu_printf format string [-Werror=format-zero-length]
   sprintf(dargv[n++], "");

Fix malloc argument while here, removing sprintf.

Reported by:	Ruslan Bukin <ruslan.bukin at cl cam ac uk>
2016-01-27 15:28:23 +00:00
Ruslan Bukin
3d32f0f6e5 Add pthread MD part for RISC-V.
Reviewed by:	andrew
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
Differential Revision:	https://reviews.freebsd.org/D5063
2016-01-27 14:10:50 +00:00
Ruslan Bukin
c9a2d57082 Add the RISC-V MD parts of libthread_db.
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
Differential Revision:	https://reviews.freebsd.org/D5064
2016-01-27 10:34:07 +00:00
Devin Teske
b888adc784 Fix a crash if -D' is used without -t title'
dialog(3)'s dlg_reallocate_gauge(), used both by dialog(3)'s dialog_gauge()
and dialog(1)'s `--gauge', will segmentation fault in strlen(3) if no title
is set for the widget. Reproducible with `dialog --gauge hi 6 20' (adding
`--title ""' is enough to prevent segmentation fault).

MFC after:	3 days
X-MFC-to:	stable/10
2016-01-27 06:21:35 +00:00
Devin Teske
138b115fcb Remove unused function prototype
MFC after:	3 days
X-MFC-to:	stable/10
2016-01-27 06:16:53 +00:00
Justin Hibbits
2dd1bdf183 Convert rman to use rman_res_t instead of u_long
Summary:
Migrate to using the semi-opaque type rman_res_t to specify rman resources.  For
now, this is still compatible with u_long.

This is step one in migrating rman to use uintmax_t for resources instead of
u_long.

Going forward, this could feasibly be used to specify architecture-specific
definitions of resource ranges, rather than baking a specific integer type into
the API.

This change has been broken out to facilitate MFC'ing drivers back to 10 without
breaking ABI.

Reviewed By: jhb
Sponsored by:	Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D5075
2016-01-27 02:23:54 +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
Devin Teske
1a5f047ab3 Bump copyrights 2016-01-27 00:02:51 +00:00
Devin Teske
80f7300d7b Add keep_tite configuration option
Similar to dialog(3) keep_tite option used to prevent visually disturbing
initialization or exit that could occur when run from a script using
dpv(3) by way of dpv(1) in sequence with other dialog(1) invocations.
2016-01-26 23:56:27 +00:00
John Baldwin
a5f14abfd2 Add support to libsysdecode for decoding system call names.
A new sysdecode_syscallname() function accepts a system call code and
returns a string of the corresponding name (or NULL if the code is
unknown).  To support different process ABIs, the new function accepts a
value from a new sysdecode_abi enum as its first argument to select the
ABI in use.  Current ABIs supported include FREEBSD (native binaries),
FREEBSD32, LINUX, LINUX32, and CLOUDABI64.  Note that not all ABIs are
supported by all platforms.  In general, a given ABI is only supported
if a platform can execute binaries for that ABI.

To simplify the implementation, libsysdecode's build reuses the
existing pre-generated files from the kernel source tree rather than
duplicating new copies of said files during the build.

kdump(1) and truss(1) now use these functions to map system call
identifiers to names.  For kdump(1), a new 'syscallname()' function
consolidates duplicated code from ktrsyscall() and ktrsyscallret().
The Linux ABI no longer requires custom handling for ktrsyscall() and
linux_ktrsyscall() has been removed as a result.

Reviewed by:	bdrewery
Differential Revision:	https://reviews.freebsd.org/D4823
2016-01-26 19:07:09 +00:00
Ruslan Bukin
4bf1032a04 Add fenv.c for RISC-V. Copied from MIPS. 2016-01-26 14:40:41 +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
Ruslan Bukin
5ac86464fc Style. 2016-01-25 10:44:10 +00:00
Ruslan Bukin
194aedf71a Do build libproc and librtld_db for RISC-V as well. 2016-01-25 10:23:36 +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
Ruslan Bukin
7dd3aed9c9 Add support for RISC-V ISA.
Reviewed by:	andrew
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
Differential Revision:	https://reviews.freebsd.org/D5040
2016-01-24 12:10:29 +00:00
Ed Maste
5abb4cd79f Use MAN= to specify that no man page is provided
NO_MAN is deprecated.

Reviewed by:	imp
2016-01-22 21:33:27 +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
Jilles Tjoelker
afa04e4170 sem: Don't free nameinfo that is still in list when open() fails.
This bug could be reproduced easily by calling sem_open() with O_CREAT |
O_EXCL on a semaphore that is already open in the process. The struct
sem_nameinfo would be freed while still in sem_list and later calls to
sem_open() or sem_close() could access freed memory.

PR:		206396
MFC after:	5 days
2016-01-22 14:52:31 +00:00
Brooks Davis
af6f4233fd Replace the last non-optional use of sbrk() in the tree with mmap().
All gmon want's is a region of memory without the overhead of malloc().
Just mapping some pages with mmap is an easy way to accomplish this.

Approved by:	jhb, cem, emaste
Obtained from:	CheriBSD (bf33e1e70b)
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D5005
2016-01-21 18:17:19 +00:00
Brooks Davis
1e3a2e82aa Fix the implementations of PSEUDO_NOERROR and PSEUDO.
The PSEUDO* macros should not declare <syscall>, only _<syscall> and
__sys_<syscall>.  This was causing the interposing C wrappers to be
ignored due to link order.

Reviewed by:	kib
Obtained from:	CheriBSD (4e8e13c90f)
MFC after:	1 week
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D4097
2016-01-21 17:29:01 +00:00
Andrew Turner
9beacb6f22 Disable -mlong-calls for the clang libraries for now, it increases the
size of the clang binary for people with a crt1.o from before r293832.
2016-01-21 12:59:54 +00:00
Bryan Drewery
628c4b98fb Add .NOMETA missed in r291320.
Sponsored by:	EMC / Isilon Storage Division
2016-01-20 20:58:42 +00:00
John Baldwin
c560a31571 Update for API changes in OpenSSH 6.8p1.
First, the authfd API now uses a direct file descriptor for the control
socket instead of a more abstract AuthenticationConnection structure.
Second, the functions now consistently return an error value.

Reviewed by:	bdrewery
2016-01-20 00:26:50 +00:00
Baptiste Daroussin
f16550ad09 Test for /etc/ssl/cert.pem existence to avoid masking SSL_CA_CERT_PATH
Prior to this patch, unless SSL_CA_CERT_FILE is set in the environment,
libfetch will set the CA file to "/usr/local/etc/cert.pem" if it exists,
and to "/etc/ssl/cert.pem" otherwise. This has the consequence of
masking SSL_CA_CERT_PATH, because OpenSSL will ignore the CA path if a CA
file is set but fails to load (see X509_STORE_load_locations()).

While here, fall back to OpenSSL defaults if neither SSL_CA_CERT_FILE nor
SSL_CA_CERT_PATH are set in the environment, and if neither of the
libfetch default CA files exists.

PR:		193871
Submitted by:	John W. O'Brien <john@saltant.com>
Approved by:	des
MFC after:	1 week
2016-01-19 15:02:37 +00:00