Commit Graph

218969 Commits

Author SHA1 Message Date
Alan Somers
4a8c3cd0df Remove dead code in dhclient(8)
The offending code has been dead ever since the import from OpenBSD in
r195805.  OpenBSD later deleted that entire function.

Reported by:	Coverity
CID:		500059
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
2017-01-04 18:13:05 +00:00
Enji Cooper
640b69be3a style cleanup
- bridge_pf_dump: use nitems instead of spelling it out longhand
- bridge_do_pfctl: sort variables by alignment for type

MFC after:	1 week
2017-01-04 17:54:44 +00:00
Enji Cooper
9577c300d8 bridge_do_pfctl: allocate mib_name dynamically using asprintf
This is being done to reduce wasted space, simplify complexity in
the code, and to quell a Coverity warning about buffer overruns.
warning about buffer overruns.

MFC after:	1 week
Reported by:	Coverity
CID:		1006736
2017-01-04 17:50:52 +00:00
Alan Somers
398b756be8 Remove dead code in rpc_parse.c
It's been dead ever since it was imported from TI-RPC in 1995.  The dead
code is still present in Illumos today, but was removed from NetBSD in 2006.

Reported by:	Coverity
CID:		270097
Obtained from:	NetBSD
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
2017-01-04 17:39:20 +00:00
Enji Cooper
758268dcae bridge_get_pfval: use nitems instead of spelling it out longhand
MFC after:	3 days
2017-01-04 17:38:18 +00:00
Enji Cooper
a0cc1855e3 Use strlcpy instead of strcpy when copying the bridge name to ifr.ifr_name
to avoid buffer overflows

MFC after:	1 week
Reported by:	Coverity
CID:		1006735, 1006737, 1006738
2017-01-04 17:33:18 +00:00
Alan Somers
f9fe16497a Delete dead code in chat(8)
It's always been dead, ever since first import in 1994.  It's still dead in
OpenBSD's version, too.

Reported by:	Coverity
CID:		270586
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
2017-01-04 16:24:40 +00:00
Konstantin Belousov
4f64c5b3cf __vdso_gettc(): be extra careful with /dev/hpet mappings, never unmap
the mapping which might be accessed by other threads.

If a pointer to the /dev/hpet register page mapping was stored into
the hpet_dev_map, other threads might access the page at any time.
Never unmap it, instead, keep track of mappings for all hpet units in
smal array.  Store pointer to the newly mapped registers page using
CAS, to detect parallel mappings.

It appeared relatively easy to demonstrate the problem by arranging
two threads which perform gettimeofday(2) concurently, first time in
the process address space, when HPET is used for timecounter.

PR:	215715
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2017-01-04 16:10:52 +00:00
Konstantin Belousov
6c4338f2ef The callers of kern_getfsstat(UIO_SYSSPACE) expect that *buf always
returns memory which must be freed, regardless of the error.  Assign
NULL to *buf in case we are not going to allocate any memory due to
invalid mode.

Reported and tested by:	pho
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	3 weeks (together with r310638)
Differential revision:	https://reviews.freebsd.org/D9042
2017-01-04 16:09:45 +00:00
Xin LI
a94dccbe27 MFV r311279: zlib 1.2.10.
MFC after:	1 month
2017-01-04 16:09:08 +00:00
Edward Tomasz Napierala
5ec7cde488 Fix bug that would result in a kernel crash in some cases involving
a symlink and an autofs mount request.  The crash was caused by namei()
calling bcopy() with a negative length, caused by numeric underflow:
in lookup(), in the relookup path, the ni_pathlen was decremented too
many times.  The bug was introduced in r296715.

Big thanks to Alex Deiter for his help with debugging this.

Reviewed by:	kib@
Tested by:	Alex Deiter <alex.deiter at gmail.com>
MFC after:	1 month
2017-01-04 14:43:57 +00:00
Edward Tomasz Napierala
3a408ce90d Don't release the cfiscsi session refcount too early. It wasn't
observed to fix any actual error, but it's the right thing to do
from the correctness point of view.

Tested by:	Eugene M. Zheganin <emz at norma.perm.ru>
MFC after:	1 month
2017-01-04 12:50:44 +00:00
Enji Cooper
ccd0cf8ffa snmp_mibII(3) requires net/if.h and net/if_mib.h
Document that requirement

MFC after:	1 week
2017-01-04 10:08:18 +00:00
Xin LI
ea3017ea00 Vendor import of zlib 1.2.10. 2017-01-04 09:37:45 +00:00
Xin LI
e16f0839c6 Restructure libz, place vendor files in contrib/zlib like other third
party software, this provides more standarized import workflow and
makes future upgrades easier.

The following files are new with this commit:

	zconf.h.in
	zlib.map
	zlib.pc.in

They are not connected to build, but were kept in tree for reference
for future maintenance.

All our local trivial changes were applied to contrib/zlib, and the
contrib/zlib vendor source code is intended to 100% match lib/libz
before this commit.

MFC after:	2 weeks
2017-01-04 09:30:47 +00:00
Enji Cooper
d6766132c2 run: ensure pthread_condattr_{init,setclock} is successful
MFC after:	1 week
Reported by:	Coverity
CID:		1268631, 1268633
2017-01-04 09:06:49 +00:00
Enji Cooper
dca7cc9815 setrlimit_basic: don't leak buf; free it on completion
MFC after:	3 days
Reported by:	Coverity
CID:		978311
2017-01-04 09:00:16 +00:00
Enji Cooper
fcc9604d43 revoke_perm: don't leak fd at the end of the test; close it
This code is unused on FreeBSD, but it mutes a valid Coverity warning
which would be true on NetBSD

MFC after:	3 days
Reported by:	Coverity
CID:		978311
2017-01-04 08:59:06 +00:00
Enji Cooper
621b0f13af stat_symlink: don't leak fd; close the file descriptor when done
MFC after:	3 days
Reported by:	Coverity
CID:		978314
2017-01-04 08:49:07 +00:00
Enji Cooper
c0b11b8e04 pipe_restart: free f on function exit to quell complaint from Coverity
MFC after:	3 days
Reported by:	Coverity
CID:		978307
2017-01-04 08:43:27 +00:00
Enji Cooper
64af3fbaba swapcontext1: test for getcontext(3) and swapcontext(3) success properly
The beforementioned libcalls both succeed if the return codes aren't -1

MFC after:	3 days
Reported by:	Coverity
CID:		976790, 976791
2017-01-04 08:35:46 +00:00
Enji Cooper
7251167f52 Clarify lifetime of child(..) function
Ensure child exits when complete as it's always run in a forked
process.

Add a missing break statement in :pselect_sigmask when calling
child(..) for clarity and to avoid weird domino effects if the
child process somehow does something it's not supposed to do
with the logfiles, file descriptors, etc

MFC after:	1 week
Reported by:	Coverity
CID:		1223369, 1223370, 1300301
2017-01-04 08:25:31 +00:00
Xin LI
0594943177 Add missing files in zlib 1.2.8. 2017-01-04 08:12:31 +00:00
Adrian Chadd
f0ab3d3668 [net80211] Add VHT flags for printf/debugging.
Whilst here, note that the last bit is currently used by ifconfig (_CHAN_HT)
so don't use it without fixing that first.
2017-01-04 08:08:50 +00:00
Enji Cooper
17a0c1eb75 fpu: ensure calls to pthread_create succeed and test sched_yield to make
sure it returns 0

sched_yield tests for values returning 0 of type int and sched_yield is
of type long, so the test is a mismatch

MFC after:	1 week
Reported by:	Coverity
CID:		1254953, 1254954, 1254965, 1254966
2017-01-04 08:07:48 +00:00
Enji Cooper
2e590d595e Use calloc instead of malloc with buffers in snmp_{recv,send}_packet
This doesn't fix the issue noted in the PR, but at the very least it
cleans up the error so it looks a bit more sane, and in the event
that bsnmp did wander off into the weeds, the likelihood of it
crashing with more sensible output is greater, in my opinion

MFC counter set high so I have enough time to resolve the real
underlying bug in bsnmpwalk

MFC after:	1 month
PR:		215721
2017-01-04 07:53:01 +00:00
Enji Cooper
b5bbd2a17c mincore_resid: free buf after use
MFC after:	3 days
Reported by:	Coverity
CID:		978304
2017-01-04 04:55:33 +00:00
Enji Cooper
83e8b13f15 {strchr,strlen}_basic: don't leak the dlopen'ed handle; close after use
MFC after:	3 days
Reported by:	Coverity
CID:		978299, 978300
2017-01-04 04:50:03 +00:00
Enji Cooper
5d37d9cc25 mknodat_fd: close dfd after use to avoid leaking it
MFC after:	3 days
Reported by:	Coverity
CID:		978287
2017-01-04 04:32:00 +00:00
Enji Cooper
f4cbf11049 mkfifoat_fd: close dfd after use to avoid leaking it
MFC after:	3 days
Reported by:	Coverity
CID:		978286
2017-01-04 04:29:53 +00:00
Enji Cooper
5641f109c1 fexecve: don't leak fd on fexecve(2) failure; close before calling err
MFC after:	3 days
Reported by:	Coverity
CID:		978285
2017-01-04 04:27:13 +00:00
Enji Cooper
3b33767589 tty: don't leak s after opening it with openpty
MFC after:	3 days
Reported by:	Coverity
CID:		978321
2017-01-04 04:19:05 +00:00
Enji Cooper
57f5b7d843 mmap_prot_3, mmap_truncate, mmap_truncate_signal: don't leak fd and map
Reported by:	Coverity
CID:		978306, 1251406, 1288196, 1300541
2017-01-04 04:10:36 +00:00
George V. Neville-Neil
fad073dd44 Followup to mtod removal in main stack (r311225). Continued removal
of mtod() calls from TCP_PROBE macros.

MFC after:	1 week
Sponsored by:	Limelight Networks
2017-01-04 04:00:28 +00:00
Enji Cooper
619898777b listen_low_port: check for errors from socket(2) before continuing
MFC after:	3 days
Reported by:	Coverity
CID:		976778
2017-01-04 03:59:50 +00:00
Enji Cooper
2020383ffd kqueue_desc_passing: initialize m.msg_flags to 0
This mutes an uninitialized scalar warning from Coverity

MFC after:	3 days
Reported by:	Coverity
CID:		979620
2017-01-04 03:54:54 +00:00
Enji Cooper
ab25ecadbf umask_open: don't leak fd on success
MFC after:	3 days
Reported by:	Coverity
CID:		978315
2017-01-04 03:41:16 +00:00
Emmanuel Vadot
358e989f83 ARM GENERIC: Add support for Allwinner A33 SoC 2017-01-04 03:37:00 +00:00
Emmanuel Vadot
cf72965fbf Allwinner: Add A33 support
Add basic support for A33/R16 that is enough to boot a kernel.
This adds the platform code, padconf data and the new clocks strings.

MFC after:	2 weeks
2017-01-04 03:35:39 +00:00
Enji Cooper
3c917d6fa3 unlink_fifo: don't leak the file descriptors opened with mkfifo and open
MFC fater:	3 days
Reported by:	Coverity
CID:		978316, 978317
2017-01-04 03:35:23 +00:00
Enji Cooper
6a64e31600 ttyname_err: close fd if it was opened successfully
MFC after:	3 days
Reported by:	Coverity
CID:		978292
2017-01-04 02:52:39 +00:00
Enji Cooper
cc34906655 Fix Coverity issues
- Initialize .sun_len before passing it to strlcpy and bind.
- Close fd on error

MFC after:	3 days
Reported by:	Coverity
CID:		978283, 979581
2017-01-04 02:46:36 +00:00
Enji Cooper
251d8e776e humanize_number_basic: don't leak buf
MFC after:	3 days
Reported by:	Coverity
CID:		1251407
2017-01-04 02:38:14 +00:00
Enji Cooper
06cd8428bc ftok_link: don't leak fd
MFC after:	3 days
Reported by:	Coverity
CID:		978291
2017-01-04 02:34:30 +00:00
Enji Cooper
05aee7d5b0 seekdir_basic: fix various Coverity issues
Address..
- .. resource leaks of file descriptors and memory
- .. unchecked return values from creat(2), mkdir(2), and telldir(3)
- .. potential NULL derefs after calling readdir(3)

MFC after:	1 week
Reported by:	Coverity
CID:		975255, 975256, 976989, 978989, 978990
2017-01-04 02:31:05 +00:00
Mateusz Guzik
391df78ad4 mtx: plug open-coded mtx_lock access missed in r311172 2017-01-04 02:25:31 +00:00
George V. Neville-Neil
2b9c998413 Fix DTrace TCP tracepoints to not use mtod() as it is both unnecessary and
dangerous.  Those wanting data from an mbuf should use DTrace itself to get
the data.

PR:	203409
Reviewed by:	hiren
MFC after:	1 week
Sponsored by:	Limelight Networks
Differential Revision:	https://reviews.freebsd.org/D9035
2017-01-04 02:19:13 +00:00
George V. Neville-Neil
593b0c8420 Fix PMC architecture check to handle later IPAs including Skylake
Tested with tools/test/hwpmc/pmctest.py

Obtained from:	Oliver Pinter
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D9036
2017-01-04 02:15:03 +00:00
Enji Cooper
b85e09dbf1 Fix logical inversion when checking result from calloc
in snmp_output_err_resp(..)

X-MFC with:	r310987
MFC after:	3 days
Reported by:	Coverity
CID:		1368195
2017-01-04 01:44:45 +00:00
Enji Cooper
1a55af1fb9 Initialize msg.msg_flags to 0
This mutes a valid coverity warning about it being uninitialized
when passed in to sendmsg(2).

MFC after:	2 weeks
Reported by:	Coverity
CID:		1368202
2017-01-04 01:38:07 +00:00