Commit Graph

16685 Commits

Author SHA1 Message Date
Andrew Turner
5ff4e2400d Fix the type used to hold the value returned from getopt. On arm64 char is
unsigned so will never be -1.

Obtained from:	ABT Systems Ltd
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2016-07-13 22:53:30 +00:00
Alan Somers
7c46e6ef06 pw should sanitize the argument of -w.
Otherwise, it will silently disable the login for the selected account if
the argument is unrecognizable.

usr.sbin/pw/pw.h
usr.sbin/pw/pw_conf.c
usr.sbin/pw/pw_user.c
	Use separate rules to validate boolean parameters and passwd
	parameters.  Error out if a password parameter cannot be parsed.

usr.sbin/pw/tests/Makefile
usr.sbin/pw/tests/crypt.c
usr.sbin/pw/tests/pw_useradd.sh
usr.sbin/pw/tests/pw_usermod.sh
	Add tests for the validation.  Also, enhance existing
	password-related tests to actually validate that the correct hash is
	written to master.passwd.

Reviewed by:	bapt
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6840
2016-07-13 17:09:20 +00:00
Bryan Drewery
ffe0dde6c6 META_MODE: Don't require filemon(4) for mergemaster(8)/etcupdate(8)
New .meta files will be created without filemon data, but any future build
that wants filemon data will force a rebuild due to the missing data
due to use of bmake's .MAKE.MODE=missing-filemon=yes feature.

Reported by:	np
Sponsored by:	EMC / Isilon Storage Division
MFC after:	3 days
2016-07-12 19:47:01 +00:00
Alexander Motin
e95b7573d7 Make unknown register reads predictable.
Reported by:	Coverity
CID:		1357525
2016-07-12 17:38:18 +00:00
Alexander Motin
a88b19f9e2 Add missing breaks in I/O BAR read/write.
This could be important if any guest actually used those registers.

Reported by:	Coverity
CID:		1357519, 1357520
2016-07-12 17:30:37 +00:00
Peter Grehan
5dab2ac7af Implement right shift/ctl, and convert the VNC/xorg scancode
of 0xff03 into right-alt.

Reported by:	lme@
MFC after:	1 week
2016-07-11 06:31:15 +00:00
Marcelo Araujo
391adcc526 Do not allow whitespace in macro names.
Obtained from:	OpenBSD (r1.19).
2016-07-11 03:34:32 +00:00
Xin LI
823c0d5f5e Allow - in distribution names. This is needed for freebsd-update to work
with 11.0+, where the debugging symbols use a new naming scheme for release
distribution files.

Errata candidate.

Approved by:	cperciva
Differential Revision:	https://reviews.freebsd.org/D7170
2016-07-11 03:31:12 +00:00
Alexander Motin
9e749f25da Add emulation for Intel e1000 (e82545) network adapter.
The code was successfully tested with FreeBSD, Linux, Solaris and Windows
guests.  This interface is predictably slower (about 2x) then virtio-net,
but it is very helpful for guests not supporting virtio-net by default.

Thanks to Jeremiah Lott and Peter Grehan for doing original heavy lifting.
2016-07-09 20:41:59 +00:00
Edward Tomasz Napierala
f9a2051818 Fix ctld(8) to not exit when reloading configuration with invalid
initiator-portal clause.

MFC after:	3 days
2016-07-09 20:01:07 +00:00
Alexander Motin
3dd7961093 Add emulation for multiple (up to 16) MSI vectors for AHCI.
It was useless before, but may improve performance now if multiple devices
are configured and guest supports this feature.

Sponsored by:	iXsystems, Inc.
2016-07-08 21:30:18 +00:00
Alexander Motin
098f5155d1 Allow AHCI controller to support up to 32 arbitrary devices.
While old syntax is still supported, new syntax looks like this:

-s 3,ahci,hd:/dev/zvol/XXX,hd:/dev/zvol/YYY,cd:/storage/ZZZ.iso

Sponsored by:	iXsystems, Inc.
2016-07-08 21:25:37 +00:00
Edward Tomasz Napierala
debc480e03 Add new unmount(2) flag, MNT_NONBUSY, to check whether there are
any open vnodes before proceeding. Make autounmound(8) use this flag.
Without it, even an unsuccessfull unmount causes filesystem flush,
which interferes with normal operation.

Reviewed by:	kib@
Approved by:	re (gjb@)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D7047
2016-07-07 09:03:57 +00:00
Enji Cooper
7e12dfe5ef Fix CTASSERT issue in a more clean way
- Replace all CTASSERT macro instances with static_assert's.
- Remove the WRAPPED_CTASSERT macro; it's now an unnecessary obfuscation.
- Localize all static_assert's to the structures being tested.
- Sort some headers per-style(9).

Approved by: re (hrs)
Differential Revision: https://reviews.freebsd.org/D7130
MFC after: 1 week
X-MFC with: r302364
Reviewed by: ed, grehan (maintainer)
Submitted by: ed
Sponsored by: EMC / Isilon Storage Division
2016-07-06 16:02:15 +00:00
Enji Cooper
eef0d63731 Fix gcc warning
Remove -Wunused-but-set-variable (`mopt`).

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7119
MFC after: 1 week
X-MFC with: r302332
Reported by: Jenkins
Reviewed by: grehan (maintainer)
Sponsored by: EMC / Isilon Storage Division
2016-07-06 05:17:56 +00:00
Enji Cooper
77334a7eb9 Fix gcc build errors with SSE 4.2 detection and gcc warnings
- Remove -Wunused-but-set-variable's (`len`, etc).
- Replace clang-specific tests in sse42_supported(..) with generic,
  FreeBSD-supported CPU feature tests, using macros and functions
  from machine/cpufunc.h and machine/specialreg.h . The previous method
  for determining SSE4.2 availability was only compatible with clang.
- Sort #includes per style(9).

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7119
MFC after: 1 week
X-MFC with: r302332
Reported by: Jenkins
Reviewed by: grehan (maintainer)
Sponsored by: EMC / Isilon Storage Division
2016-07-06 05:17:07 +00:00
Enji Cooper
73a709081c Fix gcc warnings
Remove unused function (`fifo_available`)

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7119
MFC after: 1 week
X-MFC with: r302332
Reported by: Jenkins
Reviewed by: grehan (maintainer)
Sponsored by: EMC / Isilon Storage Division
2016-07-06 05:11:39 +00:00
Enji Cooper
db17ba9691 Fix gcc warnings
- Put parentheses around bitwise OR'ed values in the `FIELD_COPY(..)` and
  `FIELD_REPLACE(..)` macros to mute warning from gcc 4.2.1.
- Remove -Wunused-but-set-variable's (`setup_addr`, `status_addr`).

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7119
MFC after: 1 week
X-MFC with: r302332
Reported by: Jenkins
Reviewed by: grehan (maintainer)
Sponsored by: EMC / Isilon Storage Division
2016-07-06 05:09:13 +00:00
Enji Cooper
98e21e80d2 Fix gcc warnings
Remove -Wunused-but-set-variable (`error`). Cast calls with
`(void)` to note that the return value is explicitly ignored.

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7119
MFC after: 1 week
Reported by: Jenkins
Reviewed by: grehan (maintainer)
Sponsored by: EMC / Isilon Storage Division
2016-07-06 05:05:03 +00:00
Enji Cooper
edb603345b Fix gcc warnings
Add `WRAPPED_CTASSERT` macro by annotating CTASSERTs with __unused
to deal with -Wunused-local-typedefs warnings from gcc 4.8+.
All other compilers (clang, etc) use CTASSERT as-is. A more generic
solution for this issue will be proposed after ^/stable/11 is forked.

Consolidate all CTASSERTs under one block instead of inlining them in
functions.

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7119
MFC after: 1 week
Reported by: Jenkins
Reviewed by: grehan (maintainer)
Sponsored by: EMC / Isilon Storage Division
2016-07-06 05:02:59 +00:00
Enji Cooper
f94fd843f4 Fix gcc warnings
Put cfl/prdt under AHCI_DEBUG #defines as they are only used in
those cases.

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7119
MFC after: 1 week
Reported by: Jenkins
Reviewed by: grehan (maintainer)
Sponsored by: EMC / Isilon Storage Division
2016-07-06 04:58:42 +00:00
Enji Cooper
9c9eaf63e3 Fix gcc warnings
- Remove -Wunused-but-set-variable (newcpu)
- Always return VMEXIT_CONTINUE as the code always set retval to that value.

Approved by: re (gjb)
Differential Revision: https://reviews.freebsd.org/D7119
MFC after: 1 week
Reported by: Jenkins
Reviewed by: grehan (maintainer)
Sponsored by: EMC / Isilon Storage Division
2016-07-06 04:56:45 +00:00
Baptiste Daroussin
7059692f3a Fix build of ppp when WITHOUT_PAM is set
PR:		210658
Reported by:	madpilot
Tested by:	madpilot
Approved by:	re@ (kib)
2016-07-04 21:18:57 +00:00
Peter Grehan
2cf9911fc1 Import bhyve_graphics into CURRENT. Thanks to all who tested
this on the branch.

Original commit message:
  Initial bhyve native graphics support.

  This adds emulations for a raw framebuffer device, PS2 keyboard/mouse,
  XHCI USB controller and a USB tablet.

  A simple VNC server is provided for keyboard/mouse input, and graphics
  output.

  A VGA emulation is included, but is currently disconnected until an
  additional bhyve change to block out VGA memory is committed.

  Credits:
   - raw framebuffer, VNC server, XHCI controller, USB bus/device emulation
      and UEFI f/w support by Leon Dang
   - VGA, console/g, initial VNC server  by tychon@
   - PS2 keyboard/mouse jointly done by tychon@ and Leon Dang
   - hypervisor framebuffer mem support by neel@

  Tested by: Michael Dexter, in a number of revisions of this code.

  With the appropriate UEFI image, FreeBSD, Windows and Linux guests can
  installed and run in graphics mode using the UEFI/GOP framebuffer.

Approved by:	re (gjb)
2016-07-04 03:19:06 +00:00
Allan Jude
e302644618 Add more machines to the bsdinstall workaround blacklist
Apply the LenovoFix (fake partition in pMBR is 2nd rather than 1st)
and GPT Active fix (mark the fake pMBR partition active) to respective
hardware that is confirmed to require such to boot correct.

Submitted by:	Sam Fourman Jr. <sfourman@gmail.com> (ThinkPad W520)
Submitted by:	Matthias Apitz <guru@unixarea.de> (Latitude E6330)
Approved by:	re (gjb)
Sponsored by:	ScaleEngine Inc.
2016-07-03 01:23:38 +00:00
Allan Jude
ca13d5d23a Fix an error in bsdinstall when ZFS installation uses a bootpool
A separate bootpool is used when the selected partition type is MBR
or when the disk is GELI encrypted and a UEFI loader is selected.

BIOS avoids the bootpool by using bootcode and loader that support GELI.

bsdinstall did not remount the bootpool after creating the main pool,
which caused an error when mkdir tried to create /boot/zfs

PR:		210717
Approved by:	re (gjb)
Sponsored by:	ScaleEngine Inc.
2016-07-03 01:22:59 +00:00
Roman Bogorodskiy
6ee52c658c bhyve: improve memory size documentation
A couple of minor memory size option related nits:

 - use common name 'memsize' (instead of 'max-size' or just 'size')
 - bhyve: update usage with memsize unit suffix, drop legacy "MB"
   unit
 - bhyveload: update usage with memsize unit suffix
 - bhyve(8): document default size
 - bhyveload(8): use memsize formatting like it's done
   in bhyve(8)

Reviewed by:            wblock, grehan
Approved by:            re (kib), wblock, grehan
Differential Revision:  https://reviews.freebsd.org/D6952
2016-06-26 14:44:01 +00:00
Alan Somers
2101ef6b90 Skip lastcomm and sa tests on unsupported architectures
usr.bin/lastcom/tests/Makefile
usr.sbin/sa/tests/Makefile
	Set allow_architectures appropriately.  These tests depend on golden
	files that must be generated for each architecture, and haven't yet
	been generated for all of them.

PR:		210566
PR:		204154
Reviewed by:	ngie
Approved by:	re (gjb)
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6960
2016-06-26 00:53:31 +00:00
Alan Somers
3185f0f02b Fix gstat's interactive f and q commands
curses and libedit don't play well together. After last year's libedit
upgrade in head, they play even less well together. This change resets some
curses settings after they get screwed up by libedit calls. Without it,
gstat's interactive commands require an extra "enter", screw up the terminal
on exit, and screw up the display if the user enters an invalid filter
string.

PR:		204852
Submitted by:	Keith White
Reviewed by:	pfg
Approved by:	re (gjb)
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6934
2016-06-23 23:13:14 +00:00
Ed Maste
5fafcca757 bsdinstall: increase EFI partition size to 200MB
A larger EFI file system size will facilitate multi-boot configurations
and the installation other EFI applications like firmware update tools.
200MB matches OS X.

Note that this changes only the partition size, not the file system that
bsdinstall places there. We need to do both, but as the partition size
is difficult to adjust later make this change for now so that at least
systems installed with FreeBSD 11.0 have a partition layout with room
to grow.

Reviewed by:	allanjude, imp
Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D6935
2016-06-23 18:04:48 +00:00
Wojciech Macek
0fbcaf7657 ARM64: bsdinstall support for creating EFI partitions
This patch enables bsdinstall to create EFI partition during installation and uploading it's contents,
    making the ARM64 FreeBSD installation bootable.

    Obtained from:         Semihalf
    Sponsored by:          Cavium
    Approved by:           re
    Reviewed by:           allanjude, emaste, nwhitehorn, wma
    Differential Revision: https://reviews.freebsd.org/D6853
2016-06-20 06:40:58 +00:00
Devin Teske
55620f43de Add bsdconfig wifi' (aka wireless' or `wlan') module
Approved by:	re (gjb)
MFC after:	8 weeks
Relnotes:	yes
2016-06-16 21:14:25 +00:00
Alan Somers
498a196b80 Fix usr.sbin/rpcbind ATF tests on 32-bit platforms
usr.sbin/rpcbind/tests/addrmerge_test.c
	Fix some sizeof calculations that work only by luck on 64-bit
	platforms.

PR:		210314
Reviewed by:	ngie
Approved by:	re (kib)
Reported by:	Mark Millard
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6855
2016-06-16 15:25:37 +00:00
Konstantin Belousov
78a6a430ca Return usual error indicator to shell.
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Approved by:	re (hrs)
2016-06-16 12:08:25 +00:00
Ed Maste
7b03d164da makefs: Provide a -T option to set timestamps to a consistent value
This is taken from the NetBSD versions listed below and adapted to the
makefs version in FreeBSD, along with a bug fix from cem@ that will be
sent to NetBSD.

Reviewed by:	pfg
Approved by:	re (gjb)
Obtained from:	NetBSD
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D6835
2016-06-14 14:03:28 +00:00
Alan Somers
9be960da8d Fix usr.sbin/extattr testcases on tmpfs
Skip the usr.sbin/extattr testscases if $TMPDIR is tmpfs, which doesn't
support extended attributes

PR:		210184
Reported by:	ngie
Reviewed by:	ngie
Approved by:	re (glebius)
MFC after:	4 weeks
Differential Revision:	https://reviews.freebsd.org/D6802
Sponsored by:	Spectra Logic Corp
2016-06-13 22:00:44 +00:00
Enji Cooper
47c5f8f2fe Add missing break in lock_partialfilelock(..) with NFS_RESERR
This will help ensure that the right error is trickled up when the
function is called if the lock status is NFS_RESERR

Differential Revision: https://reviews.freebsd.org/D6622
Reviewed by: rmacklem
Approved by: re (gjb)
Tested with: fsx; svn info/svnversion (uses bdb locking); locktests from Bull http://nfsv4.bullopensource.org/tools/tests/locktest.php
MFC after: 2 weeks
Reported by: Coverity
CID: 1008161, 1304956
Sponsored by: EMC / Isilon Storage Division
2016-06-13 11:19:06 +00:00
Enji Cooper
2c212dcc1e Change my given name from "Garrett" to "Ngie"
A legal name change from "Garrett" to "Ngie", as well as a FreeBSD
account name change, is pending.

Approved by: re (hrs)
2016-06-13 10:30:49 +00:00
Allan Jude
213a73b338 Fix a miss merge in the services_mkdb(8) man page
Restore the cross reference to getservent(3) to the correct line

Approved by:	re (gjb)
Sponsored by:	BSDCan Hacker Lounge
2016-06-10 14:59:11 +00:00
Allan Jude
52fffe9307 Fix bsdinstall for root-on-zfs with MBR partitioning
Fix an error where vfs.root.mountfrom was not always set as required
when creating a bootpool. After the recent geliboot changes, it was only
set if the main pool was encrypted.

Also resolve an error where the bootpool was unmounted twice causing
bsdinstall to stop with an error message about the failed command.

Approved by:	re (gjb)
Sponsored by:	BSDCan Hacker Lounge
2016-06-10 14:31:59 +00:00
Pedro F. Giffuni
c7310cbc6a rpcbind(8): Make use of some xdr_* macros.
xdr_rpcproc, xdr_rpcprog and xdr_rpcvers were broken in older
versions of FreeBSD but fixed in r296394.  Give them some use
hoping they help make the code somewhat more readable.
2016-06-09 22:25:00 +00:00
Edward Tomasz Napierala
03b521d4dc Decouple MaxBurstLength and FirstBurstLength from MaxRecvDataSegmentLength
reported by the ICL module in iscsid(8).  This harmed performance and was
just wrong.

MFC after:	1 month
2016-06-09 07:49:20 +00:00
Edward Tomasz Napierala
2317fdfa8c Don't cap FirstBurstLength to maximum MaxRecvDataSegmentLength claimed
by the offload driver; there is no reason to do so, and it actually
harms performance.

MFC after:	1 month
2016-06-09 07:19:02 +00:00
Mariusz Zaborski
e29a5e1bb9 Fix spelling of the casper introduced in the r296047.
PR:		210031
Reported by:	AllanJude, jmallett
2016-06-08 22:30:21 +00:00
Andriy Voskoboinyk
4913f849ab bsdinstall: add country/regulatory domain configuration dialog.
Allow to setup country and/or regulatory domain before scanning
(since channel list is affected by regulatory restrictions this may
impact scan results).

PR:		182600 (originally)
Differential Revision:	https://reviews.freebsd.org/D6325
2016-06-08 20:42:35 +00:00
Enji Cooper
6ee7c85891 Bounds check rpcbs_rmtcall(..) to ensure rtype is less than RPCBVERS_STAT
Not returning if rtype == RPCBVERS_STAT will cause us to overrun the inf array, as
it's defined to be exactly RPCBVERS_STAT elements in rpcb_prot.x:

> include/rpc/rpcb_prot.x:typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT];

The proposed change also matches the rest of the rtype upper bound checks in the
file, so the original change was likely a typo.

MFC after: 2 weeks
Reported by: Coverity
CID: 1007567
Reviewed by: truckman
Sponsored by: EMC / Isilon Storage Division
2016-06-08 12:45:22 +00:00
Kurt Lidl
c0759dac0d Separate BLACKLIST vs BLACKLIST_SUPPORT properly
Sponsored by:	The FreeBSD Foundation
2016-06-07 16:31:03 +00:00
Marcelo Araujo
1830617ec9 Bump date in both manpages.
Reported by:	rodrigc
2016-06-07 07:04:05 +00:00
Adrian Chadd
aebdb1e24e [ath3k] add a replacement ath3k firmware loading tool.
This is influenced by the ath3k driver from linux (circa 2013, this is
how long I've been sitting on this.)

It handles loading in firmware using the newer model, where it assembles
the right set of firmware blobs and board configuration based on the
device list and querying the device.

The older utility could only load in a single image - which sometimes
was ath3k-1.fw and sometimes was ath3k-2.fw.  However, the ath3k maintainers
didn't want to keep adding in binaries that were just derivatives with a
separate board config, so they deleted ath3k-2.fw from the Linux firmware
repository and instead, well, did this.

Now, this has been tested against AR3011 and AR3012 NICs from the AR9285+BT
combo up through to the QCA9565+BT combo.  It doesn't yet work with the
QCAFN222 NIC as that is some newer chip.

The firmware can be grabbed from https://github.com/erikarn/ath3kfw/ in
the share/firmware/ath3k directory.  I'll update this utility over time
to support the newer firmware drops (newer than mid-2013) which should
pull in the QCNFA222 and subsequent chips.

Tested:

* AR9285 + BT
* AR9287 + BT
* AR9485 + BT
* AR9462 + BT
* QCA9565 + BT
2016-06-07 04:22:18 +00:00
Marcelo Araujo
3db8326de1 Add an entry on rc.conf(5) explaining the new options
nis_ypldap_enable and nis_ypldap_flags.

Also add an entry on ypldap(8) that it is a feature ready and
appears on FreeBSD 11.0.

Requested by:	rodrigc
Relnotes:	Yes
2016-06-07 01:00:08 +00:00
Eric van Gyzen
c152ba971f newsyslog: Eliminate unnecessary sleep(10) when -R and -s are specified
After going through the signal work list, during which do_sigwork()
is called and essentially does nothing because -s and -R were
specified on the command line, newsyslog will sleep for 10 seconds
as the (verbose) code says: "Pause 10 seconds to allow daemon(s)
to close log file(s)".

However, the man page verbiage for -R (and -s) seems quite clear
that this sleep() is unnecessary because the daemon was expected
to have already closed the log file before calling newsyslog.

PR:		210020
Submitted by:	David A. Bright <david_a_bright@dell.com>
MFC after:	1 week
Sponsored by:	Dell Inc.
Differential Revision:	https://reviews.freebsd.org/D6727
2016-06-06 22:54:08 +00:00
Marcelo Araujo
d134fb49e5 For pointers use NULL instead of 0. 2016-06-06 04:18:56 +00:00
Edward Tomasz Napierala
31c2b42258 Remove duplicated semicolons.
MFC after:	1 month
2016-06-05 08:51:56 +00:00
Edward Tomasz Napierala
4e5408f10c Report negotiated MaxBurstLength and FirstBurstLength in "iscsictl -v"
and "ctladm islist -v" outputs.

MFC after:	1 month
2016-06-05 08:48:37 +00:00
Baptiste Daroussin
e1fc61c114 Fix typo preventing pw {user,group}next -C from working as expected
Reported by:	Mike Selnet via forums.freebsd.org
MFC after:	3 days
2016-06-04 16:31:33 +00:00
Bryan Drewery
92edc96667 WITH_META_MODE: Don't expect meta files for side-effect generated files.
The first file in these lists will generate everything else so only
it should be getting a .meta file.  With bmake's missing=yes meta
feature these would otherwise cause a rebuild without the
.NOMETA hint.

Sponsored by:	EMC / Isilon Storage Division
2016-06-03 19:25:41 +00:00
Bryan Drewery
6e9a3c415e DIRDEPS_BUILD: Connect new directories and update dependencies.
Sponsored by:	EMC / Isilon Storage Division
2016-06-03 19:25:30 +00:00
Xin LI
e27abb6689 MFV r301238:
ntp 4.2.8p8.

Security:	CVE-2016-4957, CVE-2016-4953, CVE-2016-4954
Security:	CVE-2016-4955, CVE-2016-4956
Security:	FreeBSD-SA-16:24.ntp
With hat:	so
2016-06-03 08:00:22 +00:00
Kurt Lidl
0871a7d54c Add blacklistd.conf manpage
Install the blacklistd.conf man page, missed in the original commit.

Submitted by:	Herbert J. Skuhra ( herbert at mailbox.org )
Reviewed by:	rpaulo
Approved by:	rpaulo
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D6702
2016-06-03 06:15:52 +00:00
Kurt Lidl
95856e1457 Add basic blacklist build support
Reviewed by:	rpaulo
Approved by:	rpaulo
Relnotes:	YES
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D5913
2016-06-02 19:06:04 +00:00
Glen Barber
ea580d0b45 Revert r301137 and r301163, and implement a correct fix
for the CONFS issue with dma.conf and ppp.conf.

Thank you very much to Bryan Drewery for looking into the
problem and providing this fix.

Pointyhat:	gjb
Sponsored by:	The FreeBSD Foundation
2016-06-01 20:44:28 +00:00
Glen Barber
efe50fa18a Revert r289096:
Files listed in 'CONFS' are not properly included in new
installations (missing from base.txz), for reasons I still
do not fully understand.

This reverts the change excluding /etc/ppp/ppp.conf from
a new installation.  /etc/dma/dma.conf is also affected,
but requires a different solution, still being investigated.

Reported by:	Ben Woods
Sponsored by:	The FreeBSD Foundation
2016-06-01 16:45:08 +00:00
Steven Hartland
dc30160e1a Fix tzsetup not installing /etc/localtime for UTC
If tzsetup UTC is run then it successfully configured the system for UTC
including installing /etc/localtime however if the user ran just tzsetup
for interactive configuration and select UTC no /etc/localtime was installed
which resulted in failures for utilities which require said file.

Change set_zone_utc to call install_zoneinfo("UTC") to ensure that
/etc/localtime is created for interactive UTC selection.

Users who have previously run tzsetup in interactive mode and select UTC
can install the missing /etc/localtime by running tzsetup -r.

Also correct static miss-match for set_zone_utc.

MFC after:	2 weeks
Relnotes:	Yes
Sponsored by:	Multiplay
2016-06-01 15:39:11 +00:00
Edward Tomasz Napierala
ba4a30ae97 Describe default value for "offload".
MFC after:	1 month
2016-06-01 11:45:06 +00:00
Pedro F. Giffuni
d5b9e63ca6 keyserv(1): drop useless comparison.
Comparing a character array against NULL serves no purpose. In any case
we are always asigning a value just before using the value so obviate
the comparison altogether.

Reviewed by:	ngie
Differential Revision:	https://reviews.freebsd.org/D6651

CID:	1008422
2016-05-30 20:41:55 +00:00
Enji Cooper
98a7b0ba5c Follow up to r300932
In the event MK_INET6 != no in userspace, but is disabled in the
kernel, or if there aren't any IPv6 addresses configured in userspace
(for lo0 and all physical interfaces), rpcbind would terminate
immediately instead of silently failing on

Skip over the IPv6 block to its respective cleanup with freeifaddrs if
creating the socket failed instead of terminating rpcbind immediately

MFC after: 6 days
X-MFC with: r300932
Reported by: O. Hartmann <ohartman@zedat.fu-berlin.de>
Sponsored by: EMC / Isilon Storage Division
2016-05-29 20:28:01 +00:00
Mark Johnston
5656b5057e Fix rpcbind init after r300941.
- getaddrinfo() sets res = NULL on failure and freeaddrinfo() always
  dereferences its argument, so we should only free the address list after
  a successful call.
- Address a second potential leak caused by getaddrinfo(AF_INET6)
  overwriting the address list returned by getaddrinfo(AF_INET).

X-MFC-With:	r300941
2016-05-29 19:46:34 +00:00
Ed Schouten
c200e14277 Invoke the dirname() function in a POSIX compliant way.
POSIX requires that the argument of dirname() is of type "char *". In
other words, the input buffer can be modified by the function to store
the directory name.

Pull a copy of the string before calling dirname(). We don't care about
freeing up the memory afterwards, as this is done at the very bottom of
main(), right before the program terminates.

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D6628
2016-05-29 10:41:27 +00:00
Enji Cooper
4eb767eab0 Staticize variables only used in rpcbind.c
This is some low hanging fruit necessary for making this WARNS?= 6 clean

MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division
2016-05-29 07:01:12 +00:00
Enji Cooper
370b69af0f Remove unnecessary caller_uaddr != NULL test before calling free on it
MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division
2016-05-29 06:29:22 +00:00
Enji Cooper
3f78f0a950 Remove a useless if (x != NULL) check before calling free on allocated_uaddr
MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division
2016-05-29 06:01:18 +00:00
Enji Cooper
b07f123b60 Don't leak res in network_init(..)
Call freeaddrinfo on it after it's been used

MFC after: 1 week
Reported by: Coverity
CID: 1225050
Sponsored by: EMC / Isilon Storage Division
2016-05-29 05:55:21 +00:00
Enji Cooper
06eae2c1e0 Mark out_of_mem(..) and usage(..) with __dead2 as they both directly call exit
as a hint to static analysis tools

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-05-29 04:18:47 +00:00
Enji Cooper
4b528ceaf7 Plug leak with ifp by calling freeifaddrs after calling getifaddrs
MFC after: 1 week
Obtained from: NetBSD v1.18
Sponsored by: EMC / Isilon Storage Division
2016-05-29 04:02:02 +00:00
Enji Cooper
43db5d126c Catch malloc(3) errors and socket(2) errors
- malloc failing will result in a delayed segfault
- socket failing will result in delayed failures with setsockopt

Exit in the event that either of these high-level conditions are met.

Reported by: Coverity
CID: 976288, 976321, 976858
Sponsored by: EMC / Isilon Storage Division
2016-05-29 03:42:50 +00:00
Enji Cooper
65d4c609a4 Only expose hint_uaddr in the ND_DEBUG case
This fixes a -Wunused-but-set-variable warning with gcc

MFC after: 1 week
Reported by: gcc 5
Sponsored by: EMC / Isilon Storage Division
2016-05-27 19:30:13 +00:00
Baptiste Daroussin
86bdfe1565 Improve error message when failing to open a backing file
When bhyve cannot open a backing file, it now says explicitly which file
could not be opened

Note that the change has only be maed in block_if.c and not in
pci_virtio_block.c as the error will always be catched by the first

PR:		202321 (different patch)
Reviewed by:	grehan
MFC after:	3 day
Sponsored by:	Gandi.net
Differential Revision:	https://reviews.freebsd.org/D6576
2016-05-27 11:46:54 +00:00
Bryan Drewery
eb9b07bb77 WITH_AUTO_OBJ: Fix crunchgen builds.
Passing MAKEOBJDIRPREFIX to the main prog build (rescue) would confuse
WITH_AUTO_OBJ and cause it to create a recursed object directory that
then broke the actual prog build.  This is normally not a problem since
we do not call 'make -f prog.mk obj' before building anything in it.

Crunchgen(1) also assumes that if -o is not passed then if an object
directory does not already exist then it should build in the source
directories.  The normal buildworld process will have already ran 'make
obj' in each of the component directories so this is not a problem.
With WITH_AUTO_OBJ though this is not the case.  So we must tell
crunchgen(1) that MK_AUTO_OBJ=yes will create the directory and to not
require it be present before generating its Makefile.

Sponsored by:	EMC / Isilon Storage Division
2016-05-26 23:20:36 +00:00
Bryan Drewery
07ed5ac100 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	EMC / Isilon Storage Division
2016-05-26 23:20:07 +00:00
Alan Somers
2b8f2ab90d rmextattr(8) man page clarifications regarding -qq
Reviewed by:	ngie
MFC after:	6 days
X-MFC-With:	299085
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6422
2016-05-26 14:26:49 +00:00
Andriy Voskoboinyk
fb82771908 bsdinstall: unbreak static address assignment for wired networks.
This fixes regression introduced in r298946 (fixes static address
assignment for wireless networks).

Reported & submitted by:	allanjude
2016-05-26 11:58:36 +00:00
Don Lewis
ee67f7cc77 Avoid buffer overflow or truncation when constructing path_zoneinfo_file.
Reported by:	Coverity
CID:		1011160
MFC after:	1 week
2016-05-26 01:45:04 +00:00
Ed Schouten
d93c912801 Make code compile when basename() is POSIX compliant.
The POSIX basename() function is allowed to modify its input buffer,
which means its argument is "char *". Pull a copy of the input string
before computing the base.

Reviewed by:	jtl
Differential Revision:	https://reviews.freebsd.org/D6465
2016-05-25 08:45:03 +00:00
Don Lewis
9d80a8b09e Fix Coverity CIDs 1340544 Resource leak and 1340543 Use after free
At line 479 of ldapclient.c in client_build_req(), the error return
leaks ldap_attrs (CID 1340544).  It looks like this can happen if
the first utoa() call in aldap_get_stringset() fails.  It looks
like other leaks can happen if other utoa() calls fail since scanning
this array when it is freed stops when the first NULL is encountered.
Fix these problems by not storing NULL in the array when utoa()
fails, and by freeing ret and returning NULL if nothing is stored
in the array.  That way the caller will never see the
ldap_attrs[0] == NULL case, so delete that check.

The ber_printf_element() calls ber_free_elements() on its ber
argument and returns NULL on failure.  When each of its callers
detects failure, they do a goto fail, which then calls ber_free_elements()
with the same pointer (CID 1340543).  Fix is to delete the
ber_free_elements() from ber_printf_element()

Reported by:	Coverity
CID:		1340543, 1340544
Reviewed by:	araujo
Differential Revision:	https://reviews.freebsd.org/D6550
2016-05-25 01:37:25 +00:00
Don Lewis
5fb70b0cae Delay calling yp_malloc_dnsent() until after some additional sanity
checks to avoid leaking memory on error returns.

Reported by:	Coverity
CID:		1007416
MFC after:	1 week
2016-05-25 00:25:38 +00:00
Don Lewis
a23f17d3b1 Call free(cur) if strdup(dirp->d_name) fails to avoid a memory leak.
Reported by:	Coverity
CID:		1007414
MFC after:	1 week
2016-05-25 00:16:52 +00:00
Don Lewis
668bf37a0e Fix acpidb CIDs 1011279 (Buffer not null terminated) and 978405 and
1199380 (Resource leak).

load_dsdt() calls strncpy() to copy a filename and Coverity warns
that the destination buffer may not be NUL terminated.  Fix this
by using strlcpy() instead.  If silent truncation occurs, then the
filename was not valid anyway.

load_dsdt() leaks an fd (CID 978405) and a memory region allocated
using mmap() (CID 1199380) when it returns.  Fix these by calling
close() and munmap() as appropriate.

Don't bother fixing the minor memory leak "list", allocated by
AcGetAllTablesFromFile() (CID 1355191).

Check for truncation when creating the temp file name.

Set a flag to indicate that the temp file should be unlinked.
Relying on a strcmp() test could delete the input file in contrived
cases.

Reported by:	Coverity
CID:		1011279, 978405, 1199380
Reviewed by:	jkim
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D6368
2016-05-24 23:41:36 +00:00
Don Lewis
7e2cc014bd Fix acpidump CID 1011278 (Buffer not null terminated) and other issues
Coverity reports that a buffer used for temporary file generation
might not be NUL terminated by strncpy().  This is probably not
true because the input gets passed through realpath(), but if the
path name is sufficiently long the name could be truncated and cause
other problems.  The code for generating the temp file names is
also overly complex.  Instead of a bunch of calls to strncpy() and
and strncat(), simplify the code by using snprintf() and add checks
for unexpected truncation.

The output file created by iasl -d is predictable.  Fix this by
using  mkdtemp() to create a directory to hold the iasl input and
output files.

Check the return values of more syscalls.

Reported by:	Coverity
CID:		1011278
Reviewed by:	jkim
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D6360
2016-05-24 23:36:43 +00:00
Don Lewis
660d4fe299 Fix CID 1006692 in /usr/sbin/pw pw_log() function and other fixes
The length of the name returned from the $LOGNAME and $USER can be
very long and it was being concatenated to a fixed length buffer
with no bounds checking.  Fix this problem by limiting the length
of the name copied.

Additionally, this name is actually used to create a format string
to be used in adding log file entries so embedded % characters in
the name could confuse *printf(), and embedded whitespace could
confuse a log file parser.  Handle the former by escaping each %
with an additional %, and handle the latter by simply stripping it
out.

Clean up the code by moving the variable declarations to the top
of the function, formatting them to conform with style, and moving
intialization elsewhere.

Reduce code indentation by returning early in a couple of places.

Reported by:	Coverity
CID:		1006692
Reviewed by:	markj (previous version)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D6490
2016-05-24 05:02:24 +00:00
Peter Wemm
00774f3549 It seems <sys/types.h> is a new prerequisite for <bitstring.h> after
r300539. Attempt to fix the build for i386.
2016-05-24 03:15:46 +00:00
Don Lewis
95320acebc Fix multiple Coverity Out-of-bounds access false postive issues in CAM
The currently used idiom for clearing the part of a ccb after its
header generates one or two Coverity errors for each time it is
used.  All instances generate an Out-of-bounds access (ARRAY_VS_SINGLETON)
error because of the treatment of the header as a two element array,
with a pointer to the non-existent second element being passed as
the starting address to bzero().  Some instances also alsp generate
Out-of-bounds access (OVERRUN) errors, probably because the space
being cleared is larger than the sizeofstruct ccb_hdr).

In addition, this idiom is difficult for humans to understand and
it is error prone.  The user has to chose the proper struct ccb_*
type (which does not appear in the surrounding code) for the sizeof()
in the length calculation.  I found several instances where the
length was incorrect, which could cause either an actual out of
bounds write, or incompletely clear the ccb.

A better way is to write the code to clear the ccb itself starting
at sizeof(ccb_hdr) bytes from the start of the ccb, and calculate
the length based on the specific type of struct ccb_* being cleared
as specified by the union ccb member being used.  The latter can
normally be seen in the nearby code.  This is friendlier for Coverity
and other static analysis tools because they will see that the
intent is to clear the trailing part of the ccb.

Wrap all of the boilerplate code in a convenient macro that only
requires a pointer to the desired union ccb member (or a pointer
to the union ccb itself) as an argument.

Reported by:	Coverity
CID:		1007578, 1008684, 1009724, 1009773, 1011304, 1011306
CID:		1011307, 1011308, 1011309, 1011310, 1011311, 1011312
CID:		1011313, 1011314, 1011315, 1011316, 1011317, 1011318
CID:		1011319, 1011320, 1011321, 1011322, 1011324, 1011325
CID:		1011326, 1011327, 1011328, 1011329, 1011330, 1011374
CID:		1011390, 1011391, 1011392, 1011393, 1011394, 1011395
CID:		1011396, 1011397, 1011398, 1011399, 1011400, 1011401
CID:		1011402, 1011403, 1011404, 1011405, 1011406, 1011408
CID:		1011409, 1011410, 1011411, 1011412, 1011413, 1011414
CID:		1017461, 1018387, 1086860, 1086874, 1194257, 1229897
CID:		1229968, 1306229, 1306234, 1331282, 1331283, 1331294
CID:		1331295, 1331535, 1331536, 1331539, 1331540, 1341623
CID:		1341624, 1341637, 1341638, 1355264, 1355324
Reviewed by:	scottl, ken, delphij, imp
MFH:		1 month
Differential Revision:	https://reviews.freebsd.org/D6496
2016-05-24 00:57:11 +00:00
Allan Jude
24d17f1e24 Only set kern.geom.part.mbr.enforce_chs=0 once, instead of once per disk
Sponsored by:	ScaleEngine Inc.
2016-05-24 00:23:39 +00:00
Allan Jude
bb4fd0a0d1 Add support for RAID 1+0 (striped mirrors) to bsdinstall/zfsboot
Sponsored by:	ScaleEngine Inc.
2016-05-24 00:22:29 +00:00
Allan Jude
b06bc65e71 Only export and re-import the root pool if installing on MBR
This step is required in order to dd the boot2 bits into the ZFS partition

Sponsored by:	ScaleEngine Inc.
2016-05-23 17:04:13 +00:00
Allan Jude
7289f18f78 Fix missing pool name in zfs set command 2016-05-23 16:49:26 +00:00
Allan Jude
dcf362194d Fix error in bsdinstall where additional filesystems cannot be mounted
Do not set canmount=noauto on the boot environment at create time, because
this causes / to not be mounted, and since the chroot is read only, new
mountpoints cannot be created.

The property is set later, when other properties are adjusted

Reported by:	HardenedBSD
Sponsored by:	ScaleEngine Inc.
2016-05-23 15:11:01 +00:00
Edward Tomasz Napierala
a863d33413 Build iscsid(8) with ICL_KERNEL_PROXY defined by default, as required
for iSER.

Obtained from:	Mellanox Technologies
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-23 12:58:24 +00:00
Allan Jude
a1b8f55c77 bsdinstall/zfsboot GPT+BIOS+GELI installs now make use of GELIBOOT
In this configuration, a separate bootpool is not required.
This allows ZFS Boot Environments to be used with GELI encrypted ZFS pools.

Support for GPT+EFI+GELI is planned for the future.

Tested by: Joseph Mingrone, HardenedBSD
Relnotes:	yes
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D5869
2016-05-22 20:31:52 +00:00
Enji Cooper
e5e35a7715 Wrap EXPAND(..) macro with a do-while(0) loop and put a single statement on each line
As a positive side-effect, this eliminates the double semicolons reported by Coverity:
the macro contained a trailing semicolon, in addition to the semicolon placed on
each line where EXPAND(..) was called.

MFC after: 1 week
Reported by: Coverity
CID: 1194269
Sponsored by: EMC / Isilon Storage Division
2016-05-22 19:06:38 +00:00
Allan Jude
595568b58b Fix default ZFS layout to work better by default with sysutils/beadm
The root file system is mounted early via vfs.root.mountfrom.
The canmount=noauto property only affects the zfs rc.d script.
This ensures that the 'default' BE is not mounted overtop of another BE when
one is selected from the beastie menu

Sponsored by:	ScaleEngine Inc.
2016-05-22 16:24:21 +00:00
Baptiste Daroussin
5e38260c4f Fix typo in comments for the zfsboot script
Submitted by:	Colby Swandale <colby@taplaboratories.com.au> (via github)
2016-05-22 12:59:07 +00:00
Alan Somers
c5b5b50ded Better document security_show_{success,info,badconfig} in /etc/periodic.conf
periodic(8) already handles the security_show_{success,info,badconfig}
variables correctly. However, those variables aren't explicitly set in
/etc/defaults/periodic.conf or anywhere else, which suggests to the user
that they shouldn't be used.

etc/defaults/periodic.conf
	Explicitly set defaults for security_show_{success,info,badconfig}

usr.sbin/periodic/periodic.sh
	Update usage string

usr.sbin/periodic/periodic.8
	Minor man page updates

One thing I'm _not_ doing is recommending setting security_output to
/var/log/security.log or adding that file to /etc/newsyslog.conf, because
periodic(8) would create it with default permissions, usually 644, and
that's probably a bad idea.

Reviewed by:	brd
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6477
2016-05-21 02:14:11 +00:00
Kenneth D. Merry
d3683d27cf Adjust a couple of error cases in camdd(8).
usr.sbin/camdd/camdd.c:
	In camdd_probe_file(), fix an error case after fstat where
	we were bailing out and leaving two lines of cleanup code
	unexecuted.  Instead, just goto bailout_error.

	In camdd_probe_pass(), fail if the sector size is 0.

Sponsored by:	Spectra Logic
MFC after:	3 days
2016-05-19 19:13:43 +00:00
Edward Tomasz Napierala
b7af91d012 When iscsid(8) is running in ICL proxy mode, don't try to send Logout PDUs.
The kernel already does this for us when we ask it to terminate the session.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-19 14:59:21 +00:00
Edward Tomasz Napierala
78a89597fe Fix error message.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-19 14:45:34 +00:00
Kenneth D. Merry
9a6844d55f Add support for managing Shingled Magnetic Recording (SMR) drives.
This change includes support for SCSI SMR drives (which conform to the
Zoned Block Commands or ZBC spec) and ATA SMR drives (which conform to
the Zoned ATA Command Set or ZAC spec) behind SAS expanders.

This includes full management support through the GEOM BIO interface, and
through a new userland utility, zonectl(8), and through camcontrol(8).

This is now ready for filesystems to use to detect and manage zoned drives.
(There is no work in progress that I know of to use this for ZFS or UFS, if
anyone is interested, let me know and I may have some suggestions.)

Also, improve ATA command passthrough and dispatch support, both via ATA
and ATA passthrough over SCSI.

Also, add support to camcontrol(8) for the ATA Extended Power Conditions
feature set.  You can now manage ATA device power states, and set various
idle time thresholds for a drive to enter lower power states.

Note that this change cannot be MFCed in full, because it depends on
changes to the struct bio API that break compatilibity.  In order to
avoid breaking the stable API, only changes that don't touch or depend on
the struct bio changes can be merged.  For example, the camcontrol(8)
changes don't depend on the new bio API, but zonectl(8) and the probe
changes to the da(4) and ada(4) drivers do depend on it.

Also note that the SMR changes have not yet been tested with an actual
SCSI ZBC device, or a SCSI to ATA translation layer (SAT) that supports
ZBC to ZAC translation.  I have not yet gotten a suitable drive or SAT
layer, so any testing help would be appreciated.  These changes have been
tested with Seagate Host Aware SATA drives attached to both SAS and SATA
controllers.  Also, I do not have any SATA Host Managed devices, and I
suspect that it may take additional (hopefully minor) changes to support
them.

Thanks to Seagate for supplying the test hardware and answering questions.

sbin/camcontrol/Makefile:
	Add epc.c and zone.c.

sbin/camcontrol/camcontrol.8:
	Document the zone and epc subcommands.

sbin/camcontrol/camcontrol.c:
	Add the zone and epc subcommands.

	Add auxiliary register support to build_ata_cmd().  Make sure to
	set the CAM_ATAIO_NEEDRESULT, CAM_ATAIO_DMA, and CAM_ATAIO_FPDMA
	flags as appropriate for ATA commands.

	Add a new get_ata_status() function to parse ATA result from SCSI
	sense descriptors (for ATA passthrough over SCSI) and ATA I/O
	requests.

sbin/camcontrol/camcontrol.h:
	Update the build_ata_cmd() prototype

	Add get_ata_status(), zone(), and epc().

sbin/camcontrol/epc.c:
	Support for ATA Extended Power Conditions features.  This includes
	support for all features documented in the ACS-4 Revision 12
	specification from t13.org (dated February 18, 2016).

	The EPC feature set allows putting a drive into a power power mode
	immediately, or setting timeouts so that the drive will
	automatically enter progressively lower power states after various
	idle times.

sbin/camcontrol/fwdownload.c:
	Update the firmware download code for the new build_ata_cmd()
	arguments.

sbin/camcontrol/zone.c:
	Implement support for Shingled Magnetic Recording (SMR) drives
	via SCSI Zoned Block Commands (ZBC) and ATA Zoned Device ATA
	Command Set (ZAC).

	These specs were developed in concert, and are functionally
	identical.  The primary differences are due to SCSI and ATA
	differences.  (SCSI is big endian, ATA is little endian, for
	example.)

	This includes support for all commands defined in the ZBC and
	ZAC specs.

sys/cam/ata/ata_all.c:
	Decode a number of additional ATA command names in ata_op_string().

	Add a new CCB building function, ata_read_log().

	Add ata_zac_mgmt_in() and ata_zac_mgmt_out() CCB building
	functions.  These support both DMA and NCQ encapsulation.

sys/cam/ata/ata_all.h:
	Add prototypes for ata_read_log(), ata_zac_mgmt_out(), and
	ata_zac_mgmt_in().

sys/cam/ata/ata_da.c:
	Revamp the ada(4) driver to support zoned devices.

	Add four new probe states to gather information needed for zone
	support.

	Add a new adasetflags() function to avoid duplication of large
	blocks of flag setting between the async handler and register
	functions.

	Add new sysctl variables that describe zone support and paramters.

	Add support for the new BIO_ZONE bio, and all of its subcommands:
	DISK_ZONE_OPEN, DISK_ZONE_CLOSE, DISK_ZONE_FINISH, DISK_ZONE_RWP,
	DISK_ZONE_REPORT_ZONES, and DISK_ZONE_GET_PARAMS.

sys/cam/scsi/scsi_all.c:
	Add command descriptions for the ZBC IN/OUT commands.

	Add descriptions for ZBC Host Managed devices.

	Add a new function, scsi_ata_pass() to do ATA passthrough over
	SCSI.  This will eventually replace scsi_ata_pass_16() -- it
	can create the 12, 16, and 32-byte variants of the ATA
	PASS-THROUGH command, and supports setting all of the
	registers defined as of SAT-4, Revision 5 (March 11, 2016).

	Change scsi_ata_identify() to use scsi_ata_pass() instead of
	scsi_ata_pass_16().

	Add a new scsi_ata_read_log() function to facilitate reading
	ATA logs via SCSI.

sys/cam/scsi/scsi_all.h:
	Add the new ATA PASS-THROUGH(32) command CDB.  Add extended and
	variable CDB opcodes.

	Add Zoned Block Device Characteristics VPD page.

	Add ATA Return SCSI sense descriptor.

	Add prototypes for scsi_ata_read_log() and scsi_ata_pass().

sys/cam/scsi/scsi_da.c:
	Revamp the da(4) driver to support zoned devices.

	Add five new probe states, four of which are needed for ATA
	devices.

	Add five new sysctl variables that describe zone support and
	parameters.

	The da(4) driver supports SCSI ZBC devices, as well as ATA ZAC
	devices when they are attached via a SCSI to ATA Translation (SAT)
	layer.  Since ZBC -> ZAC translation is a new feature in the T10
	SAT-4 spec, most SATA drives will be supported via ATA commands
	sent via the SCSI ATA PASS-THROUGH command.  The da(4) driver will
	prefer the ZBC interface, if it is available, for performance
	reasons, but will use the ATA PASS-THROUGH interface to the ZAC
	command set if the SAT layer doesn't support translation yet.
	As I mentioned above, ZBC command support is untested.

	Add support for the new BIO_ZONE bio, and all of its subcommands:
	DISK_ZONE_OPEN, DISK_ZONE_CLOSE, DISK_ZONE_FINISH, DISK_ZONE_RWP,
	DISK_ZONE_REPORT_ZONES, and DISK_ZONE_GET_PARAMS.

	Add scsi_zbc_in() and scsi_zbc_out() CCB building functions.

	Add scsi_ata_zac_mgmt_out() and scsi_ata_zac_mgmt_in() CCB/CDB
	building functions.  Note that these have return values, unlike
	almost all other CCB building functions in CAM.  The reason is
	that they can fail, depending upon the particular combination
	of input parameters.  The primary failure case is if the user
	wants NCQ, but fails to specify additional CDB storage.  NCQ
	requires using the 32-byte version of the SCSI ATA PASS-THROUGH
	command, and the current CAM CDB size is 16 bytes.

sys/cam/scsi/scsi_da.h:
	Add ZBC IN and ZBC OUT CDBs and opcodes.

	Add SCSI Report Zones data structures.

	Add scsi_zbc_in(), scsi_zbc_out(), scsi_ata_zac_mgmt_out(), and
	scsi_ata_zac_mgmt_in() prototypes.

sys/dev/ahci/ahci.c:
	Fix SEND / RECEIVE FPDMA QUEUED in the ahci(4) driver.

	ahci_setup_fis() previously set the top bits of the sector count
	register in the FIS to 0 for FPDMA commands.  This is okay for
	read and write, because the PRIO field is in the only thing in
	those bits, and we don't implement that further up the stack.

	But, for SEND and RECEIVE FPDMA QUEUED, the subcommand is in that
	byte, so it needs to be transmitted to the drive.

	In ahci_setup_fis(), always set the the top 8 bits of the
	sector count register.  We need it in both the standard
	and NCQ / FPDMA cases.

sys/geom/eli/g_eli.c:
	Pass BIO_ZONE commands through the GELI class.

sys/geom/geom.h:
	Add g_io_zonecmd() prototype.

sys/geom/geom_dev.c:
	Add new DIOCZONECMD ioctl, which allows sending zone commands to
	disks.

sys/geom/geom_disk.c:
	Add support for BIO_ZONE commands.

sys/geom/geom_disk.h:
	Add a new flag, DISKFLAG_CANZONE, that indicates that a given
	GEOM disk client can handle BIO_ZONE commands.

sys/geom/geom_io.c:
	Add a new function, g_io_zonecmd(), that handles execution of
	BIO_ZONE commands.

	Add permissions check for BIO_ZONE commands.

	Add command decoding for BIO_ZONE commands.

sys/geom/geom_subr.c:
	Add DDB command decoding for BIO_ZONE commands.

sys/kern/subr_devstat.c:
	Record statistics for REPORT ZONES commands.  Note that the
	number of bytes transferred for REPORT ZONES won't quite match
	what is received from the harware.  This is because we're
	necessarily counting bytes coming from the da(4) / ada(4) drivers,
	which are using the disk_zone.h interface to communicate up
	the stack.  The structure sizes it uses are slightly different
	than the SCSI and ATA structure sizes.

sys/sys/ata.h:
	Add many bit and structure definitions for ZAC, NCQ, and EPC
	command support.

sys/sys/bio.h:
	Convert the bio_cmd field to a straight enumeration.  This will
	yield more space for additional commands in the future.  After
	change r297955 and other related changes, this is now possible.
	Converting to an enumeration will also prevent use as a bitmask
	in the future.

sys/sys/disk.h:
	Define the DIOCZONECMD ioctl.

sys/sys/disk_zone.h:
	Add a new API for managing zoned disks.  This is very close to
	the SCSI ZBC and ATA ZAC standards, but uses integers in native
	byte order instead of big endian (SCSI) or little endian (ATA)
	byte arrays.

	This is intended to offer to the complete feature set of the ZBC
	and ZAC disk management without requiring the application developer
	to include SCSI or ATA headers.  We also use one set of headers
	for ioctl consumers and kernel bio-level consumers.

sys/sys/param.h:
	Bump __FreeBSD_version for sys/bio.h command changes, and inclusion
	of SMR support.

usr.sbin/Makefile:
	Add the zonectl utility.

usr.sbin/diskinfo/diskinfo.c
	Add disk zoning capability to the 'diskinfo -v' output.

usr.sbin/zonectl/Makefile:
	Add zonectl makefile.

usr.sbin/zonectl/zonectl.8
	zonectl(8) man page.

usr.sbin/zonectl/zonectl.c
	The zonectl(8) utility.  This allows managing SCSI or ATA zoned
	disks via the disk_zone.h API.  You can report zones, reset write
	pointers, get parameters, etc.

Sponsored by:	Spectra Logic
Differential Revision:	https://reviews.freebsd.org/D6147
Reviewed by:	wblock (documentation)
2016-05-19 14:08:36 +00:00
Simon J. Gerraty
1c8bdd84b8 Initialize date of rootNode.
Reviewed by:	jtl
2016-05-18 22:24:52 +00:00
Gleb Smirnoff
9aa8749970 Revert r299830, it has couple of fatal errors.
The CMSG_ family of macros take care of alignment, so we don't need r299830
at all, even if it was correct.  Put NO_WCAST_ALIGN into Makefile.

Together with:	peter
2016-05-18 22:02:19 +00:00
Pedro F. Giffuni
00b8e9fe52 makefs(8): Clarify the comment concerning seeding.
Avoid giving the impression makefs currently supports reproduceable
builds.
2016-05-18 00:22:52 +00:00
Pedro F. Giffuni
40d39b4bf5 makefs(1): use all the random(3) range.
The generation number is uint32_t so we can fit the complete range
of random(3). We could have used arc4random() but the result would
be unpredictable and it would prohibit reproducible builds.

While here add a comment where seeding is done: this affects
reproducible builds and might have to be re-visited to use a
release dependent value.

MFC after:	2 weeks
2016-05-17 18:20:33 +00:00
Pedro F. Giffuni
9f36c1fa71 makefs(8): use NULL instead of zero for pointers. 2016-05-17 16:58:39 +00:00
Eitan Adler
cef367e6a1 Don't repeat the the word 'the'
(one manual change to fix grammar)

Confirmed With: db
Approved by: secteam (not really, but this is a comment typo fix)
2016-05-17 12:52:31 +00:00
Edward Tomasz Napierala
5abae79af4 Add initial support for negotiating iSER parameters to iscsid(8). Some
rework might be needed to support asymetrical limits, but this should be
ok for now.

Obtained from:	Mellanox Technologies (earlier version)
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-17 07:54:53 +00:00
Don Lewis
78db15ccf7 When clearing rtmsg, pass &rtmsg to bzero() instead of the address of
just the header

Reported by:	Coverity
CID:		1007568, 1194256
MFC after:	1 week
2016-05-17 04:03:45 +00:00
Don Lewis
647bedd5da Don't walk off the end of the array when proto isn't explicitly
listed above.  Instead update the catch-all "Others" bucket.

Reported by:	Coverity
CID:		1007571, 1007572
MFC after:	1 week
2016-05-16 23:47:08 +00:00
Don Lewis
010e93758f Set ai2 to NULL in in find_host() before the loop and after calling
freeaddrinfo() on it to indicate that it doesn't point to a valid
addrinfo list.  This fixes this Coverity issues:
	1006368 Uninitialized pointer read
	1018506 Double free
	1305590 Resource leak
that can be triggered in the hp->hostname[0] != '\0' case.

Don't treat a character as a boolean.

Fix these Coverity issues:
	1009293 Unchecked return value from library
	1194246 Wrong size argument
by tweaking the status file extend code.

Reported by:	Coverity
CID:		1006368, 1018506, 1305590, 1009293, 1194246
Reviewed by:	rmacklem
Feedback from:	hrs
MFC after:	1 week
Differential Revision:	D6398
2016-05-16 23:29:04 +00:00
Don Lewis
b6ecea3082 Actually use the loop interation limit so carefully computed on the
previous line to prevent buffer overflow.  This turns out to not be
important because the upstream xdr code already capped the object
size at the proper value.  Using the correct limit here looks a lot
less scary and should please Coverity.

Reported by:	Coverity
CID:		1199309, 1199310
MFC after:	1 week
2016-05-16 23:00:48 +00:00
Don Lewis
e29182f6c0 Fix an off by one error to avoid overflowing rp[].
Reported by:	Coverity
CID:		1007579
2016-05-16 16:16:46 +00:00
Don Lewis
cec77ff4bf NULL releasedfl after calling deallocate_file_lock() which frees it
to avoid a use-after-free error in the debuglog() call at the top
of the loop.

Reported by:	Coverity
CID:		1006080
MFC after:	1 week
2016-05-16 05:17:43 +00:00
Don Lewis
ec77f107fa pdu_delete(request) frees request, so move the call after
login_new_response(request) to avoid a use-after-free error

Reported by:	Coverity
Reviewed by:	1331219, 1331220
2016-05-16 04:43:47 +00:00
Don Lewis
8f2c79ef85 Don't free fnamebuf before we calling cfgfile_add(). This changes a
use-after-free error into a minor memory leak.

Reported by:	Coverity
CID:		1006084
2016-05-16 04:39:16 +00:00
Marcelo Araujo
eed7cf8d2d Simplify overengineered and buggy code that looked like as if it did
some kind of UTF-8 validation, but actually didn't, but instead, for
malformed UTF-8 input, caused buffer overruns in some cases and caused
skipping of valid ASCII characters in other cases.

Obtained from:	OpenBSD (cvs 1.32)
2016-05-16 02:44:22 +00:00
Marcelo Araujo
152e878f4c When a group contains a non-existent user, make the warning
message more helpful by mentioning the group name.

Obtained from:	OpenBSD (cvs 1.19)
2016-05-16 02:35:23 +00:00
Marcelo Araujo
1dcace5ba0 Use NULL instead of 0 for pointers.
MFC after:	2 weeks.
2016-05-16 01:12:56 +00:00
Don Lewis
b0882deadb Use strlcpy() instead of strncpy() when copying ifname to ensure
that it is NUL terminated.  Additional NUL padding is not required
for short names.

Reported by:	Coverity
CID:		1009974
MFC after:	1 week
2016-05-15 22:31:03 +00:00
Don Lewis
dc47112fa5 Use strlcpy() instead of strncpy() when copying ifname to ensure
that it is NUL terminated.  Additional NUL padding is not required
for short names.

Reported by:	Coverity
CID:		99186, 991864, 991865
MFC after:	1 week
2016-05-15 22:17:41 +00:00
Don Lewis
8afa1c3d7a Use strlcpy() instead of strncpy() when copying ifname to ensure
that it is NUL terminated.  Additional NUL padding is not required
for short names.

MFC after:	1 week
2016-05-15 22:06:21 +00:00
Don Lewis
7b06334915 Use strlcpy() instead of strncpy() when copying ifname to ensure
that it is NUL terminated.  Additional NUL padding is not required
for short names.

Reported by:	Coverity
CID:		974852
MFC after:	1 week
2016-05-15 21:45:04 +00:00
Enji Cooper
471761b8bb Remove NO_WERROR and add WARNS?= 6
This now compiles cleanly on all architectures

MFC after: 1 month
Tested with: clang 3.8, gcc 4.2.1, gcc 4.5, make tinderbox
Sponsored by: EMC / Isilon Storage Division
2016-05-15 03:38:40 +00:00
Enji Cooper
99ca491ca6 Remove NO_WERROR.clang from this Makefile
This compiles with clang without warnings

MFC after: 1 month
Sponsored by: EMC / Isilon Storage Division
2016-05-15 00:42:18 +00:00
Enji Cooper
6047e12ca5 Replace malloc + memset(.., 0, ..) with calloc calls
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-05-15 00:40:05 +00:00
Enji Cooper
27c7c23864 Use strdup instead of malloc + strlcpy
Fix error messages on failure for calloc/strdup

MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
2016-05-15 00:25:36 +00:00
Enji Cooper
229bb4daa1 Correct function names that failed in error messages
It should be calloc/strdup, not malloc

MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
2016-05-15 00:24:21 +00:00
Enji Cooper
d208c8fa3f Replace QUADFMT with %ju and QUADXFMT with %jx and cast values with uintmax_t
This will cure some -Wformat warnings

MFC after: 1 week
Reported by: clang, gcc
Sponsored by: EMC / Isilon Storage Division
2016-05-15 00:10:37 +00:00
Enji Cooper
70e366f272 Bump WARNS to 6
MFC after: 1 month
Sponsored by: EMC / Isilon Storage Division
2016-05-15 00:08:09 +00:00
Enji Cooper
92f7f8fb62 Fix up r299769
Similar to r299802, it was noted that using nitems on scalar pointers is
invalid.

Use strdup instead of malloc + strlcpy (which is what the old code was doing
anyhow).

MFC after: 1 week
Pointyhat to: ngie
Sponsored by: EMC / Isilon Storage Division
2016-05-15 00:05:28 +00:00
Enji Cooper
4e312050f0 Replace malloc + memset(.., 0, ..) with calloc calls
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-05-15 00:02:55 +00:00
Enji Cooper
2501437203 Fix up both r299764 and r299770
nitems was wrong too, as it was being tested against a pointer instead of a buffer on
the stack.

Since the old code was just doing malloc, then strlcpy'ing the contents of the source
buffer into the destination buffer, replace it all with a call to strdup..

Reported by: bde
MFC after: 1 week
X-MFC with: r299764, r299770
Supersized Duncecap to: ngie
Sponsored by: EMC / Isilon Storage Division
2016-05-15 00:01:23 +00:00
Enji Cooper
4a2b63d5bb Convert tok from enum tok to int32_t in function calls
get_token(..) returns int32_t, not enum tok, and in many cases tests for items
not in enum tok (e.g. '('). Make the typing consistent with get_token, which
includes a domino effect of changing enum tok to int32_t.

MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division
2016-05-14 23:29:41 +00:00
Enji Cooper
5413861b16 Use a consistent errno save/restore pattern before running strtoul
- Save errno
- Set errno to 0
- Call strtoul
- Test errno (optional, but many calls to strtoul did this afterwards)

Some of the code was setting errno = 0 after calling strtoul, not setting
errno = 0, or setting errno to saved_errno after the call, but before the
test. These all have unwanted behavioral side-effects, depending on the
initial value of errno and whether or not the input to strtoul was correct
or incorrect.

MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
2016-05-14 23:22:38 +00:00
Enji Cooper
2c0046434b Do minimal work necessary to cure a -Wunused-but-set-variable warning from gcc
How errno is saved before and restored after strtoul calls needs a rethink

MFC after: 1 week
Reported by: gcc 5.x
Sponsored by: EMC / Isilon Storage Division
2016-05-14 23:13:23 +00:00
Enji Cooper
54811dda50 Fix up r299764
I meant to use nitems, not sizeof(..) with the destination buffer. Using sizeof(..)
on a pointer will always truncate the output in the destination buffer incorrectly

Pointyhat to: ngie
MFC after: 1 week
X-MFC with: r299764
Sponsored by: EMC / Isilon Storage Division
2016-05-14 22:43:07 +00:00
Enji Cooper
896f12fec1 Use the size of the destination buffer instead of the malloc size, repeated, in order
to mute a -Wstrlcpy-strlcat-size warning

MFC after: 1 week
Reported by: clang
Sponsored by: EMC / Isilon Storage Division
2016-05-14 22:40:35 +00:00
Enji Cooper
19ffd5ecda Mute sign compare warning by casting rc to u_int to match nbindings' type
rc cannot be negative -- that was already tested for earlier on in
the function

MFC after: 1 week
Reported by: clang, gcc
Sponsored by: EMC / Isilon Storage Division
2016-05-14 22:29:11 +00:00
Enji Cooper
715e3b39a6 Fix logically dead code pointed out by clang/Coverity
parse_context, parse_user_security: test for validity of results from
parse_ascii(..) with by casting to int32_t and comparing to -1; comparing
unsigned types to negative values will always be false.

Reported by: clang, Coverity
CID: 1011432, 1011433
MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
2016-05-14 22:04:44 +00:00
Enji Cooper
81910adfc4 Fix theoretical buffer overflow issues in snmp_oid2asn_oid
Increase the size of `string` by 1 to account for the '\0' terminator. In the event
that `str` doesn't contain any non-alpha chars, i would be set to MAXSTR, and
the subsequent strlcpy call would overflow by a character.

Remove unnecessary `string[i] = '\0'` -- this is already handled by strlcpy.

MFC after: 1 week
Reported by: clang
Sponsored by: EMC / Isilon Storage Division
2016-05-14 21:32:52 +00:00
Enji Cooper
78a780e3e5 Use the size of the destination buffer, not the source buffer.
Technically this is a no-op, but mute the clang warning in case the malloc call
above for fstring ever changes in the future

Reported by: clang
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-05-14 21:27:33 +00:00
Enji Cooper
6e229b2973 Mute -Wstrlcpy-strlcat-size warning by using nitems with the size of the buffer
This is a no-op as the malloc above set the size of the buffer to the size used
below, but this keeps things consistent in case the malloc call changes somehow.

MFC after: 1 week
Reported by: clang
Sponsored by: EMC / Isilon Storage Division
2016-05-14 20:58:34 +00:00
Enji Cooper
444991f1e6 Mark snmptoolctx unused in parse_authentication(..), parse_privacy(..),
parse_context(..), and parse_user_security(..).

MFC after: 1 week
Reported by: clang, gcc
Sponsored by: EMC / Isilon Storage Division
2016-05-14 20:33:42 +00:00
Enji Cooper
4a8c12cd34 parse_ascii: make count size_t to mute a -Wsign-compare issue
count is always unsigned.

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-05-14 20:31:12 +00:00
Enji Cooper
9a3ebeefc0 Sort variables in parse_ascii(..) per style(9)
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-05-14 20:28:23 +00:00
Enji Cooper
031987d916 Use calloc instead of memset(.., 0, ..) + malloc
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-05-14 20:25:14 +00:00
Pedro F. Giffuni
c8aa42a2da Undo the bogus gethostname() change from r299709.
The "- 1" is there specifically to enable checking for NUL termination.

I should also admit the rest change was mostly cosmetic and the
overruns can't occur in practice: still I leave them to pacify
static analyzers.

Pointed out by:	bde
2016-05-14 04:29:13 +00:00
Enji Cooper
0150b85a1c Fix some trivial clang/gcc warnings in bsnmptc.c
- By definition, `enum snmp_tc` can't be false (the implied starting sequence
  index for the enum is 0). Don't test for it being < 0.
- Staticize `struct snmp_text_conv` to mute a -Wmissing-variable-declarations
  warning from clang.
- Remove set but unused variable, ptr, in parse_bridge_id(..) and
  parse_bport_id(..) to mute warning from gcc 4.9+.
- Mark value and string unused in snmp_inetaddr2oct(..) and parse_inetaddr(..)
  as they're just stub functions.

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2016-05-14 04:13:28 +00:00
Enji Cooper
66987347e9 Fold two malloc + memset(.., 0, ..) calls into equivalent calloc calls
MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
2016-05-14 04:00:17 +00:00
Enji Cooper
29517fca53 Staticize global variables only used in bsnmpimport.c to fix
-Wmissing-variable-declarations warnings

MFC after: 3 weeks
Reported by: clang
Sponsored by: EMC / Isilon Storage Division
2016-05-14 03:57:18 +00:00
Pedro F. Giffuni
cbc796fb90 timed(8): Use strlcpy() for bounds checking.
Prevent some theorical buffer overruns reported by Coverity.
Cleanup a use of gethostname() while here.

CID:	1006713, 1011166, 1011167, 1011168,
2016-05-14 02:42:09 +00:00
Pedro F. Giffuni
555470a31d timed(8): Use stronger random number generator.
Using arc4random simplifies the code by not having to worry about
seeds which ironically depend on the time.

CID:	1300004
2016-05-14 01:12:23 +00:00
Pedro F. Giffuni
7ffbd1b5b0 timed(8): use NULL instead of zero for pointers. 2016-05-14 00:46:38 +00:00
Enji Cooper
836229c3cf Move _bsnmptools_debug extern from bsnmpmap.c to bsnmptools.h
It was used in bsnmpmap.c but was stored in bsnmptools.c; moving the extern
to the header allows us to cover all of our bases for the variable, and allows
_bsnmptools_debug to be used in the future elsewhere -- not just bsnmpmap.c.

MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
2016-05-13 21:26:12 +00:00
Don Lewis
fe579263e0 Another attempt at resolving CID 1305629. The test of cmd == -1
may make Coverity think that other negative values of cmd (used
as an index) are possible.  Testing < 0 is a more common idiom
in any case.

Reported by:	Coverity
CID:		1305629
2016-05-13 17:48:04 +00:00
Pedro F. Giffuni
48235fe344 i2c(8): uninitialized variable (UNINIT).
If i2c_opt.width is somehow zero, buf will be left uninitialized and may
cause trouble later on. This is a followup to r299586.

CID:	1331548
2016-05-13 15:57:55 +00:00
Pedro F. Giffuni
9f3dba686c bhyve: consider the bogus case of a negative bar idx.
This is a followup to r297472 to squelch Coverity.

CID:	1194319
2016-05-13 14:59:02 +00:00
Pedro F. Giffuni
40dbeed32b bhyve: replace uninitialized variable "offset".
Use io->io_req.br_offset instead.

Suggested by:	grehan
CID:		1288937
2016-05-13 14:38:04 +00:00
Don Lewis
7a7c07ef51 Properly compute the size argument to pass to malloc().
Reported by:	Coverity
CID:		1198856
MFC after:	1 week
2016-05-13 06:45:16 +00:00
Don Lewis
ae092f753a Move a call to cam_freeccb() to avoid a use after free error and
a later double free.

Reported by:	Coverity
CID:		1018507
MFC after:	1 week
2016-05-13 06:26:42 +00:00
Don Lewis
aa60f7a6de Revert r299584:
Mark usage() as __dead2 so that Coverity doesn't think that execution
  continues after the call and uses a negative array subscript.

Requested by:	bde
2016-05-13 05:39:29 +00:00
Pedro F. Giffuni
b1f46f712f i2c(8): uninitialized variable (UNINIT).
If i2c_opt.width is somehow zero, the bufsize will be left uninitialized
and make cause trouble later on.

CID:		1331549
2016-05-13 02:58:11 +00:00
Don Lewis
e402dde82d Mark usage() as __dead2 so that Coverity doesn't think that execution
continues after the call and uses a negative array subscript.

Reported by:	Coverity
CID:		1305629
2016-05-13 01:14:38 +00:00
Don Lewis
a5f637460b Avoid indexing an array with a negative value.
Reported by:	Coverity
CID:		971121
2016-05-13 00:58:05 +00:00
Don Lewis
5d29410d37 Use strlcpy() instead of strncpy() to ensure that ret->name is
NUL terminated.  The source and destination buffers are the same
size and the source *should* be NUL terminated, but be paranoid.

Reported by:	Coverity
CID:		1011274
MFC after:	1 week
2016-05-13 00:17:57 +00:00
Don Lewis
3b7e0c53d5 Use strlcpy() instead of strncpy() to ensure that qup->fsname is NUL
terminated.  Don't bother checking for truncation since the subsequent
quota_read() should detect that and fail.

Reported by:	Coverity
CID:		1009980
MFC after:	1 week
2016-05-13 00:02:03 +00:00
Don Lewis
90abdc2dd7 Use strlcpy() instead of strncpy() when copying to dom_domain to
ensure that the latter is NUL terminated since it is passed
as an argument to *printf().

Warn about NIS domains that are too long.

Reported by:	Coverity
CID:		1009620, 1009621
MFH:		1 week
2016-05-12 21:35:40 +00:00
Conrad Meyer
a09a9cbb40 rtadvd(8): Fix use-after-close in cm_handler_client
cm_send() closes 'fd' on error.  In that case, bail out early without trying to
recv from or close 'fd' again.

Reported by:	Coverity
CID:		1006078
Sponsored by:	EMC / Isilon Storage Division
2016-05-12 05:12:24 +00:00
Conrad Meyer
5c4eb89746 rtadvd(8): Don't use-after-free
This whole block of code as committed fully formed in r224144.  I'm not really
sure what the intent was, but it seems plausible that !persist ifis could need
other member cleanup.  Don't free the object until after we've finished
cleaning its members.

Reported by:	Coverity
CID:		1006079
Sponsored by:	EMC / Isilon Storage Division
2016-05-12 04:54:32 +00:00
Conrad Meyer
96aec9a5e9 rtadvd(8): Fix a typo in full msg receive logic
Check against the size of the struct, not the pointer.  Previously, a message
with a cm_len between 9 and 23 (inclusive) could cause int msglen to underflow
and read(2) to be invoked with msglen size (implicitly cast to signed),
overrunning the caller-provided buffer.

All users of cm_recv() supply a stack buffer.

On the other hand, the rtadvd control socket appears to only be writable by the
owner, who is probably root.

While here, correct some types to be size_t or ssize_t.

Reported by:	Coverity
CID:		1008477
Security:	unix socket remotes may overflow stack in rtadvd
Sponsored by:	EMC / Isilon Storage Division
2016-05-12 03:37:17 +00:00
Pedro F. Giffuni
ac97203f5b traceroute6(8): use NULL instead of zero for initializing a pointer. 2016-05-12 02:05:50 +00:00
Conrad Meyer
134fd583cb route6d(8): Fix potential double-free
In the case that the subsequent sysctl(3) call failed, 'buf' could be free(3)ed
repeatedly.  It isn't clear to me that that case is possible, but be clear and
do the right thing in case it is.

Reported by:	Coverity
CID:		272537
Sponsored by:	EMC / Isilon Storage Division
2016-05-11 22:33:20 +00:00
Conrad Meyer
02dc4f1751 mixer(8): Style: Tag no-return usage() as __dead2
Coverity really should have figured this out from the exit(3) call at the end
of the routine, but just make it explicit.

No functional change.

Reported by:	Coverity
CID:		1304866 (false positive double-close of 'baz')
Sponsored by:	EMC / Isilon Storage Division
2016-05-11 17:27:27 +00:00
Conrad Meyer
16f6b6f174 ffs_bswap: Copy one UFS dinode member at a time
No functional change.

Reported by:	Coverity
CIDs:		974635, 974636, 977396, 977397, 977398, 977399
Sponsored by:	EMC / Isilon Storage Division
2016-05-11 16:42:13 +00:00
Allan Jude
06445fc0fa bsdinstall/zfsboot: Do not mirror swap when swapsize is 0
PR:		209415
Submitted by:	Ganael LAPLANCHE <ganael.laplanche@corp.ovh.com>
MFC after:	2 weeks
2016-05-10 14:38:43 +00:00
Baptiste Daroussin
79477f3ca1 Directly set the NONBLOCK flags when creating the socket
No functional changes
2016-05-10 11:18:53 +00:00
Baptiste Daroussin
a9c48188b8 Rename getline with get_line to avoid collision with getline(3)
When getline(3) in 2009 was added a _WITH_GETLINE guard has also been added.
This rename is made in preparation for the removal of this guard
2016-05-10 11:17:19 +00:00
Baptiste Daroussin
f03ef8405b Rename getline with get_line to avoid collision with getline(3)
When getline(3) in 2009 was added a _WITH_GETLINE guard has also been added.
This rename is made in preparation for the removal of this guard
2016-05-10 11:12:31 +00:00
Baptiste Daroussin
8c98e6b1a7 Replace fparseln(3) with getline(3) to remove dependency on libutil 2016-05-09 20:04:22 +00:00
Enji Cooper
430f7286a5 Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed
after r298107

Summary of changes:

- Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that
  namespacing is kept with FILES appropriately, and that this shouldn't need
  to be repeated if the namespace changes -- only the definition of PACKAGE
  needs to be changed
- Allow PACKAGE to be overridden by callers instead of forcing it to always be
  `tests`. In the event we get to the point where things can be split up
  enough in the base system, it would make more sense to group the tests
  with the blocks they're a part of, e.g. byacc with byacc-tests, etc
- Remove PACKAGE definitions where possible, i.e. where FILES wasn't used
  previously.
- Remove unnecessary TESTSPACKAGE definitions; this has been elided into
  bsd.tests.mk
- Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES;
  ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk.
- Fix installation of files under data/ subdirectories in lib/libc/tests/hash
  and lib/libc/tests/net/getaddrinfo
- Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup)

Document the proposed changes in share/examples/tests/tests/... via examples
so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of
replacing FILES. share/mk/bsd.README didn't seem like the appropriate method
of communicating that info.

MFC after: never probably
X-MFC with: r298107
PR: 209114
Relnotes: yes
Tested with: buildworld, installworld, checkworld; buildworld, packageworld
Sponsored by: EMC / Isilon Storage Division
2016-05-04 23:20:53 +00:00
Alan Somers
8907f744ff Improve performance and functionality of the bitstring(3) api
Two new functions are provided, bit_ffs_at() and bit_ffc_at(), which allow
for efficient searching of set or cleared bits starting from any bit offset
within the bit string.

Performance is improved by operating on longs instead of bytes and using
ffsl() for searches within a long. ffsl() is a compiler builtin in both
clang and gcc for most architectures, converting what was a brute force
while loop search into a couple of instructions.

All of the bitstring(3) API continues to be contained in the header file.
Some of the functions are large enough that perhaps they should be uninlined
and moved to a library, but that is beyond the scope of this commit.

sys/sys/bitstring.h:
        Convert the majority of the existing bit string implementation from
        macros to inline functions.

        Properly protect the implementation from inadvertant macro expansion
        when included in a user's program by prefixing all private
        macros/functions and local variables with '_'.

        Add bit_ffs_at() and bit_ffc_at(). Implement bit_ffs() and
        bit_ffc() in terms of their "at" counterparts.

        Provide a kernel implementation of bit_alloc(), making the full API
        usable in the kernel.

        Improve code documenation.

share/man/man3/bitstring.3:
        Add pre-exisiting API bit_ffc() to the synopsis.

        Document new APIs.

        Document the initialization state of the bit strings
        allocated/declared by bit_alloc() and bit_decl().

        Correct documentation for bitstr_size(). The original code comments
        indicate the size is in bytes, not "elements of bitstr_t". The new
        implementation follows this lead. Only hastd assumed "elements"
        rather than bytes and it has been corrected.

etc/mtree/BSD.tests.dist:
tests/sys/Makefile:
tests/sys/sys/Makefile:
tests/sys/sys/bitstring.c:
        Add tests for all existing and new functionality.

include/bitstring.h
	Include all headers needed by sys/bitstring.h

lib/libbluetooth/bluetooth.h:
usr.sbin/bluetooth/hccontrol/le.c:
        Include bitstring.h instead of sys/bitstring.h.

sbin/hastd/activemap.c:
        Correct usage of bitstr_size().

sys/dev/xen/blkback/blkback.c
        Use new bit_alloc.

sys/kern/subr_unit.c:
        Remove hard-coded assumption that sizeof(bitstr_t) is 1.  Get rid of
        unrb.busy, which caches the number of bits set in unrb.map.  When
        INVARIANTS are disabled, nothing needs to know that information.
        callapse_unr can be adapted to use bit_ffs and bit_ffc instead.
        Eliminating unrb.busy saves memory, simplifies the code, and
        provides a slight speedup when INVARIANTS are disabled.

sys/net/flowtable.c:
        Use the new kernel implementation of bit-alloc, instead of hacking
        the old libc-dependent macro.

sys/sys/param.h
        Update __FreeBSD_version to indicate availability of new API

Submitted by:   gibbs, asomers
Reviewed by:    gibbs, ngie
MFC after:      4 weeks
Sponsored by:   Spectra Logic Corp
Differential Revision:  https://reviews.freebsd.org/D6004
2016-05-04 22:34:11 +00:00
Alan Somers
79e29f957a Fix "getextattr -x" with non-ascii attribute values
extattr/rmextattr.c
	When printing hex output, treat all attribute values as unsigned
	char arrays instead of sign extending them to 32 bit values.

extattr/tests/extattr_test.sh
	Add a regression test

PR:		209039
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
2016-05-04 21:07:30 +00:00
Alan Somers
c29930cfd6 Allow setextattr(8) to take attribute values from stdin
Add the -i option to setextattr. This option allow extended attribute data
to be provided via stdin. Add a -qq option to getextattr, which omits the
trailing newline. Together these options can be used to work with extended
attributes whose values are large and/or binary.

usr.sbin/extattr/Makefile:
	Link against libsbuf which is used for processing stdin data.

usr.sbin/extattr/rmextattr.8:
	Document setextattr's -i option, getextattr's -qq option, and remove
	the BUG about setextattr only being useful for strings.

usr.sbin/extattr/rmextattr.c:
	For setextattr operations, buffer attribute data in an sbuf. If -i
	is specified, pull the data from stdin, otherwise from the
	appropriate argurment.

	Update usage text and argument validation code for setextattr's -i
	option.

usr.sbin/extattr/tests/extattr_test.sh
	Add tests for -q and -i.

Reviewed by:	wblock (manpage)
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6090
2016-05-04 20:20:55 +00:00
Pedro F. Giffuni
989531dc9f pmcstudy.8: minor "efficiency" fix.
No functional change.
2016-05-03 22:20:55 +00:00
Andriy Voskoboinyk
6d8e01b078 bsdinstall: fix static address assignment for protected wireless networks.
Filter out IFCONFIG_PREFIX variable (which may contain WPA keyword)
from ifconfig parameters.

PR:		169199
2016-05-02 21:40:34 +00:00
Pedro F. Giffuni
e9fc928faa rpcbind: use our roundup() macro when available through <sys/param.h>.
No functional change.
2016-05-02 02:15:05 +00:00
Pedro F. Giffuni
6e560add61 quot: make use of our rounddown() macro when <sys/param.h> is available.
No functional change.
2016-05-02 02:13:22 +00:00
Marcelo Araujo
a175f065d9 Use MIN macro from sys/param.h.
MFC after:	2 weeks.
2016-05-02 01:49:42 +00:00
Marcelo Araujo
a8945bbf62 Use MIN/MAX macros from sys/param.h.
MFC after:	2 weeks.
2016-05-02 01:47:13 +00:00
Marcelo Araujo
eff97b5e63 Use MIN macro from sys/param.h.
MFC after:	2 weeks.
2016-05-02 01:45:52 +00:00
Marcelo Araujo
a1b422f4d6 Use MAX macro from sys/param.h.
MFC after:	2 weeks.
2016-05-02 01:43:22 +00:00
Jamie Gritton
a8702c8383 typo
Submitted by:	Jimmy Olgeni
2016-05-01 16:48:03 +00:00
Pedro F. Giffuni
b5635ba0a2 usr.sbin: minor spelling fixes on comments.
No functional change.
2016-05-01 16:41:25 +00:00
Pedro F. Giffuni
d7b1cc0a3c pmcstat: minor spelling fixes.
Mostly comments bur also a user-visible string.

MFC after:	2 weeks
2016-05-01 16:40:56 +00:00