]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
7 years agoConditionalize wrap(3) use based on MK_TCP_WRAPPERS instead of
ngie [Fri, 6 Jan 2017 04:10:33 +0000 (04:10 +0000)]
Conditionalize wrap(3) use based on MK_TCP_WRAPPERS instead of
always building support into ypserv.

MFC after: 2 weeks

7 years agoAdd uintmax_t casts to silence printf format warnings.
jhb [Fri, 6 Jan 2017 00:41:30 +0000 (00:41 +0000)]
Add uintmax_t casts to silence printf format warnings.

The format strings weren't checked when stacksave_subr() used a function
pointer for printf instead of directly using db_printf().

Reported by: kib
Sponsored by: DARPA / AFRL

7 years agoRemove redundant cache initialization in JZ4780 SMP startup code
kan [Fri, 6 Jan 2017 00:07:36 +0000 (00:07 +0000)]
Remove redundant cache initialization in JZ4780 SMP startup code

This was done out of pure paranoia when hunting for bugs in cache
and is not really required.

7 years agoMerge ACPICA 20161222.
jkim [Thu, 5 Jan 2017 21:28:25 +0000 (21:28 +0000)]
Merge ACPICA 20161222.

7 years agoAlso remove unnecessary extern keywords from tcpd.h.
dim [Thu, 5 Jan 2017 21:17:10 +0000 (21:17 +0000)]
Also remove unnecessary extern keywords from tcpd.h.

Noticed by: kib
X-MFC-With: r311459

7 years agoPut proper prototypes in tcpd.h
dim [Thu, 5 Jan 2017 20:44:45 +0000 (20:44 +0000)]
Put proper prototypes in tcpd.h

Clang 4.0.0 complains about tcpd.h's not-really-prototypes, e.g.:

    /usr/include/tcpd.h:75:24: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
    extern int hosts_access();              /* access control */
                           ^

To fix this, turn these declarations into real prototypes.  While here,
garbage collect the incompatible rfc931() function from scaffold.c, as
it is never used.

Reviewed by: emaste
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D9052

7 years agoUse compiler driver to link BERI boot loaders
kan [Thu, 5 Jan 2017 19:17:14 +0000 (19:17 +0000)]
Use compiler driver to link BERI boot loaders

Do not hardcode elf64-tradbigmips as output format in BERI linker scrips.
Unfortunately, in-tree toolchain and external newer versions of binutils
mean two different things under that. When creating elf binaries using
external toolchain, gcc uses elf64-tradbigmips-freebsd and so linker
script file has to match in order for ld to be able to create the final loader
binary.

Rather than trying to guess, remove hardcoded output format directive from
the linker directive files and use CC to invoke the linker instead.

Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D9050

7 years agoAdd DTS file for Armada 385 DB-AP board
zbb [Thu, 5 Jan 2017 17:27:50 +0000 (17:27 +0000)]
Add DTS file for Armada 385 DB-AP board

Armada38x is already supported in the tree.
This commit adds support for DB-AP board.
File was taken from Linux v4.8 and accustomed to FreeBSD
in minimal possible way.

Submitted by: Bartosz Szczepanek <bsz@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D7327

7 years agoAdd DTS file for Solidrun ClearFog board
zbb [Thu, 5 Jan 2017 17:25:16 +0000 (17:25 +0000)]
Add DTS file for Solidrun ClearFog board

ClearFog is equipped with Marvell Armada 388 SoC, which is already
supported in FreeBSD.

Submitted by: Bartosz Szczepanek <bsz@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D7326

7 years agosysctl net.inet.tcp.hostcache.list in a jail can see connections from other
hiren [Thu, 5 Jan 2017 17:22:09 +0000 (17:22 +0000)]
sysctl net.inet.tcp.hostcache.list in a jail can see connections from other
jails and the host. This commit fixes it.

PR: 200361
Submitted by: bz (original version), hiren (minor corrections)
Reported by: Marcus Reid <marcus at blazingdot dot com>
Reviewed by: bz, gnn
Tested by: Lohith Bellad <lohithbsd at gmail dot com>
MFC after: 1 week
Sponsored by: Limelight Networks (minor corrections)

7 years agoDo not allocate struct statfs on kernel stack.
kib [Thu, 5 Jan 2017 17:19:26 +0000 (17:19 +0000)]
Do not allocate struct statfs on kernel stack.

Right now size of the structure is 472 bytes on amd64, which is
already large and stack allocations are indesirable.  With the ino64
work, MNAMELEN is increased to 1024, which will make it impossible to have
struct statfs on the stack.

Extracted from: ino64 work by gleb
Discussed with: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

7 years agoCorrect CESA node in armada-38x.dtsi
zbb [Thu, 5 Jan 2017 17:14:56 +0000 (17:14 +0000)]
Correct CESA node in armada-38x.dtsi

CESA resources were invalid, what caused driver to fail
during attach call.

Submitted by: Bartosz Szczepanek <bsz@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D8180

7 years agoAdd buffer management entries to armada-38x.dtsi
zbb [Thu, 5 Jan 2017 17:12:53 +0000 (17:12 +0000)]
Add buffer management entries to armada-38x.dtsi

Hardware buffer management entries are not used yet by FreeBSD.
They were added for compliance with Linux Armada 38x device tree
representation and will be used in future network support.

Submitted by:  Bartosz Szczepanek <bsz@semihalf.com>
Obtained from: Semihalf
Sponsored by:  Stormshield
Differential revision: https://reviews.freebsd.org/D8179

7 years agoInclude e6000sw driver in ARMADA38X configuration
zbb [Thu, 5 Jan 2017 17:10:52 +0000 (17:10 +0000)]
Include e6000sw driver in ARMADA38X configuration

e6000sw Marvell switch driver was added to files
and Armada38x kernel configuration file.

Submitted by: Bartosz Szczepanek <bsz@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D8178

7 years agoImprove ports handling in e6000sw driver
zbb [Thu, 5 Jan 2017 17:08:10 +0000 (17:08 +0000)]
Improve ports handling in e6000sw driver

- recognize ports and vlangroups based on DTS file
- support multi-chip addresing mode (required in upcoming
  Armada-388-Clearfog support)
- refactor attachment function

Each port in 'dsa' node should have 'vlangroup' property. Otherwise,
e6000sw will fail to attach.

Submitted by: Bartosz Szczepanek <bsz@semihalf.com>
Konrad Adamczyk <ka@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D7328

7 years agoSome style fixes for getfstat(2)-related code.
kib [Thu, 5 Jan 2017 17:03:35 +0000 (17:03 +0000)]
Some style fixes for getfstat(2)-related code.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

7 years agoFix bootverbose affecting code logic in r294558.
mav [Thu, 5 Jan 2017 16:30:13 +0000 (16:30 +0000)]
Fix bootverbose affecting code logic in r294558.

Reported by: Jilles Tjoelker <jilles@stack.nl>

7 years agoFix typo from r311349
asomers [Thu, 5 Jan 2017 15:07:04 +0000 (15:07 +0000)]
Fix typo from r311349

Reported by: lwhsu
Pointy-hat-to: asomers
MFC after: 4 weeks
X-MFC-with: 311349

7 years agoWhen displaying netstat details with libxo in JSON
ume [Thu, 5 Jan 2017 11:44:27 +0000 (11:44 +0000)]
When displaying netstat details with libxo in JSON
or XML modes, the value conversion for tcp6 and udp6
port numbers drops last digit.

PR: 215682
MFC after: 3 days

7 years agoop_usm_users: don't deref uusers if it's NULL when SETting the value
ngie [Thu, 5 Jan 2017 09:46:36 +0000 (09:46 +0000)]
op_usm_users: don't deref uusers if it's NULL when SETting the value

Add an XXX comment to note that the conditional seems suspect given
how it's handled elsewhere in the SNMP_OP_SET case.

MFC after: 2 weeks
Reported by: Coverity
CID: 1008573

7 years agoOS_getSystemUptime: use nitems for calculating the number of elements
ngie [Thu, 5 Jan 2017 09:28:38 +0000 (09:28 +0000)]
OS_getSystemUptime: use nitems for calculating the number of elements
in a sysctl mib instead of hardcoding the number 2

MFC after: 3 days

7 years agoUse strlcpy and snprintf in netstat(1).
delphij [Thu, 5 Jan 2017 09:23:54 +0000 (09:23 +0000)]
Use strlcpy and snprintf in netstat(1).

Expand inet6name() line buffer to NI_MAXHOST and use strlcpy/snprintf
in various places.

Reported by: Anton Yuzhaninov <citrin citrin ru>
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D8916

7 years agosnmp_table_fetch_async: don't leak `work` if snmp_pdu_send(..) fails
ngie [Thu, 5 Jan 2017 08:49:06 +0000 (08:49 +0000)]
snmp_table_fetch_async: don't leak `work` if snmp_pdu_send(..) fails

MFC after: 1 week
Reported by: Coverity
CID: 1017276

7 years agoop_usm_users: fix indentation in SNMP_OP_SET block
ngie [Thu, 5 Jan 2017 08:27:23 +0000 (08:27 +0000)]
op_usm_users: fix indentation in SNMP_OP_SET block

MFC after: 3 days

7 years agoUse calloc instead of malloc + memset(.., 0, ..)
ngie [Thu, 5 Jan 2017 08:17:17 +0000 (08:17 +0000)]
Use calloc instead of malloc + memset(.., 0, ..)

MFC after: 3 days

7 years agolsock_init_port: address issues with initializing sockaddr_un object
ngie [Thu, 5 Jan 2017 08:14:20 +0000 (08:14 +0000)]
lsock_init_port: address issues with initializing sockaddr_un object

- Use strlcpy to ensure p->name doesn't overflow sa.sun_path [*].
- Use SUN_LEN(..) instead of spelling out calculation longhand (inspired
  by comment by jmallett).

Tested with: dgram and stream support with both bsnmpwalk and snmpwalk

MFC after: 1 week
Reported by: Coverity
CID: 1006825

7 years agolm_load: fix string copying issues
ngie [Thu, 5 Jan 2017 07:55:17 +0000 (07:55 +0000)]
lm_load: fix string copying issues

- Ensure `section` doesn't overrun section by using strlcpy instead of
  strcpy [*].
- Use strdup instead of malloc + strcpy (this wasn't flagged by Coverity,
  but is an opportunistic change).

MFC after: 1 week
Reported by: Coverity
CID: 1006826 [*]

7 years agoRedo fix for CID 979581
ngie [Thu, 5 Jan 2017 07:46:57 +0000 (07:46 +0000)]
Redo fix for CID 979581

The previous change was flawed in terms of how it calculated the
buffer length for the sockaddr_un object. Use SUN_LEN where
appropriate and mute the Coverity complaint by using memset(.., 0, ..)
to zero out the entire structure instead of setting .sun_len to a bogus
value and strlcpy'ing in the contents of argv[1].

SUN_LEN is now being passed to bind(2) as well. For some odd reason
this wasn't flagged as a bug with Coverity.

Reported by: jilles, jmallett
MFC after: 2 days
X-MFC with: r311233

7 years ago[net80211] correct VHT ieee80211com state bits.
adrian [Thu, 5 Jan 2017 05:03:11 +0000 (05:03 +0000)]
[net80211] correct VHT ieee80211com state bits.

* rename the ieee80211com field for vht mcsinfo to be ic_, not iv;
* add a vht config field, stealing from the spares I left there.

This doesn't change the ABI.

7 years ago[ath_hal] mad, mad hacks to get some semblence of correct HT/40 channels populated.
adrian [Thu, 5 Jan 2017 04:56:04 +0000 (04:56 +0000)]
[ath_hal] mad, mad hacks to get some semblence of correct HT/40 channels populated.

The HT40 channel population logic was "just" doing pairs of channels starting with
the band entry frequency.  Trouble is, a lot of the rules start way off at 5120MHz,
which isn't a valid 5GHz channel.  Then, eg for HT40U, it would populate:

* (5120,5140)
* (5160,5180)
* (5200,5220)
* (5240,5260)

.. as the HT40U pairs, with the first being the primary channel.  Channel 36
is 5180MHz, and since it's not a primary channel here, it wouldn't populate it.
Then, the next HT40U would be 5200/5220, which is highly wrong.

HT40D had the same problem.

So, this just forces that 5GHz HT40 channels start at channel 36 (5180),
no matter what the band edge says.  This includes eg doing 4.9GHz channels.

This erm, meant that the HT40 channels for the low band was always wrong.

Oops!

Tested:

* AR9380, STA mode
* AR9344 SoC, AP mode

MFC after: 1 week

7 years ago[net80211] add VHT media types in the media layer.
adrian [Thu, 5 Jan 2017 04:49:23 +0000 (04:49 +0000)]
[net80211] add VHT media types in the media layer.

7 years agoFix build when WITHOUT_INET6 is defined.
hrs [Thu, 5 Jan 2017 03:25:16 +0000 (03:25 +0000)]
Fix build when WITHOUT_INET6 is defined.

7 years agoRemove a redundant use of min().
markj [Thu, 5 Jan 2017 03:13:45 +0000 (03:13 +0000)]
Remove a redundant use of min().

Reported by: rpokala
X-MFC With: r311346

7 years agoIn the same vein as r311350, fix whitespace in handling of XPT_PATH_INQ in
rpokala [Thu, 5 Jan 2017 03:08:57 +0000 (03:08 +0000)]
In the same vein as r311350, fix whitespace in handling of XPT_PATH_INQ in
several more drivers.

Sponsored by: Panasas

7 years agoFix whitespace in handling of XPT_PATH_INQ in adw(4).
rpokala [Thu, 5 Jan 2017 02:54:03 +0000 (02:54 +0000)]
Fix whitespace in handling of XPT_PATH_INQ in adw(4).

Came across this while doing some other minor CAM cleanup. Whitespace-only
change, so not bothering w/ a review.

Sponsored by: Panasas

7 years agotabs -> spaces in etc/mtree
asomers [Thu, 5 Jan 2017 02:47:56 +0000 (02:47 +0000)]
tabs -> spaces in etc/mtree

MFC after: 4 weeks

7 years agoAdd a reasonable bound on the symbol table index size.
markj [Thu, 5 Jan 2017 02:33:10 +0000 (02:33 +0000)]
Add a reasonable bound on the symbol table index size.

7 years agoIn rtl8188eu, read R92C_HSSI_PARAM2(0)) register to detect whether it needs
kevlo [Thu, 5 Jan 2017 02:04:53 +0000 (02:04 +0000)]
In rtl8188eu, read R92C_HSSI_PARAM2(0)) register to detect whether it needs
to enable CCK high power feature or not.

Reviewed by: avos

7 years agoAdd a small allocator for exec_map entries.
markj [Thu, 5 Jan 2017 01:44:12 +0000 (01:44 +0000)]
Add a small allocator for exec_map entries.

Upon each execve, we allocate a KVA range for use in copying data to the
new image. Pages must be faulted into the range, and when the range is
freed, the backing pages are freed and their mappings are destroyed. This
is a lot of needless overhead, and the exec_map management becomes a
bottleneck when many CPUs are executing execve concurrently. Moreover, the
number of available ranges is fixed at 16, which is insufficient on large
systems and potentially excessive on 32-bit systems.

The new allocator reduces overhead by making exec_map allocations
persistent. When a range is freed, pages backing the range are marked clean
and made easy to reclaim. With this change, the exec_map is sized based on
the number of CPUs.

Reviewed by: kib
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D8921

7 years agoSort includes in kern_exec.c.
markj [Thu, 5 Jan 2017 01:28:08 +0000 (01:28 +0000)]
Sort includes in kern_exec.c.

MFC after: 1 week

7 years agoUse db_printsym() to display function names in stack traces.
jhb [Thu, 5 Jan 2017 00:59:53 +0000 (00:59 +0000)]
Use db_printsym() to display function names in stack traces.

Previously, the stack unwinder tried to locate the start of the function
in each frame by walking backwards until it found an instruction that
modified the stack pointer and then assumed that was the first instruction
in a function.  The unwinder would only print a function name if the
starting instruction's address was an exact match for a symbol name.
However, not all functions generated by modern compilers start off functions
with that instruction.  For those functions, the unwinder would fail to
find a matching function name.  As a result, most frames in a stack
trace would be printed as raw hex PC's instead of a function name.

Stop depending on this incorrect assumption and just use db_printsym()
like other platforms to display the function name and offset for each
frame.  This generates a far more useful stack trace.

While here, don't print out curproc's pid at the end of the trace.  The
pid was always from curproc even if tracing some other process.

In addition, remove some rotted comments about hardcoded constants that
are no longer hardcoded.

Sponsored by: DARPA / AFRL

7 years agoOnly call stacktrace_subr() from DDB.
jhb [Thu, 5 Jan 2017 00:08:04 +0000 (00:08 +0000)]
Only call stacktrace_subr() from DDB.

There was a single call to stacktrace() under an #ifdef DEBUG to obtain
a stack trace during a fault that resulted in a function pointer to a
printf function being passed to stacktrace_subr() in db_trace.c.  The
kernel now has existing interfaces for obtaining a stack trace outside
of DDB (kdb_backtrace(), or the stack_*() API) that should be used instead.
Rather than fix the one call however, remove it since the kernel will
dump a trace anyway once it panics.

Make stacktrace_subr() static, remove the function pointer and change it
to use db_printf() explicitly.

Discussed with: kan
Sponsored by: DARPA / AFRL

7 years agoMisc Coverity fixes for tail(1)
asomers [Wed, 4 Jan 2017 23:22:34 +0000 (23:22 +0000)]
Misc Coverity fixes for tail(1)

CID 1006402: Initialize stack variable
CID 271580: Don't leak memory when ENOMEM.

Reported by: Coverity
CID: 271580 1006402
MFC after: 4 weeks
Sponsored by: Spectra Logic Corp

7 years agoFix assertion that checks that pages are consecutive to properly
glebius [Wed, 4 Jan 2017 22:31:09 +0000 (22:31 +0000)]
Fix assertion that checks that pages are consecutive to properly
handle bogus_page insertion(s).

7 years agoMove bogus_page declaration to vm_page.h and initialization to vm_page.c.
glebius [Wed, 4 Jan 2017 22:27:19 +0000 (22:27 +0000)]
Move bogus_page declaration to vm_page.h and initialization to vm_page.c.

Reviewed by: kib

7 years agoRemove llvm-objdump when Clang is disabled. It was missed in r310889.
jkim [Wed, 4 Jan 2017 21:55:52 +0000 (21:55 +0000)]
Remove llvm-objdump when Clang is disabled.  It was missed in r310889.

Submitted by: dim

7 years agoFurther refine MIPS stack traces across trapframes.
jhb [Wed, 4 Jan 2017 21:13:21 +0000 (21:13 +0000)]
Further refine MIPS stack traces across trapframes.

Use the trapframe unwinder recently added for kernel stack overflow
panics for frames crossing MipsKernGenException and MipsKernIntr.
This provides more reliably unwinding across nested interrupts and
exceptions in the kernel.

While here, dump the value of the CAUSE and BADVADDR registers when
crossing a trapframe.

Submitted by: rwatson (original version)
Obtained from: CheriBSD
Sponsored by: DARPA / AFRL

7 years agoAlways null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name)
asomers [Wed, 4 Jan 2017 20:26:42 +0000 (20:26 +0000)]
Always null-terminate ccb_pathinq.(sim_vid|hba_vid|dev_name)

The sim_vid, hba_vid, and dev_name fields of struct ccb_pathinq are
fixed-length strings. AFAICT the only place they're read is in
sbin/camcontrol/camcontrol.c, which assumes they'll be null-terminated.
However, the kernel doesn't null-terminate them. A bunch of copy-pasted code
uses strncpy to write them, and doesn't guarantee null-termination. For at
least 4 drivers (mpr, mps, ciss, and hyperv), the hba_vid field actually
overflows. You can see the result by doing "camcontrol negotiate da0 -v".

This change null-terminates those fields everywhere they're set in the
kernel. It also shortens a few strings to ensure they'll fit within the
16-character field.

PR: 215474
Reported by: Coverity
CID: 1009997 1010000 1010001 1010002 1010003 1010004 1010005
CID: 1331519 1010006 1215097 1010007 1288967 1010008 1306000
CID: 1211924 1010009 1010010 1010011 1010012 1010013 1010014
CID: 1147190 1010017 1010016 1010018 1216435 1010020 1010021
CID: 1010022 1009666 1018185 1010023 1010025 1010026 1010027
CID: 1010028 1010029 1010030 1010031 1010033 1018186 1018187
CID: 1010035 1010036 1010042 1010041 1010040 1010039
Reviewed by: imp, sephe, slm
MFC after: 4 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D9037
Differential Revision: https://reviews.freebsd.org/D9038

7 years agoRemove duplicate iic and iicbus devices from JZ4780 kernel
kan [Wed, 4 Jan 2017 18:36:30 +0000 (18:36 +0000)]
Remove duplicate iic and iicbus devices from JZ4780 kernel

7 years agoRemove dead code in dhclient(8)
asomers [Wed, 4 Jan 2017 18:13:05 +0000 (18:13 +0000)]
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

7 years agostyle cleanup
ngie [Wed, 4 Jan 2017 17:54:44 +0000 (17:54 +0000)]
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

7 years agobridge_do_pfctl: allocate mib_name dynamically using asprintf
ngie [Wed, 4 Jan 2017 17:50:52 +0000 (17:50 +0000)]
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

7 years agoRemove dead code in rpc_parse.c
asomers [Wed, 4 Jan 2017 17:39:20 +0000 (17:39 +0000)]
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

7 years agobridge_get_pfval: use nitems instead of spelling it out longhand
ngie [Wed, 4 Jan 2017 17:38:18 +0000 (17:38 +0000)]
bridge_get_pfval: use nitems instead of spelling it out longhand

MFC after: 3 days

7 years agoUse strlcpy instead of strcpy when copying the bridge name to ifr.ifr_name
ngie [Wed, 4 Jan 2017 17:33:18 +0000 (17:33 +0000)]
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: 100673510067371006738

7 years agoDelete dead code in chat(8)
asomers [Wed, 4 Jan 2017 16:24:40 +0000 (16:24 +0000)]
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

7 years ago__vdso_gettc(): be extra careful with /dev/hpet mappings, never unmap
kib [Wed, 4 Jan 2017 16:10:52 +0000 (16:10 +0000)]
__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

7 years agoThe callers of kern_getfsstat(UIO_SYSSPACE) expect that *buf always
kib [Wed, 4 Jan 2017 16:09:45 +0000 (16:09 +0000)]
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

7 years agoMFV r311279: zlib 1.2.10.
delphij [Wed, 4 Jan 2017 16:09:08 +0000 (16:09 +0000)]
MFV r311279: zlib 1.2.10.

MFC after: 1 month

7 years agoFix bug that would result in a kernel crash in some cases involving
trasz [Wed, 4 Jan 2017 14:43:57 +0000 (14:43 +0000)]
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

7 years agoDon't release the cfiscsi session refcount too early. It wasn't
trasz [Wed, 4 Jan 2017 12:50:44 +0000 (12:50 +0000)]
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

7 years agosnmp_mibII(3) requires net/if.h and net/if_mib.h
ngie [Wed, 4 Jan 2017 10:08:18 +0000 (10:08 +0000)]
snmp_mibII(3) requires net/if.h and net/if_mib.h

Document that requirement

MFC after: 1 week

7 years agoRestructure libz, place vendor files in contrib/zlib like other third
delphij [Wed, 4 Jan 2017 09:30:47 +0000 (09:30 +0000)]
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

7 years agorun: ensure pthread_condattr_{init,setclock} is successful
ngie [Wed, 4 Jan 2017 09:06:49 +0000 (09:06 +0000)]
run: ensure pthread_condattr_{init,setclock} is successful

MFC after: 1 week
Reported by: Coverity
CID: 12686311268633

7 years agosetrlimit_basic: don't leak buf; free it on completion
ngie [Wed, 4 Jan 2017 09:00:16 +0000 (09:00 +0000)]
setrlimit_basic: don't leak buf; free it on completion

MFC after: 3 days
Reported by: Coverity
CID: 978311

7 years agorevoke_perm: don't leak fd at the end of the test; close it
ngie [Wed, 4 Jan 2017 08:59:06 +0000 (08:59 +0000)]
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

7 years agostat_symlink: don't leak fd; close the file descriptor when done
ngie [Wed, 4 Jan 2017 08:49:07 +0000 (08:49 +0000)]
stat_symlink: don't leak fd; close the file descriptor when done

MFC after: 3 days
Reported by: Coverity
CID: 978314

7 years agopipe_restart: free f on function exit to quell complaint from Coverity
ngie [Wed, 4 Jan 2017 08:43:27 +0000 (08:43 +0000)]
pipe_restart: free f on function exit to quell complaint from Coverity

MFC after: 3 days
Reported by: Coverity
CID: 978307

7 years agoswapcontext1: test for getcontext(3) and swapcontext(3) success properly
ngie [Wed, 4 Jan 2017 08:35:46 +0000 (08:35 +0000)]
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

7 years agoClarify lifetime of child(..) function
ngie [Wed, 4 Jan 2017 08:25:31 +0000 (08:25 +0000)]
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: 122336912233701300301

7 years agoAdd missing files in zlib 1.2.8.
delphij [Wed, 4 Jan 2017 08:12:31 +0000 (08:12 +0000)]
Add missing files in zlib 1.2.8.

7 years ago[net80211] Add VHT flags for printf/debugging.
adrian [Wed, 4 Jan 2017 08:08:50 +0000 (08:08 +0000)]
[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.

7 years agofpu: ensure calls to pthread_create succeed and test sched_yield to make
ngie [Wed, 4 Jan 2017 08:07:48 +0000 (08:07 +0000)]
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: 1254953125495412549651254966

7 years agoUse calloc instead of malloc with buffers in snmp_{recv,send}_packet
ngie [Wed, 4 Jan 2017 07:53:01 +0000 (07:53 +0000)]
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

7 years agomincore_resid: free buf after use
ngie [Wed, 4 Jan 2017 04:55:33 +0000 (04:55 +0000)]
mincore_resid: free buf after use

MFC after: 3 days
Reported by: Coverity
CID: 978304

7 years ago{strchr,strlen}_basic: don't leak the dlopen'ed handle; close after use
ngie [Wed, 4 Jan 2017 04:50:03 +0000 (04:50 +0000)]
{strchr,strlen}_basic: don't leak the dlopen'ed handle; close after use

MFC after: 3 days
Reported by: Coverity
CID: 978299, 978300

7 years agomknodat_fd: close dfd after use to avoid leaking it
ngie [Wed, 4 Jan 2017 04:32:00 +0000 (04:32 +0000)]
mknodat_fd: close dfd after use to avoid leaking it

MFC after: 3 days
Reported by: Coverity
CID: 978287

7 years agomkfifoat_fd: close dfd after use to avoid leaking it
ngie [Wed, 4 Jan 2017 04:29:53 +0000 (04:29 +0000)]
mkfifoat_fd: close dfd after use to avoid leaking it

MFC after: 3 days
Reported by: Coverity
CID: 978286

7 years agofexecve: don't leak fd on fexecve(2) failure; close before calling err
ngie [Wed, 4 Jan 2017 04:27:13 +0000 (04:27 +0000)]
fexecve: don't leak fd on fexecve(2) failure; close before calling err

MFC after: 3 days
Reported by: Coverity
CID: 978285

7 years agotty: don't leak s after opening it with openpty
ngie [Wed, 4 Jan 2017 04:19:05 +0000 (04:19 +0000)]
tty: don't leak s after opening it with openpty

MFC after: 3 days
Reported by: Coverity
CID: 978321

7 years agommap_prot_3, mmap_truncate, mmap_truncate_signal: don't leak fd and map
ngie [Wed, 4 Jan 2017 04:10:36 +0000 (04:10 +0000)]
mmap_prot_3, mmap_truncate, mmap_truncate_signal: don't leak fd and map

Reported by: Coverity
CID: 978306, 125140612881961300541

7 years agoFollowup to mtod removal in main stack (r311225). Continued removal
gnn [Wed, 4 Jan 2017 04:00:28 +0000 (04:00 +0000)]
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

7 years agolisten_low_port: check for errors from socket(2) before continuing
ngie [Wed, 4 Jan 2017 03:59:50 +0000 (03:59 +0000)]
listen_low_port: check for errors from socket(2) before continuing

MFC after: 3 days
Reported by: Coverity
CID: 976778

7 years agokqueue_desc_passing: initialize m.msg_flags to 0
ngie [Wed, 4 Jan 2017 03:54:54 +0000 (03:54 +0000)]
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

7 years agoumask_open: don't leak fd on success
ngie [Wed, 4 Jan 2017 03:41:16 +0000 (03:41 +0000)]
umask_open: don't leak fd on success

MFC after: 3 days
Reported by: Coverity
CID: 978315

7 years agoARM GENERIC: Add support for Allwinner A33 SoC
manu [Wed, 4 Jan 2017 03:37:00 +0000 (03:37 +0000)]
ARM GENERIC: Add support for Allwinner A33 SoC

7 years agoAllwinner: Add A33 support
manu [Wed, 4 Jan 2017 03:35:39 +0000 (03:35 +0000)]
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

7 years agounlink_fifo: don't leak the file descriptors opened with mkfifo and open
ngie [Wed, 4 Jan 2017 03:35:23 +0000 (03:35 +0000)]
unlink_fifo: don't leak the file descriptors opened with mkfifo and open

MFC fater: 3 days
Reported by: Coverity
CID: 978316, 978317

7 years agottyname_err: close fd if it was opened successfully
ngie [Wed, 4 Jan 2017 02:52:39 +0000 (02:52 +0000)]
ttyname_err: close fd if it was opened successfully

MFC after: 3 days
Reported by: Coverity
CID: 978292

7 years agoFix Coverity issues
ngie [Wed, 4 Jan 2017 02:46:36 +0000 (02:46 +0000)]
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

7 years agohumanize_number_basic: don't leak buf
ngie [Wed, 4 Jan 2017 02:38:14 +0000 (02:38 +0000)]
humanize_number_basic: don't leak buf

MFC after: 3 days
Reported by: Coverity
CID: 1251407

7 years agoftok_link: don't leak fd
ngie [Wed, 4 Jan 2017 02:34:30 +0000 (02:34 +0000)]
ftok_link: don't leak fd

MFC after: 3 days
Reported by: Coverity
CID: 978291

7 years agoseekdir_basic: fix various Coverity issues
ngie [Wed, 4 Jan 2017 02:31:05 +0000 (02:31 +0000)]
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

7 years agomtx: plug open-coded mtx_lock access missed in r311172
mjg [Wed, 4 Jan 2017 02:25:31 +0000 (02:25 +0000)]
mtx: plug open-coded mtx_lock access missed in r311172

7 years agoFix DTrace TCP tracepoints to not use mtod() as it is both unnecessary and
gnn [Wed, 4 Jan 2017 02:19:13 +0000 (02:19 +0000)]
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

7 years agoFix PMC architecture check to handle later IPAs including Skylake
gnn [Wed, 4 Jan 2017 02:15:03 +0000 (02:15 +0000)]
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

7 years agoFix logical inversion when checking result from calloc
ngie [Wed, 4 Jan 2017 01:44:45 +0000 (01:44 +0000)]
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

7 years agoInitialize msg.msg_flags to 0
ngie [Wed, 4 Jan 2017 01:38:07 +0000 (01:38 +0000)]
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

7 years agoQuell Coverity for diskinfo(8)
asomers [Wed, 4 Jan 2017 00:39:06 +0000 (00:39 +0000)]
Quell Coverity for diskinfo(8)

* CID 1198994: Don't run the speed disk on a disk with no sectors
* CID 1011442: Don't call close(2) if open(2) fails
* CID 1011161: Use snprintf instead of sprintf
* CID 1009825: Check the return value of lseek

Reported by: Coverity
CID: 1198994 1011442 1011161 1009825
MFC after: 4 weeks
Sponsored by: Spectra Logic Corp

7 years agortwn: fix possible buffer overrun.
avos [Wed, 4 Jan 2017 00:26:41 +0000 (00:26 +0000)]
rtwn: fix possible buffer overrun.

r297596 was not merged properly into new code; restore lost part.