]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agobectl(8): add description for create subcommand
kevans [Wed, 22 May 2019 23:07:40 +0000 (23:07 +0000)]
bectl(8): add description for create subcommand

In commit r345845, a portion of documentation for the create subcommand was
removed. Specifically, for creating a snapshot of an existing boot
environment. bectl even has a test-case for this functionality.

Removing the sub-command description was discussed in PR 235850.

This patch brings back the second "create" description that was originally
in place. Albeit, with a few wording/clarifying changes.

Submitted by: Rob Fairbanks <rob.fx907 gmail com>
Reviewed by: kevans
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D20249

5 years agoAdd pnp info to the imx_i2c driver.
ian [Wed, 22 May 2019 21:47:26 +0000 (21:47 +0000)]
Add pnp info to the imx_i2c driver.

5 years agosave-entropy(8), rc.d/random: Set nodump flag
cem [Wed, 22 May 2019 21:47:17 +0000 (21:47 +0000)]
save-entropy(8), rc.d/random: Set nodump flag

Tag saved entropy files as "nodump," to signal that the files should not be
backed up by dump(8) or other automated backup software that honors the file
flag.

Do not produce an error if the target file resides on a filesystem that does
not support file flags (e.g., msdos /boot).

Reviewed by: delphij
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D20358

5 years agoFix gateway setup for the interface routes.
melifaro [Wed, 22 May 2019 21:20:15 +0000 (21:20 +0000)]
Fix gateway setup for the interface routes.

Currently rinit1() and its IPv6 counterpart
  nd6_prefix_onlink_rtrequest() uses dummy null_sdl gateway address
  during route insertion and change it afterwards. This behaviour
  brings complications to the routing stack and the users of its
  upcoming notification system.

This change fixes both rinit1() and nd6_prefix_onlink_rtrequest()
  by filling in proper gateway in the beginning. It does not change any
  of the userland notifications as in both cases, they happen after
  the insertion and fixup process (rt_newaddrmsg_fib() and nd6_rtmsg()).

MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20328

5 years agoAdd a new 'tr' (transfer) mode to i2c(8) to support more i2c controllers.
ian [Wed, 22 May 2019 21:06:10 +0000 (21:06 +0000)]
Add a new 'tr' (transfer) mode to i2c(8) to support more i2c controllers.

Some i2c controller hardware does not provide a way to do individual START,
REPEAT-START and STOP actions on the i2c bus.  Instead, they can only do
a complete transfer as a single operation.  Typically they can do either
START-data-STOP or START-data-REPEATSTART-data-STOP.  In the i2c driver
framework, this corresponds to the iicbus_transfer method.  In the userland
interface they are initiated with the I2CRDWR ioctl command.

These changes add a new 'tr' mode which can be specified with the '-m'
command line option.  This mode should work on all hardware; when an i2c
controller driver doesn't directly support the iicbus_transfer method,
code in the i2c driver framework uses the lower-level START/REPEAT/STOP
methods to implement the transfer.  After this new mode has gotten some
testing on various hardware, the 'tr' mode should probably become the
new default mode.

PR: 189914

5 years agoAllocate buffers smaller then ABD chunk size as linear.
mav [Wed, 22 May 2019 18:43:48 +0000 (18:43 +0000)]
Allocate buffers smaller then ABD chunk size as linear.

This allows to reduce memory waste by letting UMA to put multiple small
buffers into one memory page slab.  The page sharing means that UMA
may not be able to free memory page when some of buffers are freed, but
alternatively memory used by that buffer would just be wasted from the
beginning.

This change follows alike change in ZoL, but unlike Linux (according to
my understanding of it from comments) FreeBSD never shares slabs bigger
then one memory page, so this should be even less invasive then there.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

5 years agoPassing a parameter to vm_map_entry_resize_free that describes the
dougm [Wed, 22 May 2019 17:40:54 +0000 (17:40 +0000)]
Passing a parameter to vm_map_entry_resize_free that describes the
amount of resizing reduces the number of functions changing the vm_map
invariants regarding the max_free field of map entries.

Reviewed by: markj (mentor)
Approved by: kib (mentor)
Differential Revision: https://reviews.freebsd.org/D20356

5 years agoFix ObsoleteFiles after ethernet driver removal
zeising [Wed, 22 May 2019 16:59:22 +0000 (16:59 +0000)]
Fix ObsoleteFiles after ethernet driver removal

Fix OpsoleteFiles.inc after removal of ethernet drivers.  The drivers have
manual pages, and manual pages are generally stored compressed, with a .gz
suffix, but this is not reflected in ObsoleteFiles and make delete-old fails
to remove them.

Approved by: brooks
Sponsored by: B3 Init
Differential Revision: https://reviews.freebsd.org/D20351

5 years agoUpdate VFS_FHTOVP(9) with the flags argument
asomers [Wed, 22 May 2019 16:24:39 +0000 (16:24 +0000)]
Update VFS_FHTOVP(9) with the flags argument

Revison 222167 added a new argument to VFS_FHTOVP. This revision updates the
man page to match.

Reviewed by: rmacklem
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20323

5 years agoFix PPC64 kernel build with clang8 + lld8
luporl [Wed, 22 May 2019 15:56:41 +0000 (15:56 +0000)]
Fix PPC64 kernel build with clang8 + lld8

This patch fixes the following lld link errors:

- unsupported dynamic relocations on read-only sections
- out-of-range TOC references

Submitted by: git_bdragon.rtk0.net
Reviewed by: jhibbits, luporl
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19352

5 years agoSimplify math added in r310524.
mav [Wed, 22 May 2019 15:39:35 +0000 (15:39 +0000)]
Simplify math added in r310524.

Should be no functional change.

Reported by: danfe
MFC after: 1 week

5 years agoFix condition broken at r345815.
mav [Wed, 22 May 2019 15:25:10 +0000 (15:25 +0000)]
Fix condition broken at r345815.

Reported by: danfe
MFC after: 3 days

5 years agox86 MCA: introduce MCA hooks for different vendor implementations
gallatin [Wed, 22 May 2019 13:44:15 +0000 (13:44 +0000)]
x86 MCA: introduce MCA hooks for different vendor implementations

This is needed for AMD SMCA processors, as SMCA uses different
MSR address for access MCA banks.

Use IA32 specific msr_ops as defualt, and use SMCA-specific msr_ops
when on an SMCA-enabled processor

Submitted by: chandu from amd dot com
Reviewed by: cem
Differential Revision: https://reviews.freebsd.org/D18055

5 years agoacpi_hpet: restore support for timers defined only in HPET table
avg [Wed, 22 May 2019 08:30:03 +0000 (08:30 +0000)]
acpi_hpet: restore support for timers defined only in HPET table

This fixes a regress introduced in r339754.
After that change the code required that there is a HPET device
in the ACPI namespace.
The problem has been noticed on an PC Engines apu2 system.

While here, fix a small formatting issue.

5 years agopkgbase: Really move login.access
manu [Wed, 22 May 2019 07:41:58 +0000 (07:41 +0000)]
pkgbase: Really move login.access

Messed up with git->svn r348102

5 years agopkgbase: Really move termcap.small
manu [Wed, 22 May 2019 07:41:20 +0000 (07:41 +0000)]
pkgbase: Really move termcap.small

Messed up with git->svn in r348101

5 years agopkgbase: Really move rc.sendmail
manu [Wed, 22 May 2019 07:40:39 +0000 (07:40 +0000)]
pkgbase: Really move rc.sendmail

Messed up with git->svn in r348100

5 years agopkgbase: Really move rc.bsdextended
manu [Wed, 22 May 2019 07:39:59 +0000 (07:39 +0000)]
pkgbase: Really move rc.bsdextended

Messed up with git->svn in r348099

5 years agopkgbase: Really move rc.firewall
manu [Wed, 22 May 2019 07:38:54 +0000 (07:38 +0000)]
pkgbase: Really move rc.firewall

Messed up with git->svn in r348098

5 years agopkgbase: Move login.access to usb.bin/login
manu [Wed, 22 May 2019 07:23:03 +0000 (07:23 +0000)]
pkgbase: Move login.access to usb.bin/login

Also remove the etc-examples target as we don't have any files
to handle here.

Reviewed by: bapt

5 years agopkgbase: Move termcap.small to share/termcap
manu [Wed, 22 May 2019 07:22:34 +0000 (07:22 +0000)]
pkgbase: Move termcap.small to share/termcap

Reviewed by: bapt

5 years agopkgbase: Move rc.sendmail to libexec/rc
manu [Wed, 22 May 2019 07:22:08 +0000 (07:22 +0000)]
pkgbase: Move rc.sendmail to libexec/rc

Reviewed by: bapt

5 years agopkgbase: Move rc.bsdextended to libexec/rc
manu [Wed, 22 May 2019 07:21:39 +0000 (07:21 +0000)]
pkgbase: Move rc.bsdextended to libexec/rc

Reviewed by: bapt

5 years agopkgbase: Move rc.firewall to libexec/rc
manu [Wed, 22 May 2019 07:21:05 +0000 (07:21 +0000)]
pkgbase: Move rc.firewall to libexec/rc

Put it with all the other rc files

Reviewed by: bapt

5 years agoMake aacraid(4) working on ASR8805 & ASR8402 in particular. This patch
sobomax [Wed, 22 May 2019 04:51:08 +0000 (04:51 +0000)]
Make aacraid(4) working on ASR8805 & ASR8402 in particular. This patch
has been in the PR system for 5 months and then on reviews for another 5.
Nobody came with any cases where it fails, while many people cried for
it to be commited & merged.

PR: 209468
Submitted by: Prasad B M <prasad.munirathnam@microsemi.com>
Reported by: Steven Peterson <scp@mainstream.net>
Approved by: scottl
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D18408

5 years agoMarginally improve usage() message style in bootpd.
markj [Wed, 22 May 2019 04:13:57 +0000 (04:13 +0000)]
Marginally improve usage() message style in bootpd.

- Remove an extra space after "usage:".
- Avoid lines exceeding 80 columns.

Based on notes from rgrimes.

MFC with: r348066
Event: Waterloo Hackathon 2019

5 years agoUpdate the example added in r348082 to specify a dump device priority.
markj [Wed, 22 May 2019 03:52:39 +0000 (03:52 +0000)]
Update the example added in r348082 to specify a dump device priority.

Event: Waterloo Hackathon 2019

5 years agoProvide an example of using dhclient-script(5) to configure netdump.
markj [Wed, 22 May 2019 03:49:38 +0000 (03:49 +0000)]
Provide an example of using dhclient-script(5) to configure netdump.

Reviewed by: cem
MFC after: 1 week
Event: Waterloo Hackathon 2019
Differential Revision: https://reviews.freebsd.org/D20345

5 years agoHook up the existing i386 DTrace tests to the build.
markj [Wed, 22 May 2019 03:42:03 +0000 (03:42 +0000)]
Hook up the existing i386 DTrace tests to the build.

Now that it's relatively easy to do so, we might as well.

MFC after: 1 week
Event: Waterloo Hackathon 2019

5 years agoMake it possible to generate makefiles for arch-dependent DTrace tests.
markj [Wed, 22 May 2019 03:10:23 +0000 (03:10 +0000)]
Make it possible to generate makefiles for arch-dependent DTrace tests.

MFC after: 1 week
Event: Waterloo Hackathon 2019

5 years agopowerpc/booke: Use wrtee instead of msr to restore EE bit
jhibbits [Wed, 22 May 2019 02:43:17 +0000 (02:43 +0000)]
powerpc/booke: Use wrtee instead of msr to restore EE bit

The MSR[EE] bit does not require synchronization when changing.  This is a
trivial micro-optimization, removing the trailing isync from mtmsr().

MFC after: 1 week

5 years agopmc: Fix stack std::string lifetime
cem [Wed, 22 May 2019 01:22:33 +0000 (01:22 +0000)]
pmc: Fix stack std::string lifetime

It's invalid to reference a C++ string's c_str() buffer after the object
goes out of scope.  Adjust the scope of the string to match the use in
write(2) to fix the misuse.

CID: 1393383
Reported by: Coverity

5 years agoLink fhlinkat(2) man page
asomers [Wed, 22 May 2019 01:11:21 +0000 (01:11 +0000)]
Link fhlinkat(2) man page

Reviewed by: kib
MFC after: 3 days
MFC-With: r341689
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20339

5 years agoRevert r348070
cem [Wed, 22 May 2019 00:21:42 +0000 (00:21 +0000)]
Revert r348070

Konstantin points out that lockmgr probably requires the whole lock.h anyway.

Requested by: kib

5 years agoDo not call hw_mds_recalculate() from initializecpu().
kib [Tue, 21 May 2019 22:56:21 +0000 (22:56 +0000)]
Do not call hw_mds_recalculate() from initializecpu().

If MDS mitigation is enabled by the tunable but MDS microcode is not
early-loaded, software mitigation is selected.  This causes
initializecpu() to try to allocate memory which makes boot process
very unhappy.

Create SYSINIT that runs sufficiently late to succeed.

Reported by: naddy
PR: 237968
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoThis revision began as a simple change to eliminate an uninitialized warning
mckusick [Tue, 21 May 2019 22:24:38 +0000 (22:24 +0000)]
This revision began as a simple change to eliminate an uninitialized warning
found by Coverity. However, upon closer inspection the implementation of
fsck_ffs's fsck_readdir() and dircheck() functions is both nearly impossible
to follow and fails to check / fix directories in several cases. So, this
revision is an entire rewrite of these two functions to clarify what they
are doing and also to get something that works properly.

Referred by:  cem
Reviewed by:  kib, David G Lawrence
MFC after:    3 days
CID 1401317:  namlen may be used uninitialized

5 years agoAdd admonitions against using MD5 and SHA1 to the API man pages
allanjude [Tue, 21 May 2019 22:17:00 +0000 (22:17 +0000)]
Add admonitions against using MD5 and SHA1 to the API man pages

5 years agoAdd missing errors section to md[2-5], ripemd160, sha*, and skein* manpages
allanjude [Tue, 21 May 2019 22:11:53 +0000 (22:11 +0000)]
Add missing errors section to md[2-5], ripemd160, sha*, and skein* manpages

PR: 148987
Submitted by: Dan Lukes <dan@obluda.cz> (original version)
MFC after: 1 week
Sponsored by: Klara Systems
Event: Waterloo Hackathon 2019

5 years agoFix typo in r348068
allanjude [Tue, 21 May 2019 21:39:03 +0000 (21:39 +0000)]
Fix typo in r348068

5 years agosys/lockmgr.h: Update #error to point at correct _lock.h
cem [Tue, 21 May 2019 21:35:37 +0000 (21:35 +0000)]
sys/lockmgr.h: Update #error to point at correct _lock.h

After r347984, these macros live in sys/_lock.h.  No functional change.

Sponsored by: Dell EMC Isilon

5 years agobootpd: avoid the same error indication for different issues
emaste [Tue, 21 May 2019 21:27:14 +0000 (21:27 +0000)]
bootpd: avoid the same error indication for different issues

There were several (apparently) copy-pasted NEED validation macros,
leading to the same error string for different issues.  Change the
YP and NTP tags so they are distinct.

PR: 30863
Submitted by: Dan Lukes <dan@obluda.cz>
Reviewed by: markj
MFC after: 1 week
Event: Waterloo Hackathon 2019

5 years agoZFS: Make deadman tunables no longer read-only
allanjude [Tue, 21 May 2019 21:26:18 +0000 (21:26 +0000)]
ZFS: Make deadman tunables no longer read-only

This allows the user to enable, disable, and adjust the I/O deadman at
runtime. This can be especially useful when a pool is backed by remote
storage (such as iscsi, ggated, etc).

PR: 221906
Submitted by: Fabian Keil <fk@fabiankeil.de>
Obtained from: ElectroBSD
MFC after: 1 week
Sponsored by: Klara Systems
Event: Waterloo Hackathon 2019

5 years agomqueuefs: Do not allow manipulation of the pseudo-dirents "." and ".."
cem [Tue, 21 May 2019 21:26:14 +0000 (21:26 +0000)]
mqueuefs: Do not allow manipulation of the pseudo-dirents "." and ".."

"." and ".." names are not maintained in the mqueuefs dirent datastructure and
cannot be opened as mqueues.  Creating or removing them is invalid; return
EINVAL instead of crashing.

PR: 236836
Submitted by: Torbjørn Birch Moltu <t.b.moltu AT lyse.net>
Discussed with: jilles (earlier version)

5 years agobootpd: Add an option to skip modifications to the ARP table.
markj [Tue, 21 May 2019 21:22:43 +0000 (21:22 +0000)]
bootpd: Add an option to skip modifications to the ARP table.

PR: 30854
Submitted by: Dan Lukes <dan@obluda.cz>
Reviewed by: imp (previous version)
MFC after: 1 week
Event: Waterloo Hackathon 2019
Differential Revision: https://reviews.freebsd.org/D2581

5 years agoCorrect the way remaining battery life is calculated
allanjude [Tue, 21 May 2019 21:14:22 +0000 (21:14 +0000)]
Correct the way remaining battery life is calculated

Previously, if a system had multiple batteries, the remaining life
percentage was calculated as the average of each battery's percent
remaining. This results in rather incorrect values when you consider the
case of the Thinkpad X270 that has a small 3 cell internally battery, and
a hot-swappable 9 cell battery that is used first. Battery 0 is at 100%,
but battery 1 is at 10%, you do not infact have 55% of your capacity
remaining.

The new method calculates the percentage based on remaining capacity
out of total capacity, giving a much more accurate reading.

PR: 229818
Submitted by: Keegan Drake H.P. <kd-dev@pm.me>
MFC after: 2 weeks
Sponsored by: Klara Systems
Event: Waterloo Hackathon 2019

5 years agoInclude ktr.h in more compilation units
cem [Tue, 21 May 2019 20:38:48 +0000 (20:38 +0000)]
Include ktr.h in more compilation units

Similar to r348026, exhaustive search for uses of CTRn() and cross reference
ktr.h includes.  Where it was obvious that an OS compat header of some kind
included ktr.h indirectly, .c files were left alone.  Some of these files
clearly got ktr.h via header pollution in some scenarios, or tinderbox would
not be passing prior to this revision, but go ahead and explicitly include it
in files using it anyway.

Like r348026, these CUs did not show up in tinderbox as missing the include.

Reported by: peterj (arm64/mp_machdep.c)
X-MFC-With: r347984
Sponsored by: Dell EMC Isilon

5 years agoAdd very basic afinet socket tests which I started to write in order
bz [Tue, 21 May 2019 19:42:04 +0000 (19:42 +0000)]
Add very basic afinet socket tests which I started to write in order
to then try to reproduce a kernel panic, which turned out to be a
race condition and hard to test from here.

Commit the changes anywhere as the "bind zero" case was a surprise
to me and we should try to maintain this status.

Also it is easy examples someone can build upon.

With help from: markj
Event: Waterloo Hackathon 2019

5 years agoMassively blow up the locking-related KASSERTs used to make sure
bz [Tue, 21 May 2019 19:23:56 +0000 (19:23 +0000)]
Massively blow up the locking-related KASSERTs used to make sure
that we end up in a consistent locking state at the end of
udp_output() in order to be able to see what the values are based
on which we once took a decision (note: some values may have changed).

This helped to debug a syzkaller report.

MFC after: 2 months
Event: Waterloo Hackathon 2019

5 years agoSimilarly to r338257,338306 try to fold the two consecutive
bz [Tue, 21 May 2019 19:18:55 +0000 (19:18 +0000)]
Similarly to r338257,338306 try to fold the two consecutive
#ifdef RSS section in udp_output() into one by moving a '}'
outside of the conditional block.

MFC after: 2 months
Event: Waterloo Hackathon 2019

5 years agovt efifb: add suspend/resume calls
emaste [Tue, 21 May 2019 18:42:36 +0000 (18:42 +0000)]
vt efifb: add suspend/resume calls

Using the latest NVIDIA driver, upon resuming from suspend with X
running the display remained blank.  Additionally OpenGL applications
that were running triggered a number of error messages from the NVIDIA
driver.

This occurred because the vt efifb back-end did not signal the X server
to release the display before suspending (or to re-acquire it after
resuming).  The NVIDIA driver includes code for smoothly shutting down
and re-initializing the GPU, which was not getting called.

Since the NVIDIA driver doesn't currently support framebuffer devices
and vt is forced to fall back to the efifb back-end, add vd_suspend and
vd_resume members to connect the suspend/resume path.  This ensures the
X server is properly able to re-initialize the display.

PR: 237050
Submitted by: Erik Kurzinger <ekurzinger@nvidia.com>
Reviewed by: markj
MFC after: 2 weeks
Event: Waterloo Hackathon 2019

5 years agoDo not leak sa in linux_recvmsg() call if kern_recvit() fails.
dchagin [Tue, 21 May 2019 18:08:19 +0000 (18:08 +0000)]
Do not leak sa in linux_recvmsg() call if kern_recvit() fails.

MFC after: 1 week

5 years agoDo not use uninitialised sa.
dchagin [Tue, 21 May 2019 18:05:57 +0000 (18:05 +0000)]
Do not use uninitialised sa.

Reported by: tijl@
MFC after: 1 week

5 years agoDo not leak sa in linux_recvfrom() call if kern_recvit() fails.
dchagin [Tue, 21 May 2019 18:03:58 +0000 (18:03 +0000)]
Do not leak sa in linux_recvfrom() call if kern_recvit() fails.

MFC after: 1 week

5 years agoNDFREE(): Fix unlocking for LOCKPARENT|LOCKLEAF and ndp->ni_dvp == ndp->ni_vp.
kib [Tue, 21 May 2019 15:12:13 +0000 (15:12 +0000)]
NDFREE(): Fix unlocking for LOCKPARENT|LOCKLEAF and ndp->ni_dvp == ndp->ni_vp.

NDFREE() calculates unlock_dvp after ndp->ni_vp is unlocked and zeroed
out. This makes the comparision of ni_dvp with ni_vp always fail.
Move the calculation of unlock_dvp right after unlock_vp, so that the
code sees correct ni_vp value.

Reproduced by
   chdir("/usr");
   open("/..", O_BENEATH | O_RDONLY);

Reported by: syzkaller
Reviewed by: markj, mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D20304

5 years agoThe older detection methods (smbios.bios.vendor and smbios.system.product)
stevek [Tue, 21 May 2019 13:29:53 +0000 (13:29 +0000)]
The older detection methods (smbios.bios.vendor and smbios.system.product)
are able to determine some virtual machines, but the vm_guest variable was
still only being set to VM_GUEST_VM.

Since we do know what some of them specifically are, we can set vm_guest
appropriately.

Also, if we see the CPUID has the HV flag, but we were unable to find a
definitive vendor in the Hypervisor CPUID Information Leaf, fall back to
the older detection methods, as they may be able to determine a specific
HV type.

Add VM_GUEST_PARALLELS value to VM_GUEST for Parallels.

Approved by: cem
Differential Revision: https://reviews.freebsd.org/D20305

5 years agoXr make_dev(9) from devfs(5).
trasz [Tue, 21 May 2019 08:24:22 +0000 (08:24 +0000)]
Xr make_dev(9) from devfs(5).

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

5 years agoMake linux_ptrace() use linux_msg() instead of printf().
trasz [Tue, 21 May 2019 08:23:24 +0000 (08:23 +0000)]
Make linux_ptrace() use linux_msg() instead of printf().

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

5 years agoAdd my name to the copyright
ngie [Tue, 21 May 2019 04:11:16 +0000 (04:11 +0000)]
Add my name to the copyright

I have contributed a number of changes to these tests over the past few
hundred revisions, and believe I deserve credit for the changes I have
made (plus, the copyright hadn't been updated since 2014).

MFC after: 1 week

5 years agoFollow up to r348042: cast `aad` to a byte array
ngie [Tue, 21 May 2019 04:03:22 +0000 (04:03 +0000)]
Follow up to r348042: cast `aad` to a byte array

This is not completely necessary today, but this change is being made in a
conservative manner to avoid accidental breakage in the future, if this ever
was a unicode string.

PR: 237403
MFC after: 1 week

5 years agoFix encoding issues with python 3
ngie [Tue, 21 May 2019 03:52:48 +0000 (03:52 +0000)]
Fix encoding issues with python 3

In python 3, the default encoding was switched from ascii character sets to
unicode character sets in order to support internationalization by default.
Some interfaces, like ioctls and packets, however, specify data in terms of
non-unicode encodings formats, either in host endian (`fcntl.ioctl`) or
network endian (`dpkt`) byte order/format.

This change alters assumptions made by previous code where it was all
data objects were assumed to be basestrings, when they should have been
treated as byte arrays. In order to achieve this the following are done:
* str objects with encodings needing to be encoded as ascii byte arrays are
  done so via `.encode("ascii")`. In order for this to work on python 3 in a
  type agnostic way (as it anecdotally varied depending on the caller), call
  `.encode("ascii")` only on str objects with python 3 to cast them to ascii
  byte arrays in a helper function name `str_to_ascii(..)`.
* `dpkt.Packet` objects needing to be passed in to `fcntl.ioctl(..)` are done
  so by casting them to byte arrays via `bytes()`, which calls
  `dpkt.Packet__str__` under the covers and does the necessary str to byte array
  conversion needed for the `dpkt` APIs and `struct` module.

In order to accomodate this change, apply the necessary typecasting for the
byte array literal in order to search `fop.name` for nul bytes.

This resolves all remaining python 2.x and python 3.x compatibility issues on
amd64. More work needs to be done for the tests to function with i386, in
general (this is a legacy issue).

PR: 237403
MFC after: 1 week
Tested with: python 2.7.16 (amd64), python 3.6.8 (amd64)

5 years agostand: TARGET_ARCH is spelled MACHINE_ARCH in Makefiles
jhibbits [Tue, 21 May 2019 03:05:24 +0000 (03:05 +0000)]
stand: TARGET_ARCH is spelled MACHINE_ARCH in Makefiles

Reported by: imp

5 years agoRemove spurious newline
ngie [Tue, 21 May 2019 02:49:15 +0000 (02:49 +0000)]
Remove spurious newline

Even though some python styles suggest there should be multiple newlines between
methods/classes, for consistency with the surrounding code, it's best to be
consistent by having merely one newline between each functional block.

MFC after: 1 week

5 years agoFix `KAT(CCM)?Parser` file descriptor leaks
ngie [Tue, 21 May 2019 02:30:43 +0000 (02:30 +0000)]
Fix `KAT(CCM)?Parser` file descriptor leaks

Make `KAT(CCM)?Parser` into a context suite-capable object by implementing
`__enter__` and `__exit__` methods which manage opening up the file descriptors
and closing them on context exit. This implementation was decided over adding
destructor logic to a `__del__` method, as there are a number of issues around
object lifetimes when dealing with threading cleanup, atexit handlers, and a
number of other less obvious edgecases. Plus, the architected solution is more
pythonic and clean.

Complete the iterator implementation by implementing a `__next__` method for
both classes which handles iterating over the data using a generator pattern,
and by changing `__iter__` to return the object instead of the data which it
would iterate over. Alias the `__next__` method to `next` when working with
python 2.x in order to maintain functional compatibility between the two major
versions.

As part of this work and to ensure readability, push the initialization of the
parser objects up one layer and pass it down to a helper function. This could
have been done via a decorator, but I was trying to keep it simple for other
developers to make it easier to modify in the future.

This fixes ResourceWarnings with python 3.

PR: 237403
MFC after: 1 week
Tested with: python 2.7.16 (amd64), python 3.6.8 (amd64)

5 years agoSquash deprecation warning related to array.array(..).tostring()
ngie [Tue, 21 May 2019 02:13:46 +0000 (02:13 +0000)]
Squash deprecation warning related to array.array(..).tostring()

In version 3.2+, `array.array(..).tostring()` was renamed to
`array.array(..).tobytes()`. Conditionally call `array.array(..).tobytes()` if
the python version is 3.2+.

PR: 237403
MFC after: 1 week

5 years agostand/powerpc: Only build loader.kboot for powerpc64
jhibbits [Tue, 21 May 2019 01:42:57 +0000 (01:42 +0000)]
stand/powerpc: Only build loader.kboot for powerpc64

kboot is only made for powerpc64 systems, not 32-bit systems.

This unbreaks the build for powerpcspe.

Reported by: ngie

5 years agoInclude eventhandler.h in more compilation units
cem [Tue, 21 May 2019 01:18:43 +0000 (01:18 +0000)]
Include eventhandler.h in more compilation units

This was enumerated with exhaustive search for sys/eventhandler.h includes,
cross-referenced against EVENTHANDLER_* usage with the comm(1) utility.  Manual
checking was performed to avoid redundant includes in some drivers where a
common os_bsd.h (for example) included sys/eventhandler.h indirectly, but it is
possible some of these are redundant with driver-specific headers in ways I
didn't notice.

(These CUs did not show up as missing eventhandler.h in tinderbox.)

X-MFC-With: r347984

5 years agoUnbreak the build when `ELF_VERBOSE` is defined after r348005
ngie [Tue, 21 May 2019 00:46:47 +0000 (00:46 +0000)]
Unbreak the build when `ELF_VERBOSE` is defined after r348005

This change properly terminates the formatting string quote modification done
in r348005, which is triggered when `ELF_VERBOSE` is defined.

MFC with: r348005
Reported by: ci (amd64, gcc)

5 years agoFollowup to r347996
ngie [Tue, 21 May 2019 00:30:29 +0000 (00:30 +0000)]
Followup to r347996

Replace uses of `foo.encode("hex")` with `binascii.hexlify(foo)` for forwards
compatibility between python 2.x and python 3.

PR: 237403
MFC after: 1 week

5 years agoAdd two missing eventhandler.h headers
cem [Tue, 21 May 2019 00:04:19 +0000 (00:04 +0000)]
Add two missing eventhandler.h headers

These are obviously missing from the .c files, but don't show up in any
tinderbox configuration (due to latent header pollution of some kind).  It
seems some configurations don't have this pollution, and the includes are
obviously missing, so go ahead and add them.

Reported by: Peter Jeremy <peter AT rulingia.com>
X-MFC-With: r347984

5 years agoReverse the bit logic of sc_led_modes_mask. Instead of initializing it to
ian [Mon, 20 May 2019 22:32:31 +0000 (22:32 +0000)]
Reverse the bit logic of sc_led_modes_mask.  Instead of initializing it to
all-ones then carving out blocks of zeroes where specified values go, init
it to all-zeroes, put in ones where values need to be masked, then use it
as value &= ~sc_led_modes_mask.  In addition to being more idiomatic, this
means everything related to FDT data is initialized to zero along with the
rest of the softc, and that allows removing some #ifdef FDT sections and
wrapping the whole muge_set_leds() function in a single ifdef block.

This also deletes the early-out from muge_set_leds() when an eeprom exists.
Even if there is an eeprom with led config in it, the fdt data (if present)
should override that, because the user is in control of the fdt data.

5 years agoAllow the end-user to pass along arguments to cryptotest.py via `$CRYPTOTEST_ARGS`
ngie [Mon, 20 May 2019 22:32:26 +0000 (22:32 +0000)]
Allow the end-user to pass along arguments to cryptotest.py via `$CRYPTOTEST_ARGS`

This allows someone to use `-v` to dump out standard output.

5 years agoA MAC adddress from FDT data should override anything stored in eeprom or
ian [Mon, 20 May 2019 22:21:47 +0000 (22:21 +0000)]
A MAC adddress from FDT data should override anything stored in eeprom or
OTP registers (because the user is in control of the fdt data).  Remove the
early returns from the code that tries to find a good mac address, so that
the execution always flows through the routine to get an address from FDT
data last, when on FDT-enabled systems.

5 years agoDon't detour through sc->sc_ue when we have a direct pointer to ue in hand
ian [Mon, 20 May 2019 22:04:01 +0000 (22:04 +0000)]
Don't detour through sc->sc_ue when we have a direct pointer to ue in hand
already.  Also, shorten a variable name for nicer line-wrapping.

No functional changes.

5 years agoUse the new usb fdt support functions to locate the proper fdt node for
ian [Mon, 20 May 2019 21:45:00 +0000 (21:45 +0000)]
Use the new usb fdt support functions to locate the proper fdt node for
the device instance, and to get the MAC address for the device instance.
The ad-hoc code this replaces could find the wrong instance if multiple
devices were present.

5 years agoHook DEFINE_IFUNC.9 up to the build.
markj [Mon, 20 May 2019 21:23:33 +0000 (21:23 +0000)]
Hook DEFINE_IFUNC.9 up to the build.

Reported by: pluknet
MFC with: r348003

5 years agomips: remove 16-byte alignment from .init and .fini epilogues
emaste [Mon, 20 May 2019 20:48:04 +0000 (20:48 +0000)]
mips: remove 16-byte alignment from .init and .fini epilogues

The .init and .fini epilogues from crtn should be placed immediately
after any instructions in .init and .fini sections from the linked
objects.  Using 16-byte alignment for the epilogues on MIPS was a bug,
but it did not cause any issue with GNU ld as GNU ld (2.17.50) fills the
padding with NOPs.

Current versions of LLD fill any padding between different object files
with trap instructions.  Inserting trap padding prior to the .init/.fini
epilogue is undesriable as the resulting binary will crash at runtime.

The .init and .fini sections in object files linked between crti and
crtn must already be a multiple of the instruction size and so no
alignment directive is required in crtn.  Indeed, other architectures
(except sparc64) do not specify alignment in their crtn implementations.

Reported by: arichardson
Reviewed by: andrew
Event: Waterloo Hackathon 2019
Differential Revision: https://reviews.freebsd.org/D18291

5 years agomuge: update FDT LED configuration
emaste [Mon, 20 May 2019 19:31:49 +0000 (19:31 +0000)]
muge: update FDT LED configuration

Also use LED mode settings from the FDT to set the PHY.
From v3 of the patch submitted in the PR.

I moved the sc_led_modes and sc_led_modes_mask default setting outside
of the #ifdef FDT case.

PR: 237325
Submitted by: Ralf <iz-rpi03@hs-karlsruhe.de>
Reviewed by: ian
MFC after: 2 weeks
MFC with: r348001
Event: Waterloo Hackathon 2019
Differential Revision: https://reviews.freebsd.org/D20325

5 years ago[PowerPC64] stand: fix build using clang 8 as compiler
luporl [Mon, 20 May 2019 19:21:35 +0000 (19:21 +0000)]
[PowerPC64] stand: fix build using clang 8 as compiler

This change fixes "stand" build issues when using clang 8
as compiler.

Submitted by:   alfredo.junior_eldorado.org.br
Reviewed by:    jhibbits
Differential Revision: https://reviews.freebsd.org/D20026

5 years agokcov depends on eventhandler.h.
markj [Mon, 20 May 2019 19:14:07 +0000 (19:14 +0000)]
kcov depends on eventhandler.h.

MFC after: 3 days

5 years agoAdd a man page for DEFINE_IFUNC.
markj [Mon, 20 May 2019 19:12:29 +0000 (19:12 +0000)]
Add a man page for DEFINE_IFUNC.

Reviewed by: kib
Discussed with: emaste
MFC after: 2 weeks
Event: Waterloo Hackathon 2019
Differential Revision: https://reviews.freebsd.org/D20310

5 years agoTypo.
markj [Mon, 20 May 2019 19:08:55 +0000 (19:08 +0000)]
Typo.

MFC after: 3 days

5 years agomuge: configure LEDs per dtb (for Raspberry Pi 3B+)
emaste [Mon, 20 May 2019 18:41:07 +0000 (18:41 +0000)]
muge: configure LEDs per dtb (for Raspberry Pi 3B+)

Also apply some style(9) and remove the message about EEPROM configuration
(if there's an EEPROM the hardware handles LED configuration itself).

PR: 237325
Reviewed by: ian
MFC after: 2 weeks
Submitted by: Ralf <iz-rpi03@hs-karlsruhe.de>

5 years agoImprove tree(3) tests by using ATF_REQUIRE where applicable.
trasz [Mon, 20 May 2019 18:35:23 +0000 (18:35 +0000)]
Improve tree(3) tests by using ATF_REQUIRE where applicable.

MFC after: 2 weeks
Sponsored by: Klara Inc.

5 years agoInstall missing data file for
lwhsu [Mon, 20 May 2019 18:07:45 +0000 (18:07 +0000)]
Install missing data file for
lib.libarchive.functional_test.test_read_format_zip_utf8_paths

MFC after: 2 weeks (with r347989)
Sponsored by: The FreeBSD Foundation

5 years ago[mediatek] Add support for non-flash devices on the SPI bus of the Mediatek SoCs.
adrian [Mon, 20 May 2019 17:43:58 +0000 (17:43 +0000)]
[mediatek] Add support for non-flash devices on the SPI bus of the Mediatek SoCs.

The existing SPI support only worked for directly attached flash chips.
it didn't implement clock programming or chipselect.  It also supports
transfers with unbalanced tx/rx command sizes.

Submitted by: <yamori813@yahoo.co.jp>
Differential Revision: https://reviews.freebsd.org/D20101

5 years agoReplace uses of `foo.(de|en)code('hex')` with `binascii.(un)?hexlify(foo)`
ngie [Mon, 20 May 2019 16:38:12 +0000 (16:38 +0000)]
Replace uses of `foo.(de|en)code('hex')` with `binascii.(un)?hexlify(foo)`

Python 3 no longer doesn't support encoding/decoding hexadecimal numbers using
the `str.format` method. The backwards compatible new method (using the
binascii module/methods) is a comparable means of converting to/from
hexadecimal format.

In short, the functional change is the following:
* `foo.decode('hex')` -> `binascii.unhexlify(foo)`
* `foo.encode('hex')` -> `binascii.hexlify(foo)`

While here, move the dpkt import in `cryptodev.py` down per PEP8, so it comes
after the standard library provided imports.

PR: 237403
MFC after: 1 week

5 years ago[PPC] Enable build/install of ld.bfd on base
luporl [Mon, 20 May 2019 16:00:32 +0000 (16:00 +0000)]
[PPC] Enable build/install of ld.bfd on base

When using LLVM+clang+lld on PowerPC64, ld.bfd is also needed,
to link 32-bit binaries correctly, as lld support for 32-bit is
still minimal.

This change enables it to be built and installed when lld is used.

Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D20259

5 years agoMFV r347989:
mm [Mon, 20 May 2019 12:57:39 +0000 (12:57 +0000)]
MFV r347989:
Sync libarchive with vendor.

Relevant vendor changes:
  Issue #795: XAR - do not try to add xattrs without an allocated name
  PR #812: non-recursive option for extract and list
  PR #958: support reading metadata from compressed files
  PR #999: add --exclude-vcs option to bsdtar
  Issue #1062: treat empty archives with a GNU volume header as valid
  PR #1074: Handle ZIP files with trailing 0s in the extra fields
            (Android APK archives)
  PR #1109: Ignore padding in Zip extra field data (Android APK archives)
  PR #1167: fix problems related to unreadable directories
  Issue #1168: fix handling of strtol() and strtoul()
  PR #1172: RAR5 - fix invalid window buffer read in E8E9 filter
  PR #1174: ZIP reader - fix of MSZIP signature parsing
  PR #1175: gzip filter - fix reading files larger than 4GB from memory
  PR #1177: gzip filter - fix memory leak with repeated header reads
  PR #1180: ZIP reader - add support for Info-ZIP Unicode Path Extra Field
  PR #1181: RAR5 - fix merge_block() recursion
            (OSS-Fuzz 12999, 13029, 13144, 13478, 13490)
  PR #1183: fix memory leak when decompressing ZIP files with LZMA
  PR #1184: fix RAR5 OSS-Fuzz issues 12466, 14490, 14491, 12817
    OSS-Fuzz 12466: RAR5 - fix buffer overflow when parsing huffman tables
    OSS-Fuzz 14490, 14491: RAR5 - fix bad shift-left operations
    OSS-Fuzz 12817: RAR5 - handle a case with truncated huffman tables
  PR #1186: RAR5 - fix invalid type used for dictionary size mask
            (OSS-Fuzz 14537)
  PR #1187: RAR5 - fix integer overflow (OSS-Fuzz 14555)
  PR #1190: RAR5 - RAR5 don't try to unpack entries marked as directories
            (OSS-Fuzz 14574)
  PR #1196: RAR5 - fix a potential SIGSEGV on 32-bit builds
  OSS-Fuzz 2582: RAR - fix use after free if there is an invalid entry
  OSS-Fuzz 14331: RAR5 - fix maximum owner name length
  OSS-Fuzz 13965: RAR5 - use unsigned int for volume number + range check

  Additional RAR5 reader changes:
    - support symlinks, hardlinks, file owner, file group, versioned files
    - change ARCHIVE_FORMAT_RAR_V5 to 0x100000
    - set correct mode for readonly directories
    - support readonly, hidden and system Windows file attributes

MFC after: 2 weeks

5 years agoUpdate vendor/libarchive/dist to git b5818e39e128eca4951e2ab10467d4d850a2ba57
mm [Mon, 20 May 2019 12:32:00 +0000 (12:32 +0000)]
Update vendor/libarchive/dist to git b5818e39e128eca4951e2ab10467d4d850a2ba57

Relevant vendor changes:
Issue #795: XAR - do not try to add xattrs without an allocated name
PR #812: non-recursive option for extract and list
PR #958: support reading metadata from compressed files
PR #999: add --exclude-vcs option to bsdtar
Issue #1062: treat empty archives with a GNU volume header as valid
PR #1074: Handle ZIP files with trailing 0s in the extra fields
          (Android APK archives)
PR #1109: Ignore padding in Zip extra field data (Android APK archives)
PR #1167: fix problems related to unreadable directories
Issue #1168: fix handling of strtol() and strtoul()
PR #1172: RAR5 - fix invalid window buffer read in E8E9 filter
PR #1174: ZIP reader - fix of MSZIP signature parsing
PR #1175: gzip filter - fix reading files larger than 4GB from memory
PR #1177: gzip filter - fix memory leak with repeated header reads
PR #1180: ZIP reader - add support for Info-ZIP Unicode Path Extra Field
PR #1181: RAR5 - fix merge_block() recursion
          (OSS-Fuzz 12999, 13029, 13144, 13478, 13490)
PR #1183: fix memory leak when decompressing ZIP files with LZMA
PR #1184: fix RAR5 OSS-Fuzz issues 12466, 14490, 14491, 12817
  OSS-Fuzz 12466: RAR5 - fix buffer overflow when parsing huffman tables
  OSS-Fuzz 14490, 14491: RAR5 - fix bad shift-left operations
  OSS-Fuzz 12817: RAR5 - handle a case with truncated huffman tables
PR #1186: RAR5 - fix invalid type used for dictionary size mask
          (OSS-Fuzz 14537)
PR #1187: RAR5 - fix integer overflow (OSS-Fuzz 14555)
PR #1190: RAR5 - RAR5 don't try to unpack entries marked as directories
          (OSS-Fuzz 14574)
PR #1196: RAR5 - fix a potential SIGSEGV on 32-bit builds
OSS-Fuzz 2582: RAR - fix use after free if there is an invalid entry
OSS-Fuzz 14331: RAR5 - fix maximum owner name length
OSS-Fuzz 13965: RAR5 - use unsigned int for volume number + range check

Additional RAR5 reader changes:
  - support symlinks, hardlinks, file owner, file group, versioned files
  - change ARCHIVE_FORMAT_RAR_V5 to 0x100000
  - set correct mode for readonly directories
  - support readonly, hidden and system Windows file attributes

NOTE: a version bump of libarchive will happen in the following days

5 years agoUpdate loader size on powerpc isos
jhibbits [Mon, 20 May 2019 03:35:14 +0000 (03:35 +0000)]
Update loader size on powerpc isos

Summary:
loader has grown to the point it's overflowing the existing 307200 bytes
allocated to it in the HFS boot partition on the isos.

Bump the space reservation up to 500k.

Submitted by: Brandon Bergren
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20301

5 years agoksyms: Fixup symbols for powerpc in the kernel, not just modules
jhibbits [Mon, 20 May 2019 02:41:09 +0000 (02:41 +0000)]
ksyms: Fixup symbols for powerpc in the kernel, not just modules

Summary:
PowerPC kernels are fully position independent, just like kernel modules.
The same fixups that are done for modules therefore need to be done to the
kernel, else symbol resolution in, e.g., DTrace, cannot resolve the kernel
symbols, so only addresses in the kernel are printed, while kernel module
symbols are printed.

Test Plan:
Run lockstat on powerpc64.  Note symbols are resolved for kernel and
modules.

Reviewed By: markj
Differential Revision: https://reviews.freebsd.org/D20316

5 years agoExtract eventfilter declarations to sys/_eventfilter.h
cem [Mon, 20 May 2019 00:38:23 +0000 (00:38 +0000)]
Extract eventfilter declarations to sys/_eventfilter.h

This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h"
in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header
pollution substantially.

EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c
files into appropriate headers (e.g., sys/proc.h, powernv/opal.h).

As a side effect of reduced header pollution, many .c files and headers no
longer contain needed definitions.  The remainder of the patch addresses
adding appropriate includes to fix those files.

LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by
sys/mutex.h since r326106 (but silently protected by header pollution prior
to this change).

No functional change (intended).  Of course, any out of tree modules that
relied on header pollution for sys/eventhandler.h, sys/lock.h, or
sys/mutex.h inclusion need to be fixed.  __FreeBSD_version has been bumped.

5 years agoFix rt_ifa selection during loopback route insertion process.
melifaro [Sun, 19 May 2019 21:49:56 +0000 (21:49 +0000)]
Fix rt_ifa selection during loopback route insertion process.
  Currently such routes are added with a link-level IFA, which is
  plain wrong. Only after the insertion they get fixed by the special
  link_rtrequest() ifa handler. This behaviour complicates routing code
  and makes ifa selection more complex.
Streamline this process by explicitly moving link_rtrequest() logic
  to the pre-insertion rt_getifa_fib() ifa selector. Avoid calling all
  this logic in the loopback route case by explicitly specifying
  proper rt_ifa inside the ifa_maintain_loopback_route().§

MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20076

5 years agolibsecureboot: allow control of when pseudo pcr is updated
sjg [Sun, 19 May 2019 20:28:49 +0000 (20:28 +0000)]
libsecureboot: allow control of when pseudo pcr is updated

During boot we only want to measure things which *must*
be verified - this should provide more deterministic ordering.

Reviewed by: stevek
MFC after: 1 week
Sponsored by: Juniper Networks
Differential Revision: https://reviews.freebsd.org/D20297

5 years agoload_key_buf do not free data from dearmor
sjg [Sun, 19 May 2019 20:24:17 +0000 (20:24 +0000)]
load_key_buf do not free data from dearmor

The data returned by dearmor is referenced by the key
leave it alone!

Reviewed by: stevek
MFC after: 2 days

5 years agoTo avoid unnecessarily modifying ports, add a -lgomp symlink, since GCC
dim [Sun, 19 May 2019 20:13:55 +0000 (20:13 +0000)]
To avoid unnecessarily modifying ports, add a -lgomp symlink, since GCC
does not ship a -lomp symlink.  Also update OptionalObsoleteFiles for
this, and add 32-bit variants while here.

Submitted by: jbeich
PR: 237975
MFC after: 3 days

5 years agoFix OptionalObsoleteFiles copy/paste mistake from r345236, which
dim [Sun, 19 May 2019 19:42:35 +0000 (19:42 +0000)]
Fix OptionalObsoleteFiles copy/paste mistake from r345236, which
connected libomp to the build.  The comparison should not have been
against ${MK_OPENSSH}, but against ${MK_OPENMP}, obviously.

MFC after: 3 days

5 years agoAllow sending on demand SCTP HEARTBEATS only in the ESTABLISHED state.
tuexen [Sun, 19 May 2019 17:53:36 +0000 (17:53 +0000)]
Allow sending on demand SCTP HEARTBEATS only in the ESTABLISHED state.
This issue was found by running syzkaller.

MFC after: 3 days

5 years agoImprove input validation for the IPPROTO_SCTP level socket options
tuexen [Sun, 19 May 2019 17:28:00 +0000 (17:28 +0000)]
Improve input validation for the IPPROTO_SCTP level socket options
SCTP_CONNECT_X and SCTP_CONNECT_X_DELAYED.

Some issues where found by running syzkaller.

MFC after: 3 days

5 years agoAdd common support functions for USB devices configured via FDT data.
ian [Sun, 19 May 2019 16:56:59 +0000 (16:56 +0000)]
Add common support functions for USB devices configured via FDT data.

FDT data is sometimes used to configure usb devices which are hardwired into
an embedded system. Because the devices are instantiated by the usb
enumeration process rather than by ofwbus iterating through the fdt data, it
is somewhat difficult for a usb driver to locate fdt data that belongs to
it. In the past, various ad-hoc methods have been used, which can lead to
errors such applying configuration that should apply only to a hardwired
device onto a similar device attached by the user at runtime. For example,
if the user adds an ethernet device that uses the same driver as the builtin
ethernet, both devices might end up with the same MAC address.

These changes add a new usb_fdt_get_node() helper function that a driver can
use to locate FDT data that belongs to a single unique instance of the
device. This function locates the proper FDT data using the mechanism
detailed in the standard "usb-device.txt" binding document [1].

There is also a new usb_fdt_get_mac_addr() function, used to retrieve the
mac address for a given device instance from the fdt data. It uses
usb_fdt_get_node() to locate the right node in the FDT data, and attempts to
obtain the mac-address or local-mac-address property (in that order, the
same as linux does it).

The existing if_smsc driver is modified to use the new functions, both as an
example and for testing the new functions. Rpi and rpi2 boards use this
driver and provide the mac address via the fdt data.

[1] https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/usb/usb-device.txt

Differential Revision: https://reviews.freebsd.org/D20262