Commit Graph

16685 Commits

Author SHA1 Message Date
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
Pedro F. Giffuni
ec65e4f8d0 usr.sbin/bsdconfig: minor spelling fixes on comments.
No functional change.
2016-05-01 16:38:12 +00:00
Pedro F. Giffuni
beb45c4fd4 bluetooth: minor spelling fixes.
User-visible strings.

MFC after:	2 weeks
2016-05-01 16:36:14 +00:00
Jamie Gritton
ab9604e1bb Clarify when happens when there is a "depend" parameter in jail.conf,
and how this affects the "jail_list" option in rc.conf.
2016-04-30 21:27:41 +00:00
Glen Barber
49dae58b28 Fix including Kyuafile in packaged base system.
Fix a related typo while here.

Note, this change results in the Kyuafile inclusion in the runtime
package, which needs to be fixed, however addresses the PR as far
as I can tell in my tests.

PR:		209114
Submitted by:	ngie
Sponsored by:	The FreeBSD Foundation
2016-04-29 05:28:40 +00:00
Enji Cooper
a08b636a9d Use a better idiom for finding UTC prefixed timezones
Instead of copy-pasting the string literal for "UTC" 3 times and using
strlen, use a static char[3] buffer and sizeof(..).

MFC after: 3 days
X-MFC with: r298507
Submitted by: kib
Sponsored by: EMC / Isilon Storage Division
2016-04-28 17:57:17 +00:00
Alan Somers
654399bfd4 Add PACKAGE fields to usr.sbin/extattr/tests/Makefile
usr.sbin/extattr/tests/Makefile
	Add boiler plate required by 298107 but omitted by 298483.  These
	two changes passed through CR in parallel.  I think this should get
	the full test suite running in Jenkins again.

MFC after:	22 days
X-MFC-with:	298483
Sponsored by:	Spectra Logic Corp
2016-04-28 15:13:50 +00:00
Jung-uk Kim
f8146b882b Merge ACPICA 20160422. 2016-04-27 19:09:21 +00:00
John Baldwin
88eb5c506d Add 'devctl delete' that calls device_delete_child().
'devctl delete' can be used to delete a device that is no longer present.
As an anti-foot-shooting measure, 'delete' will not delete a device
unless it's parent bus says it is no longer present.  This can be
overridden by passing the force ('-f') flag.

Note that this command should be used with care.  If a device is deleted
that is actually present it can't be resurrected unless the parent bus
device's driver supports rescans.

Differential Revision:	https://reviews.freebsd.org/D6019
2016-04-27 16:33:17 +00:00
John Baldwin
a907c6914c Add a new rescan method to the bus interface.
The BUS_RESCAN() method rescans a single bus device checking for devices
that have been added or removed from the bus.  A new 'rescan' command is
added to devctl(8) to trigger a rescan.

Differential Revision:	https://reviews.freebsd.org/D6016
2016-04-27 16:29:03 +00:00
Xin LI
4990d495fc MFV r298691:
ntp 4.2.8p7.

Security:	CVE-2016-1547, CVE-2016-1548, CVE-2016-1549, CVE-2016-1550
Security:	CVE-2016-1551, CVE-2016-2516, CVE-2016-2517, CVE-2016-2518
Security:	CVE-2016-2519
Security:	FreeBSD-SA-16:16.ntp
With hat:	so
2016-04-27 07:46:38 +00:00
Marcelo Araujo
1f3d62ab98 For pointers use NULL instead of 0.
Reviewed by:	rpaulo
MFC after:	2 weeks.
Differential Revision:	https://reviews.freebsd.org/D5946
2016-04-27 03:06:53 +00:00
Bjoern Heidotting
7bb0da8d70 Remove redundant word.
Reviewed by:	 bjk, bcr
Differential Revision:	https://reviews.freebsd.org/D6064
2016-04-26 18:54:44 +00:00
Ed Schouten
4e7e2cad09 Remove unportable calls to basename().
The POSIX version of basename() doesn't use a 'const char *' argument;
the function may overwrite its input buffer. Instead of copying the
input string, let's just simplify this code by using our getprogname()
function that already returns the name of the application in the right
format.

Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D6094
2016-04-26 10:04:06 +00:00
Garance A Drosehn
820a9567ed Remove a variable and three lines of code which I should have removed as
part of revision 98776 back on June 24/2002.  Noticed by pfg@ trying
coccinelle for checking code.

MFC after:	3 weeks
2016-04-25 20:58:54 +00:00
Jamie Gritton
52a510ace9 Encapsulate SYSV IPC objects in jails. Define per-module parameters
sysvmsg, sysvsem, and sysvshm, with the following bahavior:

inherit: allow full access to the IPC primitives.  This is the same as
the current setup with allow.sysvipc is on.  Jails and the base system
can see (and moduly) each other's objects, which is generally considered
a bad thing (though may be useful in some circumstances).

disable: all no access, same as the current setup with allow.sysvipc off.

new: A jail may see use the IPC objects that it has created.  It also
gets its own IPC key namespace, so different jails may have their own
objects using the same key value.  The parent jail (or base system) can
see the jail's IPC objects, but not its keys.

PR:		48471
Submitted by:	based on work by kikuchan98@gmail.com
MFC after:	5 days
2016-04-25 17:06:50 +00:00
Jamie Gritton
5d6cb09dfc Note the existence of module-specific jail paramters, starting with the
linux.* parameters when linux emulation is loaded.

MFC after:	5 days
2016-04-25 17:01:13 +00:00
Jamie Gritton
a99d821068 Make jail(8) interpret escape codes in fstab the same as getfsent(3).
PR:		208663
MFC after:	3 days
2016-04-25 03:24:48 +00:00
Warren Block
9b8a603ef0 Add a single example of adding a user that roughly corresponds with the
adduser example in the Handbook.

MFC after:	1 week
2016-04-23 22:57:54 +00:00
Benedict Reuschling
4209de56bb Define which of the username options (-u/-U) to jexec(8) is the default.
Bump Dd.

PR:		207587
Submitted by:	dewayne@heuristicsystems.com.au
MFC after:	3 days
Sponsored by:	Essen Hackathon 2016
2016-04-23 22:31:58 +00:00
Enji Cooper
62bc9ed546 Fix looking for "UTC" at start of ptr by using strnmp instead of improperly
unrolled equivalent

CID: 1347118
MFC after: 1 week
Reported by: Coverity
Sponsored by: EMC / Isilon Storage Division
2016-04-23 08:10:04 +00:00
Alan Somers
83e2bfb685 Add ATF tests for usr.sbin/extattr
Add ATF tests for the existing behavior of setextattr, rmextattr, lsextattr,
and getextattr.

Reviewed by:	ngie
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D5889
2016-04-22 17:02:47 +00:00
Marcelo Araujo
59c895f143 Use MIN()/MAX() macros from sys/param.h.
Reviewed by:	grehan
Differential Revision:	https://reviews.freebsd.org/D6054
2016-04-22 06:25:32 +00:00
Enji Cooper
9899399c06 Don't try to free string (stack allocated char[])
Fix minor style with warnx call while in the neighborhood

MFC after: 1 week
CID: 1009683
Reported by: Coverity, gcc 5.x
Sponsored by: EMC / Isilon Storage Division
2016-04-22 06:01:11 +00:00
Enji Cooper
81b3868083 Don't use entry after free in the "already in lists" case
Return with 0 as it isn't an error.

MFC after: 1 week
CID: 1006085
Reported by: Coverity
Obtained from: Isilon OneFS (part of r493633)
Submitted by: Thor Steingrimsson <thor.steingrimsson@isilon.com>
Sponsored by: EMC / Isilon Storage Division
2016-04-22 05:52:40 +00:00
Marcelo Araujo
a301ee66ba Use macro MAX() from sys/param.h.
MFC after:	2 weeks.
2016-04-22 05:07:59 +00:00
Marcelo Araujo
5d6026c25e Use macro MAX() from sys/param.h.
MFC after:	2 weeks.
2016-04-22 03:55:33 +00:00
Baptiste Daroussin
f734685ea4 Plug memory leak
Reported by:	coverity
CID:		1331664, 1331665
2016-04-20 21:37:32 +00:00
Baptiste Daroussin
0ce8c4a33c Plug various resources leak
While here fix a test logic

Reported by:	coverity
CID:		1332096, 1332097, 1332098, 1332099, 1332100, 1332101, 1332102
MFC after:	1 week
2016-04-20 21:32:34 +00:00
Baptiste Daroussin
4ecb514126 Plug leaks
Reported by:	Coverity
CID:		1340155 and 1340156
MFC after:	1 week
2016-04-20 21:11:49 +00:00
Peter Grehan
e37bf586eb Don't use SYSDIR to avoid conflicts with existing usage.
Also, use SRCTOP to locate the top of the source tree
instead of a relative path.

PR:	208856
2016-04-20 17:05:32 +00:00
Roman Bogorodskiy
c2202d41f9 Update the bhyve(8) man page:
- Document powering off by sending SIGTERM signal
 - Document exit codes

Reviewed by:		wblock, neel
Approved by:		wblock
Differential Revision:	D5982
2016-04-20 06:29:03 +00:00
John Baldwin
cff92ffd4d Always emit an error message on passthru configuration errors.
Previously, many errors (such as the PCI device not being attached
to the ppt(4) driver) resulted in bhyve silently exiting without
starting the virtual machine.  Now any errors encountered when
configuring a virtual slot for a PCI passthru device should be noted
on stderr.

Reviewed by:	neel
Differential Revision:	https://reviews.freebsd.org/D5990
2016-04-19 20:43:05 +00:00
Allan Jude
4d41f47272 Add a new installation type to bsdinstall/zfsboot: BIOS+UEFI
Installs both pmbr+gptzfsboot as well as boot1.efifat in separate partitions
The resulting system can be booted with either UEFI or BIOS/CSM.
Preference is controlled by the user's firmware boot settings.

This is now the default for zfsboot installs

PR:		208629
Submitted by:	Galael LAPLANCHE <ganael.laplanche@corp.ovh.com> (original version)
2016-04-19 03:25:36 +00:00
Pedro F. Giffuni
c4c510be1e Reuse our roundup2() macro instead of reinventing the wheel.
Obtained from:	DragonflyBSD
2016-04-18 17:30:33 +00:00
Marcelo Araujo
bb0bd931dc The malloc will return NULL if it can't allocate memory.
MFC after:	2 weeks.
2016-04-18 05:19:45 +00:00
Marcelo Araujo
6a35cae5ed Use nitems instead of 'sizeof(mapnames) / sizeof(mapnames[0]'. 2016-04-18 03:44:42 +00:00
Baptiste Daroussin
02277afdb1 Use the SOCK_CLOEXEC flags in the socket(2) 'type' attribute instead of
calling fcntl(2)

MFC after:	1 week
2016-04-16 13:10:31 +00:00
Baptiste Daroussin
29808109ea Use pipe2(2) to directly set the close-on-exec flags directly
MFC after:	1 week
2016-04-16 12:42:01 +00:00
Glen Barber
0edd2576c0 MFH
Sponsored by:	The FreeBSD Foundation
2016-04-16 02:32:12 +00:00
Pedro F. Giffuni
80c7cc1c8f Cleanup unnecessary semicolons from utilities we all love. 2016-04-15 22:31:22 +00:00
Marcelo Araujo
b916534496 Use NULL instead of 0 for pointers.
fgetln(3) will returns NULL if cannot get a line from a stream.
strsep(3) it will returns NULL if the end of the string was reached.
jemalloc(3) malloc will returns NULL if it cannot allocate memory.
fgetln(3) it will returns NULL if it cannot get a line from a stream.

MFC after:	4 weeks
2016-04-15 04:10:47 +00:00
Marcelo Araujo
71866e627e Use NULL instead of 0 for pointers.
getenv(3) returns NULL if the variable name is not in the current
environment.
getservent(3) returns NULL on EOF or error

MFC after:	4 weeks
2016-04-15 03:50:33 +00:00
Marcelo Araujo
2c6167310e Use NULL instead of 0 for pointers.
fopen(3) returns NULL in case it can't open the STREAM.
fgetln(3) returns NULL if it can't get a line from a STREAM.
malloc returns NULL if it can't allocate memory.
2016-04-15 03:38:58 +00:00
Marcelo Araujo
960536b69f Use NULL instead of 0 for pointers and memory allocation.
malloc and realloc will return NULL pointer if it can't alloc memory.

MFC after:	4 weeks
2016-04-15 02:14:11 +00:00
Warren Block
4a2e0710e1 Remove a link to the CTM section of the Handbook, which no longer exists.
MFC after:	1 week
2016-04-14 21:56:36 +00:00
Marcelo Araujo
a5de41c600 Use NULL instead of 0 for pointers.
fopen(3) will return NULL in case it can't open the STREAM.
2016-04-14 12:53:38 +00:00
Marcelo Araujo
d11537c785 Use NULL instead of 0 for pointers.
The malloc will return a pointer to the allocated memory if successful,
otherwise a NULL pointer is returned.
2016-04-14 12:51:06 +00:00
Marcelo Araujo
45be165f23 Use NULL instead of 0 for pointers.
The strchr(3) returns a NULL if the character does not appears in the string.
The malloc will return NULL if cannot allocate memory.
2016-04-14 12:46:46 +00:00
Marcelo Araujo
fa02fc2d8f Use NULL instead of 0 for pointers.
fopen(3) will return NULL in case it can't open the STREAM.
The malloc will return a pointer to the allocated memory if successful,
otherwise a NULL pointer is returned.

Also add an extra DEBUG1 to print out the error to open a file.

Reviewed by:	ed
Differential Revision:	https://svnweb.freebsd.org/changeset/base/297959
2016-04-14 12:25:00 +00:00
Marcelo Araujo
f9e059ac83 Use NULL instead of 0 for pointers.
fopen(3) returns a FILE pointer, otherwise NULL is returned.

MFC after:	2 weeks
2016-04-14 11:41:30 +00:00
John Baldwin
5c40acf8b5 Handle PBA that shares a page with MSI-X table for passthrough devices.
If the PBA shares a page with the MSI-X table, map the shared page via
/dev/mem and emulate accesses to the portion of the PBA in the shared
page by accessing the mapped page.

Reviewed by:	grehan
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D5919
2016-04-13 18:39:33 +00:00
Glen Barber
010855174a MFH
Sponsored by:	The FreeBSD Foundation
2016-04-13 16:19:50 +00:00
Marcelo Araujo
eaf209de36 Convert ypldap_addr list to a tailq(queue(3)).
Obtained from:	OpenBSD r1.11, r1.17 and r1.36
2016-04-13 03:36:34 +00:00
Glen Barber
9c831bbd69 MFH
Sponsored by:	The FreeBSD Foundation
2016-04-13 02:04:09 +00:00
Marcelo Araujo
0e3562425e Apply revisions 1.4 and 1.5 from ldapd's ber.c to ypldap's copy, so it can
deal with messages that haven't been fully read from the server yet.

Obtained from:	OpenBSD r1.11
2016-04-13 01:54:33 +00:00
Glen Barber
a123f26e92 MFH
Sponsored by:	The FreeBSD Foundation
2016-04-12 17:00:13 +00:00
Edward Tomasz Napierala
e321146fc5 Make the usage() mention the -u option added in r295212.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-04-12 16:07:41 +00:00
Glen Barber
876d357fa7 MFH
Sponsored by:	The FreeBSD Foundation
2016-04-11 15:24:59 +00:00
Pedro F. Giffuni
bc17d12da3 lpr: replace 0 with NULL for pointers.
Found with devel/coccinelle.

Reviewed by:	gad
2016-04-10 23:47:40 +00:00
Peter Grehan
5ccf6ce169 Allow the location of the kernel source tree to be overridden.
This makes it easier for the bhyve executable to be built
out of the tree.
2016-04-10 05:58:19 +00:00
Allan Jude
b3f7b13945 bsdinstall/zfsboot should create /tmp and /var/tmp if they do not exist
PR:		208629
PR:		208568
Submitted by:	Galael LAPLANCHE <ganael.laplanche@corp.ovh.com>
MFC after:	2 weeks
2016-04-08 15:08:22 +00:00
Allan Jude
6b5e33ba48 Do not add swap to fstab when swapsize is 0
If a user requested encrypted swap, but 0 sized, it would still be added to fstab

PR:		208630
Submitted by:	Ganael LAPLANCHE <ganael.laplanche@corp.ovh.com>
MFC after:	2 weeks
Sponsored by:	ScaleEngine Inc.
2016-04-08 15:05:06 +00:00
Enji Cooper
ce570b1e96 Chase r296204 by renaming tzsetup(1) to tzsetup(8) in the tests
MFC after: 3 days
X-MFC with: r296204
Sponsored by: EMC / Isilon Storage Division
2016-04-06 03:12:44 +00:00
Glen Barber
2263fb580e MFH
Sponsored by:	The FreeBSD Foundation
2016-04-06 01:44:21 +00:00
Pedro F. Giffuni
8f61276d40 bhyveload: fix from loading undefined size.
We were setting an incorrect/undefined size and as it came out the st
struct was not really being used at all. This was actually a bug but
by sheer luck it had no visual effect.

CID:		1194320
Reviewed by:	grehan
2016-04-06 00:01:03 +00:00
Pedro F. Giffuni
91e34616df bhyve: Remove unneeded variable ncq.
ncq was not being inititialized properly but it was not actually
necessary either, so make the code smaller by removing it.

CID:		1248842
Reviewed by:	grehan
2016-04-05 19:30:19 +00:00
Glen Barber
d60840138f MFH
Sponsored by:	The FreeBSD Foundation
2016-04-04 23:55:32 +00:00
John Baldwin
0b03514943 Output information about PCI-e devices with slots.
In particular this includes additional information on HotPlug capable
slots.
2016-04-02 01:59:53 +00:00
John Baldwin
c36c6e72c6 Various updates to the PCI-express capability output.
- Group the output so that it follows the capability register set more
  closely.  The first line now contains device information and the
  second line contains link information.  As a result, ARI status is now
  output on the first line, and the link width is moved down to the second
  line of link information.
- Only read the DEVICE_CAP2 register to check for ARI if the capability
  version is >= 2.
- Don't output any link information if the link capability and status
  registers are zero.
- Label the MSI interrupt index value as "MSI" instead of "IRQ".
2016-04-02 01:55:43 +00:00
Pedro F. Giffuni
2b5554fec0 mtest: Prevent access to uninitialized value.
case 'g' makes use of value n, which is initialized for case 'b'
and passe through to case 'g'. If case 'g' is called directly
value 'n' is not initialized.

Avoid the issue by initializing n before entering the switch.

CID:		1006375
Reviewed by:	bms
2016-04-01 01:35:52 +00:00
Pedro F. Giffuni
6e43f3ed6d pci_emul_dior(): fix uninitialized scalar variable.
Prevent from returning an unitialized value in case the
ior size is unknown.

CID:		1194319
Reviewed by:	grehan
2016-03-31 19:07:03 +00:00
Bryan Drewery
497e80911e Remove the old depend (mkdep) code and make FAST_DEPEND the one true way.
Reviewed by:	emaste, hselasky (partial), brooks (brief)
Discussed on:	arch@
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D5742
2016-03-30 23:50:23 +00:00
Warren Block
579a636f2a Adjust misleading wording of the -G option and simplify a few
surrounding sentences.  From a discussion on -ports.

Reviewed by:	David Wolfskill <david@catwhisker.org>
2016-03-28 02:05:35 +00:00
Baptiste Daroussin
1427ff7da9 Cleanup headers
Found by:	include-what-you-use
2016-03-26 12:11:46 +00:00
Baptiste Daroussin
41328b4417 Remove some unneeded headers
Found by 'include-what-you-use'
2016-03-26 11:41:35 +00:00
Maksim Yevmenkin
52a4455b80 fix incorrect usage of hid_set_data() which causes crash
in bthidd(8) on amd64 WITH_SSP builds

Submitted by:	rakuco
Reviewed by:	rakuco
Tested by:	rakuco
MFC after:	1 week
2016-03-23 22:07:13 +00:00
Warner Losh
1ed9c427e5 Implement suggestion by jhb@ to have _PATH_FIRMWARE instead of hard
coding it to be "/usr/share/firmware".
2016-03-23 04:18:57 +00:00
Justin Hibbits
da1b038af9 Use uintmax_t (typedef'd to rman_res_t type) for rman ranges.
On some architectures, u_long isn't large enough for resource definitions.
Particularly, powerpc and arm allow 36-bit (or larger) physical addresses, but
type `long' is only 32-bit.  This extends rman's resources to uintmax_t.  With
this change, any resource can feasibly be placed anywhere in physical memory
(within the constraints of the driver).

Why uintmax_t and not something machine dependent, or uint64_t?  Though it's
possible for uintmax_t to grow, it's highly unlikely it will become 128-bit on
32-bit architectures.  64-bit architectures should have plenty of RAM to absorb
the increase on resource sizes if and when this occurs, and the number of
resources on memory-constrained systems should be sufficiently small as to not
pose a drastic overhead.  That being said, uintmax_t was chosen for source
clarity.  If it's specified as uint64_t, all printf()-like calls would either
need casts to uintmax_t, or be littered with PRI*64 macros.  Casts to uintmax_t
aren't horrible, but it would also bake into the API for
resource_list_print_type() either a hidden assumption that entries get cast to
uintmax_t for printing, or these calls would need the PRI*64 macros.  Since
source code is meant to be read more often than written, I chose the clearest
path of simply using uintmax_t.

Tested on a PowerPC p5020-based board, which places all device resources in
0xfxxxxxxxx, and has 8GB RAM.
Regression tested on qemu-system-i386
Regression tested on qemu-system-mips (malta profile)

Tested PAE and devinfo on virtualbox (live CD)

Special thanks to bz for his testing on ARM.

Reviewed By: bz, jhb (previous)
Relnotes:	Yes
Sponsored by:	Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D4544
2016-03-18 01:28:41 +00:00
Allan Jude
6203e46b84 Remove 50% ZFS conditional from bsdinstall/zfsboot
Remove the requirement that the resulting partition table be atleast 50% ZFS

PR:		208094
Requested by:	brooks
Sponsored by:	ScaleEngine Inc.
2016-03-17 17:53:38 +00:00
Ed Maste
8c0d1b4798 kbdcontrol: add -P path option to add keymap search paths
PR:		193865
Reviewed by:	cem
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D5645
2016-03-16 04:05:02 +00:00
Edward Tomasz Napierala
535bd9beaf Make fail() preserve the errno.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-03-15 11:10:08 +00:00
Edward Tomasz Napierala
e19462c33b Use the log_errno value passed to the function instead of the errno global
variable.

Suggested by:	Daniel Braniss
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-03-15 11:03:45 +00:00
Warner Losh
486607d0b6 Just install ar5523.bin into /usr/share/firmware and stop compiling it
in.

Differential Review: https://reviews.freebsd.org/D5639
2016-03-15 04:42:37 +00:00
Glen Barber
538354481e MFH
Sponsored by:	The FreeBSD Foundation
2016-03-14 18:54:29 +00:00
Ryan Stone
faf139cc5d Clean up repeated "All rights reserved" 2016-03-14 17:41:17 +00:00
George V. Neville-Neil
69ab30910f Fix typo: nmd->cur_tx_ring should be used in pci_vtnet_netmap_writev()
The buffer length should be checked to avoid overflow, but there
is no API to get the slot length, so the hardcoded value is used.
Return the currently-first request chain back to the available
queue if there are no more packets.
Report the link as up if we managed to open vale port.
Use consistent coding style.

Submitted by: btw
MFC after: 1 week
Differential Revision:	https://reviews.freebsd.org/D5595
2016-03-14 08:48:16 +00:00
Jakub Wojciech Klama
bb3844b388 Check value returned from ucl_parser_add_file().
Reviewed by:	trasz
Approved by:	trasz (mentor)
MFC after:	1 month
Sponsored by:	iXsystems, Inc.
2016-03-13 19:50:17 +00:00
Alexander Motin
2c4f4af7a8 dd report short write as error, so don't halt on it. 2016-03-12 23:04:10 +00:00
Dimitry Andric
e74d991d69 Fix gcc warnings about possibly uninitialized variables in gpioctl.c.
Noticed by:	bz
2016-03-12 15:10:30 +00:00
Oleksandr Tymoshenko
3b2bb13317 Make it possible for operations to refer to GPIO pins by name
- Try to guess what is provided as a pin spec for -t or for get/set
    operation: number or name. Fails in case of ambiguity.
- Add -p and -N switches to force pin specification interpretation:
    -p forces spec to be pin number, -N forces it to be name

Submitted by:	Emmanuel Vadot <manu@bidouilliste.com>
Differential Revision:	https://reviews.freebsd.org/D5201
2016-03-11 21:05:16 +00:00
Justin Hibbits
bf081e9948 Add to CFLAGS, rather than replacing.
This allows additional CFLAGS, as set in bsd.cpu.mk, to go through.
2016-03-11 20:04:32 +00:00
Alexander Motin
b8eb229d6f Oops, remove debugging forgotten in r296655.
MFC after:	2 weeks
2016-03-11 17:39:54 +00:00
Alexander Motin
5f7bd9a1c5 Don't bother to invoke gmirror or zpool if the module is not loaded. 2016-03-11 14:24:32 +00:00
Alexander Motin
edfb94f75b Unify and improve metadata wiping.
MFC after:	2 weeks
2016-03-11 14:14:15 +00:00
Alexander Motin
cdba914b3f Use geom disk list instead camcontrol identify.
The new way works for almost any disk, while the old only for ATA.

MFC after:	2 weeks
2016-03-11 13:06:11 +00:00
Glen Barber
7d536dc855 MFH
Sponsored by:	The FreeBSD Foundation
2016-03-10 21:16:01 +00:00
Bryan Drewery
15c433351f DIRDEPS_BUILD: Connect MK_TESTS.
Sponsored by:	EMC / Isilon Storage Division
2016-03-09 22:46:01 +00:00
Glen Barber
b655ec9752 MFH
Sponsored by:	The FreeBSD Foundation
2016-03-06 04:13:17 +00:00
Marcelo Araujo
5707468385 Set argument encode/result decode call backs for 'maplist' and 'all'.
Note: Listing a map is still not fully implemented.

Obtained from:	OpenBSD (r1.16, r1.17)
2016-03-04 03:10:08 +00:00
Marcelo Araujo
619d20a133 Implement the 'master' request.
Obtained from:	OpenBSD (r1.15)
2016-03-04 02:14:32 +00:00