]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoFix a use-after-free in an error case.
Takanori Watanabe [Wed, 26 May 2021 09:23:33 +0000 (18:23 +0900)]
Fix a use-after-free in an error case.

PR: 255872
Submitted by:  lylgood
Differential Revision:  https://reviews.freebsd.org/D30454

(cherry picked from commit 14803ec8d193d8d46f4137a7dba61b277c6a2fed)

3 years agotcp: A better fix for the previously attempted fix of the ack-war issue with tcp.
Randall Stewart [Fri, 4 Jun 2021 09:26:43 +0000 (05:26 -0400)]
tcp: A better fix for the previously attempted fix of the ack-war issue with tcp.

So it turns out that my fix before was not correct. It ended with us failing
some of the "improved" SYN tests, since we are not in the correct states.
With more digging I have figured out the root of the problem is that when
we receive a SYN|FIN the reassembly code made it so we create a segq entry
to hold the FIN. In the established state where we were not in order this
would be correct i.e. a 0 len with a FIN would need to be accepted. But
if you are in a front state we need to strip the FIN so we correctly handle
the ACK but ignore the FIN. This gets us into the proper states
and avoids the previous ack war.

I back out some of the previous changes but then add a new change
here in tcp_reass() that fixes the root cause of the issue. We still
leave the rack panic fixes in place however.

Reviewed by: mtuexen
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30627

(cherry picked from commit 4747500deaaa7765ba1c0413197c23ddba4faf49)

3 years agotcp: When we have an out-of-order FIN we do want to strip off the FIN bit.
Randall Stewart [Thu, 27 May 2021 14:50:32 +0000 (10:50 -0400)]
tcp: When we have an out-of-order FIN we do want to strip off the FIN bit.

The last set of commits fixed both a panic (in rack) and an ACK-war (in freebsd and bbr).
However there was a missing case, i.e. where we get an out-of-order FIN by itself.
In such a case we don't want to leave the FIN bit set, otherwise we will do the
wrong thing and ack the FIN incorrectly. Instead we need to go through the
tcp_reasm() code and that way the FIN will be stripped and all will be well.

Reviewed by: mtuexen,rscheff
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30497

(cherry picked from commit 8c69d988a8d32e53310c7b73ec8721b04b7249e6)

3 years agotcp: Add a socket option to rack so we can test various changes to the slop value...
Randall Stewart [Wed, 26 May 2021 10:43:30 +0000 (06:43 -0400)]
tcp: Add a socket option to rack so we can test various changes to the slop value in timers.

Timer_slop, in TCP, has been 200ms for a long time. This value dates back
a long time when delayed ack timers were longer and links were slower. A
200ms timer slop allows 1 MSS to be sent over a 60kbps link. Its possible that
lowering this value to something more in line with todays delayed ack values (40ms)
might improve TCP. This bit of code makes it so rack can, via a socket option,
adjust the timer slop.

Reviewed by: mtuexen
Sponsered by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30249

(cherry picked from commit 4f3addd94be5e02e6e425f6119f5409972ab5d14)

3 years agotcp: Fix bugs related to the PUSH bit and rack and an ack war
Randall Stewart [Tue, 25 May 2021 17:23:31 +0000 (13:23 -0400)]
tcp: Fix bugs related to the PUSH bit and rack and an ack war

Michaels testing with UDP tunneling found an issue with the push bit, which was only partly fixed
in the last commit. The problem is the left edge gets transmitted before the adjustments are done
to the send_map, this means that right edge bits must be considered to be added only if
the entire RSM is being retransmitted.

Now syzkaller also continued to find a crash, which Michael sent me the reproducer for. Turns
out that the reproducer on default (freebsd) stack made the stack get into an ack-war with itself.
After fixing the reference issues in rack the same ack-war was found in rack (and bbr). Basically
what happens is we go into the reassembly code and lose the FIN bit. The trick here is we
should not be going into the reassembly code if tlen == 0 i.e. the peer never sent you anything.
That then gets the proper action on the FIN bit but then you end up in LAST_ACK with no
timers running. This is because the usrclosed function gets called and the FIN's and such have
already been exchanged. So when we should be entering FIN_WAIT2 (or even FIN_WAIT1) we get
stuck in LAST_ACK. Fixing this means tweaking the usrclosed function so that we properly
recognize the condition and drop into FIN_WAIT2 where a timer will allow at least TP_MAXIDLE
before closing (to allow time for the peer to retransmit its FIN if the ack is lost). Setting the fast_finwait2
timer can speed this up in testing.

Reviewed by: mtuexen,rscheff
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30451

(cherry picked from commit 13c0e198ca275447f9a60a03f730c38c98f19009)

3 years agotcp: Fix an issue with the PUSH bit as well as fill in the missing mtu change for...
Randall Stewart [Mon, 24 May 2021 18:42:15 +0000 (14:42 -0400)]
tcp: Fix an issue with the PUSH bit as well as fill in the missing mtu change for fsb's

The push bit itself was also not actually being properly moved to
the right edge. The FIN bit was incorrectly on the left edge. We
fix these two issues as well as plumb in the mtu_change for
alternate stacks.

Reviewed by: mtuexen
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30413

(cherry picked from commit 631449d5d03506295eaa6947c1b0e8a168a2f6b7)

3 years agotcp: Handle stack switch while processing socket options
Michael Tuexen [Sat, 22 May 2021 12:35:09 +0000 (14:35 +0200)]
tcp: Handle stack switch while processing socket options

Handle the case where during socket option processing, the user
switches a stack such that processing the stack specific socket
option does not make sense anymore. Return an error in this case.

Reviewed by: markj
Reported by: syzbot+a6e1d91f240ad5d72cd1@syzkaller.appspotmail.com
Sponsored by: Netflix, Inc.
Differential revision: https://reviews.freebsd.org/D30395

(cherry picked from commit 8923ce630492d21ec57c2637757bcc44da9970f8)

3 years agotcp: Fix sending of TCP segments with IP level options
Michael Tuexen [Fri, 21 May 2021 07:45:00 +0000 (09:45 +0200)]
tcp: Fix sending of TCP segments with IP level options

When bringing in TCP over UDP support in
https://cgit.FreeBSD.org/src/commit/?id=9e644c23000c2f5028b235f6263d17ffb24d3605,
the length of IP level options was considered when locating the
transport header. This was incorrect and is fixed by this patch.

X-MFC with: https://cgit.FreeBSD.org/src/commit/?id=9e644c23000c2f5028b235f6263d17ffb24d3605
Reviewed by: markj, rscheff
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D30358

(cherry picked from commit 500eb6dd80404ea512e31a8f795c73cb802c9c64)

3 years agotcp: Incorrect KASSERT causes a panic in rack
Randall Stewart [Thu, 13 May 2021 11:36:04 +0000 (07:36 -0400)]
tcp: Incorrect KASSERT causes a panic in rack

Skyzall found an interesting panic in rack. When a SYN and FIN are
both sent together a KASSERT gets tripped where it is validating that
a mbuf pointer is in the sendmap. But a SYN and FIN often will not
have a mbuf pointer. So the fix is two fold a) make sure that the
SYN and FIN split the right way when cloning an RSM SYN on left
edge and FIN on right. And also make sure the KASSERT properly
accounts for the case that we have a SYN or FIN so we don't
panic.

Reviewed by: mtuexen
Sponsored by: Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D30241

(cherry picked from commit 02cffbc2507e83944b0c29d69d6ddf26c9386d54)

3 years agomod_cc: cross reference CC modules consistently
Michael Tuexen [Thu, 13 May 2021 08:47:45 +0000 (10:47 +0200)]
mod_cc: cross reference CC modules consistently

Reviewed by: bcr, gbe
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D30240

(cherry picked from commit 8ea5eeb913b94aa45aa7773d14b31222d509ec34)

3 years agotcp rack: improve initialisation of retransmit timeout
Michael Tuexen [Wed, 12 May 2021 15:58:56 +0000 (17:58 +0200)]
tcp rack: improve initialisation of retransmit timeout

When the TCP is in the front states, don't take the slop variable
into account. This improves consistency with the base stack.

Reviewed by: rrs@
Differential Revision: https://reviews.freebsd.org/D30230
Sponsored by: Netflix, Inc.

(cherry picked from commit 251842c63927fc4af63bdc61989bbfbf3823c679)

3 years agotcp: In rack, we must only convert restored rtt when the hostcache does restore them.
Randall Stewart [Tue, 11 May 2021 12:15:05 +0000 (08:15 -0400)]
tcp: In rack, we must only convert restored rtt when the hostcache does restore them.

Rack now after the previous commit is very careful to translate any
value in the hostcache for srtt/rttvar into its proper format. However
there is a snafu here in that if tp->srtt is 0 is the only time that
the HC will actually restore the srtt. We need to then only convert
the srtt restored when it is actually restored. We do this by making
sure it was zero before the call to cc_conn_init and it is non-zero
afterwards.

Reviewed by: Michael Tuexen
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30213

(cherry picked from commit 4b86a24a76a4d58c1d870fcb2252b321f61cb3cc)

3 years agotcp:Host cache and rack ending up with incorrect values.
Randall Stewart [Mon, 10 May 2021 15:25:51 +0000 (11:25 -0400)]
tcp:Host cache and rack ending up with incorrect values.

The hostcache up to now as been updated in the discard callback
but without checking if we are all done (the race where there are
more than one calls and the counter has not yet reached zero). This
means that when the race occurs, we end up calling the hc_upate
more than once. Also alternate stacks can keep there srtt/rttvar
in different formats (example rack keeps its values in microseconds).
Since we call the hc_update *before* the stack fini() then the
values will be in the wrong format.

Rack on the other hand, needs to convert items pulled from the
hostcache into its internal format else it may end up with
very much incorrect values from the hostcache. In the process
lets commonize the update mechanism for srtt/rttvar since we
now have more than one place that needs to call it.

Reviewed by: Michael Tuexen
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30172

(cherry picked from commit 9867224bab3f247ac875d89c2472aa4bc855fe3b)

3 years agoThis takes Warners suggested approach to making it so that
Randall Stewart [Fri, 7 May 2021 21:32:32 +0000 (17:32 -0400)]
This takes Warners suggested approach to making it so that
platforms that for whatever reason cannot include the RATELIMIT option
can still work with rack. It adds two dummy functions that rack will
call and find out that the highest hw supported b/w is 0 (which
kinda makes sense and rack is already prepared to handle).

Reviewed by: Michael Tuexen, Warner Losh
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30163

(cherry picked from commit 5a4333a5378f7afe4f8cab293a987865ae0c32c4)

3 years agoFix a UDP tunneling issue with rack. Basically there are two
Randall Stewart [Fri, 7 May 2021 18:06:43 +0000 (14:06 -0400)]
Fix a UDP tunneling issue with rack. Basically there are two
issues.
A) Not enough hdrlen was being calculated when a UDP tunnel is
   in place.
and
B) Not enough memory is allocated in racks fsb. We need to
   overbook the fsb to include a udphdr just in case.

Submitted by: Peter Lei
Reviewed by: Michael Tuexen
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30157

(cherry picked from commit a16cee0218652230d94a73690201e76baab0bba1)

3 years agoThis brings into sync FreeBSD with the netflix versions of rack and bbr.
Randall Stewart [Thu, 6 May 2021 15:22:26 +0000 (11:22 -0400)]
This brings into sync FreeBSD with the netflix versions of rack and bbr.
This fixes several breakages (panics) since the tcp_lro code was
committed that have been reported. Quite a few new features are
now in rack (prefecting of DGP -- Dynamic Goodput Pacing among the
largest). There is also support for ack-war prevention. Documents
comming soon on rack..

Sponsored by:           Netflix
Reviewed by: rscheff, mtuexen
Differential Revision: https://reviews.freebsd.org/D30036

(cherry picked from commit 5d8fd932e418f03e98b3469c4088a36f0ef34ffe)

3 years agoFix LINT kernel builds after 1a714ff20419 .
Hans Petter Selasky [Mon, 1 Feb 2021 12:23:21 +0000 (13:23 +0100)]
Fix LINT kernel builds after 1a714ff20419 .

Discussed with: rrs@
Differential Revision:  https://reviews.freebsd.org/D28357
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit db46c0d0cb3da2813727e56df1f2db292065867a)

3 years agozfs: merge openzfs/zfs@7d9f3ef0e (zfs-2.1-release) into stable/13
Martin Matuska [Tue, 8 Jun 2021 15:01:18 +0000 (17:01 +0200)]
zfs: merge openzfs/zfs@7d9f3ef0e (zfs-2.1-release) into stable/13

Notable upstream pull request merges:
  #11710 Allow zfs to send replication streams with missing snapshots
  #11786 Ratelimit deadman zevents as with delay zevents
  #11813 Allow pool names that look like Solaris disk names
  #11822 Atomically check and set dropped zevent count
  #11822 Don't scale zfs_zevent_len_max by CPU count
  #11837 zfs get -p only outputs 3 columns if "clones" property is empty
  #11849 Use dsl_scan_setup_check() to setup a scrub
  #11861 Improvements to the 'compatibility' property
  #11862 cmd/zfs receive: allow dry-run (-n) to check property args
  #11864 receive: don't fail inheriting (-x) properties on wrong dataset type
  #11877 Combine zio caches if possible
  #11881 FreeBSD: use vnlru_free_vfsops if available
  #11883 FreeBSD: add support for lockless symlink lookup
  #11884 FreeBSD: add missing seqc write begin/end around zfs_acl_chown_setattr
  #11896 Fix crash in zio_done error reporting
  #11905 zfs-send(8): Restore sorting of flags
  #11926 FreeBSD: damage control racing .. lookups in face of mkdir/rmdir
  #11938 Fix AVX512BW Fletcher code on AVX512-but-not-BW machines
  #11966 Scale worker threads and taskqs with number of CPUs
  #11997 FreeBSD: Don't force xattr mount option
  #11997 FreeBSD: Use SET_ERROR to trace xattr name errors
  #11998 Simplify/fix dnode_move() for dn_zfetch
  #12003 FreeBSD: Initialize/destroy zp->z_lock
  #12010 Fix dRAID self-healing short columns
  #12033 Revert "Fix raw sends on encrypted datasets when copying back snapshots"
  #12040 Reinstate the old zpool read label logic as a fallback
  #12049 FreeBSD: avoid memory allocation in arc_prune_async
  #12061 Fix dRAID sequential resilver silent damage handling
  #12077 FreeBSD: Retry OCF ENOMEM errors.
  #12088 Propagate vdev state due to invalid label corruption
  #12097 FreeBSD: Update dataset_kstats for zvols in dev mode

Obtained from: OpenZFS
OpenZFS commit: 7d9f3ef0ef5c26424d6f1eab2c7d4dfa3e7f9950
OpenZFS tag: 2.1.0-rc6

3 years agozfs: merge openzfs/zfs@3522f57b6 (zfs-2.1-release) to stable/13
Martin Matuska [Tue, 8 Jun 2021 14:36:23 +0000 (16:36 +0200)]
zfs: merge openzfs/zfs@3522f57b6 (zfs-2.1-release) to stable/13

This changes branch tracking of sys/contrib/openzfs to a new
direct-import branch vendor/openzfs/zfs-2.1-release.

No functional changes.

OpenZFS tag: 2.1.0-rc1

3 years agoamd64: Clear the local TSS when creating a new thread
Mark Johnston [Tue, 1 Jun 2021 23:38:22 +0000 (19:38 -0400)]
amd64: Clear the local TSS when creating a new thread

Otherwise it is copied from the creating thread.  Then, if either thread
exits, the other is left with a dangling pointer, typically resulting in
a page fault upon the next context switch.

Reported by: syzkaller
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 8cd05b883330049d536a40e2f4c9ff92d0e6944e)

3 years agoi386: Make setidt_disp a size_t instead of uintptr_t
Mark Johnston [Tue, 1 Jun 2021 14:28:57 +0000 (10:28 -0400)]
i386: Make setidt_disp a size_t instead of uintptr_t

setidt_disp is the offset of the ISR trampoline relative to the address
of the routines in exception.s, so uintptr_t is not quite right.

Also remove a bogus declaration I added in commit 18f55c67f7, it is not
required after all.

Reported by: jrtc27
Reviewed by: jrtc27, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit cbe59a6475b6c36fac4073bcfc328099fc873420)

3 years agopf: Avoid leaking pad bytes in struct pfr_astats when copying out
Mark Johnston [Tue, 1 Jun 2021 14:56:23 +0000 (10:56 -0400)]
pf: Avoid leaking pad bytes in struct pfr_astats when copying out

There is padding between pfr_astats.pfras_a and pfras_packets that was
not getting initialized.

Reported by: KMSAN
Reviewed by: kp, imp
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 60a38abb8982e11ee71559057dd7128bd097043e)

3 years agong_parse: IP address parsing in netgraph eating too many characters
Markus Stoff [Tue, 18 May 2021 20:35:33 +0000 (22:35 +0200)]
ng_parse: IP address parsing in netgraph eating too many characters

Once the final component of the IP address has been parsed, the offset
on the input must not be advanced, as this would remove an unparsed
character from the input.

Submitted by: Markus Stoff
Reviewed by: donner
Differential Revision: https://reviews.freebsd.org/D26489

(cherry picked from commit 63b6a08ce2467b8e230e7a4ecb3e1ddf1b48851c)

3 years agoThis pulls over all the changes that are in the netflix
Randall Stewart [Tue, 26 Jan 2021 16:54:42 +0000 (11:54 -0500)]
This pulls over all the changes that are in the netflix
tree that fix the ratelimit code. There were several bugs
in tcp_ratelimit itself and we needed further work to support
the multiple tag format coming for the joint TLS and Ratelimit dances.

    Sponsored by: Netflix Inc.
    Differential Revision:  https://reviews.freebsd.org/D28357

(cherry picked from commit 1a714ff204193b9eb810426048e03f5d76e9730e)

3 years agoAdd thread_reap_barrier()
Konstantin Belousov [Tue, 25 May 2021 18:51:00 +0000 (21:51 +0300)]
Add thread_reap_barrier()

(cherry picked from commit f62c7e54e9cc692603081328597ba0ba0d1f21cf)
(cherry picked from commit d3f7975fcb346ea28dde079a9c04cff5ef20a8d7)

3 years agoquisce_cpus(): add special handling for PDROP
Konstantin Belousov [Fri, 28 May 2021 17:10:47 +0000 (20:10 +0300)]
quisce_cpus(): add special handling for PDROP

(cherry picked from commit 3a68546d2377d6e9776060043372d66f07022543)

3 years agokern_thread.c: wrap too long lines
Konstantin Belousov [Tue, 25 May 2021 18:09:33 +0000 (21:09 +0300)]
kern_thread.c: wrap too long lines

(cherry picked from commit 845d77974b3b6ab78297836ead2d2acbcdebeba7)

3 years agokern linker: do not allow more than one kldload and kldunload syscalls simultaneously
Konstantin Belousov [Thu, 20 May 2021 14:50:43 +0000 (17:50 +0300)]
kern linker: do not allow more than one kldload and kldunload syscalls simultaneously

(cherry picked from commit e266a0f7f001c7886eab56d8c058d92d87010400)

3 years agopf tests: Make killstate:match more robust
Kristof Provost [Thu, 3 Jun 2021 13:22:19 +0000 (15:22 +0200)]
pf tests: Make killstate:match more robust

The killstate:match test starts nc as a background process. There was no
guarantee that the nc process would have connected by the time we check
for states, so this test occasionally failed without good reason.

Teach the test to wait for at least some states to turn up before
executing the critical checks.

MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 70dd30d49c29a27e1ef159660a7e3dbb84082674)

3 years agotcp: fix man page
Michael Tuexen [Sat, 24 Apr 2021 20:31:36 +0000 (22:31 +0200)]
tcp: fix man page

Reviewed by: gbe, rscheff
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D29963

(cherry picked from commit 6096814d3134234d48936f557d431a793e35d8b3)

3 years agomend
Michael Tuexen [Sun, 18 Apr 2021 14:08:08 +0000 (16:08 +0200)]
mend

3 years agosctp: fix another locking bug in COOKIE handling
Michael Tuexen [Wed, 12 May 2021 21:02:31 +0000 (23:02 +0200)]
sctp: fix another locking bug in COOKIE handling

Thanks to Tolya Korniltsev for reporting the issue for
the userland stack and testing the fix.

(cherry picked from commit eec6aed5b8c848841ae8d25940e0a333e5039ce9)

3 years agolibalias: Remove unused function LibAliasCheckNewLink
Lutz Donnerhacke [Sat, 15 May 2021 13:24:12 +0000 (15:24 +0200)]
libalias: Remove unused function LibAliasCheckNewLink

The functionality to detect a newly created link after processing a
single packet is decoupled from the packet processing.  Every new
packet is processed asynchronously and will reset the indicator, hence
the function is unusable.  I made a Google search for third party code,
which uses the function, and failed to find one.

That's why the function should be removed: It unusable and unused.
A much simplified API/ABI will remain in anything below 14.

Discussed with: kp
Reviewed by: manpages (bcr)
Differential Revision: https://reviews.freebsd.org/D30275

(cherry picked from commit bfd41ba1fe1d0e40b6a813aeb0354cac8d884f5b)

3 years agoffs: Correct the input size check in sysctl_ffs_fsck()
Mark Johnston [Mon, 31 May 2021 22:56:34 +0000 (18:56 -0400)]
ffs: Correct the input size check in sysctl_ffs_fsck()

Make sure we return an error if no input was specified, since
SYSCTL_IN() will report success in that case.

Reported by: KMSAN
Reviewed by: mckusick
Sponsored by: The FreeBSD Foundation

(cherry picked from commit b2f9575646f89cdddcad76acae3e9305535506a2)

3 years agoamd64: Relax the assertion added in commit 4a59cbc12
Mark Johnston [Tue, 1 Jun 2021 23:38:09 +0000 (19:38 -0400)]
amd64: Relax the assertion added in commit 4a59cbc12

We only need to ensure that interrupts are disabled when handling a
fault from iret.  Otherwise it's possible to trigger the assertion
legitimately, e.g., by copying in from an invalid address.

Fixes: 4a59cbc12
Reported by: pho
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6cda62755612d706f30a99f70ff13ffa0f3f2422)

3 years agoamd64: Avoid enabling interrupts when handling kernel mode prot faults
Mark Johnston [Mon, 31 May 2021 22:49:33 +0000 (18:49 -0400)]
amd64: Avoid enabling interrupts when handling kernel mode prot faults

When PTI is enabled, we may have been on the trampoline stack when iret
faults.  So, we have to switch back to the regular stack before
re-entering trap().

trap() has the somewhat strange behaviour of re-enabling interrupts when
handling certain kernel-mode execeptions.  In particular, it was doing
this for exceptions raised during execution of iret.  When switching
away from the trampoline stack, however, the thread must not be migrated
to a different CPU.  Fix the problem by simply leaving interrupts
disabled during the window.

Reported by: syzbot+6cfa544fd86ad4647ffc@syzkaller.appspotmail.com
Reported by: syzbot+cfdfc9e5a8f28f11a7f5@syzkaller.appspotmail.com
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4a59cbc1253266ea70d6fa43b1a7c77cc33ec6cd)

3 years agox86: Fix lapic_ipi_alloc() on i386
Mark Johnston [Mon, 31 May 2021 22:51:14 +0000 (18:51 -0400)]
x86: Fix lapic_ipi_alloc() on i386

The loop which checks to see if "dynamic" IDT entries are allocated
needs to compare with the trampoline address of the reserved ISR.
Otherwise it will never succeed.

Reported by: Harry Schmalzbauer <freebsd@omnilan.de>
Tested by: Harry Schmalzbauer <freebsd@omnilan.de>
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 18f55c67f746f0ad12fe972328234d340a621df9)

3 years agokqueue: replace kq_ncallouts loop with atomic_fetchadd
Mateusz Guzik [Wed, 2 Jun 2021 15:14:58 +0000 (15:14 +0000)]
kqueue: replace kq_ncallouts loop with atomic_fetchadd

(cherry picked from commit c9f8dcda856c50325190326a618dc251311bc43a)

3 years agoarm64: correct END() copy-pasteo for generic_bs_fault
Ed Maste [Fri, 28 May 2021 00:10:26 +0000 (20:10 -0400)]
arm64: correct END() copy-pasteo for generic_bs_fault

PR: 256197
Reported by: Nick Reilly
MFC after: 1 week
Fixes: 95a85c125d0e67 ("Add NetBSD compatible bus_space...")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit d097687b315671191b16494c938d3ceecd3eca4f)

3 years agotmpfs: save on relocking the allnode lock in tmpfs_free_node_locked
Mateusz Guzik [Thu, 27 May 2021 08:57:59 +0000 (10:57 +0200)]
tmpfs: save on relocking the allnode lock in tmpfs_free_node_locked

(cherry picked from commit f4aa64528e4557cd18cdb376b0f88f4a34d69912)

3 years agotmpfs: save on common case relocking in tmpfs_reclaim
Mateusz Guzik [Sat, 29 May 2021 01:36:50 +0000 (03:36 +0200)]
tmpfs: save on common case relocking in tmpfs_reclaim

(cherry picked from commit 331a7601c9c21c1e55c57c5338e7affced9c7b7c)

3 years agotmpfs: drop a redundant NULL check in tmpfs_alloc_vp
Mateusz Guzik [Sat, 29 May 2021 01:10:53 +0000 (03:10 +0200)]
tmpfs: drop a redundant NULL check in tmpfs_alloc_vp

(cherry picked from commit 439d942b9e7ab4df2bb7a628602069d31788df17)

3 years agotmpfs: drop useless parent locking from tmpfs_dir_getdotdotdent
Mateusz Guzik [Sat, 29 May 2021 15:38:21 +0000 (17:38 +0200)]
tmpfs: drop useless parent locking from tmpfs_dir_getdotdotdent

The id field is immutable until the node gets freed.

(cherry picked from commit 7fbeaf33b8e1a5e69af42a77c78a6fcb3029f1ca)

3 years agovfs: use the sentinel trick in locked lookup path parsing
Mateusz Guzik [Tue, 25 May 2021 17:34:26 +0000 (19:34 +0200)]
vfs: use the sentinel trick in locked lookup path parsing

(cherry picked from commit d81aefa8b7dd8cbeffeda541fca9962802404983)

3 years agoFix up macro use in lim_cur
Mateusz Guzik [Sat, 29 May 2021 17:46:37 +0000 (19:46 +0200)]
Fix up macro use in lim_cur

(cherry picked from commit dde5c031ed0d93d080442b26133e9ea800bbcd22)

3 years agofd: use PROC_WAIT_UNLOCKED when clearing p_fd/p_pd
Mateusz Guzik [Thu, 27 May 2021 14:29:26 +0000 (14:29 +0000)]
fd: use PROC_WAIT_UNLOCKED when clearing p_fd/p_pd

(cherry picked from commit 9bfddb3ac4ce8a2fbd5bb212a263747343a931e7)

3 years agovfs: retire unused vn_seqc_write_begin_unheld*
Mateusz Guzik [Sat, 29 May 2021 02:26:19 +0000 (04:26 +0200)]
vfs: retire unused vn_seqc_write_begin_unheld*

(cherry picked from commit 3cf75ca220fb6a9006fa0481b97e154602f6f554)

3 years agoproc: add PROC_WAIT_UNLOCKED
Mateusz Guzik [Thu, 27 May 2021 14:29:14 +0000 (14:29 +0000)]
proc: add PROC_WAIT_UNLOCKED

(cherry picked from commit 528f8f38953d92aa917cbe70d3c72d89440624ca)

3 years agovfs: elide vnode locking when it is only needed for audit if possible
Mateusz Guzik [Sun, 23 May 2021 19:28:26 +0000 (21:28 +0200)]
vfs: elide vnode locking when it is only needed for audit if possible

(cherry picked from commit a269183875f6d5141c81277d41b552871e2171e5)

3 years agoumtx: convert umtxq_lock to a macro
Mateusz Guzik [Sat, 22 May 2021 20:51:37 +0000 (20:51 +0000)]
umtx: convert umtxq_lock to a macro

Then LOCK_PROFILING starts reporting callers instead of the inline.

(cherry picked from commit 138f78e94bf83a8a92987d8be81f1e2c6c277cf8)

3 years agoext2: add missing uio_td initialization to ext2_htree_append_block
Mateusz Guzik [Sun, 30 May 2021 17:14:02 +0000 (19:14 +0200)]
ext2: add missing uio_td initialization to ext2_htree_append_block

Reported by: pho

(cherry picked from commit 284cf3f18b5395e29e128702d50342d706813773)

3 years agonfs: even up value returned by nfsrv_parsename with copyinstr
Mateusz Guzik [Mon, 31 May 2021 16:32:04 +0000 (16:32 +0000)]
nfs: even up value returned by nfsrv_parsename with copyinstr

Reported by: dim
Reviewed by: rmacklem

(cherry picked from commit 68c254426467e3f900f9a19de4dd9a234ea75388)

3 years agovfs: fix MNT_SYNCHRONOUS check in vn_write
Rich Ercolani [Wed, 2 Jun 2021 13:00:29 +0000 (13:00 +0000)]
vfs: fix MNT_SYNCHRONOUS check in vn_write

ca1ce50b2b5ef11d ("vfs: add more safety against concurrent forced
unmount to vn_write") has a side effect of only checking MNT_SYNCHRONOUS
if O_FSYNC is set.

Reviewed By: mjg
Differential Revision: https://reviews.freebsd.org/D30610

(cherry picked from commit a19ae1b099ad4d43588f15ef19b8506f606b27cb)

3 years agosctp: fix locking in case of error handling during a restart
Michael Tuexen [Wed, 12 May 2021 13:29:06 +0000 (15:29 +0200)]
sctp: fix locking in case of error handling during a restart

Thanks to Taylor Brandstetter for finding the issue and providing
a patch for the userland stack.

(cherry picked from commit 12dda000ed32efa16f59909a6294e4d4b5a771ba)

3 years agosctp: improve consistency when handling chunks of wrong size
Michael Tuexen [Wed, 5 May 2021 23:02:41 +0000 (01:02 +0200)]
sctp: improve consistency when handling chunks of wrong size

(cherry picked from commit d1cb8d11b0c09c35b87c144bab7b02b75c5725b6)

3 years agosctp: drop packet with SHUTDOWN-ACK chunks with wrong vtags
Michael Tuexen [Tue, 4 May 2021 16:42:31 +0000 (18:42 +0200)]
sctp: drop packet with SHUTDOWN-ACK chunks with wrong vtags

(cherry picked from commit b621fbb1bf1b2a1e6ea22e0ad2d7667b1aec9fae)

3 years agosctp: improve address list scanning
Michael Tuexen [Mon, 3 May 2021 00:50:05 +0000 (02:50 +0200)]
sctp: improve address list scanning

If the alternate address has to be removed, force the stack to
find a new one, if it is still needed.

(cherry picked from commit 8b3d0f6439fa27f0d37a9a7b9d27bbfdfdf487c4)

3 years agosctp: improve restart handling
Michael Tuexen [Mon, 3 May 2021 00:20:24 +0000 (02:20 +0200)]
sctp: improve restart handling

This fixes in particular a possible use after free bug reported
Anatoly Korniltsev and Taylor Brandstetter for the userland stack.

(cherry picked from commit a89481d328fd96ccbfa642e1db6d03825fa1dc6d)

3 years agoFix build after 5f2e1835054ee84f2e68ebc890d92716a91775b7.
Alexander Motin [Mon, 3 May 2021 00:07:38 +0000 (20:07 -0400)]
Fix build after 5f2e1835054ee84f2e68ebc890d92716a91775b7.

(cherry picked from commit 655c200cc89185c940bc7d5724be09a0f2e1a8a6)

3 years agosctp: improve error handling in INIT/INIT-ACK processing
Michael Tuexen [Sun, 2 May 2021 20:38:27 +0000 (22:38 +0200)]
sctp: improve error handling in INIT/INIT-ACK processing

When processing INIT and INIT-ACK information, also during
COOKIE processing, delete the current association, when it
would end up in an inconsistent state.

(cherry picked from commit 5f2e1835054ee84f2e68ebc890d92716a91775b7)

3 years agosctp: update the vtag for INIT and INIT-ACK chunks
Michael Tuexen [Fri, 30 Apr 2021 11:31:38 +0000 (13:31 +0200)]
sctp: update the vtag for INIT and INIT-ACK chunks

This is needed in case of responding with an ABORT to an INIT-ACK.

(cherry picked from commit e010d20032c8c2a04da103b3402a8d24bd682dd5)

3 years agosctp: fix SCTP_PEER_ADDR_PARAMS socket option
Michael Tuexen [Fri, 30 Apr 2021 10:27:47 +0000 (12:27 +0200)]
sctp: fix SCTP_PEER_ADDR_PARAMS socket option

Ignore spp_pathmtu if it is 0, when setting the IPPROTO_SCTP level
socket option SCTP_PEER_ADDR_PARAMS as required by RFC 6458.

(cherry picked from commit eb79855920ffa33d6c096221eac9cc9a6d7a484b)

3 years agosctp: use RTO.Initial of 1 second as specified in RFC 4960bis
Michael Tuexen [Thu, 29 Apr 2021 22:45:56 +0000 (00:45 +0200)]
sctp: use RTO.Initial of 1 second as specified in RFC 4960bis

(cherry picked from commit eecdf5220b1a559e4b58c3c21daf502e3fbfd1cd)

3 years agosctp: improve consistency in handling chunks with wrong size
Michael Tuexen [Wed, 28 Apr 2021 16:09:11 +0000 (18:09 +0200)]
sctp: improve consistency in handling chunks with wrong size

Just skip the chunk, if no other handling is required by the
specification.

(cherry picked from commit 9de7354bb8e0c7821aa90db3486605f933c6796d)

3 years agosctp: cleanup verification of INIT and INIT-ACK chunks
Michael Tuexen [Tue, 27 Apr 2021 10:45:14 +0000 (12:45 +0200)]
sctp: cleanup verification of INIT and INIT-ACK chunks

(cherry picked from commit 059ec2225c00cc18ed9745d733cc9aa0dbd9eaa2)

3 years agosctp: improve handling of illegal packets containing INIT chunks
Michael Tuexen [Mon, 26 Apr 2021 08:38:05 +0000 (10:38 +0200)]
sctp: improve handling of illegal packets containing INIT chunks

Stop further processing of a packet when detecting that it
contains an INIT chunk, which is too small or is not the only
chunk in the packet. Still allow to finish the processing
of chunks before the INIT chunk.

Thanks to Antoly Korniltsev and Taylor Brandstetter for reporting
an issue with the userland stack, which made me aware of this
issue.

(cherry picked from commit c70d1ef15db0d994eff4a2c4d9feabdc46bff1c6)

3 years agosctp: small cleanup, no functional change
Michael Tuexen [Mon, 26 Apr 2021 00:56:48 +0000 (02:56 +0200)]
sctp: small cleanup, no functional change

(cherry picked from commit 163153c2a0809d2710e607463dcb24c7f795e156)

3 years agosctp: fix handling of RTO.initial of 1 ms
Michael Tuexen [Mon, 22 Mar 2021 15:40:41 +0000 (16:40 +0100)]
sctp: fix handling of RTO.initial of 1 ms

Reported by: syzbot+5eb0e009147050056ce9@syzkaller.appspotmail.com

(cherry picked from commit d995cc7e5431873b839269fe22577acfa3b157bd)

3 years agotcp: improve handling of SYN segments in SYN-SENT state
Michael Tuexen [Mon, 22 Mar 2021 14:58:49 +0000 (15:58 +0100)]
tcp: improve handling of SYN segments in SYN-SENT state

Ensure that the stack does not generate a DSACK block for user
data received on a SYN segment in SYN-SENT state.

Reviewed by: rscheff
Differential Revision: https://reviews.freebsd.org/D29376
Sponsored by: Netflix, Inc.

(cherry picked from commit 40f41ece765dc0b0907ca90796a1af4f4f89b2a0)

3 years agosqlite3: import sqlite3 3.35.5
Cy Schubert [Fri, 7 May 2021 01:01:44 +0000 (18:01 -0700)]
sqlite3: import sqlite3 3.35.5

Merge commit '0511e356f5e2106928ee352ee974d1470c860a9a' into new_merge

Changes at https://www.sqlite.org/releaselog/3_35_5.html.

(cherry picked from commit ce9de47260d4edc963a94140789e4a52642c28e6)

3 years agoImport sqlite 3.34.1 (3340100).
Cy Schubert [Mon, 25 Jan 2021 17:45:04 +0000 (09:45 -0800)]
Import sqlite 3.34.1 (3340100).

(cherry picked from commit 25cdacf79b06356c929e59d5074d26c9dac41bdf)

3 years agovinvalbuf: do not panic if we were unable to flush dirty buffers
Konstantin Belousov [Sun, 30 May 2021 16:52:42 +0000 (19:52 +0300)]
vinvalbuf: do not panic if we were unable to flush dirty buffers

PR: 238565

(cherry picked from commit 27006229f7a40a18a61a0e8fd270bc583326b690)

3 years agoCirrus-CI: Add descriptive task name
Ed Maste [Wed, 2 Jun 2021 15:31:48 +0000 (11:31 -0400)]
Cirrus-CI: Add descriptive task name

Previously it appeared only as "main" in places like GitHub's list
of checks run as part of a pull request.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 903526542ac2309c08c769e517ea173a9f67cdb2)

3 years agoRestore Cirrus-CI boot smoke test
Ed Maste [Sun, 2 May 2021 19:28:36 +0000 (15:28 -0400)]
Restore Cirrus-CI boot smoke test

This reverts commit a7d593dd1da27833b5384349700bc3c7bcae6aad.
We now use compute_engine_instance which allows us to specify a custom
disk size.  Also go back to using the default qemu version (rather than
qemu42 or qemu-devel) as any issues were fixed some time ago.

Reviewed by: lwhsu, markj
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30082

(cherry picked from commit cec2682cd2910080951782391d7d7cd30c95c4ea)

3 years agoAdd C++ headers <barrier> <concepts> <execution> <latch> <numbers> <semaphore>
Dimitry Andric [Thu, 3 Jun 2021 18:53:18 +0000 (20:53 +0200)]
Add C++ headers <barrier> <concepts> <execution> <latch> <numbers> <semaphore>

I missed adding these to the libc++ Makefile, when importing
llvm-project 11.0.0-rc1, even though they were supplied by upstream.

While here, update OptionalObsoleteFiles.inc to add these new headers,
and cleanup old cruft.

Reported by: yuri
Submitted by: jkim (Makefile diff)
PR: 255374
MFC after: 3 days

(cherry picked from commit 95aa617e4bf09fcc813b1bab3d0dbf4b606807b1)

3 years agoMerge llvm commits for kernel address and memory sanitizer support
Dimitry Andric [Sun, 6 Jun 2021 11:38:33 +0000 (13:38 +0200)]
Merge llvm commits for kernel address and memory sanitizer support

Merge commit 99eca1bd9c7a from llvm git (by Mark Johnston):

  [Driver] Enable kernel address and memory sanitizers on FreeBSD

  Test Plan: using kernel ASAN and MSAN implementations in FreeBSD

  Reviewed By: emaste, dim, arichardson

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

Merge commit f511dc75e4c1 from llvm git (by Mark Johnston):

  [asan] Add an offset for the kernel address sanitizer on FreeBSD

  This is based on a port of the sanitizer runtime to the FreeBSD kernel
  that has been commited as https://cgit.freebsd.org/src/commit/?id=38da497a4dfcf1979c8c2b0e9f3fa0564035c147
  and the following commits.

  Reviewed By: emaste, dim
  Differential Revision: https://reviews.llvm.org/D98285

Requested by: markj
MFC after: 3 days

(cherry picked from commit 1b00608b264f1fac846e571e23d8ef7134834638)

3 years agorun(4): add support for DLINK DWA-130 rev F1 wireless adaptor.
Dmitry Chagin [Sun, 23 May 2021 18:31:51 +0000 (21:31 +0300)]
run(4): add support for DLINK DWA-130 rev F1 wireless adaptor.

PR: 256092
Submitted by: Francois Briere <purplefiasco at gmail.com>

(cherry picked from commit 8746bc91873430d977b09bcc3fbd4d1b417a5a57)

3 years agorsu(4): add ASUS WL-167G V3 to the list of supported devices.
Dmitry Chagin [Sun, 23 May 2021 15:42:29 +0000 (18:42 +0300)]
rsu(4): add ASUS WL-167G V3 to the list of supported devices.

(cherry picked from commit b595729ccfde8e5d5bac0acf9690de9d437a1afd)

3 years agocron: consume blanks in system crontabs before options
Oleksandr Tymoshenko [Thu, 4 Mar 2021 07:23:31 +0000 (23:23 -0800)]
cron: consume blanks in system crontabs before options

On system crontabs, multiple blanks are not being consumed after reading the
username. This change adds blank consumption before parsing any -[qn] options.
Without this change, an entry like:

  * * * * * username  -n true  # Two spaces between username and option.

will fail, as the shell will try to execute (' -n true'), while an entry like:

  * * * * * username -n true   # One space between username and option.

works as expected (executes 'true').

For user crontabs, this is not an issue as the preceding (day of week
or @shortcut) processing consumes any leading whitespace.

PR: 253699
Submitted by: Eric A. Borisch <eborisch@gmail.com>
MFC after: 1 week

(cherry picked from commit 37cd6c20dbcf251e38d6dfb9d3e02022941f6fc7)

3 years agonfscl: Add hash lists for the NFSv4 opens
Rick Macklem [Sat, 22 May 2021 21:51:38 +0000 (14:51 -0700)]
nfscl: Add hash lists for the NFSv4 opens

A problem was reported via email, where a large (130000+) accumulation
of NFSv4 opens on an NFSv4 mount caused significant lock contention
on the mutex used to protect the client mount's open/lock state.
Although the root cause for the accumulation of opens was not
resolved, it is obvious that the NFSv4 client is not designed to
handle 100000+ opens efficiently.  When searching for an open,
usually for a match by file handle, a linear search of all opens
is done.

This patch adds a table of hash lists for the opens, hashed on
file handle.  This table will be used by future commits to
search for an open based on file handle more efficiently.

(cherry picked from commit 3f7e14ad93454476bb11b4b8de5b41930d13312e)

3 years agopf: Fix more ioctl memory leaks
Kristof Provost [Tue, 1 Jun 2021 14:05:47 +0000 (16:05 +0200)]
pf: Fix more ioctl memory leaks

We must also remember to free nvlists added to a parent nvlist with
nvlist_append_nvlist_array().

More importantly, when nvlist_pack() allocates memory for us it does so
in the M_NVLIST zone, so we must free it with free(.., M_NVLIST). Using
free(.., M_TEMP) as we did silently failed to free the memory.

MFC after: 3 days
Reported by: kib@
Tested by: kib@
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30595

(cherry picked from commit 0f86492b09ca82042166a41f6f21b2dbe4f4a464)

3 years agonfsd: Add support for CLAIM_DELEG_PREV_FH to the NFSv4.1/4.2 Open
Rick Macklem [Fri, 21 May 2021 01:37:40 +0000 (18:37 -0700)]
nfsd: Add support for CLAIM_DELEG_PREV_FH to the NFSv4.1/4.2 Open

Commit b3d4c70dc60f added support for CLAIM_DELEG_CUR_FH to Open.
While doing this, I noticed that CLAIM_DELEG_PREV_FH support
could be added the same way.  Although I am not aware of any extant
NFSv4.1/4.2 client that uses this claim type, it seems prudent to add
support for this variant of Open to the NFSv4.1/4.2 server.

This patch does not affect mounts from extant NFSv4.1/4.2 clients,
as far as I know.

(cherry picked from commit d80a903a1c2acd73afbf06598955a0887433f8c6)

3 years agodaemon: add some basic tests
Alan Somers [Wed, 17 Mar 2021 16:35:00 +0000 (10:35 -0600)]
daemon: add some basic tests

Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D29316

(cherry picked from commit 3b57d80c7aa924ed0fad565591f5292c2ac88da5)

3 years agoFix handling of errors from pru_send(PRUS_NOTREADY)
Mark Johnston [Fri, 21 May 2021 21:44:46 +0000 (17:44 -0400)]
Fix handling of errors from pru_send(PRUS_NOTREADY)

PRUS_NOTREADY indicates that the caller has not yet populated the chain
with data, and so it is not ready for transmission.  This is used by
sendfile (for async I/O) and KTLS (for encryption).  In particular, if
pru_send returns an error, the caller is responsible for freeing the
chain since other implicit references to the data buffers exist.

For async sendfile, it happens that an error will only be returned if
the connection was dropped, in which case tcp_usr_ready() will handle
freeing the chain.  But since KTLS can be used in conjunction with the
regular socket I/O system calls, many more error cases - which do not
result in the connection being dropped - are reachable.  In these cases,
KTLS was effectively assuming success.

So:
- Change sosend_generic() to free the mbuf chain if
  pru_send(PRUS_NOTREADY) fails.  Nothing else owns a reference to the
  chain at that point.
- Similarly, in vn_sendfile() change the !async I/O && KTLS case to free
  the chain.
- If async I/O is still outstanding when pru_send fails in
  vn_sendfile(), set an error in the sfio structure so that the
  connection is aborted and the mbuf chain is freed.

Reviewed by: gallatin, tuexen
Discussed with: jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 916c61a5ed37da8ecdedd3c5512813d8dcec9a24)

3 years agotcp: Make error handling in tcp_usr_send() more consistent
Mark Johnston [Fri, 21 May 2021 21:44:40 +0000 (17:44 -0400)]
tcp: Make error handling in tcp_usr_send() more consistent

- Free the input mbuf in a single place instead of in every error path.
- Handle PRUS_NOTREADY consistently.
- Flush the socket's send buffer if an implicit connect fails.  At that
  point the mbuf has already been enqueued but we don't want to keep it
  in the send buffer.

Reviewed by: gallatin, tuexen
Discussed with: jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7d2608a5d24ec3534dad7f24191f12a8181ea206)

3 years agox86: initialize initial FPU state earlier
Konstantin Belousov [Thu, 27 May 2021 16:26:10 +0000 (19:26 +0300)]
x86: initialize initial FPU state earlier

PR: 255997

(cherry picked from commit c56de177d28295b4b07ad0b17e4faf4f11c9e4f2)

3 years agortld: Rename -t option to -u (ignore LD_ vars)
Konstantin Belousov [Wed, 2 Jun 2021 22:50:49 +0000 (01:50 +0300)]
rtld: Rename -t option to -u (ignore LD_ vars)

(cherry picked from commit e3149e0a02d6d09fb4c3acd085da2509dbab7320)

3 years agortld direct exec: add option to ignore LD_ variables
Konstantin Belousov [Fri, 28 May 2021 23:59:07 +0000 (02:59 +0300)]
rtld direct exec: add option to ignore LD_ variables

(cherry picked from commit d81f999ac22342789f2b3e21206d83d410be4df3)

3 years agoaic7xxx: Fix re-building firmware with -fno-common
Jessica Clarke [Fri, 28 May 2021 18:07:17 +0000 (19:07 +0100)]
aic7xxx: Fix re-building firmware with -fno-common

The generated C output for aicasm_scan.l defines yylineno already, so
references to it from other files should use an extern declaration.

The STAILQ_HEAD use in aicasm_symbol.h also provided an identifier,
causing it to both define the struct type and define a variable of that
struct type, causing any C file including the header to define the same
variable. This variable is not used (and confusingly clashes with a
field name just below) and was likely caused by confusion when switching
between defining fields using similar type macros and defining the type
itself.

Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30525

(cherry picked from commit 5e912f5fec025766521f535d1237330ede7f18e2)

3 years agosmartpqi: clear CCBs allocated on the stack
Edward Tomasz Napierala [Fri, 28 May 2021 06:33:37 +0000 (00:33 -0600)]
smartpqi: clear CCBs allocated on the stack

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

(cherry picked from commit e20e60be501204c3ba742e266afecc6c6e498a6c)

3 years agoNewly added features and bug fixes in latest Microchip SmartPQI driver
PAPANI SRIKANTH [Fri, 28 May 2021 06:17:56 +0000 (00:17 -0600)]
Newly added features and bug fixes in latest Microchip SmartPQI driver

It includes:

1)Newly added TMF feature.
2)Added newly Huawei & Inspur PCI ID's
3)Fixed smartpqi driver hangs in Z-Pool while running on FreeBSD12.1
4)Fixed flooding dmesg in kernel while the controller is offline during in ioctls.
5)Avoided unnecessary host memory allocation for rcb sg buffers.
6)Fixed race conditions while accessing internal rcb structure.
7)Fixed where Logical volumes exposing two different names to the OS it's due to the system memory is overwritten with DMA stale data.
8)Fixed dynamically unloading a smartpqi driver.
9)Added device_shutdown callback instead of deprecated shutdown_final kernel event in smartpqi driver.
10)Fixed where Os is crashed during physical drive hot removal during heavy IO.
11)Fixed OS crash during controller lockup/offline during heavy IO.
12)Fixed coverity issues in smartpqi driver
13)Fixed system crash while creating and deleting logical volume in a continuous loop.
14)Fixed where the volume size is not exposing to OS when it expands.
15)Added HC3 pci id's.

Reviewed by: Scott Benesh (microsemi), Murthy Bhat (microsemi), imp
Differential Revision: https://reviews.freebsd.org/D30182

(cherry picked from commit 9fac68fc3853b696c8479bb3a8181d62cb9f59c9)

3 years agolibpfctl: Improve error handling in pfctl_get_states()
Kristof Provost [Thu, 27 May 2021 09:43:17 +0000 (11:43 +0200)]
libpfctl: Improve error handling in pfctl_get_states()

Ensure that we always free nvlists and other allocated memory.

Reviewed by: scottl
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30493

(cherry picked from commit 27c77f42ae7402c313deec47aa67a8a8e0889410)

3 years agolibpfctl: fix memory leak
Kristof Provost [Thu, 27 May 2021 09:28:36 +0000 (11:28 +0200)]
libpfctl: fix memory leak

When we create an nvlist and insert it into another nvlist we must
remember to destroy it. The nvlist_add_nvlist() function makes a copy,
just like nvlist_add_string() makes a copy of the string.

See also 4483fb47735c29408c72045469c9c4b3e549668b

Reviewed by: scottl
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30492

(cherry picked from commit 6dbb729d35d59cc8bc8451bd56f220f9c35a43f3)

3 years agotcp, udp: Permit binding with AF_UNSPEC if the address is INADDR_ANY
Mark Johnston [Mon, 31 May 2021 22:53:34 +0000 (18:53 -0400)]
tcp, udp: Permit binding with AF_UNSPEC if the address is INADDR_ANY

Prior to commit f161d294b we only checked the sockaddr length, but now
we verify the address family as well.  This breaks at least ttcp.  Relax
the check to avoid breaking compatibility too much: permit AF_UNSPEC if
the address is INADDR_ANY.

Fixes: f161d294b
Reported by: Bakul Shah <bakul@iitbombay.org>
Reviewed by: tuexen
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f96603b56f0f74fa52d8f1ef0be869fca7305b99)

3 years agoktrace: Handle negative array sizes in ktrstructarray
Mark Johnston [Thu, 27 May 2021 19:49:12 +0000 (15:49 -0400)]
ktrace: Handle negative array sizes in ktrstructarray

ktrstructarray() may be used to create copies of kevent(2) change and
event arrays.  It is called before parameter validation is done and so
should check for bogus array lengths before allocating a copy.

Reported by: syzkaller
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f88510077377157008f648b7036e1d1c9c83ea23)

3 years agoipfilter: Fix ip_nat memory leak and use-after-free
Cy Schubert [Tue, 25 May 2021 18:54:49 +0000 (11:54 -0700)]
ipfilter: Fix ip_nat memory leak and use-after-free

Unfortunately the wrong elemet is freed, also resulting in use-after-free.

PR: 255859
Submitted by: lylgood@foxmail.com
Reported by: lylgood@foxmail.com

(cherry picked from commit 323a4e2c4e285e6f8eee8db3fe2cb7490a734da0)

3 years agoMFV d60fa10fd872db7e3d8cb1e161cfdae026c43b14:
Cy Schubert [Wed, 10 Feb 2021 04:25:05 +0000 (20:25 -0800)]
MFV d60fa10fd872db7e3d8cb1e161cfdae026c43b14:

Update unbound 1.13.0 --> 1.13.1.

Includes numerous bugfixes documented at:
https://www.nlnetlabs.nl/projects/unbound/download/#unbound-1-13-1

(cherry picked from commit f44e67d120ad78ef7894241b519ee79fd190a16e)

3 years agonfscl: Fix NFSv4.1/4.2 mount recovery from an expired lease
Rick Macklem [Wed, 19 May 2021 21:52:56 +0000 (14:52 -0700)]
nfscl: Fix NFSv4.1/4.2 mount recovery from an expired lease

The most difficult NFSv4 client recovery case happens when the
lease has expired on the server.  For NFSv4.0, the client will
receive a NFSERR_EXPIRED reply from the server to indicate this
has happened.
For NFSv4.1/4.2, most RPCs have a Sequence operation and, as such,
the client will receive a NFSERR_BADSESSION reply when the lease
has expired for these RPCs.  The client will then call nfscl_recover()
to handle the NFSERR_BADSESSION reply.  However, for the expired lease
case, the first reclaim Open will fail with NFSERR_NOGRACE.

This patch recognizes this case and calls nfscl_expireclient()
to handle the recovery from an expired lease.

This patch only affects NFSv4.1/4.2 mounts when the lease
expires on the server, due to a network partitioning that
exceeds the lease duration or similar.

(cherry picked from commit c28cb257ddfe3339756f6fd659fa4a2efa4de2cb)

3 years agoFix fsck_ufs segfault when it needs to rerun.
Kirk McKusick [Sat, 29 May 2021 02:41:05 +0000 (19:41 -0700)]
Fix fsck_ufs segfault when it needs to rerun.

Sponsored by: Netflix

(cherry picked from commit 5c9e9eb7a27feb24136c16706f3db8ce7c8bbc47)

3 years agopf tests: Only log critical errors from scapy
Kristof Provost [Wed, 26 May 2021 11:07:50 +0000 (13:07 +0200)]
pf tests: Only log critical errors from scapy

See a26e895f3d803cc1f4ee1c2b33c61330998808b9. Silence these new tests as
well.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 9d0bc96ef8c0288c05a627b3961edd2da046c5c9)