Commit Graph

8124 Commits

Author SHA1 Message Date
Pedro F. Giffuni
65e2bd0ab8 routed(8): Dereference before null check.
CID:		272432
Obtained from:	NetBSD (CVS ref. 1.16)
MFC after:	2 weeks.
2016-05-15 02:41:20 +00:00
Pedro F. Giffuni
7b011d21db routed(8): Avoid NULL de-reference and two possible memory leaks.
The reports and fixes are straightforward but it's nice to be able
to confirm against NetBSD.

CID:		271080, 272306, 272307
Obtained from:	NetBSD (CVS ref. 1.21 - 1.23)
MFC after:	2 weeks.
2016-05-15 02:30:34 +00:00
Pedro F. Giffuni
5728318b35 Avoid NULL de-references.
CID:		271079
Obtained from:	NetBSD
MFC after:	2 weeks.
2016-05-14 23:32:03 +00:00
Pedro F. Giffuni
365cb451d3 routed(8): Use arc4random.
CID:		1305962
Obtained from:	NetBSD (CVS Rev. 1.34, Itojun)
2016-05-14 23:22:19 +00:00
Pedro F. Giffuni
0b279f8c94 routed: Fix use after free.
For the multihomed case, ifp be used after being freed. NULL the value
after freeing it and avoid getting into the branch without reassigning
a new value.

CID:		272671
Obtained from:	NetBSD
MFC after:	2 weeks
2016-05-14 23:07:26 +00:00
Pedro F. Giffuni
562c5a82cb routed(8): use NULL instead of zero for pointers. 2016-05-14 22:40:08 +00:00
Don Lewis
eeb6394364 Check for socket creation success before calling bind().
Reported by:	Coverity
CID:		1194209
2016-05-12 05:43:54 +00:00
Conrad Meyer
021b92e5ba dhclient: Fix some trivial buffer overruns
There was some confusion about how to limit a hardware address to at most 16
bytes.  In some cases it would overrun a byte off the end of the array.
Correct the types and rectify the overrun.

Reported by:	Coverity
CIDs:		1008682, 1305550
Sponsored by:	EMC / Isilon Storage Division
2016-05-12 04:28:22 +00:00
Conrad Meyer
fdaa5d1c07 camcontrol(8): Fix another trivial double-free
Reported by:	Coverity
CID:		1331222
Sponsored by:	EMC / Isilon Storage Division
2016-05-11 22:25:14 +00:00
Conrad Meyer
3aeebae9ca camcontrol(8): Fix trival double-free
Reported by:	Coverity
CID:		1331223
Sponsored by:	EMC / Isilon Storage Division
2016-05-11 22:22:49 +00:00
Conrad Meyer
333d028407 fsck_ffs: Don't overrun mount device buffer
Maybe this case is impossible.  Either way, when attempting to "/dev/"-prefix a
non-global device name, check that we do not overrun the f_mntfromname buffer.

In this case, truncating (with strlcpy or similar) would not be useful, since
the f_mntfromname result of getmntpt() is passed directly to open(2) later.

Reported by:	Coverity
CID:		1006789
Sponsored by:	EMC / Isilon Storage Division
2016-05-11 16:20:23 +00:00
Edward Tomasz Napierala
377b6d1e7c When rerooting, take the init(8) path from argv[0] instead of fetching
it via kern.proc.pathname sysctl(2).  In some cases - booting from NFS
or rerooting after replacing the init binary with a new one - the sysctl
would fail.  In other cases - after upgrading, which moves the old init
to /sbin/init.bak - it would return /sbin/init.bak, which is the actual
path of the running init, instead of /sbin/init.

Reported by:	Melissa Jenkins <melissa-freebsd at littlebluecar.co.uk>, jilles@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-11 10:03:13 +00:00
Edward Tomasz Napierala
126ba2193b When rerooting, ignore ESRCH returned from kill(2). I couldn't reproduce
this by myself, but apparently it sometimes happens when rerooting from
single user mode.

Reported by:	jilles@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-11 09:30:18 +00:00
Edward Tomasz Napierala
b8a1930fcf Cosmetic fixes for growfs(8) - remove unneeded capitalization and a spurious
newline, clarify a message.

MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-11 09:26:23 +00:00
Edward Tomasz Napierala
e49345fa3d Update the example growfs(8) manual page to include information on how
to make the system "notice" the updated disk size.

(Relnotes, since I've forget to set it for "camcontrol reprobe", and
it's worth mentioning.)

MFC after:	1 month
Relnotes:	yes
Sponsored by:	The FreeBSD Foundation
2016-05-10 18:28:38 +00:00
Edward Tomasz Napierala
d68fae5849 Add "camcontrol reprobe" subcommand, and implement it for da(4).
This makes it possible to manually force updating capacity data
after the disk got resized. Without it it might be neccessary to
reboot before FreeBSD notices updated disk size under eg VMWare.

Discussed with:	imp@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D6108
2016-05-10 15:46:33 +00:00
Baptiste Daroussin
997f8ff84f 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:35:03 +00:00
Andriy Voskoboinyk
db930544a3 ifconfig: fix check for 40 MHz channels while applying country/regdomain.
Do not use 20 MHz channel list while checking 40 MHz channels;
it may be different. Just use the corresponding list instead.

Tested by:	Masachika ISHIZUKA <ish@amail.plala.or.jp>

PR:		209328
2016-05-09 16:15:52 +00:00
Renato Botelho
89d18e14f1 Add missing parameters -N and -l to reroot and halt usage()
Approved by:	bapt
Sponsored by:	Rubicon Communications (Netgate)
Differential Revision:	https://reviews.freebsd.org/D6173
2016-05-06 20:49:14 +00:00
Pedro F. Giffuni
eabd8f1210 nvmecontrol.8: minor spelling fix.
No functional change.
2016-05-06 03:11:34 +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
Pedro F. Giffuni
dd3f00cbaf fsck_msdosfs: Adjust a check.
The on-disk FAT array does not include anything before CLUST_FIRST,
compensate in size check.

Obtained from:	NetBSD (CVS Rev. 1.20)
MFC after:	2 weeks
2016-05-04 22:27:22 +00:00
Marcelo Araujo
2c953857dd Use MIN macro from sys/param.h.
MFC after:	2 weeks
2016-05-02 01:40:31 +00:00
Marcelo Araujo
1120faab41 Use MIN/MAX macros from sys/param.h.
MFC after:	2 weeks.
2016-05-02 01:28:21 +00:00
Marcelo Araujo
0193043c46 Use MIN()/MAX() macros from sys/param.h.
Reviewed by:	trasz
MFC after:	2 weeks.
Differential Revision:	https://reviews.freebsd.org/D6118
2016-05-02 00:45:46 +00:00
Marcelo Araujo
e921a133f1 Use MIN() macro from sys/param.h.
Reviewed by:	trasz
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D6119
2016-05-02 00:44:19 +00:00
Pedro F. Giffuni
71a53e69d6 restore: promote some getfiles() parameters to size_t.
This is based on a change from OpenBSD:

"Fix restore so that it can actually restore files larger than 4GB by
changing the type of "size" to off_t in getfiles() plus little dependent
type cleanup, from Daniel Lucq."

It is an important for machines with 32 bit longs.
While here unsign the flags, also from OpenBSD.

Obtained from:	OpenBSD (through bitrig, I hate CVS)
MFC after:	2 weeks
2016-05-01 21:17:30 +00:00
Ed Schouten
e33d251e8e Remove useless calls to basename().
There are a couple of places in the source three where we call
basename() on constant strings. This is bad, because the prototype
standardized by POSIX allows the implementation to use its argument as a
storage buffer.

This change eliminates some of these unportable calls to basename() in
cases where it was only added for cosmetical reasons, namely to trim
argv[0]. There's nothing wrong with setting argv[0] to the full path.

Reviewed by:	jilles
Differential Revision:	https://reviews.freebsd.org/D6093
2016-05-01 08:22:11 +00:00
Pedro F. Giffuni
24229eeb2f restore: fix resource handle leak.
CID:		1007784
MFC after:	5 days
2016-05-01 02:39:39 +00:00
Pedro F. Giffuni
12527d70ac restore: drop casts for calloc(). 2016-05-01 02:31:22 +00:00
Pedro F. Giffuni
f32d2926b0 sbin: ake use of our rounddown() macro when sys/param.h is available.
No functional change.
2016-05-01 02:24:05 +00:00
Pedro F. Giffuni
312717174d sbin: use our howmany() macro when available through <sys/param.h>. 2016-05-01 02:19:49 +00:00
Pedro F. Giffuni
e451cf5f4c restore: fix memory leak.
CID:		272297
MFC after:	5 days
2016-04-30 22:51:09 +00:00
Pedro F. Giffuni
cac8854eb6 restore: use our howmany() instead of reinventing the macro. 2016-04-30 20:05:23 +00:00
Pedro F. Giffuni
fbcfcbbc5b fdisk: drop unused macro and make use of roundup()/rounddown(). 2016-04-30 19:58:54 +00:00
Pedro F. Giffuni
b68ac8007d sbin: minor spelling fixes.
No functional change.
2016-04-30 19:04:59 +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
dc8a83a5b6 Remove logically impossible test in scsidoinquiry(..)
It was already done 4 lines prior and the value of error didn't change

MFC after: 3 days
Reported by: Coverity
CID: 1011236
Sponsored by: EMC / Isilon Storage Division
2016-04-28 21:17:23 +00:00
Marcelo Araujo
7de7df1554 Use macro MIN() from sys/param.h.
MFC after:	2 weeks.
2016-04-27 02:02:44 +00:00
Pedro F. Giffuni
11ec5dd04b fsck_ffs: Revert partially the unsigned changes.
Any value of uint16_t will be internally promoted to int so
changing them to an unsigned value doesn't help.

Missing revert value in suj_read().

X-MFC with:	r298551
2016-04-27 01:36:25 +00:00
Pedro F. Giffuni
4235bafa7e fsck_ffs: Revert partially the unsigned changes.
Any value of uint16_t will be internally promoted to int so
changing them to an unsigned value doesn't help.

Make clear we want to use uint32_t for closedisk()

X-MFC with:	r298551
2016-04-27 01:32:11 +00:00
Alan Somers
96edd3f3ee Add GEOM::physpath documentation to devd.conf(5)
Suggested by:	trasz
Reviewed by:	trasz
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6063
2016-04-26 14:48:58 +00:00
Adrian Chadd
6605a047e7 [ifconfig] add STBC TX/RX configuration
This adds the ability to view and configure the STBC parameter for
both transmit and receive.

Whilst here, fix a typo for AMSDU.

TODO:

* manpage update
2016-04-26 01:30:29 +00:00
Pedro F. Giffuni
de497205b0 ifconfig: prevent some improbable signed integer overflows.
ic_nchans, from struct:ieee80211req_chaninfo, is an unsigned int.
Use an unsigned index to prevent overflowing the index.

Adopt unsigned integers in other cases where it is useful
to be aware of the unsigned quantities and there is no
risk of the values being negative.

MFC after:	1 week
2016-04-25 00:41:23 +00:00
Pedro F. Giffuni
0f8c0b0ae4 fsck_ffs: Adopt some type safety for the journalling checks.
fs_ncg is of type uint32, and we were indexing it with an int.
Fixed this using an unsigned type and adopt some other unsigned
indexes to remind us when we are dealing with unsigned numbers.

Reviewed by:	mckusick
MFC after:	5 days
2016-04-24 20:31:22 +00:00
Marcelo Araujo
091ea4a091 Use macro MAX() from sys/param.h.
MFC after:	2 weeks.
2016-04-22 03:32:14 +00:00
Marcelo Araujo
f4b72a8dd2 Use MIN()/MAX() macros from sys/param.h.
MFC after:	2 weeks.
2016-04-21 06:24:13 +00:00
Marcelo Araujo
67210fb3b8 Use MAX() from sys/param.h.
MFC after:	2 weeks.
2016-04-21 06:21:33 +00:00
Marcelo Araujo
6a25181bba Fix a missing blank space. 2016-04-21 06:14:30 +00:00