]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
7 years agoMFC r316530, r316535
asomers [Wed, 26 Apr 2017 14:50:06 +0000 (14:50 +0000)]
MFC r316530, r316535

r316530:
Fix clearing geom metadata if DIOCGSECTORSIZE fails

An unhandled error case would result in passing SIZE_MAX to malloc.
While I'm here, remove an unnecessary NULL check before free

Reported by: Coverity
CID: 1017793
Sponsored by: Spectra Logic Corp

r316535:
Fix memory leak in "gpart bootcode"

Also, annotate that gpart_issue never returns

Reported by: Coverity
CID: 1007105
Sponsored by: Spectra Logic Corp

7 years agoMFC r316501, r316523
asomers [Wed, 26 Apr 2017 14:44:39 +0000 (14:44 +0000)]
MFC r316501, r316523

r316501:
Fix file descriptor and memory leaks in pr(1)

Also, hook NetBSD's pr test into the build, and add three more test cases.

Reported by: Coverity, Valgrind
CID: 271650 271651 271652 271653 271654 271655 271656 271656
CID: 271657 271658 271659 1006939 1006940 1006941 1006942 1009098
Reviewed by: ngie
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D9137

r316523:
Remove a duplicate fclose() that snuck into r316501

Reported by: Coverity
CID: 1373338
X-MFC-With: 316501
Sponsored by: Spectra Logic Corp

7 years agoMFC r316500:
asomers [Wed, 26 Apr 2017 14:43:21 +0000 (14:43 +0000)]
MFC r316500:

strcpy => strlcpy, strcat => strlcat

Reported by: Coverity
CID: 1006703 978863 1006745 1347163
Reviewed by: cem
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D10192

7 years agoMFC r316810, r316814, r316816, r316991:
cy [Wed, 26 Apr 2017 02:37:25 +0000 (02:37 +0000)]
MFC r316810, r316814, r316816, r316991:

Keep state incorrectly assumes keep frags. This is counter to the
ipfilter man pages. This also currently restricts keep frags to only when
keep state is used, which is redundant because keep state currently
assumes keep frags. This commit fixes this.

To the user this change means that to maintain the current behaviour
one must add keep frags to any ipfilter keep state rule (as documented
in the man pages).

This patch also allows the flexability to specify and use keep frags
separate from keep state, as documented in an example in ipf.conf.5,
instead of the currently broken behaviour.

MFC suggested by: rgrimes
Relnotes: yes

7 years agoMFC: r316692
rmacklem [Tue, 25 Apr 2017 23:43:37 +0000 (23:43 +0000)]
MFC: r316692
Set initial values for nfsstatfs in the NFSv4 client.

The AmazonEFS NFSv4.1 server does not support the FILES_FREE and FILES_TOTAL
attributes. As such, an NFSv4.1 mount to the server would return garbage
for these values. This patch initializes the fields of the nfsstatfs structure,
so that "df" and friends will at least return consistent bogus values.

7 years agoMFC: r316669
rmacklem [Tue, 25 Apr 2017 20:24:00 +0000 (20:24 +0000)]
MFC: r316669
Avoid starvation of the server crash recovery thread for the NFSv4 client.

This patch gives a requestor of the exclusive lock on the client state
in the NFSv4 client priority over shared lock requestors. This avoids
the server crash recovery thread being starved out by other threads doing
RPCs.

7 years agoMFC: r316667
rmacklem [Tue, 25 Apr 2017 19:14:31 +0000 (19:14 +0000)]
MFC: r316667
Fix the NFSv4 client hndling of a stale write verifier in the Commit operation.

When the NFSv4 client Commit operation encountered a stale write verifier,
it erroneously mapped that to EIO. This could have caused recently written
data to be lost when a server crashes/reboots between an UNSTABLE write
and the subsequent commit. This patch fixes this.
The bug was only for the NFSv4 client and did not affect NFSv3.

7 years agoMFC: r316666
rmacklem [Tue, 25 Apr 2017 19:02:34 +0000 (19:02 +0000)]
MFC: r316666
Fix the NFSv4.1 client for NFSERR_BADSESSION recovery via ReclaimComplete.

For the ReclaimComplete operation, the RPC layer should not loop on
NFSERR_BADSESSION. If it does, the recovery thread (nfscl) can get stuck
looping and will not do a recovery.
This patch fixes it so it does not loop. This bug only affects NFSv4.1 and
only when a server reboots.

7 years agoMFC r316698:
kib [Tue, 25 Apr 2017 13:07:06 +0000 (13:07 +0000)]
MFC r316698:
Remove debugging printf.

7 years agoMFC: r316655
rmacklem [Tue, 25 Apr 2017 11:59:23 +0000 (11:59 +0000)]
MFC: r316655
Fix parsing failure for NFSv4 Setattr operation for failed case.

If an operation that preceeds a Setattr in an NFSv4 compound fails,
there is no bitmap of attributes to parse. Without this patch, the
parsing would fail and return EBADRPC instead of the correct failure
error. This could break recovery from a server crash/reboot.

7 years agoMFC r316699:
ae [Tue, 25 Apr 2017 11:19:22 +0000 (11:19 +0000)]
MFC r316699:
  Do not adjust interface MTU automatically. Leave this task to the system
  administrator.

  Before r274246 interface MTU was adjusted only when GRE key is configured.
  The r274246 has changed this behavior to automatically adjust MTU when any
  option, that changes the size of GRE header is configured.
  This patch removes automatic MTU adjustment from if_gre(4) and if_me(4),
  and restores the behavior that was prior to r274246.

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

7 years agoMFC r317273 (by cem):
markj [Tue, 25 Apr 2017 00:00:34 +0000 (00:00 +0000)]
MFC r317273 (by cem):
fuse: Implement FOPEN_KEEP_CACHE flag

7 years agoMFC: r310491
rmacklem [Mon, 24 Apr 2017 23:47:12 +0000 (23:47 +0000)]
MFC: r310491
Fix NFSv4.1 client recovery from NFS4ERR_BAD_SESSION errors.

For most NFSv4.1 servers, a NFS4ERR_BAD_SESSION error is a rare failure
that indicates that the server has lost session/open/lock state.
However, recent testing by cperciva@ against the AmazonEFS server found
several problems with client recovery from this due to it generating this
failure frequently.
Briefly, the problems fixed are:
- If all session slots were in use at the time of the failure, some processes
  would continue to loop waiting for a slot on the old session forever.
- If an RPC that doesn't use open/lock state failed with NFS4ERR_BAD_SESSION,
  it would fail the RPC/syscall instead of initiating recovery and then
  looping to retry the RPC.
- If a successful reply to an RPC for an old session wasn't processed
  until after a new session was created for a NFS4ERR_BAD_SESSION error,
  it would erroneously update the new session and corrupt it.
- The use of the first element of the session list in the nfs mount
  structure (which is always the current metadata session) was slightly
  racey. With changes for the above problems it became more racey, so all
  uses of this head pointer was wrapped with a NFSLOCKMNT()/NFSUNLOCKMNT().
- Although the kernel malloc() usually allocates more bytes than requested
  and, as such, this wouldn't have caused problems, the allocation of a
  session structure was 1 byte smaller than it should have been.
  (Null termination byte for the string not included in byte count.)

There are probably still problems with a pNFS data server that fails
with NFS4ERR_BAD_SESSION, but I have no server that does this to test
against (the AmazonEFS server doesn't do pNFS), so I can't fix these yet.

Although this patch is fairly large, it should only affect the handling
of NFS4ERR_BAD_SESSION error replies from an NFSv4.1 server.
Thanks go to cperciva@ for the extension testing he did to help isolate/fix
these problems.

7 years agoMFC r316768:
brooks [Mon, 24 Apr 2017 22:37:54 +0000 (22:37 +0000)]
MFC r316768:

Fix an out-of-bounds write when a zero-length buffer is passed.

Found with ttyname_test and CHERI bounds checking.

Reviewed by: emaste
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL

7 years agoMFC r316766:
brooks [Mon, 24 Apr 2017 21:35:02 +0000 (21:35 +0000)]
MFC r316766:

Correct an out of bounds read with HN_AUTOSCALE and very large numbers.

The maximum scale is 6 (K, M, G, T, P, E) (B is 0).

Overly large explict scales were checked correctly, but for sufficently
large numbers HN_AUTOSCALE would get to 7 resulting in an out of bounds
read.

Found with humanize_number_test and CHERI bounds checking.

Reviewed by: emaste
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL

7 years agoMFC r302788, r303026, r305471
andrew [Mon, 24 Apr 2017 16:49:30 +0000 (16:49 +0000)]
MFC r302788, r303026, r305471

r302788:
Fix the type used to hold the value returned from getopt. On arm64 char is
unsigned so will never be -1.

r303026:
Add missing flags from acpidump. These are defined in the header, but not
printed. The HW_REDUCED flag is useful as it should be set on arm64 to
comply with the ARM Server Base Boot Requirements.

r305471:
Teach acpidump how to parse ACPI 5.1 tables found on the development
ThunderX units in the netperf cluster.

7 years agoMFC r312558:
asomers [Mon, 24 Apr 2017 16:07:30 +0000 (16:07 +0000)]
MFC r312558:

Misc Coverity fixes in camcontrol(8)

CID 1229913 Fix output of "camcontrol persist -i report_capabilities".
The reported Persistent Reservation Types were wrong in all
cases.
CID 1356029 Annotate the code so Coverity will know that this is a false
positive.
CID 1366830 Fix a memory leak in "camcontrol timestamp -s"
CID 1366832 Fix a segfault that could be caused by bad drive firmware

Also, fix the man page entry for the "camcontrol epc state" command to match
what the code does.

Reviewed by: ken, wblock
MFC after: 4 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D9239

7 years agoMFC r316342, r316358
asomers [Mon, 24 Apr 2017 15:29:17 +0000 (15:29 +0000)]
MFC r316342, r316358

r316342:
Consolidate random sleeps in periodic scripts

Multiple periodic scripts sleep for a random amount of time in order to
mitigate the thundering herd problem. This is bad, because the sum of
multiple uniformly distributed random variables approaches a normal
distribution, so the problem isn't mitigated as effectively as it would be
with a single sleep.

This change creates a single configurable anticongestion sleep. periodic
will only sleep if at least one script requires it, and it will never sleep
more than once per invocation. It also won't sleep if periodic was run
interactively, fixing an unrelated longstanding bug.

PR: 217055
PR: 210188
Reviewed by: cy
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D10211

r316358:
Fix man page typo from r316342

Reported by: rgrimes
MFC after: 20 days
X-MFC-With: 316342

7 years agoMFC r316676:
smh [Mon, 24 Apr 2017 11:34:02 +0000 (11:34 +0000)]
MFC r316676:

Use estimated RTT for receive buffer auto resizing instead of timestamps

Relnotes: Yes
Sponsored by: Multiplay

7 years agoMFC r315913: Add brackets to fix incorrect macro expansion.
mav [Mon, 24 Apr 2017 11:12:03 +0000 (11:12 +0000)]
MFC r315913: Add brackets to fix incorrect macro expansion.

7 years agoMFC r315908: Unify initiator and target DMA setup and command sending.
mav [Mon, 24 Apr 2017 10:21:13 +0000 (10:21 +0000)]
MFC r315908: Unify initiator and target DMA setup and command sending.

The code is so alike that it is pointless to keep it separate.

7 years agoMFC r315870: isp field in struct isp_pcmd is also unused.
mav [Mon, 24 Apr 2017 10:20:36 +0000 (10:20 +0000)]
MFC r315870: isp field in struct isp_pcmd is also unused.

7 years agoMFC r315869: Remove write-only crn field from struct isp_pcmd.
mav [Mon, 24 Apr 2017 10:19:59 +0000 (10:19 +0000)]
MFC r315869: Remove write-only crn field from struct isp_pcmd.

7 years agoMFC r315708: Cleanup response queue processing.
mav [Mon, 24 Apr 2017 10:19:26 +0000 (10:19 +0000)]
MFC r315708: Cleanup response queue processing.

7 years agoMFC r316679:
kib [Mon, 24 Apr 2017 07:52:44 +0000 (07:52 +0000)]
MFC r316679:
Do not lose dirty bits for removing PROT_WRITE on arm64.

7 years agoMFC r316677: Do not register in CTL portal groups without portals.
mav [Mon, 24 Apr 2017 06:32:35 +0000 (06:32 +0000)]
MFC r316677: Do not register in CTL portal groups without portals.

From config synthax point of view such portal groups are not incorrect,
but they are useless since can not receive any connection.  And since
CTL port resource is very limited, it is good to save it.

7 years agoMFC r316213:
kib [Sun, 23 Apr 2017 20:32:46 +0000 (20:32 +0000)]
MFC r316213:
Implement the memset_s(3) function as specified by the C11 ISO/IEC
9899:2011 Appendix K 3.7.4.1.

MFC r316258:
Only activate __EXT1_VISIBLE block when using sys/errno.h in userspace.

7 years agoMFC r316657:
bcr [Sun, 23 Apr 2017 10:29:09 +0000 (10:29 +0000)]
MFC r316657:

Make setkey(8) more clear about anti-replay window size option semantics.

PR: 172913
Submitted by: john@saltant.com
Reviewed by: ae@
Differential Revision:  https://reviews.freebsd.org/D10304

7 years agoMFC r314290: Implement use of multiple transfers per I/O.
mav [Sun, 23 Apr 2017 09:01:40 +0000 (09:01 +0000)]
MFC r314290: Implement use of multiple transfers per I/O.

This change removes limitation of single S/G list entry and limitation on
maximal I/O size, using multiple data transfers per I/O if needed.  Also
it removes code duplication between send and receive paths, which are now
completely equal.

7 years agoMFC r314256: Use ctl_queue_sense() to implement sense data reporting.
mav [Sun, 23 Apr 2017 09:01:01 +0000 (09:01 +0000)]
MFC r314256: Use ctl_queue_sense() to implement sense data reporting.

USB MS BBB transport does not support autosense, so we have to queue any
sense data back to CTL for later fetching via REQUEST SENSE.

7 years agoMFC r314254: Update kern_data_resid according to r312291.
mav [Sun, 23 Apr 2017 09:00:26 +0000 (09:00 +0000)]
MFC r314254: Update kern_data_resid according to r312291.

This now mandatory for correct operation.

7 years agoMFC r317186
kp [Sun, 23 Apr 2017 08:58:50 +0000 (08:58 +0000)]
MFC r317186

pf: Fix possible incorrect IPv6 fragmentation

When forwarding pf tracks the size of the largest fragment in a fragmented
packet, and refragments based on this size.
It failed to ensure that this size was a multiple of 8 (as is required for all
but the last fragment), so it could end up generating incorrect fragments.

For example, if we received an 8 byte and 12 byte fragment pf would emit a first
fragment with 12 bytes of payload and the final fragment would claim to be at
offset 8 (not 12).

We now assert that the fragment size is a multiple of 8 in ip6_fragment(), so
other users won't make the same mistake.

Reported by: Antonios Atlasis <aatlasis at secfu net>

7 years agoMFC r316589:
trasz [Sun, 23 Apr 2017 08:45:55 +0000 (08:45 +0000)]
MFC r316589:

Unify capitalization.

7 years agoMFC r316587:
trasz [Sun, 23 Apr 2017 08:44:50 +0000 (08:44 +0000)]
MFC r316587:

Update hier(7) by removing files and directories that no longer
exist and doing a few random tweaks.

7 years agoMFC r316467:
trasz [Sun, 23 Apr 2017 08:43:45 +0000 (08:43 +0000)]
MFC r316467:

Add basic description of kernel source layout.

7 years agoMFC r316466:
trasz [Sun, 23 Apr 2017 08:41:58 +0000 (08:41 +0000)]
MFC r316466:

Remove excessive horizontal whitespace from hier(7) by correctly
using "-width". The http://mdocml.bsd.lv/mdoc/details/width.html
says: "Do not use macros in the argument specifying the width,
that's not portable. While GNU troff can handle it, mandoc cannot."
The same problem seems to exist in many other man pages.

7 years agoMFC r316468:
trasz [Sun, 23 Apr 2017 08:40:34 +0000 (08:40 +0000)]
MFC r316468:

Fix typo.

Sponsored by: DARPA, AFRL

7 years agoMFC r316057:
trasz [Sun, 23 Apr 2017 08:39:46 +0000 (08:39 +0000)]
MFC r316057:

Document EVENTHANDLER_DEFINE(9).

Sponsored by: DARPA, AFRL

7 years agoMFC r316056:
trasz [Sun, 23 Apr 2017 08:38:47 +0000 (08:38 +0000)]
MFC r316056:

The cn_consume was removed in r296716.

Sponsored by: DARPA, AFRL

7 years agoMFC r315560:
trasz [Sun, 23 Apr 2017 08:36:29 +0000 (08:36 +0000)]
MFC r315560:

Document how to use reroot with NFS.

Sponsored by: DARPA, AFRL

7 years agoMFC r316652: Fix few minor issues found by Clang Analyzer.
mav [Sun, 23 Apr 2017 07:36:44 +0000 (07:36 +0000)]
MFC r316652: Fix few minor issues found by Clang Analyzer.

7 years agoMFC r316653: Fix few minor issues found by Clang Analyzer.
mav [Sun, 23 Apr 2017 07:35:10 +0000 (07:35 +0000)]
MFC r316653: Fix few minor issues found by Clang Analyzer.

7 years agoMFC r315506:
dchagin [Sun, 23 Apr 2017 06:45:21 +0000 (06:45 +0000)]
MFC r315506:

Glibc get_nprocs() and get_nprocs_conf() uses the sysfs cpu infrastructure
to get number of processors. Implement /sys/devices/system/cpu/.

7 years agoMFC r315505:
dchagin [Sun, 23 Apr 2017 06:43:52 +0000 (06:43 +0000)]
MFC r315505:

Implement getrandom() syscall.
Note. GRND_RANDOM option is not supported for now.

7 years agoMFC r316993, r316994, r316997 as follows:
cy [Sun, 23 Apr 2017 03:16:38 +0000 (03:16 +0000)]
MFC r316993, r316994, r316997 as follows:

r316993:

Fix CID 1372601 in ipfilter/lib/parsefields.c, possible NULL pointer
dereference should reallocarray() fail.

Reported by: Coverity CID 1372601

r316994:

Fix CID 1372600 in ipfilter/tools/ipf_y.y, possible NULL pointer
dereference should reallocarray() fail.

Reported by: Coverity CID 1372600

r316997:

Use warnx() to issue error message.

Reported by: cem

7 years agoMFC: r314694
rgrimes [Sat, 22 Apr 2017 22:05:23 +0000 (22:05 +0000)]
MFC: r314694

  Make vmrun.sh passthrough -u and -w to bhybe

PR: 214273
Submitted by: Martin Birgmeier <la5lb...@aon.at>
Approved by: grehan (mentor)

7 years agoMFC r314691:
rgrimes [Sat, 22 Apr 2017 21:49:59 +0000 (21:49 +0000)]
MFC r314691:

Document 3 more src/ directories

Approved by: grehan (mentor)

7 years agoMFC r316065: Enable route and LLE (ndp) caching in TCP/IPv6
karels [Sat, 22 Apr 2017 18:55:25 +0000 (18:55 +0000)]
MFC r316065: Enable route and LLE (ndp) caching in TCP/IPv6

tcp_output.c was using a route on the stack for IPv6, which does not
allow route caching or LLE/ndp caching. Switch to using the route
(v6 flavor) in the in_pcb, which was already present, which caches
both L3 and L2 lookups.

Reviewed by: gnn hiren

7 years agoMFC r302664:
pfg [Fri, 21 Apr 2017 20:03:08 +0000 (20:03 +0000)]
MFC r302664:
mkimg(1): minor cleanups with argument order in calloc(3).

Generally the first argument in calloc is supposed to stand for a count
and the second for a size. Try to make that consistent. While here,
attempt to make some use of the overflow detection capability in
calloc(3).

Requested by: manu

7 years agoDocument EN-17:01 through EN-17:05, SA-16:39 through SA-17:03
gjb [Fri, 21 Apr 2017 19:41:33 +0000 (19:41 +0000)]
Document EN-17:01 through EN-17:05, SA-16:39 through SA-17:03

Sponsored by: The FreeBSD Foundation

7 years agoMFC r316824:
ae [Fri, 21 Apr 2017 17:09:37 +0000 (17:09 +0000)]
MFC r316824:
  The rule field in the ipfw_dyn_rule structure is used as storage
  to pass rule number and rule set to userland. In r272840 the kernel
  internal rule representation was changed and the rulenum field of
  struct ip_fw_rule got the type uint32_t, but userlevel representation
  still have the type uint16_t. To not overflow the size of pointer
  on the systems with 32-bit pointer size use separate variable to
  copy rulenum and set.

  Reported by: PVS-Studio

7 years agoMFC r316989:
dim [Fri, 21 Apr 2017 17:03:48 +0000 (17:03 +0000)]
MFC r316989:

Pull in r300404 from upstream llvm trunk (by me):

  Use correct registers for "A" inline asm constraint

  Summary:
  In PR32594, inline assembly using the 'A' constraint on x86_64 causes
  llvm to crash with a "Cannot select" stack trace.  This is because
  `X86TargetLowering::getRegForInlineAsmConstraint` hardcodes that 'A'
  means the EAX and EDX registers.

  However, on x86_64 it means the RAX and RDX registers, and on 16-bit
  x86 (ia16?) it means the old AX and DX registers.

  Add new register classes in `X86RegisterInfo.td` to support these
  cases, and amend the logic in `getRegForInlineAsmConstraint` to cope
  with different subtargets.  Also add a test case, derived from
  PR32594.

  Reviewers: craig.topper, qcolombet, RKSimon, ab

  Reviewed By: ab

  Subscribers: ab, emaste, royger, llvm-commits

  Differential Revision: https://reviews.llvm.org/D31902

This should fix crashes when using the 'A' constraint on amd64, for
example as it is being used in Xen.

Reported by: royger

MFC r317079:

Pull in r300429 from upstream llvm trunk (by Benjamin Kramer):

  [X86] Remove special handling for 16 bit for A asm constraints.

  Our 16 bit support is assembler-only + the terrible hack that is
  .code16gcc. Simply using 32 bit registers does the right thing for
  the latter.

  Fixes PR32681.

This fixes some cases of assembling 16 bit code (i.e. SeaBIOS) that uses
the 'A' inline asm constraint, after r316989.

7 years agoMFC r317100:
gjb [Fri, 21 Apr 2017 16:47:57 +0000 (16:47 +0000)]
MFC r317100:
 Use relative symlink for 'latest' to allow repo to work after being
 moved.

PR: 217197
Sponsored by: The FreeBSD Foundation

7 years agoMFC r310181 (matthew) (originally r309314):
gjb [Fri, 21 Apr 2017 16:47:09 +0000 (16:47 +0000)]
MFC r310181 (matthew) (originally r309314):
 Allow a user-overridable setting 'PKG_CMD' to control the command used
 to create a repo during 'make packages'.

Sponsored by: The FreeBSD Foundation

7 years agoMFC r316770:
ae [Fri, 21 Apr 2017 16:45:43 +0000 (16:45 +0000)]
MFC r316770:
  Clear h/w csum flags on mbuf handled by UDP.

  When checksums of received IP and UDP header already checked, UDP uses
  sbappendaddr_locked() to pass received data to the socket.
  sbappendaddr_locked() uses given mbuf as is, and if NIC supports checksum
  offloading, mbuf contains csum_data and csum_flags that were calculated
  for already stripped headers. Some NICs support only limited checksums
  offloading and do not use CSUM_PSEUDO_HDR flag, and csum_data contains
  some value that UDP/TCP should use for pseudo header checksum calculation.

  When L2TP is used for tunneling with mpd5, ng_ksocket receives mbuf with
  filled csum_flags and csum_data, that were calculated for outer headers.
  When L2TP header is stripped, a packet that was tunneled goes to the IP
  layer and due to presence of csum_flags (without CSUM_PSEUDO_HDR) and
  csum_data, the UDP/TCP checksum check fails for this packet.

  Reported by: Irina Liakh <spell at itl ua>
  Tested by: Irina Liakh <spell at itl ua>

MFC r316822,316823:
  Rework r316770 to make it protocol independent and general, like we
  do for streaming sockets.

  And do more cleanup in the sbappendaddr_locked_internal() to prevent
  leak information from existing mbuf to the one, that will be possible
  created later by netgraph.

  Suggested by: glebius
  Tested by: Irina Liakh <spell at itl ua>

7 years agoMFC r316852:
kib [Fri, 21 Apr 2017 10:13:07 +0000 (10:13 +0000)]
MFC r316852:
In fsck_ffs pass1, prevent the inosused variable from wrapping.

PR: 218592

7 years agoMFC r316851:
kib [Fri, 21 Apr 2017 10:11:08 +0000 (10:11 +0000)]
MFC r316851:
Correct calculation of the entry->free_down in the invariants-checking
code.

7 years agoMFC r316811, r317139:
cy [Fri, 21 Apr 2017 02:02:52 +0000 (02:02 +0000)]
MFC r316811, r317139:

Add missing free()'s after calls to randomize().

PR: NetBSD PR/50559
Obtained from: Netbsd radix_ipf.c r1.6

7 years agoMFC r316809:
cy [Fri, 21 Apr 2017 01:51:49 +0000 (01:51 +0000)]
MFC r316809:

Fix a use after free panic in ipfilter's fragment processing.
Memory is malloc'd, then a search for a match in the fragment table
is made and if the fragment matches, the wrong fragment table is
freed, causing a use after free panic. This commit fixes this.

A symptom of the problem is a kernel page fault in bcopy() called by
ipf_frag_lookup() at line 715 in ip_frag.c. Another symptom is a
kernel page fault in ipf_frag_delete() when called by ipf_frag_expire()
via ipf_slowtimer().

7 years agoMFC r312764:
andrew [Thu, 20 Apr 2017 12:48:01 +0000 (12:48 +0000)]
MFC r312764:
Pull the R_AARCH64_TLSDESC code out into a common function and use them in
both the plt and non-plt case.

This fixes an issue where libraries built with LLD can fail with
"Unhandled relocation 1031"

7 years agoMFC r308569,r308570:
skra [Thu, 20 Apr 2017 11:52:10 +0000 (11:52 +0000)]
MFC r308569,r308570:

  r308569:
    Always call PHYS_TO_VM_PAGE() in is_managed(). Fast road for addresses
    under first_page cannot be taken as this variable is connected only to
    vm_page_array segment. There could be more segments in system like the ones
    for various fictitious page ranges. These can be situated under
    vm_page_array segment and so, they could be skipped before this fix.
    However, as far as I know, there is no report associated with it.
  r308570:
    The return type of is_managed() was changed from boolean_t to bool type in
    r308569. Now, propagate this change further for consistency sake.

7 years agoMFC r316183
davidcs [Thu, 20 Apr 2017 04:26:47 +0000 (04:26 +0000)]
MFC r316183
Upgrade firmware and other related files to version 5.4.64

7 years agoMFC r316533:
bdrewery [Wed, 19 Apr 2017 17:32:32 +0000 (17:32 +0000)]
MFC r316533:

  Support assym.s in DPSRCS to depend on it but not link it in.

7 years agoMFC r316534:
bdrewery [Wed, 19 Apr 2017 17:29:54 +0000 (17:29 +0000)]
MFC r316534:

  Stop building assym.o into the module.

7 years agoMFC r313006 (by cem), r315983 (by bde):
markj [Wed, 19 Apr 2017 16:16:41 +0000 (16:16 +0000)]
MFC r313006 (by cem), r315983 (by bde):
Add an SSE4.2 implementation of crc32 for x86.

7 years agoMFC 313772:
andrew [Wed, 19 Apr 2017 15:59:16 +0000 (15:59 +0000)]
MFC 313772:

Load the new sp_el0 with interrupts disabled in fork_trampoline. If an
interrupt arrives in fork_trampoline after sp_el0 was written we may then
switch to a new thread, enter userland so change this stack pointer, then
return to this code with the wrong value. This fixes this case by moving
the load of sp_el0 until after interrupts have been disabled.

7 years agoMFC 305355:
andrew [Wed, 19 Apr 2017 15:46:34 +0000 (15:46 +0000)]
MFC 305355:

Explicitly include all .rodata.* sections in the kernel .rodata. This
helps link the kernel with lld as it will then put all these into a single
.rodata section.

7 years agoMFC r303442, r305343: remove CONSTRUCTORS from linker scripts
emaste [Wed, 19 Apr 2017 15:33:24 +0000 (15:33 +0000)]
MFC r303442, r305343: remove CONSTRUCTORS from linker scripts

r303442: remove CONSTRUCTORS from kernel linker scripts

r305343: remove CONSTRUCTORS from MIPS uboot linker script

The linker script CONSTRUCTORS keyword is only meaningful "when linking
object file formats which do not support arbitrary sections, such as
ECOFF and XCOFF"[1] and is ignored for other object file formats.

LLVM's lld does not yet accept (and ignore) CONSTRUCTORS, so just remove
CONSTRUCTORS from the linker script as it has no effect.

[1] https://sourceware.org/binutils/docs/ld/Output-Section-Keywords.html

Reported by: andrew
Sponsored by: The FreeBSD Foundation

7 years agoFix the arm64 userland building with lld:
andrew [Wed, 19 Apr 2017 14:07:35 +0000 (14:07 +0000)]
Fix the arm64 userland building with lld:

MFC 308124:
 On arm64 build the efi loader with -fPIC. Without this clang 3.9 will
 generate relocation in the self relocation code.

MFC 316608:
 Add -fPIC to the standalone build flags on arm64. This is needed as
 loader.efi is position independend, however we were not building it as
 such causing a build failure when building with lld.

MFC 315452:
 Mark the EFI PE header as allocated. While ld.bfd doesn't seem to care
 about not having this flag ld.lld fails to link without it.

7 years agoMFC r316532:
kib [Wed, 19 Apr 2017 11:13:32 +0000 (11:13 +0000)]
MFC r316532:
Make nfs pageout coherent with the dirty state of the buffers.

7 years agoMFC r316531:
kib [Wed, 19 Apr 2017 11:11:51 +0000 (11:11 +0000)]
MFC r316531:
Handle nfs IO_ASYNC write requests asynchronously.

7 years agoMFC r316529:
kib [Wed, 19 Apr 2017 11:10:02 +0000 (11:10 +0000)]
MFC r316529:
Handle possible vnode reclamation after ncl_vinvalbuf() call.

7 years agoMFC r316739:
kib [Wed, 19 Apr 2017 10:54:08 +0000 (10:54 +0000)]
MFC r316739:
Fix reporting of _SC_SEM_NSEMS_MAX and _SC_SEM_VALUE_MAX.

7 years agoMFC 316813,316815
sephe [Wed, 19 Apr 2017 03:39:50 +0000 (03:39 +0000)]
MFC 316813,316815

316813
    hyperv/storvsc: Use ULL for 64bits value shift.

    Reported by:    PVS
    Sponsored by:   Microsoft

316815
    hyperv/kvp: Remove always false condition.

    Reported by:    PVS
    Sponsored by:   Microsoft

7 years agoMFC 316515,316812
sephe [Wed, 19 Apr 2017 03:30:37 +0000 (03:30 +0000)]
MFC 316515,316812

316515
    hyperv/kbd: Add support for synthetic keyboard.

    Synthetic keyboard is the only supported keyboard on GEN2 Hyper-V.

    Submitted by:   Hongjiang Zhang <honzhan microsoft com>
    Sponsored by:   Microsoft
    Differential Revision:  https://reviews.freebsd.org/D10196

316812
    hyperv/kbd: Remove unnecessary assignment.

    Reported by:    PVS
    Sponsored by:   Microsoft

7 years agoMFC r316747
davidcs [Wed, 19 Apr 2017 03:18:11 +0000 (03:18 +0000)]
MFC r316747
Fix rss_ind_table entry for num_funcs > 1

7 years agoMFC r316720
davidcs [Wed, 19 Apr 2017 03:13:58 +0000 (03:13 +0000)]
MFC r316720
Fix defects reported by Coverity
  1. Deadcode in ecore_init_cache_line_size(), qlnx_ioctl() and
   qlnx_clean_filters()
  2. ARRAY_VS_SINGLETON issue in qlnx_remove_all_mcast_mac() and
   qlnx_update_rx_prod()

7 years agoMFC r316485
davidcs [Wed, 19 Apr 2017 03:09:20 +0000 (03:09 +0000)]
MFC r316485
  Add 25/40/100Gigabit Ethernet Driver version v1.3.0 for Cavium Inc's.
  Qlogic 45000 Series Adapters

7 years agoMFC r316310
davidcs [Wed, 19 Apr 2017 02:54:59 +0000 (02:54 +0000)]
MFC r316310
Update man page for commit r316309 "Add support for optional Soft LRO".
The driver provides the ability to select either HW or Software LRO, when
LRO is enabled (default HW LRO).

7 years agoMFC r316309
davidcs [Wed, 19 Apr 2017 02:52:55 +0000 (02:52 +0000)]
MFC r316309
Add support for optional Soft LRO

7 years agoMFC 317107
sephe [Wed, 19 Apr 2017 02:48:38 +0000 (02:48 +0000)]
MFC 317107
    hyperv: Use kmem_malloc for hypercall memory due to NX bit change.

    Reported by:    dexuan@
    Sponsored by:   Microsoft

7 years agoMFC r316715:
ae [Tue, 18 Apr 2017 09:27:26 +0000 (09:27 +0000)]
MFC r316715:
  Make sysctl identifiers for direct netisr queue unique.
  Introduce IPCTL_INTRDQMAXLEN and IPCTL_INTRDQDROPS macros for this purpose.

  Reviewed by: gnn
  Differential Revision: https://reviews.freebsd.org/D10358

7 years agoMFC r316716:
ae [Tue, 18 Apr 2017 09:17:20 +0000 (09:17 +0000)]
MFC r316716:
  Inherit IPv6 checksum offloading flags to vlan interfaces.

  if_vlan(4) interfaces inherit IPv4 checksum offloading flags from the
  parent when VLAN_HWCSUM and VLAN_HWTAGGING flags are present on the
  parent interface. Do the same for IPv6 checksum offloading flags.

  Reported by: Harry Schmalzbauer
  Reviewed by: np, gnn
  Differential Revision: https://reviews.freebsd.org/D10356

7 years agoMFC r313025, r313395, r314113, r314442, r315458, r315656
asomers [Mon, 17 Apr 2017 20:13:20 +0000 (20:13 +0000)]
MFC r313025, r313395, r314113, r314442, r315458, r315656

r313025:
Add tests for multi-fib IPv6 routing

PR: 196361
Submitted by: jhujhiti@adjectivism.org
Reported by: Jason Healy <jhealy@logn.net>
MFC after: 4 weeks
Sponsored by: Spectra Logic Corp

r313395:
Add fibs_test:udp_dontroute6, another IPv6 multi-FIB test

PR: 196361
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp

r314113:
Remove tests/sys/netinet/fibs_tests's dependency on net/socat

Instead of bridging two tap interfaces with socat, just use an epair pair.

MFC after: 3 weeks
Sponsored by: Spectra Logic Corp

r314442:
Add an ATF test for IPv6 SLAAC with multiple fibs

Tests that an interface can get a SLAAC address and that it inserts its
routes into the correct fib. Does not test anything to do with NDP.

PR: 196361
Reviewed by: Erick Turnquist <jhujhiti@adjectivism.org>
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D9776

r315458:
Constrain IPv6 routes to single FIBs when net.add_addr_allfibs=0

sys/netinet6/icmp6.c
Use the interface's FIB for source address selection in ICMPv6 error
responses.

sys/netinet6/in6.c
In in6_newaddrmsg, announce arrival of local addresses on the
interface's FIB only.  In in6_lltable_rtcheck, use a per-fib ND6
cache instead of a single cache.

sys/netinet6/in6_src.c
In in6_selectsrc, use the caller's fib instead of the default fib.
In in6_selectsrc_socket, remove a superfluous check.

sys/netinet6/nd6.c
In nd6_lle_event, use the interface's fib for routing socket
messages.  In nd6_is_new_addr_neighbor, check all FIBs when trying
to determine whether an address is a neighbor.  Also, simplify the
code for point to point interfaces.

sys/netinet6/nd6.h
sys/netinet6/nd6.c
sys/netinet6/nd6_rtr.c
Make defrouter_select fib-aware, and make all of its callers pass in
the interface fib.

sys/netinet6/nd6_nbr.c
When inputting a Neighbor Solicitation packet, consider the
interface fib instead of the default fib for DAD.  Output NS and
Neighbor Advertisement packets on the correct fib.

sys/netinet6/nd6_rtr.c
Allow installing the same host route on different interfaces in
different FIBs.  If rt_add_addr_allfibs=0, only install or delete
the prefix route on the interface fib.

tests/sys/netinet/fibs_test.sh
Clear some expected failures, but add a skip for the newly revealed
BUG217871.

PR: 196361
Submitted by: Erick Turnquist <jhujhiti@adjectivism.org>
Reported by: Jason Healy <jhealy@logn.net>
Reviewed by: asomers
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D9451

r315656:
Fix back-to-back runs of sys/netinet/fibs_test;slaac_on_nondefault_fib6

This test was failing if run twice because rtadvd takes too long to die.
The rtadvd process from the first run was still running when the
second run created its interfaces.  The solution is to use SIGKILL during
the cleanup instead of SIGTERM so rtadvd will die faster.

While I'm here, randomize the addresses used for the test, which makes bugs
like this easier to spot, and fix the cleanup order to be the opposite of
the setup order

PR: 217871
MFC after: 18 days
X-MFC-With: 315458
Sponsored by: Spectra Logic Corp

7 years agoMFC r316956:
bapt [Mon, 17 Apr 2017 19:08:49 +0000 (19:08 +0000)]
MFC r316956:

Update pci_vendors to 2017.04.03

7 years agoMFC r314987-r314989, r314993-r314994, r315046-r315049, r315102
araujo [Mon, 17 Apr 2017 18:55:54 +0000 (18:55 +0000)]
MFC r314987-r314989, r314993-r314994, r315046-r315049, r315102

r314987:
Use nitems() from sys/param.h.

Reviewed by: asomers
MFC after: 3 weeks.
Differential Revision: https://reviews.freebsd.org/D9944

r314988:
Use nitems() from sys/param.h.

Reviewed by: ume
MFC after: 3 weeks.
Differential Revision: https://reviews.freebsd.org/D9938

r314989:
Use nitems() from sys/param.h and also remove the cast.

Reviewed by: markj
MFC after: 3 weeks.
Differential Revision: https://reviews.freebsd.org/D9937

r314993:
Use nitems() from sys/param.h.

Reviewed by: ngie
MFC after: 3 weeks.
Differential Revision: https://reviews.freebsd.org/D9936

r314994:
Use nitems() from sys/param.h.

Reviewed by: ngie
MFC after: 3 weeks.
Differential Revision: https://reviews.freebsd.org/D9940

r315046:
Use nitems() from sys/param.h

Reviewed by: jhb
MFC after: 3 weeks.
Differential Revision: https://reviews.freebsd.org/D9941

r315047:
Use nitems() from sys/param.h.

Reviewed by: np
MFC after: 3 weeks.
Differential Revision: https://reviews.freebsd.org/D9945

r315048:
Use nitems() from sys/param.h.

MFC after: 3 weeks.

r315049:
Bring back the cast removed in my previous commit to allow us build vmstat
with WARNS 2. This cast was first introduced at r87690.

Reported by: bde, pfg and ngie
MFC after: 3 weeks.

r315102:
Use nitems() from sys/param.h.

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

7 years agoMFC r316686, r316687, r316689
markj [Mon, 17 Apr 2017 16:59:18 +0000 (16:59 +0000)]
MFC r316686, r316687, r316689
Fix a race between vm_map_wire() and vm_map_protect().

7 years agoMFC r316592:
garga [Mon, 17 Apr 2017 13:01:42 +0000 (13:01 +0000)]
MFC r316592:

Introduce libxo support to arp(8)

Reviewed by: wblock, gnn, allanjude, phil
Approved by: allanjude
Sponsored by: Rubicon Communications (Netgate)
Differential Revision: https://reviews.freebsd.org/D9563

7 years agoMFC r316435:
ae [Mon, 17 Apr 2017 09:42:05 +0000 (09:42 +0000)]
MFC r316435:
  Add ipfw_pmod kernel module.

  The module is designed for modification of a packets of any protocols.
  For now it implements only TCP MSS modification. It adds the external
  action handler for "tcp-setmss" action.

  A rule with tcp-setmss action does additional check for protocol and
  TCP flags. If SYN flag is present, it parses TCP options and modifies
  MSS option if its value is greater than configured value in the rule.
  Then it adjustes TCP checksum if needed. After handling the search
  continues with the next rule.

  Obtained from: Yandex LLC
  Relnotes: yes
  Sponsored by: Yandex LLC
  Differential Revision: https://reviews.freebsd.org/D10150

7 years agoMFC r316433:
ae [Mon, 17 Apr 2017 09:38:15 +0000 (09:38 +0000)]
MFC r316433:
  Add the log formatting for an external action opcode.

  Obtained from: Yandex LLC
  Sponsored by: Yandex LLC

7 years agoMFC r316434:
ae [Mon, 17 Apr 2017 09:36:35 +0000 (09:36 +0000)]
MFC r316434:
  Add O_EXTERNAL_DATA opcode support.

  This opcode can be used to attach some data to external action opcode.
  And unlike to O_EXTERNAL_INSTANCE opcode, this opcode does not require
  creating of named instance to pass configuration arguments to external
  action handler. The data is coming just next to O_EXTERNAL_ACTION opcode.

  The userlevel part currenly supports formatting for opcode with ipfw_insn
  size, by default it expects u16 numeric value in the arg1.

  Obtained from: Yandex LLC
  Sponsored by: Yandex LLC

7 years agoMFC r316461:
ae [Mon, 17 Apr 2017 09:34:09 +0000 (09:34 +0000)]
MFC r316461:
  Remove "IPFW static rules" rmlock.

  Make PFIL's lock global and use it for this purpose.
  This reduces the number of locks needed to acquire for each packet.

  Obtained from: Yandex LLC
  Sponsored by: Yandex LLC
  Differential Revision: https://reviews.freebsd.org/D10154

7 years agoMFC r307686:
mmel [Sun, 16 Apr 2017 09:00:10 +0000 (09:00 +0000)]
MFC r307686:

  Use MACHINE_ARCH rather than TARGET_ARCH which has no meaning outside of
  Makefile.inc1

7 years agoMFC r309538:
mmel [Sun, 16 Apr 2017 08:21:14 +0000 (08:21 +0000)]
MFC r309538:

  Fixes for NVIDIA Tegra124 clocks:
   - EMC clock have standard peripheral clock block. Use it.  - Implement full
   frequency set method for PLLD2. This PLL
     is used as HDMI pixel clock so we must be able to set it to wide range of
     frequencies, within 5% tolerance allowed by HDMI specification. Due to
     this, full state space search (over m, n, p fields) is necessary.

7 years agoMFC r308286,r308287:
mmel [Sun, 16 Apr 2017 08:18:37 +0000 (08:18 +0000)]
MFC r308286,r308287:

  r308286:
    TEGRA: Add basic driver for memory controller.  For now, it only reports
    memory and SMMU access errors.
  r308287:
    TEGRA: Fix numerous issues in clock code.  Define and export clocks related
    to XUSB driver.

7 years agoMFC r310593,r310599:
mmel [Sun, 16 Apr 2017 08:07:38 +0000 (08:07 +0000)]
MFC r310593,r310599:

  r310593:
    Fix late monitor hotplug event.  If system starts without attached monitor,
    DRM create framebuffer for VT console. Later, when monitor is attached, the
    hotplug event must issue full modeset procedure to setup CRTC.  In original
    code, this was done in drm_fb_helper_set_par(), but we don't have this
    function implemented yet. Use unrolled version of drm_fb_helper_set_par()
    to ensure same functionality.
  r310599:
    Import drm_patform.c, an implementation of non-PCI based attachment for
    graphics drivers.  It will be used in upcoming driver for Nvidia Tegra
    boards.

7 years agoMFC r309532,r310674:
mmel [Sun, 16 Apr 2017 08:04:01 +0000 (08:04 +0000)]
MFC r309532,r310674:

  r309532:
    Add IDs for HDA codecs found on Nvidia Tegra SoCs.
  r310674:
    Limit number of stripes supported by HDA codec to maximum number announced
    by HDA controller.  Incorrectly implermented HDA codec may report support
    for more stripes that HDA controller already have. Due to this, always
    limit number of enabled stripes by global controller maximum.

7 years agoMFC r309537:
mmel [Sun, 16 Apr 2017 08:01:57 +0000 (08:01 +0000)]
MFC r309537:

  Clock framework fixes:
   - The clk_test_freq() (aka CLK_SET_DRYRUN) doesn't change frequency,
     don't cache it result.
   - Fix busy condition for clk_set_freq().

7 years agoMFC r308612,r308614:
mmel [Sun, 16 Apr 2017 07:58:41 +0000 (07:58 +0000)]
MFC r308612,r308614:

  r308612:
    Allow DRM2 code to be built on platforms without AGP.  This patch is taken
    from original drm-3.8 code.
  r308614:
    Allow embeding DRM2 code into kernel.  It's usefull for development (for
    netboot) and it also helps to boot FreeBSD on some embeded platforms (where
    we must boot kernel directly, without standard boot loader).

7 years agoMFC r306703:
mmel [Sun, 16 Apr 2017 07:43:29 +0000 (07:43 +0000)]
MFC r306703:

  ARM: Disconnect elf_trampoline.c from ARMv6 build.  The trampoline code never
  functioned properly for Cortex CPUs, and its functionality is already
  provided by ubldr.