]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agolibradius: Fix input validation bugs
Mark Johnston [Tue, 25 May 2021 17:59:09 +0000 (13:59 -0400)]
libradius: Fix input validation bugs

Approved by: so
Security: FreeBSD-SA-21:12.libradius
Security: CVE-2021-29629
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 8d5c7813061dfa0b187500dfe3aeea7a28181c13)

2 years agoamd64/linux*: add required header to get the constant value
Konstantin Belousov [Tue, 25 May 2021 22:19:44 +0000 (01:19 +0300)]
amd64/linux*: add required header to get the constant value

Otherwise asm silently interpret it as the external global symbol.

Reported by: bz
Sponsored by: The FreeBSD Foundation
Fixes: 91aae953cb80

(cherry picked from commit a59f0285377aa3d61cccda64e9ade126ecb3d2d9)

2 years agoamd64: clear PSL.AC in the right frame
Konstantin Belousov [Sat, 22 May 2021 19:48:36 +0000 (22:48 +0300)]
amd64: clear PSL.AC in the right frame

If copyin family of routines fault, kernel does clear PSL.AC on the
fault entry, but the AC flag of the faulted frame is kept intact.  Since
onfault handler is effectively jump, AC survives until syscall exit.

Reported by: m00nbsd, via Sony
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
admbugs: 975

(cherry picked from commit 91aae953cb807d6fb7a70782b323bf9beb60d7c9)

2 years agoalc(4): add support for Mikrotik 10/25G NIC
Konstantin Belousov [Wed, 19 May 2021 22:14:18 +0000 (01:14 +0300)]
alc(4): add support for Mikrotik 10/25G NIC

PR: 256000

(cherry picked from commit 77b637338a3656d4ccedb9798a3f98ac283962f4)

2 years agodummynet: Fix mbuf tag allocation failure handling
Mark Johnston [Tue, 18 May 2021 19:22:21 +0000 (15:22 -0400)]
dummynet: Fix mbuf tag allocation failure handling

PR: 255875, 255878, 255879, 255880
Reviewed by: donner, kp
Sponsored by: The FreeBSD Foundation

(cherry picked from commit c4a6258d70f73c27d8f0c6233edbcc609791806b)

2 years agosocket: Release cred reference later in sodealloc()
Lv Yunlong [Tue, 18 May 2021 19:23:15 +0000 (15:23 -0400)]
socket: Release cred reference later in sodealloc()

We dereference so->so_cred to update the per-uid socket buffer
accounting, so the crfree() call must be deferred until after that
point.

PR: 255869

(cherry picked from commit b295c5ddcef4744ef7044d2327b4258b6ad055f0)

2 years agottydev_write: prevent stops while terminal is busied
Konstantin Belousov [Thu, 13 May 2021 01:35:06 +0000 (04:35 +0300)]
ttydev_write: prevent stops while terminal is busied

PR: 255816

(cherry picked from commit 8cf912b017a04a2eec01fbaa1f7b9ef556403ede)

2 years agoipfw.8: Fix table example
Lutz Donnerhacke [Mon, 10 May 2021 18:31:52 +0000 (20:31 +0200)]
ipfw.8: Fix table example

Fix some erronous lines in the example section.

PR: 248943
Submitted by: Jose Luis Duran
Reviewers: ae, manpages (gbe)
Differential Revision: https://reviews.freebsd.org/D30191

(cherry picked from commit 802637be06457c7593692bdf79f8466fa5f54d4a)

2 years agopf tests: Explicitly ask for python3
Kristof Provost [Wed, 17 Feb 2021 10:45:54 +0000 (11:45 +0100)]
pf tests: Explicitly ask for python3

If we install the scapy package (which we do list as a dependency) we
don't automatically install python (but we do have python3).

MFC after:      1 week
Sponsored by:   Rubicon Communications, LLC (“Netgate”’)

(cherry picked from commit 4a7d84058d88244c405fc0b73d6985681eb661f5)

2 years agonetpfil tests: Add missing copyright & license statements
Kristof Provost [Tue, 29 Oct 2019 09:47:12 +0000 (09:47 +0000)]
netpfil tests: Add missing copyright & license statements

(cherry picked from commit 65d553b0f055e192b80217632a91833c9f509ccf)

2 years agodummynet: Remove unused code
Kristof Provost [Mon, 17 May 2021 11:41:39 +0000 (13:41 +0200)]
dummynet: Remove unused code

We never set 'busy' and never dequeue from the pending mq. Remove this
code.

Reviewed by: ae
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30313

(cherry picked from commit 02c44f40f984951fe34a1c5a43f40ff8147c52ca)

2 years agopf tests: More set skip on <ifgroup> tests
Kristof Provost [Sun, 16 May 2021 06:51:54 +0000 (08:51 +0200)]
pf tests: More set skip on <ifgroup> tests

Test the specific case reported in PR 255852. Clearing the skip flag
on groups was broken because pfctl couldn't work out if a kif was a
group or not, because the kernel no longer set the pfik_group pointer.

PR: 255852
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30285

(cherry picked from commit 45db38554517c7e1b0cc0265113c22f92a0eb494)

2 years agopf: Set the pfik_group for userspace
Kristof Provost [Sun, 16 May 2021 06:50:17 +0000 (08:50 +0200)]
pf: Set the pfik_group for userspace

Userspace relies on this pointer to work out if the kif is a group or
not. It can't use it for anything else, because it's a pointer to a
kernel address. Substitute 0xfeedc0de for 'true', so that we don't leak
kernel memory addresses to userspace.

PR: 255852
Reviewed by: donner
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30284

(cherry picked from commit d69cc040147284c414dfd1c9f498dcc7c8291a8b)

2 years agolinux: Fix a mistake in commit fb58045145
Mark Johnston [Mon, 17 May 2021 02:17:53 +0000 (22:17 -0400)]
linux: Fix a mistake in commit fb58045145

The change to futex_andl_smap() should have ordered stac before the
load from a user address, otherwise it does not fix anything.

Fixes: fb58045145 ("linux: Fix SMAP-enabled futex routines")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 60cb98a1bd2e4ea8fda532261f7211f5d4eba9c0)

2 years agolinux: Fix SMAP-enabled futex routines
Mark Johnston [Sun, 16 May 2021 17:41:41 +0000 (13:41 -0400)]
linux: Fix SMAP-enabled futex routines

Some of them were dereferencing the user pointer before disabling SMAP.

PR: 255591
Reviewed by: kib
Tested by: pitwuu@gmail.com
Sponsored by: The FreeBSD Foundation

(cherry picked from commit fb580451456aa769daa2f4b2f077e39692f80c62)

2 years agorpi_ft5406: Recognize raspberrypi,firmware-ts touchscreen
Juraj Lutter [Fri, 7 May 2021 21:48:21 +0000 (23:48 +0200)]
rpi_ft5406: Recognize raspberrypi,firmware-ts touchscreen

- Recognize raspberrypi,firmware-ts touchscreen
- Move the driver from ofwbus to simplebus

Reviewed by: manu
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30169

(cherry picked from commit c2c9ef3cedf6d83bdf27308e9e022658cc9b2a08)
(cherry picked from commit e7cd56cfe03720b5c0e8596303f6d1672a402903)

2 years agonetgraph/ng_checksum: Fix double free error
Lutz Donnerhacke [Sat, 15 May 2021 09:32:57 +0000 (11:32 +0200)]
netgraph/ng_checksum: Fix double free error

m_pullup(9) frees the mbuf(9) chain in the case of an allocation error.
The mbuf chain must not be freed again in this case.

PR: 255874
Submitted by: <lylgood@foxmail.com>
Approved by: markj
Differential Revision: https://reviews.freebsd.org/D30273

(cherry picked from commit 687e510e5ce32fddf46a9dc1d517ccc8a8e25581)

2 years agoif_vlan.c: really fix it.
Eugene Grosbein [Sun, 23 May 2021 03:01:56 +0000 (10:01 +0700)]
if_vlan.c: really fix it.

Sigh... Another direct commit to stable/12 to fix build.

2 years agoif_vlan.c: fix breakage after previous merge
Eugene Grosbein [Sun, 23 May 2021 01:04:47 +0000 (08:04 +0700)]
if_vlan.c: fix breakage after previous merge

Fix breakage after the commit 18fa0cbfc4e906fbf824651140f68d0a85c1d08f.
This is direct commit to stable/12 due to code base difference with head.

2 years agoMFC r351629: sys/net/if_vlan.c: Wrap a vlan's parent's if_output
Matt Joras [Fri, 30 Aug 2019 20:19:43 +0000 (20:19 +0000)]
MFC r351629: sys/net/if_vlan.c: Wrap a vlan's parent's if_output
in a separate function.

The merge is done in preparation of another merge
to support 802.1ad (qinq). Original commit log follows.

When a vlan interface is created, its if_output is set directly to the
parent interface's if_output. This is fine in the normal case but has an
unfortunate consequence if you end up with a certain combination of vlan
and lagg interfaces.

Consider you have a lagg interface with a single laggport member. When
an interface is added to a lagg its if_output is set to
lagg_port_output, which blackholes traffic from the normal networking
stack but not certain frames from BPF (pseudo_AF_HDRCMPLT). If you now
create a vlan with the laggport member (not the lagg interface) as its
parent, its if_output is set to lagg_port_output as well. While this is
confusing conceptually and likely represents a misconfigured system, it
is not itself a problem. The problem arises when you then remove the
lagg interface. Doing this resets the if_output of the laggport member
back to its original state, but the vlan's if_output is left pointing to
lagg_port_output. This gives rise to the possibility that the system
will panic when e.g. bpf is used to send any frames on the vlan
interface.

Fix this by creating a new function, vlan_output, which simply wraps the
parent's current if_output. That way when the parent's if_output is
restored there is no stale usage of lagg_port_output.

Reviewed by: rstone
Differential Revision: D21209

(cherry picked from commit 16cf6bdbb6cb18a5af7b499034b2176a1fa0a503)

2 years agostorvsc: fix auto-sense reporting
Andriy Gapon [Fri, 7 May 2021 07:17:57 +0000 (10:17 +0300)]
storvsc: fix auto-sense reporting

I saw a situation where the driver set CAM_AUTOSNS_VALID on a failed ccb
even though SRB_STATUS_AUTOSENSE_VALID was not set in the status.
The actual sense data remained all zeros.
The problem seems to be that create_storvsc_request() always sets
hv_storvsc_request::sense_info_len, so checking for sense_info_len != 0
is not enough to determine if any auto-sense data is actually available.

Sponsored by: CyberSecure

(cherry picked from commit 8afecefd57c5ac95200f43227cd00f265154acee)

2 years agompsutil: extend show adapter information, add NCQ control
Daniel Austin [Fri, 7 May 2021 11:41:53 +0000 (14:41 +0300)]
mpsutil: extend show adapter information, add NCQ control

'show adapter' now shows PCIe width and speed, IOC Speed, and the
temperature of the controller.

A new command, 'set ncq', is added.
It enables or disables SATA NCQ in the NVRAM of the card.
Its current setting is added to 'show adapter' as well.

PR: 254841
Relnotes: perhaps

(cherry picked from commit e2ea6942ab316d4cd5c2fef73ab28dc974b8dc51)

2 years agoPCI hot-plug: use dedicated taskqueue for device attach / detach
Andriy Gapon [Thu, 6 May 2021 18:49:37 +0000 (21:49 +0300)]
PCI hot-plug: use dedicated taskqueue for device attach / detach

Attaching and detaching devices can be heavy-weight and detaching can
sleep waiting for events.  For that reason using the system-wide
single-threaded taskqueue_thread is not really appropriate.
There is even a possibility for a deadlock if taskqueue_thread is used
for detaching.

In fact, there is an easy to reproduce deadlock involving nvme, pass
and a sudden removal of an NVMe device.
A pass peripheral would not release a reference on an nvme sim until
pass_shutdown_kqueue() is executed via taskqueue_thread.  But the
taskqueue's thread is blocked in nvme_detach() -> ... -> cam_sim_free()
because of the outstanding reference.

Sponsored by: CyberSecure
Reviewed by: mav, imp

(cherry picked from commit 12588ce02dd835b332952d9fece5881d943554a9)

2 years agoCorrect assert added to dump program.
Kirk McKusick [Mon, 17 May 2021 23:33:59 +0000 (16:33 -0700)]
Correct assert added to dump program.

(cherry picked from commit efe145a7453e4208f032816ce3f80e9fb6b0e4ee)

2 years agonetgraph/ng_bridge: Handle send errors during loop handling
Lutz Donnerhacke [Tue, 27 Apr 2021 07:49:50 +0000 (09:49 +0200)]
netgraph/ng_bridge: Handle send errors during loop handling

If sending out a packet fails during the loop over all links, the
allocated memory is leaked and not all links receive a copy.  This
patch fixes those problems, clarifies a premature abort of the loop,
and fixes a minory style(9) bug.

PR: 255430
Submitted by: Dancho Penev
Tested by: Dancho Penev
Differential Revision: https://reviews.freebsd.org/D30008

(cherry picked from commit a56e5ad6903037861457da754574b4903dcb0e7e)

2 years agoEnsure that files with no allocated blocks are trimmed to zero length.
Kirk McKusick [Tue, 11 May 2021 21:51:06 +0000 (14:51 -0700)]
Ensure that files with no allocated blocks are trimmed to zero length.

(cherry picked from commit a3628327e7b62c955e7bad9e43044cdb01984d80)

2 years agotests: Only log critical errors from scapy
Kristof Provost [Wed, 12 May 2021 17:13:40 +0000 (19:13 +0200)]
tests: Only log critical errors from scapy

Since 2.4.5 scapy started issuing warnings about a few different
configurations during our tests. These are harmless, but they generate
stderr output, which upsets atf_check.

Configure scapy to only log critical errors (and thus not warnings) to
fix these tests.

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

(cherry picked from commit a26e895f3d803cc1f4ee1c2b33c61330998808b9)

2 years agobridge tests: Test STP config BPDU validation
Kristof Provost [Thu, 15 Apr 2021 12:55:00 +0000 (14:55 +0200)]
bridge tests: Test STP config BPDU validation

PR: 254924
Reviewed by: donner
Differential Revision: https://reviews.freebsd.org/D29783

(cherry picked from commit 4ae3a97e127cea14277b904af31483af7e6e2891)

2 years agobridgestp: validate timer values in config BPDU
Jonah Caplan [Thu, 15 Apr 2021 09:28:42 +0000 (11:28 +0200)]
bridgestp: validate timer values in config BPDU

IEEE Std 802.1D-2004 Section 17.14 defines permitted ranges for timers.
Incoming BPDU messages should be checked against the permitted ranges.
The rest of 17.14 appears to be enforced already.

PR: 254924
Reviewed by: kp, donner
Differential Revision: https://reviews.freebsd.org/D29782

(cherry picked from commit 0e4025bffa2bab3461b72b40d0b1468722ff76e6)

2 years agonetinet6 tests: Fix Python warning
Kristof Provost [Tue, 11 May 2021 13:47:45 +0000 (15:47 +0200)]
netinet6 tests: Fix Python warning

Python 3.8 warns about line 112:
    'SyntaxWarning: "is" with a literal. Did you mean "=="?'

Use '==' as Python suggests.

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

(cherry picked from commit 80430c15caac0c10832455f868fa01c912996982)

2 years agoe1000: fix em_mac_min and 82547 packet buffer
Kevin Bowling [Thu, 15 Apr 2021 16:58:36 +0000 (09:58 -0700)]
e1000: fix em_mac_min and 82547 packet buffer

The boundary differentiating "lem" vs "em" class devices was wrong
after the iflib conversion of lem(4).

The Packet Buffer size for 82547 class chips was not set correctly
after the iflib conversion of lem(4).

These changes restore functionality on an 82547 for the submitter.

PR: 236119
Reported by: Jeff Gibbons <jgibbons@protogate.com>
Reviewed by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29766

(cherry picked from commit bb1b375fa7487ee5c3843121a0621ac8379c18e6)

2 years agoe1000: disable hw.em.sbp debug setting
Kevin Bowling [Thu, 15 Apr 2021 16:48:41 +0000 (09:48 -0700)]
e1000: disable hw.em.sbp debug setting

This is a debugging tunable that shouldn't have retained this setting
after the initial iflib conversion of the driver

PR: 248934
Reported by: Franco Fichtner <franco@opnsense.org>
Reviewed by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29768

(cherry picked from commit 548d8a131d536d5f8e0818ff8cff7ffd63dbedfe)

2 years agosbin/ipfw: Fix parsing error in table based forward
Lutz Donnerhacke [Fri, 7 May 2021 18:59:34 +0000 (20:59 +0200)]
sbin/ipfw: Fix parsing error in table based forward

The argument parser does not recognise the optional port for an
"tablearg" argument.  Fix simplifies the code by make the internal
representation expicit for the parser.  Includes the fix from D30208.

PR: 252744
Reported by: <bugs.freebsd.org@mx.zzux.com>
Approved by: nc
Tested by: <bugs.freebsd.org@mx.zzux.com>
Differential Revision: https://reviews.freebsd.org/D30164

(cherry picked from commit 6cb13813caa09305046e0cecad8bba3ae2287b0d)
(cherry picked from commit f6f297871d469daf808f78faead8f950a2c81e36)

2 years agonfscl: fix typo in a comment
Rick Macklem [Tue, 4 May 2021 01:29:27 +0000 (18:29 -0700)]
nfscl: fix typo in a comment

(cherry picked from commit 0755df1eeee838e5b114c61886d6462507290977)

2 years agoin6_mcast: Return EADDRINUSE when we've already joined the group
Kristof Provost [Tue, 4 May 2021 17:23:15 +0000 (19:23 +0200)]
in6_mcast: Return EADDRINUSE when we've already joined the group

Distinguish between truly invalid requests and those that fail because
we've already joined the group. Both cases fail, but differentiating
them allows userspace to make more informed decisions about what the
error means.

For example. radvd tries to join the all-routers group on every SIGHUP.
This fails, because it's already joined it, but this failure should be
ignored (rather than treated as a sign that the interface's multicast is
broken).

This puts us in line with OpenBSD, NetBSD and Linux.

Reviewed by: donner
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30111

(cherry picked from commit 2ef5d803e3847f56771c107d9517ec560cf318c9)

2 years agoservice/ipfw: Silence warning on restart
Lutz Donnerhacke [Sun, 2 May 2021 20:47:04 +0000 (22:47 +0200)]
service/ipfw: Silence warning on restart

Once the ipfw0 interface has been created, ifconfig(8) create will
throw a warning: "ifconfig: create: bad value" when trying to create
it again.

PR: 241013
Submitted by: Jose Luis Duran
Approved by: kp
Differential Revision: https://reviews.freebsd.org/D30083

(cherry picked from commit 5c4fe2ac81a5e05062266d684fb53b9faefd0d38)

2 years agoClean up copyright messages.
Kirk McKusick [Tue, 11 May 2021 06:01:58 +0000 (23:01 -0700)]
Clean up copyright messages.

(cherry picked from commit 9e16b9530aab5e1c4efee2a8fe2feaf33340c764)

2 years agoClean up fsck_ffs error message output.
Kirk McKusick [Tue, 27 Apr 2021 01:42:48 +0000 (18:42 -0700)]
Clean up fsck_ffs error message output.

(cherry picked from commit 689724cb23c2acf58091c80f27de4823d7cd87ca)

Sponsored by: Netflix

2 years agoMake fsck_ffs more persistent in creating a lost+found directory.
Kirk McKusick [Mon, 26 Apr 2021 23:47:27 +0000 (16:47 -0700)]
Make fsck_ffs more persistent in creating a lost+found directory.

(cherry picked from commit 84a0e3f95700733695115fb2a9d84d6666efe5d9)

Sponsored by: Netflix

3 years agofind(1): Document the -f option
Ceri Davies [Thu, 13 May 2021 08:10:22 +0000 (10:10 +0200)]
find(1): Document the -f option

PR: 223127
Reported by: Mathieu Arnold <mat at FreeBSD dot org>
Reviewed by: bcr, gbe
Differential Revision: https://reviews.freebsd.org/D30215

(cherry picked from commit 82483ea7adfe4213059f6dacf31f3bd1327b2cc0)

3 years agousr.bin/patch: remove unneeded header.
Xin LI [Sun, 2 May 2021 16:27:32 +0000 (09:27 -0700)]
usr.bin/patch: remove unneeded header.

(cherry picked from commit 9769f6f808210ddc304bc9e3c55121e6ce4d9075)

3 years agopf tests: Test killing matching states
Kristof Provost [Mon, 3 May 2021 13:31:03 +0000 (15:31 +0200)]
pf tests: Test killing matching states

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30093

(cherry picked from commit ac200a9c3847d3a92c347de60e32a7af430dede6)

3 years agopf: Support killing 'matching' states
Kristof Provost [Mon, 3 May 2021 13:35:50 +0000 (15:35 +0200)]
pf: Support killing 'matching' states

Optionally also kill states that match (i.e. are the NATed state or
opposite direction state entry for) the state we're killing.

See also https://redmine.pfsense.org/issues/8555

Submitted by: Steven Brown
Reviewed by: bcr (man page)
Obtained from: https://github.com/pfsense/FreeBSD-src/pull/11/
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30092

(cherry picked from commit 93abcf17e6cf3c1cd8511c8ff7a8bf20b2d76367)

3 years agoauthpf: Start using libpfctl
Kristof Provost [Fri, 30 Apr 2021 08:26:52 +0000 (10:26 +0200)]
authpf: Start using libpfctl

Use pfctl_kill_states() rather than the DIOCKILLSTATES ioctl directly.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30057

(cherry picked from commit 2b2ed4a69730be72f792179d57dedf2945b3d1aa)

3 years agopf tests: Test killing states by gateway
Kristof Provost [Fri, 30 Apr 2021 15:07:23 +0000 (17:07 +0200)]
pf tests: Test killing states by gateway

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30059

(cherry picked from commit c2e11d81d295f7d55ac8b6858b09d8fa123cbfe8)

3 years agopf: Allow states to by killed per 'gateway'
Kristof Provost [Fri, 30 Apr 2021 13:15:05 +0000 (15:15 +0200)]
pf: Allow states to by killed per 'gateway'

This allows us to kill states created from a rule with route-to/reply-to
set.  This is particularly useful in multi-wan setups, where one of the
WAN links goes down.

Submitted by: Steven Brown
Obtained from: https://github.com/pfsense/FreeBSD-src/pull/11/
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30058

(cherry picked from commit abbcba9cf5b1c26e837f00e0fbc205652cb05e51)

3 years agopfctl: Optionally show gateway information for states
Kristof Provost [Wed, 28 Apr 2021 16:17:40 +0000 (18:17 +0200)]
pfctl: Optionally show gateway information for states

When showing the states, in very verbose mode, also display the gateway
(i.e. the target for route-to/reply-to).

Submitted by: Steven Brown
Reviewed by: donner
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30051

(cherry picked from commit cc948296e632e023f9374ccee68b5710f2ad54a9)

3 years agopfctl: Start using DIOCKILLSTATESNV
Kristof Provost [Thu, 29 Apr 2021 19:24:56 +0000 (21:24 +0200)]
pfctl: Start using DIOCKILLSTATESNV

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30055

(cherry picked from commit 2a00c4db93b8db0c326a57363ca8a690ef6ab082)

3 years agopfctl: Start using DIOCCLRSTATESNV
Kristof Provost [Thu, 29 Apr 2021 13:10:50 +0000 (15:10 +0200)]
pfctl: Start using DIOCCLRSTATESNV

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30053

(cherry picked from commit 53714a586133fd8ae662427007f84ec663cd83ef)

3 years agopf: Introduce DIOCKILLSTATESNV
Kristof Provost [Thu, 29 Apr 2021 15:20:36 +0000 (17:20 +0200)]
pf: Introduce DIOCKILLSTATESNV

Introduce an nvlist based alternative to DIOCKILLSTATES.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30054

(cherry picked from commit e989530a09b6e9f77b89c950ecf32f1b4fa709da)

3 years agopf: Introduce DIOCCLRSTATESNV
Kristof Provost [Thu, 29 Apr 2021 09:07:02 +0000 (11:07 +0200)]
pf: Introduce DIOCCLRSTATESNV

Introduce an nvlist variant of DIOCCLRSTATES.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30052

(cherry picked from commit 7606a45dcc87cb6b222af929dad37b615cb925cf)

3 years agorelease.sh: pass UNAME_r for embedded builds
Glen Barber [Thu, 13 May 2021 15:02:16 +0000 (11:02 -0400)]
release.sh: pass UNAME_r for embedded builds

This is a direct commit to stable/12 due to a merge conflict
mistake.

Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agorelease: fix logic for ports update/checkout if the directory exists
Glen Barber [Wed, 12 May 2021 15:29:54 +0000 (11:29 -0400)]
release: fix logic for ports update/checkout if the directory exists

This is a direct commit to stable/12.

Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agorelease: fix command to check out ports tree
Glen Barber [Wed, 12 May 2021 15:12:34 +0000 (11:12 -0400)]
release: fix command to check out ports tree

This is a direct commit to stable/12.

Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agorelease: permanently remove the 'reldoc' target and associates
Glen Barber [Thu, 18 Feb 2021 04:00:03 +0000 (23:00 -0500)]
release: permanently remove the 'reldoc' target and associates

Following 7b1d1a1658ffb69eff93afc713f9e88ed8b20eac, the structure
for the reldoc target has significantly changed as result of the
ASCIIDoctor/Hugo migration.  As the release notes related files
on the installation medium are inherently out of date, purge them
entirely.

Discussed within: re, doceng
No objection: re (silence), doceng (silence)
Timeout: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit f61e92ca5a23450bc28169bbdd71d7674df98c19)

3 years agorelease: disable the 'reldoc' target after the ASCIIDoctor switch
Glen Barber [Fri, 5 Feb 2021 16:46:49 +0000 (11:46 -0500)]
release: disable the 'reldoc' target after the ASCIIDoctor switch

The 'reldoc' target includes release-related documentation on
installation medium.  Since the switch from XML to ASCIIDoctor,
the file locations have moved, and it will take some time to sort
out how this target should work now.

Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 7b1d1a1658ffb69eff93afc713f9e88ed8b20eac)

3 years agofull(4): Use correct section name for AUTHORS
Gordon Bergling [Sun, 9 May 2021 15:31:52 +0000 (17:31 +0200)]
full(4): Use correct section name for AUTHORS

PR: 255715
Reported by: Christos Margiolis <christos at christosmarg dot xyz>

(cherry picked from commit 416051f5818e3270e019ef8978e2f1168f2628fc)

3 years agonfscl: Fix mis-merge in cherry-pick commit 44d99af3c545
Rick Macklem [Wed, 12 May 2021 02:46:46 +0000 (19:46 -0700)]
nfscl: Fix mis-merge in cherry-pick commit 44d99af3c545

This is a direct commit.

3 years agonfscl: add check for NULL clp and forced dismounts to nfscl_delegreturnvp()
Rick Macklem [Wed, 28 Apr 2021 00:30:16 +0000 (17:30 -0700)]
nfscl: add check for NULL clp and forced dismounts to nfscl_delegreturnvp()

Commit aad780464fad added a function called nfscl_delegreturnvp()
to return delegations during the NFS VOP_RECLAIM().
The function erroneously assumed that nm_clp would
be non-NULL. It will be NULL for NFSV4.0 mounts until
a regular file is opened. It will also be NULL during
vflush() in nfs_unmount() for a forced dismount.

This patch adds a check for clp == NULL to fix this.

Also, since it makes no sense to call nfscl_delegreturnvp()
during a forced dismount, the patch adds a check for that
case and does not do the call during forced dismounts.

PR: 255436
(cherry picked from commit f6fec55fe30088bbefd3efe70b62565399a7b9b8)

3 years agonfscl: return delegations in the NFS VOP_RECLAIM()
Rick Macklem [Mon, 26 Apr 2021 00:57:55 +0000 (17:57 -0700)]
nfscl: return delegations in the NFS VOP_RECLAIM()

After a vnode is recycled it can no longer be
acquired via vfs_hash_get() and, as such,
a delegation for the vnode cannot be recalled.

In the unlikely event that a delegation still
exists when the vnode is being recycled, return
the delegation since it will no longer be
recallable.

Until you have this patch in your NFSv4 client,
you should consider avoiding the use of delegations.

(cherry picked from commit aad780464fad1e32c97316515a4044d661413a6b)

3 years agopf: Error tracing SDTs
Kristof Provost [Tue, 20 Apr 2021 09:18:26 +0000 (11:18 +0200)]
pf: Error tracing SDTs

Add additional DTrace static trace points to facilitate debugging
failing pf ioctl calls.

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

(cherry picked from commit 6b146f3b9b665c9baf6ba2cb038bbee359cb738a)

3 years agopf tests: Test set keepcounters
Kristof Provost [Thu, 15 Apr 2021 14:53:16 +0000 (16:53 +0200)]
pf tests: Test set keepcounters

MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29781

(cherry picked from commit e14d56f370184fdf7ef33ec57883a45f4a220cff)

3 years agopf: Optionally attempt to preserve rule counter values across ruleset updates
Kristof Provost [Thu, 15 Apr 2021 14:12:11 +0000 (16:12 +0200)]
pf: Optionally attempt to preserve rule counter values across ruleset updates

Usually rule counters are reset to zero on every update of the ruleset.
With keepcounters set pf will attempt to find matching rules between old
and new rulesets and preserve the rule counters.

MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29780

(cherry picked from commit 42ec75f83aa321fcea8d2eddc4e9099724f0669e)

3 years agopf: Implement the NAT source port selection of MAP-E Customer Edge
Kurosawa Takahiro [Tue, 13 Apr 2021 08:50:00 +0000 (10:50 +0200)]
pf: Implement the NAT source port selection of MAP-E Customer Edge

MAP-E (RFC 7597) requires special care for selecting source ports
in NAT operation on the Customer Edge because a part of bits of the port
numbers are used by the Border Relay to distinguish another side of the
IPv4-over-IPv6 tunnel.

PR: 254577
Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D29468

(cherry picked from commit 2aa21096c7349390f22aa5d06b373a575baed1b4)

3 years agonfscl: fix the handling of NFSERR_DELAY for Open/LayoutGet RPCs
Rick Macklem [Tue, 27 Apr 2021 00:48:21 +0000 (17:48 -0700)]
nfscl: fix the handling of NFSERR_DELAY for Open/LayoutGet RPCs

For a pNFS mount, the NFSv4.1/4.2 client uses compound RPCs that
have both Open and LayoutGet operations in them.
If the pNFS server were tp reply NFSERR_DELAY for one of these
compounds, the retry after a delay cannot be handled by
newnfs_request(), since there is a reference held on the open
state for the Open operation in them.

Fix this by adding these RPCs to the "don't do delay here"
list in newnfs_request().

This patch is only needed if the mount is using pNFS (the "pnfs"
mount option) and probably only matters if the MDS server
is issuing delegations as well as pNFS layouts.

Found by code inspection.

(cherry picked from commit f5ff282bc025f0395afcef40f5b6e778202c4181)

3 years agonfsd: fix a NFSv4.1 Linux client mount stuck in CLOSE_WAIT
Rick Macklem [Tue, 27 Apr 2021 22:32:35 +0000 (15:32 -0700)]
nfsd: fix a NFSv4.1 Linux client mount stuck in CLOSE_WAIT

It was reported that a NFSv4.1 Linux client mount against
a FreeBSD12 server was hung, with the TCP connection in
CLOSE_WAIT state on the server.
When a NFSv4.1/4.2 mount is done and the back channel is
bound to the TCP connection, the soclose() is delayed until
a new TCP connection is bound to the back channel, due to
a reference count being held on the SVCXPRT structure in
the krpc for the socket. Without the soclose() call, the socket
will remain in CLOSE_WAIT and this somehow caused the Linux
client to hang.

This patch adds calls to soshutdown(.., SHUT_WR) that
are performed when the server side krpc sees that the
socket is no longer usable.  Since this can be done
before the back channel is bound to a new TCP connection,
it allows the TCP connection to proceed to CLOSED state.

PR: 254590
(cherry picked from commit db8c27f499105dcc9872dcc46e88bdd570c24fee)

3 years agonfsclient: Copy only initialized fields in nfs_getattr()
Mark Johnston [Tue, 4 May 2021 12:53:57 +0000 (08:53 -0400)]
nfsclient: Copy only initialized fields in nfs_getattr()

When loading attributes from the cache, the NFS client is careful to
copy only the fields that it initialized.  After fetching attributes
from the server, however, it would copy the entire vattr structure
initialized from the RPC response, so uninitialized stack bytes would
end up being copied to userspace.  In particular, va_birthtime (v2 and
v3) and va_gen (v3) had this problem.

Use a common subroutine to copy fields provided by the NFS client, and
ensure that we provide a dummy va_gen for the v3 case.

Reviewed by: rmacklem
Reported by: KMSAN
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30090

(cherry picked from commit 8bde6d15d1fa9a947c2bdc5eddae36cfbb1076dc)

3 years agopf: Trivial typo fix
Kristof Provost [Thu, 29 Apr 2021 08:34:00 +0000 (10:34 +0200)]
pf: Trivial typo fix

PV -> PF

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

(cherry picked from commit eaabed8ac449dbd9a7f4f567e9378bda4636221e)

3 years agopfsync: Expose PFSYNCF_OK flag to userspace
Kristof Provost [Fri, 23 Apr 2021 12:24:59 +0000 (14:24 +0200)]
pfsync: Expose PFSYNCF_OK flag to userspace

Add 'syncok' field to ifconfig's pfsync interface output. This allows
userspace to figure out when pfsync has completed the initial bulk
import.

Reviewed by: donner
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29948

(cherry picked from commit 5f5bf88949df421ec3ccd7e14a999e8d8b9251bf)

3 years agopf tests: Test killing states with multiple labels
Kristof Provost [Wed, 21 Apr 2021 14:12:48 +0000 (16:12 +0200)]
pf tests: Test killing states with multiple labels

Now that we support having multiple labels on a rule ensure that we can
use each rule label to kill states.

MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29938

(cherry picked from commit 5632f585355ad380cb9ef932c419e2efdb1fc46b)

3 years agopf: Allow multiple labels to be set on a rule
Kristof Provost [Tue, 20 Apr 2021 09:04:48 +0000 (11:04 +0200)]
pf: Allow multiple labels to be set on a rule

Allow up to 5 labels to be set on each rule.
This offers more flexibility in using labels. For example, it replaces
the customer 'schedule' keyword used by pfSense to terminate states
according to a schedule.

Reviewed by: glebius
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29936

(cherry picked from commit 6fcc8e042ac480f9276177339f7de1ad0f95c1b0)

3 years agopf tests: Test automatically generated tables
Kristof Provost [Mon, 26 Apr 2021 09:14:44 +0000 (11:14 +0200)]
pf tests: Test automatically generated tables

Add a test case where the pfctl optimizer will generate a table
automatically. These tables have long names, which we accidentally broke
in the nvlist ADDRULE ioctl.

Reviewed by: melifaro
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29989

(cherry picked from commit 08d77308211f823b8532d27790e8fd29eaf75c77)

3 years agopf: Fix parsing of long table names
Kristof Provost [Sat, 24 Apr 2021 13:55:24 +0000 (15:55 +0200)]
pf: Fix parsing of long table names

When parsing the nvlist for a struct pf_addr_wrap we unconditionally
tried to parse "ifname". This broke for PF_ADDR_TABLE when the table
name was longer than IFNAMSIZ. PF_TABLE_NAME_SIZE is longer than
IFNAMSIZ, so this is a valid configuration.

Only parse (or return) ifname or tblname for the corresponding
pf_addr_wrap type.

This manifested as a failure to set rules such as these, where the pfctl
optimiser generated an automatic table:

pass in proto tcp to 192.168.0.1 port ssh
pass in proto tcp to 192.168.0.2 port ssh
pass in proto tcp to 192.168.0.3 port ssh
pass in proto tcp to 192.168.0.4 port ssh
pass in proto tcp to 192.168.0.5 port ssh
pass in proto tcp to 192.168.0.6 port ssh
pass in proto tcp to 192.168.0.7 port ssh

Reported by: Florian Smeets
Tested by: Florian Smeets
Reviewed by: donner
X-MFC-With: 5c11c5a3655842a176124ef2334fcdf830422c8a
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29962

(cherry picked from commit 402dfb0a8d2c6417cb9bff4460ef250a42b0aa05)

3 years agoUPDATING: Add an entry for commit e9959506d2cc
Rick Macklem [Mon, 10 May 2021 16:05:10 +0000 (09:05 -0700)]
UPDATING: Add an entry for commit e9959506d2cc

3 years agoparam.h: Bump __FreeBSD_version to 1202507 for commit e9959506d2cc
Rick Macklem [Mon, 10 May 2021 16:00:50 +0000 (09:00 -0700)]
param.h: Bump __FreeBSD_version to 1202507 for commit e9959506d2cc

Commit e9959506d2cc changed the internal KAPI between the
nfscl.ko and nfscommon.ko modules, so they both need to be
rebuilt from sources.

3 years agonfsd: fix the slot sequence# when a callback fails
Rick Macklem [Mon, 26 Apr 2021 23:24:10 +0000 (16:24 -0700)]
nfsd: fix the slot sequence# when a callback fails

Commit 4281bfec3628 patched the server so that the
callback session slot would be free'd for reuse when
a callback attempt fails.
However, this can often result in the sequence# for
the session slot to be advanced such that the client
end will reply NFSERR_SEQMISORDERED.

To avoid the NFSERR_SEQMISORDERED client reply,
this patch negates the sequence# advance for the
case where the callback has failed.
The common case is a failed back channel, where
the callback cannot be sent to the client, and
not advancing the sequence# is correct for this
case.  For the uncommon case where the client's
reply to the callback is lost, not advancing the
sequence# will indicate to the client that the
next callback is a retry and not a new callback.
But, since the FreeBSD server always sets "csa_cachethis"
false in the callback sequence operation, a retry
and a new callback should be handled the same way
by the client, so this should not matter.

Until you have this patch in your NFSv4.1/4.2 server,
you should consider avoiding the use of delegations.
Even with this patch, interoperation with the
Linux NFSv4.1/4.2 client in kernel versions prior
to 5.3 can result in frequent 15second delays if
delegations are enabled.  This occurs because, for
kernels prior to 5.3, the Linux client does a TCP
reconnect every time it sees multiple concurrent
callbacks and then it takes 15seconds to recover
the back channel after doing so.

(cherry picked from commit 87597731488105dd1ab921a95e39bb62e1abe668)

3 years agonfsd: fix session slot handling for failed callbacks
Rick Macklem [Fri, 23 Apr 2021 22:24:47 +0000 (15:24 -0700)]
nfsd: fix session slot handling for failed callbacks

When the NFSv4.1/4.2 server does a callback to a client
on the back channel, it will use a session slot in the
back channel session. If the back channel has failed,
the callback will fail and, without this patch, the
session slot will not be released.
As more callbacks are attempted, all session slots
can become busy and then the nfsd thread gets stuck
waiting for a back channel session slot.

This patch frees the session slot upon callback
failure to avoid this problem.

Without this patch, the problem can be avoided by leaving
delegations disabled in the NFS server.

(cherry picked from commit 4281bfec36285e2212f41568459c077bf4dbd91c)

3 years agobhyve: Set SO_REUSEADDR on the gdb stub socket
Mark Johnston [Mon, 3 May 2021 16:42:54 +0000 (12:42 -0400)]
bhyve: Set SO_REUSEADDR on the gdb stub socket

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30037

(cherry picked from commit 02e7a6514e63ceca680fade40797280aef1bf55f)

3 years agoAdd Apollo Lake SIO/LPSS UARTs PCI IDs
Jose Luis Duran [Sun, 2 May 2021 21:20:25 +0000 (21:20 +0000)]
Add Apollo Lake SIO/LPSS UARTs PCI IDs

PR: 255556

(cherry picked from commit 8f1562430fbb83f6cedff6450e1aa1b593e3d7e7)

3 years agouart_bus_pci.c: Style
Jose Luis Duran [Sun, 2 May 2021 21:20:25 +0000 (21:20 +0000)]
uart_bus_pci.c: Style

PR: 255556

(cherry picked from commit 5b8b6b26e40a81320f02a46df98b96bd8e93295a)

3 years agoifconfig: Minor documentation fix
Jose Luis Duran [Thu, 29 Apr 2021 11:03:48 +0000 (11:03 +0000)]
ifconfig: Minor documentation fix

PR: 255557

(cherry picked from commit 0ea8a7f36db31bfc550bbe5e39703fdedd12fa8c)

3 years agonetgraph/ng_source: Switch queuing framework
Lutz Donnerhacke [Fri, 29 Jan 2021 11:03:17 +0000 (12:03 +0100)]
netgraph/ng_source: Switch queuing framework

Change the queuing framework from ifq to mbufq.

Reported by: glebius
Reviewed by: glebius, kp
Differential Revision: https://reviews.freebsd.org/D28407

(cherry picked from commit ebc61c86b5567f2e5a3c5f452e86879b558b376b)

3 years agonetgraph/ng_source: If queue is full, don't enqueue
Lutz Donnerhacke [Sat, 23 Jan 2021 17:54:47 +0000 (18:54 +0100)]
netgraph/ng_source: If queue is full, don't enqueue

Submitted by: nc
Reviewed by: donner, kp
Differential Revision: https://reviews.freebsd.org/D23477

(cherry picked from commit d7dd28bb09fa51b9958a5dc288d2aeef56a67491)

3 years agonetgraph/ng_base: Allow larger BINARY2ASCII conversions
Lutz Donnerhacke [Sun, 7 Feb 2021 21:07:34 +0000 (22:07 +0100)]
netgraph/ng_base: Allow larger BINARY2ASCII conversions

Allocate the necessary memory for the conversion dynamically starting
with a value which is sufficient for almost all normal cases.

PR: 187835
Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D23840

(cherry picked from commit 45d75e3ac3fb5bf8230ca28dc09b48c6e5ed7a4f)

3 years agosbin/ipfw: Fix null pointer deference when printing counters
Lutz Donnerhacke [Sun, 9 May 2021 12:48:47 +0000 (14:48 +0200)]
sbin/ipfw: Fix null pointer deference when printing counters

ipfw -[tT] prints statistics of the last access. If the rule was never
used, the counter might be not exist.  This happens unconditionally on
inserting a new rule.  Avoid printing statistics in this case.

PR: 255491
Reported by: Haisheng Zhouz
Reviewed by: ae
Differential Revision: https://reviews.freebsd.org/D30046

(cherry picked from commit bf7cc0f9cb6603a6bdd6131c8d1939724ce6e62d)

3 years agonfscl: fix delegation recall when the file is not open
Rick Macklem [Sun, 25 Apr 2021 19:52:48 +0000 (12:52 -0700)]
nfscl: fix delegation recall when the file is not open

Without this patch, if a NFSv4 server recalled a
delegation when the file is not open, the renew
thread would block in the NFS VOP_INACTIVE()
trying to acquire the client state lock that it
already holds.

This patch fixes the problem by delaying the
vrele() call until after the client state
lock is released.

This bug has been in the NFSv4 client for
a long time, but since it only affects
delegation when recalled due to another
client opening the file, it got missed
during previous testing.

Until you have this patch in your client,
you should avoid the use of delegations.

(cherry picked from commit 02695ea8909d818ceaa726f90f889889dfd39fac)

3 years agoless: upgrade to v581.2.
Xin LI [Mon, 19 Apr 2021 02:46:19 +0000 (19:46 -0700)]
less: upgrade to v581.2.

(cherry picked from commit 50d31dbc6e2bc3aa6007edb8cdecbcb84e85d6c0)

less: upgrade to v581.

(cherry picked from commit 2235c7feac959bcc9ddfd6a2bc6be32102b1f84c)

3 years agorelease.7: update for current context
Ed Maste [Tue, 1 Sep 2020 15:30:40 +0000 (15:30 +0000)]
release.7: update for current context

It's no longer unusual to be able to build a release with a single
command, so drop "actually" that hints at a surprise.  Also just use
"network install directory" instead of referencing FTP; it's more
likely to be HTTP now.

Reviewed by: gjb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26260

(cherry picked from commit 55c9a224e2a9c01d461003837ff6563803b63210)

3 years agopf tests: Test scrub fragment reassemble on interfaces with different MTU
Kristof Provost [Tue, 27 Apr 2021 16:46:03 +0000 (18:46 +0200)]
pf tests: Test scrub fragment reassemble on interfaces with different MTU

There's a problem with pf's reassembly code where it produces incorrect
checksums when reassembling across interfaces with different MTUs.
Test this.

PR: 255432
Reviewed by: donner
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30013

(cherry picked from commit 388c0cde10293d9a3434e99146bf391aec6878a3)

3 years agopf: Fix IP checksum on reassembly
Kristof Provost [Wed, 28 Apr 2021 10:56:06 +0000 (12:56 +0200)]
pf: Fix IP checksum on reassembly

If we reassemble a packet we modify the IP header (to set the length and
remove the fragment offset information), but we failed to update the
checksum. On certain setups (mostly where we did not re-fragment again
afterwards) this could lead to us sending out packets with incorrect
checksums.

PR: 255432
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30026

(cherry picked from commit 055c55abefbe19fe46a56894595af9c9dad7678c)

3 years agopf: PFRULE_REFS should not be user-visible
Kristof Provost [Thu, 15 Apr 2021 11:38:56 +0000 (13:38 +0200)]
pf: PFRULE_REFS should not be user-visible

Split the PFRULE_REFS flag from the rule_flag field. PFRULE_REFS is a
kernel-internal flag and should not be exposed to or read from
userspace.

MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29778

(cherry picked from commit 4f1f67e88853ac9e3c2d8897cf6dab6cfda8d16e)

3 years agolibpfct: Fix PIC flag
Kristof Provost [Fri, 16 Apr 2021 19:00:51 +0000 (21:00 +0200)]
libpfct: Fix PIC flag

Use ${PICFLAG} rather than hard-adding -fPIC, which removes the
requirement for libnv to be built PIC.

MFC after:      4 weeks
Sponsored by:   Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 8403170b3d39326f836bc999534fe8c4d41cda11)

3 years agopf tests: Test clearing rules counters
Kristof Provost [Mon, 12 Apr 2021 15:29:19 +0000 (17:29 +0200)]
pf tests: Test clearing rules counters

This was briefly broken, so ensure that we can read and clear rules
counters.

MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29728

(cherry picked from commit 112f007e12818ba3d54869b331139090e69dbc74)

3 years agopfctl: Fix clearing rules counters
Kristof Provost [Mon, 12 Apr 2021 15:23:33 +0000 (17:23 +0200)]
pfctl: Fix clearing rules counters

After the migration to libpfctl for rule retrieval we accidentally lost
support for clearing the rules counters.

Introduce a get_clear variant of pfctl_get_rule() which allows rules
counters to be cleared.

MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29727

(cherry picked from commit 4eabfe468b6e80a0823523d83dc908c27ec823c7)

3 years agopfctl, libpfctl: introduce pfctl_pool
Kurosawa Takahiro [Mon, 12 Apr 2021 14:03:40 +0000 (16:03 +0200)]
pfctl, libpfctl: introduce pfctl_pool

Introduce pfctl_pool to be able to extend the pool part of the pf rule
without breaking the ABI.

Reviewed by: kp
MFC after: 4 weeks
Differential Revision: https://reviews.freebsd.org/D29721

(cherry picked from commit 600bd6ce0639c84b763516477250df5964e8edf6)

3 years agopf: Ensure that we don't use kif passed to pfi_kkif_attach()
Kristof Provost [Mon, 12 Apr 2021 09:45:48 +0000 (11:45 +0200)]
pf: Ensure that we don't use kif passed to pfi_kkif_attach()

Once a kif is passed to pfi_kkif_attach() we must ensure we never re-use
it for anything else.
Set the kif to NULL afterwards to guarantee this.

Reported-by: syzbot+be5d4f4a7a4c295e659a@syzkaller.appspotmail.com
MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 5e98cae661f3a7e85df7f277660765b823454073)

3 years agolibnv: Use PICFLAG rather than -fPIC
Kristof Provost [Sat, 10 Apr 2021 09:23:57 +0000 (11:23 +0200)]
libnv: Use PICFLAG rather than -fPIC

Suggested by: andrew
MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 15ca66220874c177602c13a114b2f3d17773b788)

3 years agolibpfctl: Fix u_* counters
Kristof Provost [Thu, 8 Apr 2021 08:36:18 +0000 (10:36 +0200)]
libpfctl: Fix u_* counters

struct pf_rule had a few counter_u64_t counters. Those couldn't be
usefully comminicated with userspace, so the fields were doubled up in
uint64_t u_* versions.

Now that we use struct pfctl_rule (i.e. a fully userspace version) we
can safely change the structure and remove this wart.

Reviewed by: glebius
MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29645

(cherry picked from commit ab5707a5cf86ed66dbd11e03ad9676766da9a47b)

3 years agolibpfctl: Switch to pfctl_rule
Kristof Provost [Thu, 8 Apr 2021 08:31:46 +0000 (10:31 +0200)]
libpfctl: Switch to pfctl_rule

Stop using the kernel's struct pf_rule, switch to libpfctl's pfctl_rule.
Now that we use nvlists to communicate with the kernel these structures
can be fully decoupled.

Reviewed by: glebius
MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29644

(cherry picked from commit e9eb09414a8de8f3329f51b48c90a5e5ac8f09cf)

3 years agopf: Move prototypes for userspace functions to userspace header
Kristof Provost [Wed, 7 Apr 2021 17:49:51 +0000 (19:49 +0200)]
pf: Move prototypes for userspace functions to userspace header

These functions no longer exist in the kernel, so there's no reason to
keep the prototypes in a kernel header. Move them to pfctl where they're
actually implemented.

Reviewed by: glebius
MFC after: 4 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29643

(cherry picked from commit a9b338b260be39cc74dddb599d6c95b8794ca98b)