Commit graph

266008 commits

Author SHA1 Message Date
Martin Matuska
aef1ff87fe libarchive: import changes from upstream
Libarchive 3.5.2

New features:
  PR #1502: Support for PWB and v7 binary cpio formats
  PR #1509: Support of deflate algorithm in symbolic link decompression
            for ZIP archives

Important bugfixes:
  IS #1044: fix extraction of hardlinks to symlinks
  PR #1480: Fix truncation of size values during 7zip archive
            extraction on 32bit architectures
  PR #1504: fix rar header skiming
  PR #1514: ZIP excessive disk read - fix location of central directory
  PR #1520: fix double-free in CAB reader
  PR #1521: Fixed leak of rar before ending with error
  PR #1530: Handle short writes from archive_write_callback
  PR #1532: 7zip: Use compression settings from file also for file header
  IS #1566: do not follow symlinks when processing the fixup list

Relnotes:	yes

(cherry picked from commit ddce862ad8)
2021-09-10 10:24:13 +02:00
Toomas Soome
1f91b3b631 loader.efi: fix console output after BS off
When Boot Services (BS) are switched off, we can not use BS
functions any more. Since drawn console does implement our own
Blt(), we can use it to draw the console.

However, SimpleTextOutput protocol based console output must be
blocked.

Tested by inserting printf() after ExitBootServices() call.

(cherry picked from commit 4c7a3a70e0)
2021-09-09 11:28:07 +03:00
Konstantin Belousov
f09db311a9 cluster_write(): do not access buffer after it is released
(cherry picked from commit 5cc82c563e)
2021-09-09 04:21:44 +03:00
Ed Maste
887bc9fc9f openssh: regenerate freebsd-namespace.h
For some reason poly64 was omitted when this file was last generated
(perhaps it was inlined by the Clang version then in use).

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c7b4c21ee4)
2021-09-08 20:55:13 -04:00
Ed Maste
1ceb4ca5c5 openssh: disable libwrap (TCP wrappers) at configure time
We define LIBWRAP at build time in secure/usr.sbin/sshd/Makefile if
WITH_TCPWRAPPERS is in effect, so it should not be set in config.h.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 36cd1e5e8c)
2021-09-08 20:50:05 -04:00
Ed Maste
f63bf8a421 openssh: clarify krb5 use in freebsd-configure
freebsd-configure.sh runs configure twice, --with-kerberos5 and
--without-kerberos5, in order to build a config.h that defaults to
kerberos5 disabled, and a small config file that represents the
differences.

Rename config.h.orig to config.h.kerberos5 to clarify the intent of this
script.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 5e4dd21fd6)
2021-09-08 20:49:44 -04:00
Ed Maste
bd6137e1e6 openssh: tag generated file with @generated
Tools like Phabricator use the @generated tag to identify files that
may be excluded from review by default.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit b3e858f762)
2021-09-08 20:49:22 -04:00
Alfredo Dal'Ava Junior
d8199cf063 llvm: Revert "[HardwareLoops] Change order of SCEV expression construction for InitLoopCount."
Reverts llvm commit 42eaf4fe0adef3344adfd9fbccd49f325cb549ef, pointed
from bisect as source of regression that causes liblzma to compress/
uncompress incorrectly. It's know to affect powerpc64 BE only.

The patch unbreaks FreeBSD powerpc64 installation media, since
bsdinstall can't uncompress the *.txz produced by FreeBSD CI. It's
probably miscompiling other software bas well.

Upstream PR: https://bugs.llvm.org/show_bug.cgi?id=51714

Reviewed by:	dim
MFC after:	2 days
Sponsored by:	Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D31804

(cherry picked from commit f21fcae487)
2021-09-08 18:16:20 -03:00
Mark Johnston
aacbd4dd57 sctp: Implement sctp_inpcb_bind_locked()
This will be used by sctp_listen() to avoid dropping locks when
performing an implicit bind.  No functional change intended.

Reviewed by:	tuexen
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 457abbb857)
2021-09-08 08:41:16 -04:00
Mark Johnston
6bfe4afe73 sctp: Release the socket reference when detaching an association
Later in sctp_free_assoc(), when we clean up chunk lists,
sctp_free_spbufspace() is used to reset the byte count in the socket
send buffer.  However, if the PCB is going away, the socket may already
have been detached from the PCB, in which case this becomes a use-after
free.  Clear the socket reference from the association before detaching
it from the PCB, if the PCB has already lost its socket reference.

Reviewed by:	tuexen
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 65f30a39e1)
2021-09-08 08:40:36 -04:00
Mark Johnston
d30602a2b4 sctp: Hold association locks across socket wakeups when freeing
At this point we do not hold the inpcb lock, so the only thing holding
the socket reference live is the TCB lock, which needs to be acquired by
sctp_inpcb_free() in order to destroy associations.  Defer the unlock to
until after we dereference the socket reference.

Reported by:	syzbot+1d0f2c4675de76a4cf1e@syzkaller.appspotmail.com
Reported by:	syzbot+fabee77954fe69d3a5ad@syzkaller.appspotmail.com
Reviewed by:	tuexen
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d35be50f57)
2021-09-08 08:40:33 -04:00
Mark Johnston
2d0d1d6e07 sctp: Add macros to assert on inp info lock state
Reviewed by:	tuexen
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit be8ee77e9e)
2021-09-08 08:40:29 -04:00
Mark Johnston
617d22e2e8 kevent: Fix races between timer detach and kqtimer_proc_continue()
- When detaching a knote, we need to double check the enqueued flag
  after acquiring the process lock, as kqtimer_proc_continue() may have
  toggled it.
- kqtimer_proc_continue() could in principle reschedule a stopped
  callout after filt_timerdetach() drains the callout.  So, we need to
  re-check.

Reported by:	syzbot+4a4cebb3ec07892cb040@syzkaller.appspotmail.com
Reported by:	syzbot+a9c04bc76078a3b7dd8d@syzkaller.appspotmail.com
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c511383de7)
2021-09-08 08:39:38 -04:00
Kristof Provost
c298e0a0c2 pfctl: print counters in decimal
795d78a467 pfctl: Don't use PRIu64 mistakenly changed these to be
printed as hexadecimal numbers.

Reported by:	Florian Smeets
MFC after:	4 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 846a6e8f9a)
2021-09-08 09:28:29 +02:00
Kristof Provost
0c976ab9c0 pfctl: Don't use PRIu64
Rather than PRIu64 we can just treat the data as uintmax_t, and use %jx
instead.

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

(cherry picked from commit 795d78a467)
2021-09-08 09:28:25 +02:00
Kristof Provost
5804de11fd pf: import pf_set_protostate() from OpenBSD
to change a state's state (that term is overloaded in pf, protocol state
like ESTABLISHED for tcp here), don't do it directly, but go through a newly
introduced pf_set_protostate()

Reviewed by:	kbowling
Obtainted from:	OpenBSD
MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D31729

(cherry picked from commit ce3ea45047)
2021-09-08 09:28:21 +02:00
Kristof Provost
9136dfca19 pf: Add counters for syncookies
Count when we send a syncookie, receive a valid syncookie or detect a
synflood.

Reviewed by:	kbowling
MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D31713

(cherry picked from commit 4cab80a8df)
2021-09-08 09:28:14 +02:00
Vladimir Kondratyev
139144a7ae wsp(4): Add evdev support.
Reviewed by:	hselasky
Tested by:	Greg V, Constantin Furst<constantin_AT_fuersten_DOT_info>
PR:		252236
Differential revision:	https://reviews.freebsd.org/D31653

(cherry picked from commit 8d73071c47)
2021-09-08 03:01:07 +03:00
Vladimir Kondratyev
d780fe9df0 wsp(4): Compact parameter structure.
(cherry picked from commit 250ab00407)
2021-09-08 03:00:47 +03:00
Vladimir Kondratyev
5a5bab49a0 atp(4), wsp(4): Return correct priority from probe() method;
(cherry picked from commit 9fa1201d60)
2021-09-08 03:00:27 +03:00
Vladimir Kondratyev
45fd5fe9e9 evdev: Add support for automatic MT protocol type A to type B conversion.
(cherry picked from commit d056693d7b)
2021-09-08 02:59:57 +03:00
Vladimir Kondratyev
4174302b4a evdev: Add implicit mode for touch tracking.
In implicit mode assignment of slot number and tracking id is performed
automatically on each synchronization requested by device driver.

This is done with creation of intermediate buffer for multitouch events.
This buffer holds untracked events until synchronization is requested by
device driver. It is needed as touch assigment requires
knowledges of all touch positions pushed in current and previous reports.

(cherry picked from commit f76051c7da)
2021-09-08 02:59:35 +03:00
Vladimir Kondratyev
b79de251fc evdev: Import support for touch-tracking.
Touch tracking is a process of assignment of unique trackingID to each
initiated contact on the surface.  Keeping the trackingIDs persistent
across multitouch reports requires solving of so called Euclidian
Bipartite Matching problem.

This commit imports EBM-solver implementation based on Dinitz-Kronrod
algorithm to find minimum cost matching between contacts listed in two
consecutive reports.

Obtained from:	OpenBSD

(cherry picked from commit 4c0a134e32)
2021-09-08 02:59:12 +03:00
Vladimir Kondratyev
f160aa0d3d evdev: Make MT tracking IDs monotonically increasing sequence.
(cherry picked from commit 66bd52f5e2)
2021-09-08 02:58:47 +03:00
Vladimir Kondratyev
759a5cd1ef evdev: Give short aliases to items of evdev_mt_slot array
with using of unioned anonymous structure.

Access to the same data by using different members of union generally
works despite it is not supported by C specs.

Also add helper function to report entire slot state.

(cherry picked from commit 059360287e)
2021-09-08 02:58:25 +03:00
Vladimir Kondratyev
de6d60ee1c evdev: Normalize width and pressure of single touch compat events
to match Synaptics touchpad reporting range.

(cherry picked from commit 127e54deb6)
2021-09-08 02:57:57 +03:00
Vladimir Kondratyev
de20578e6d evdev: force no fuzz for autogenerated single touch compat events.
As fuzz has already been applied on multitouch event processing.
This allows to remove existing workaround for double fuzz procesing.

(cherry picked from commit 314913ed7c)
2021-09-08 02:57:34 +03:00
Vladimir Kondratyev
f7d9821cdb evdev: Send first active rather than 0-th slot state as ST report
(cherry picked from commit fbe17f9017)
2021-09-08 02:57:11 +03:00
Vladimir Kondratyev
5bf6cf0fbb evdev: Use bitsets to track active touches and slots changed in current report
Obtained from:	OpenBSD

(cherry picked from commit 2dc7188e53)
2021-09-08 02:55:37 +03:00
Vladimir Kondratyev
a437dfa5ca evdev: Multitouch code style changes.
1. Move touch count reporting helpers to utils. They are not multitouch.
2. Use evdev_mt prefix for private multitouch support routines.
3. Use int instead of int32_t where fixed size is not required.
4. Export some internal functions.

This change should be no-op.

(cherry picked from commit 98a7606b85)
2021-09-08 02:55:12 +03:00
Alexander V. Chernikov
f3d6900337 routing: Bring back the ability to specify transmit interface via its name.
Some software references outgoing interfaces by specifying name instead of
 index.

Use rti_ifp from rt_addrinfo if provided instead of always using
 address interface when constructing nexthop.

PR: 		255678
Reported by:	martin.larsson2 at gmail.com

(cherry picked from commit d98954e229)
2021-09-07 21:25:24 +00:00
Zhenlei Huang
e8df60a69a routing: Allow using IPv6 next-hops for IPv4 routes (RFC 5549).
Implement kernel support for RFC 5549/8950.

* Relax control plane restrictions and allow specifying IPv6 gateways
 for IPv4 routes. This behavior is controlled by the
 net.route.rib_route_ipv6_nexthop sysctl (on by default).

* Always pass final destination in ro->ro_dst in ip_forward().

* Use ro->ro_dst to exract packet family inside if_output() routines.
 Consistently use RO_GET_FAMILY() macro to handle ro=NULL case.

* Pass extracted family to nd6_resolve() to get the LLE with proper encap.
 It leverages recent lltable changes committed in c541bd368f.

Presence of the functionality can be checked using ipv4_rfc5549_support feature(3).
Example usage:
  route add -net 192.0.0.0/24 -inet6 fe80::5054:ff:fe14:e319%vtnet0

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

(cherry picked from commit 62e1a437f3)
2021-09-07 21:25:06 +00:00
Alexander V. Chernikov
e86f5d4fcb routing: Disallow zero nexthop weights in nexthop groups.
Adding such nexthops breaks calc_min_mpath_slots() assumptions,
 thus resulting in the incorrect nexthop group creation and
 eventually leading to panic.
Reported by:	avg

(cherry picked from commit 0a3a377aee)
2021-09-07 21:02:59 +00:00
Alexander V. Chernikov
8c73907c66 routing: simplify malloc flags in alloc_nhgrp().
(cherry picked from commit 639d7abec6)
2021-09-07 21:02:59 +00:00
Alexander V. Chernikov
0e77fc2a79 routing: Fix newly-added rt_get_inet[6]_parent() api.
Correctly handle the case when no default route is present.

Reported by:	Konrad <konrad.kreciwilk at korbank.pl>

(cherry picked from commit f84c30106e)
2021-09-07 21:02:59 +00:00
Alexander V. Chernikov
4e97cbba1c lltable: fix crash introduced in c541bd368f.
Reported by:	cy

(cherry picked from commit f8c1b1a929)
2021-09-07 21:02:58 +00:00
Alexander V. Chernikov
48f38f47b1 lltable: Add support for "child" LLEs holding encap for IPv4oIPv6 entries.
Currently we use pre-calculated headers inside LLE entries as prepend data
 for `if_output` functions. Using these headers allows saving some
 CPU cycles/memory accesses on the fast path.

However, this approach makes adding L2 header for IPv4 traffic with IPv6
 nexthops more complex, as it is not possible to store multiple
 pre-calculated headers inside lle. Additionally, the solution space is
 limited by the fact that PCB caching saves LLEs in addition to the nexthop.

Thus, add support for creating special "child" LLEs for the purpose of holding
 custom family encaps and store mbufs pending resolution. To simplify handling
 of those LLEs, store them in a linked-list inside a "parent" (e.g. normal) LLE.
 Such LLEs are not visible when iterating LLE table. Their lifecycle is bound
 to the "parent" LLE - it is not possible to delete "child" when parent is alive.
 Furthermore, "child" LLEs are static (RTF_STATIC), avoding complex state
 machine used by the standard LLEs.

nd6_lookup() and nd6_resolve() now accepts an additional argument, family,
 allowing to return such child LLEs. This change uses `LLE_SF()` macro which
 packs family and flags in a single int field. This is done to simplify merging
 back to stable/. Once this code lands, most of the cases will be converted to
 use a dedicated `family` parameter.

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

(cherry picked from commit c541bd368f)
2021-09-07 21:02:58 +00:00
Alexander V. Chernikov
5007bc4e13 routing: Fix crashes with dpdk_lpm[46] algo.
When a prefix gets deleted from the RIB, dpdk_lpm algo needs to know
 the nexthop of the "parent" prefix to update its internal state.
The glue code, which utilises RIB as a backing route store, uses
 fib[46]_lookup_rt() for the prefix destination after its deletion
 to fetch the desired nexthop.
This approach does not work when deleting less-specific prefixes
 with most-specific ones are still present. For example, if
 10.0.0.0/24, 10.0.0.0/23 and 10.0.0.0/22 exist in RIB, deleting
 10.0.0.0/23 would result in 10.0.0.0/24 being returned as a search
 result instead of 10.0.0.0/22. This, in turn, results in the failed
 datastructure update: part of the deleted /23 prefix will still
 contain the reference to an old nexthop. This leads to the
 use-after-free behaviour, ending with the eventual crashes.

Fix the logic flaw by properly fetching the prefix "parent" via
 newly-created rt_get_inet[6]_parent() helpers.

Differential Revision: https://reviews.freebsd.org/D31546
PR:	256882,256833

(cherry picked from commit 36e15b717e)
2021-09-07 21:02:58 +00:00
Alexander V. Chernikov
b17ecfd3a7 routing: add IPv6 fib validation procedure.
Allow consistency validation of the inet6 fib based on rib data.
Validation can be kicked off by loading test_lookup module and
 running sysctl net.route.test.run_inet6_scan=1

(cherry picked from commit cbfba56c45)
2021-09-07 21:02:58 +00:00
Alexander V. Chernikov
5b35ba2be3 routing: Use process fib instead of fib 0 when conducting tests.
* Allow to do validation/performance tests by using process
 fib instead of default fib 0.
* Print all validation errors instead of just the first one.

(cherry picked from commit 4a77a9b649)
2021-09-07 21:02:58 +00:00
Alexander V. Chernikov
10e0976103 Simplify nhop operations in ip_output().
Consistently use `nh` instead of always dereferencing
 ro->ro_nh inside the if block.
Always use nexthop mtu, as it provides guarantee that mtu is accurate.
Pass `nh` pointer to rt_update_ro_flags() to allow upcoming uses
 of updating ro flags based on different nexthop.

Differential Revision: https://reviews.freebsd.org/D31451
Reviewed by:	kp

(cherry picked from commit 9748eb7427)
2021-09-07 21:02:58 +00:00
Alexander V. Chernikov
4151d8ccdc [lltable] Restructure nd6 code.
Factor out lltable locking logic from lltable_try_set_entry_addr()
 into a separate lltable_acquire_wlock(), so the latter can be used
 in other parts of the code w/o duplication.

Create nd6_try_set_entry_addr() to avoid code duplication in nd6.c
 and nd6_nbr.c.

Move lle creation logic from nd6_resolve_slow() into a separate
 nd6_get_llentry() to simplify the former.

These changes serve as a pre-requisite for implementing
 RFC8950 (IPv4 prefixes with IPv6 nexthops).

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

(cherry picked from commit 0b79b007eb)
2021-09-07 21:02:58 +00:00
Alexander V. Chernikov
0ea561762b Use lltable calculated header when sending lle holdchain after successful lle resolution.
Subscribers: imp, ae, bz

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

(cherry picked from commit 8482aa7748)
2021-09-07 21:02:58 +00:00
Alexander V. Chernikov
2802014380 [lltable] Unify datapath feedback mechamism.
Use newly-create llentry_request_feedback(),
 llentry_mark_used() and llentry_get_hittime() to
 request datapatch usage check and fetch the results
 in the same fashion both in IPv4 and IPv6.

While here, simplify llentry_provide_feedback() wrapper
 by eliminating 1 condition check.

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

(cherry picked from commit f3a3b06121)
2021-09-07 21:02:58 +00:00
Alexander V. Chernikov
0f7162e0cd Fix typo in rib_unsibscribe<_locked>().
Submitted by:	Zhenlei Huang<zlei.huang at gmail.com>
Differential Revision: https://reviews.freebsd.org/D31356

(cherry picked from commit 5b42b494d5)
2021-09-07 21:02:57 +00:00
Alexander V. Chernikov
36854c4e1e [netflow] fix gateway reporting in ng_netflow
Reported by:	Guy Yur <guyyur at gmail.com>

(cherry picked from commit 8e55a80e0c)
2021-09-07 21:02:57 +00:00
Alexander V. Chernikov
a27813e130 Enforce check for using the return result for ifa?_try_ref().
Suggested by:	hps
Differential Revision:	https://reviews.freebsd.org/D29504

(cherry picked from commit 9e5243d7b6)
2021-09-07 21:01:31 +00:00
Alexander V. Chernikov
efa8c43ed6 Rename variables inside nexhtop group consider_resize() code.
No functional changes.

(cherry picked from commit 0f30a36ded)
2021-09-07 21:01:31 +00:00
Alexander V. Chernikov
311cf25c24 Simplify ifa/ifp refcounting in the routing stack.
The routing stack control depends on quite a tree of functions to
 determine the proper attributes of a route such as a source address (ifa)
 or transmit ifp of a route.

When actually inserting a route, the stack needs to ensure that ifa and ifp
 points to the entities that are still valid.
Validity means slightly more than just pointer validity - stack need guarantee
 that the provided objects are not scheduled for deletion.

Currently, callers either ignore it (most ifp parts, historically) or try to
 use refcounting (ifa parts). Even in case of ifa refcounting it's not always
 implemented in fully-safe manner. For example, some codepaths inside
 rt_getifa_fib() are referencing ifa while not holding any locks, resulting in
 possibility of referencing scheduled-for-deletion ifa.

Instead of trying to fix all of the callers by enforcing proper refcounting,
 switch to a different model.
As the rib_action() already requires epoch, do not require any stability guarantees
 other than the epoch-provided one.
Use newly-added conditional versions of the refcounting functions
 (ifa_try_ref(), if_try_ref()) and fail if any of these fails.

Reviewed by:	donner
Differential Revision:	https://reviews.freebsd.org/D28837

(cherry picked from commit 5964172837)
2021-09-07 20:55:51 +00:00
Alexander V. Chernikov
04e967d727 Add if_try_ref() to simplify refcount handling inside epoch.
When we have an ifp pointer and the code is running inside epoch,
 epoch guarantees the pointer will not be freed.
However, the following case can still happen:

* in thread 1 we drop to refcount=0 for ifp and schedule its deletion.
* in thread 2 we use this ifp and reference it
* destroy callout kicks in
* unhappy user reports a bug

This can happen with the current implementation of ifnet_byindex_ref(),
 as we're not holding any locks preventing ifnet deletion by a parallel thread.

To address it, add if_try_ref(), allowing to return failure when
 referencing ifp with refcount=0.
Additionally, enforce existing if_ref() is with KASSERT to provide a
 cleaner error in such scenarios.

Finally, fix ifnet_byindex_ref() by using if_try_ref() and returning NULL
 if the latter fails.

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

(cherry picked from commit 7563019bc6)
2021-09-07 20:55:51 +00:00