]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agosbin/md5: add md5sum to synopsis in the man-page
Stefan Eßer [Sat, 19 Jun 2021 11:27:16 +0000 (13:27 +0200)]
sbin/md5: add md5sum to synopsis in the man-page

When invoked with "sum" following the hash name, the -c option takes a
file argument, not a string argument.

(cherry picked from commit 84f35b6f86efd004a8f25ef6eecea0f5d02733c4)

sbin/md5: improve compatibility with coreutils -c option

The -c option expects a digest file in either BSD or coreutils format.

The output for matched and mismatched files is identical to that
of the coreutils version.

The review of these changes included test cases that have already
been committed for the functionality that existed before.
Another test script is added to cover the coreutils compatible
extension implemented by this patch.

This commit contains a tests/Makefile that has been cleaned up
compared to the review version, using an implicit rule to apply the
TESTBASE path at build time (and the scripts have been renamed to
have an extension of .SH instead of .sh to trigger this rule).

Reviewed by:    imp
Differential Revision:  https://reviews.freebsd.org/D30812

(cherry picked from commit b33d1898c1b0e6d76b52eb48078260588802dc95)

md5: Improve compatibility with coreutils and format fix

The previous changes that added support for the coreutils -c option
modified the output generated by passing -r to match that of the
coreutils versions. The difference is that coreutils separates the
hash from the file name by two blanks "  " (or a blank followed by
an asterisk " *" with the -b option denoting).

While most scripts or users will not notice the difference, it might
be considered a violation of POLA and this commit reverts the change
for the non-sum programs. These will print a single blank " " as the
separator, as they die before the previous commit.

In order to still generate output that is identical to that of the
coreutils programs, this commit generates the "  " or " *" separator
used by them for the -sum versions, depending on the presence of the
-b option.

(cherry picked from commit b33d1898c1b0e6d76b52eb48078260588802dc95)

md5: Fix cross-build after c2870e576bd2

On macOS and Linux the current set of headers do not end up pulling in
sys/param.h, causing MAXPATHLEN to not be defined and the build to fail.

(cherry picked from commit cab31e0e216c7defefd4aba14693ba2252ea7308)

2 years agomd5: portability fix -- include stdbool.h explicitly
Warner Losh [Thu, 20 May 2021 17:26:46 +0000 (11:26 -0600)]
md5: portability fix -- include stdbool.h explicitly

stdbool.h needs to be included to use type bool variables. Due to
namespace pollution, this gets brought in on FreeBSD, but not on
other systems. Include it explicilty.

Noticed by: arichards@
Sponsored by: Netflix

2 years agomd5: Create md5sum, etc compatible programs
Warner Losh [Wed, 19 May 2021 17:26:20 +0000 (11:26 -0600)]
md5: Create md5sum, etc compatible programs

On Linux, there's a similar set of programs to ours, but that end in the
letters 'sum'. These act basically like FreeBSD versions run with the -r
option. Add code so that when the program ends in 'sum' you get the
linux -r behavior. This is enough to make most things that use sha*sum
work correctly (the -c / --check options, as well as the long args are
not implemented). When running with the -sum programs, ignore -t instead
of running internal speed tests and make -c an error.

Reviewed by: sef, and kp and allanjude (earlier version)
Relnotes: yes
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D30309

2 years agosbin/md5: Create /usr/tests/sbin/md5 directory for placing tests
Li-Wen Hsu [Fri, 25 Jun 2021 10:29:46 +0000 (18:29 +0800)]
sbin/md5: Create /usr/tests/sbin/md5 directory for placing tests

Author: Li-Wen Hsu <lwhsu@FreeBSD.org>
Sponsored by: The FreeBSD Foundation

(cherry picked from commit cb194afef50dc4e1473413a69462aaf03cfe0ce4)

sbin/md5: add tests

While the correctness of the supported hash algorithms can be tested
with the built-in self-test feature, these test cases are meant to
detect changes in the output format.

A follow-up commit will improve the compatibility with the coreutils
versions of the hash programs, and these tests should detect any
unintended side-effects of such a change on existing functionality.

(cherry picked from commit 884fc5527a3ffd9830b941cbec328de1623044cc)

sbin/md5: fix test case to not write outside temp directory

The bsd-p-test did create files 1.out .. 8.out in the test directory.
This has been fixed and the temporary output files are now written
to the temporary directory.

(cherry picked from commit 95d3044bbdadfca6120a3e7c61c9ebb9a476f369)

2 years agolibalias: Switch to SPLAY trees
Lutz Donnerhacke [Thu, 27 May 2021 21:42:54 +0000 (23:42 +0200)]
libalias: Switch to SPLAY trees

Current data structure is using a hash of unordered lists.  Those
unordered lists are quite efficient, because the least recently
inserted entries are most likely to be used again.  In order to avoid
long search times in other cases, the lists are hashed into many
buckets.  Unfortunatly a search for a miss needs an exhaustive
inspection and a careful definition of the hash.

Splay trees offer a similar feature - almost O(1) for access of the
least recently used entries), and amortized O(ln(n) - for almost all
other cases.  Get rid of the hash.

Now the data structure should able to quickly react to external
packets without eating CPU cycles for breakfast, preventing a DoS.

PR: 192888
Discussed with: Dimitry Luhtionov
Differential Revision: https://reviews.freebsd.org/D30516
Differential Revision: https://reviews.freebsd.org/D30536
Differential Revision: https://reviews.freebsd.org/D30844

(cherry picked from commit 935fc93af157dee352eb4b6c83f8a2a9e7fd9a4e)
(cherry picked from commit d261e57deacb0d00d9e827447f235df83dda3e3a)
(cherry picked from commit f70c98a2f5d993dc518efd606aa341eda99400ef)
(cherry picked from commit 25392fac9488bcae5c451500df2e2945430484a6)
(cherry picked from commit 2f4d91f9cb22fc65eb65407e8118b433a5d71976)
(cherry picked from commit 4060e77f49d1b9fd2254f3f4da94fd64fce83f72)

2 years agolibalias: Restructure
Lutz Donnerhacke [Tue, 25 May 2021 13:03:34 +0000 (15:03 +0200)]
libalias: Restructure

Clean up the database handling in order to switch to more efficient
data structures.  The development of this patch was artificially split
in to many small steps to ease reviewing.

- Common search terms
- Separate fully qualified search
- Separate table for partial links
- Cleanup _FindLinkIn
- Factor out the outgoing search function
- Factor out a common idiom to return found links
- Reorder incoming links by grouping of common search terms
- Remove LSNAT from outgoing search
- Group internal structure semantically
- Separate table for PPTP
- Use AliasRange instead of PORT_BASE
- Remove temporary state deleteAllLinks from global struct
- Avoid uninitialized expiration

Discussed with: Dimitry Luhtionov
Differential Revision: https://reviews.freebsd.org/D30568
Differential Revision: https://reviews.freebsd.org/D30569
Differential Revision: https://reviews.freebsd.org/D30570
Differential Revision: https://reviews.freebsd.org/D30571
Differential Revision: https://reviews.freebsd.org/D30572
Differential Revision: https://reviews.freebsd.org/D30573
Differential Revision: https://reviews.freebsd.org/D30574
Differential Revision: https://reviews.freebsd.org/D30575
Differential Revision: https://reviews.freebsd.org/D30580
Differential Revision: https://reviews.freebsd.org/D30581
Differential Revision: https://reviews.freebsd.org/D30604
Differential Revision: https://reviews.freebsd.org/D30582

(cherry picked from commit d41044ddfdbc2a026570cae11d5fc2e18f5e4b92)
(cherry picked from commit 32f9c2ceb3ec8266e48ec0f6d1556fd98ef12db6)
(cherry picked from commit cac129e6030095c33e95c5ce1cdcb9c5c21efce9)
(cherry picked from commit 19dcc4f2250b3850991366e3058ca8a64b2f135d)
(cherry picked from commit d5419034381d0e8e8c99f0f678118b197144bfff)
(cherry picked from commit d4ab07d2aeb13b1aae9ad5d73e5fe77131f2350c)
(cherry picked from commit 492d3b7109b45ff30fd199b7eeed797447746e42)
(cherry picked from commit 7b44ff4c52ce9e7a89e772566a249e5481fe0ac4)
(cherry picked from commit 1178dda53d10b096e0b99e356d15b7c24390e099)
(cherry picked from commit 9efcad61d8309ecad3c15392b277fd329a1e45e4)
(cherry picked from commit fe83900f9fa931e3d0942ec9c0709896b887c3d7)
(cherry picked from commit d989935b5bcd880353f0de89eda958c45e7e3342)
(cherry picked from commit b50a4dce185481bebf8096c27588ae04a4a2fd7c)
(cherry picked from commit f28455344483310cfd1aa5c0bdd4d014810c0e32)

2 years agolibalias: Promote per instance global variable timeStamp
Lutz Donnerhacke [Tue, 25 May 2021 07:07:21 +0000 (09:07 +0200)]
libalias: Promote per instance global variable timeStamp

Summary:
- Use LibAliasTime as a real global variable for central timekeeping.
- Reduce number of syscalls in user space considerably.
- Dynamically adjust the packet counters to match the second resolution.
- Only check the first few packets after a time increase for expiry.

Discussed with: hselasky
Differential Revision: https://reviews.freebsd.org/D30566

(cherry picked from commit ef828d39be8e4b6d922db080ed41611702dec56d)

2 years agolibalias: Stats are unsigned
Lutz Donnerhacke [Mon, 31 May 2021 22:08:24 +0000 (00:08 +0200)]
libalias: Stats are unsigned

Stats counters are used as unsigned valued (i.e. printf("%u")) but are
defined as signed int.  This causes trouble later, so fix it early.

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

(cherry picked from commit 3fd20a79e7b55d135bbc5fa197980fe0e9ee0f14)

2 years agolibalias: tidy up housekeeping
Lutz Donnerhacke [Sat, 15 May 2021 15:35:36 +0000 (17:35 +0200)]
libalias: tidy up housekeeping

Replace current expensive, but sparsly called housekeeping
by a single, repetive action.

This is part of a larger restructure of libalias in order to switch to
more efficient data structures.  The whole restructure process is
split into 15 reviews to ease reviewing.  All those steps will be
squashed into a single commit for MFC in order to hide the
intermediate states from production systems.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30277

(cherry picked from commit 294799c6b081faece556a5010a4f51552e131c2f)

2 years agorefcount: add refcount_releasen
Mateusz Guzik [Mon, 5 Jul 2021 12:45:32 +0000 (12:45 +0000)]
refcount: add refcount_releasen

This is a direct commit as the routine in main was added as a side
effect of functionality which later got reverted.

2 years agopf: make DIOCGETSTATESNV iterations killable
Mateusz Guzik [Fri, 2 Jul 2021 07:28:48 +0000 (09:28 +0200)]
pf: make DIOCGETSTATESNV iterations killable

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

(cherry picked from commit 48d5b86364fa8e86318805d0078ccf9066e94ae8)

2 years agopfctl: cache getprotobynumber results
Mateusz Guzik [Thu, 1 Jul 2021 19:25:43 +0000 (21:25 +0200)]
pfctl: cache getprotobynumber results

As for example pfctl -ss keeps calling it, it saves a lot of overhead
from elided parsing of /etc/nsswitch.conf and /etc/protocols.

Sample result when running a pre-nvlist binary with nfs root and dumping
7 mln states:
before: 24.817u 62.993s 1:28.52 99.1%
after: 8.064u 1.117s 0:18.87 48.5%

Idea by Jim Thompson

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

(cherry picked from commit 858937bea4599d254a97ee6321683f8629604e15)

2 years agopf: revert: Use counter(9) for pf_state byte/packet tracking
Mateusz Guzik [Mon, 28 Jun 2021 18:50:56 +0000 (20:50 +0200)]
pf: revert: Use counter(9) for pf_state byte/packet tracking

stats are not shared and consequently per-CPU counters only waste
memory.

No slowdown was measured when passing over 20M pps.

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

(cherry picked from commit 55cc305dfcad0ad7c4f528fa47f7473927e8223a)

2 years agopf: make sure the dtrace probe has safe access to state
Mateusz Guzik [Mon, 28 Jun 2021 19:32:20 +0000 (21:32 +0200)]
pf: make sure the dtrace probe has safe access to state

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

(cherry picked from commit d26ef5c7ac830812f07a02787f25fed5d6f8609e)

2 years agopf: deduplicate V_pf_state_z handling with pfsync
Mateusz Guzik [Mon, 28 Jun 2021 18:18:26 +0000 (20:18 +0200)]
pf: deduplicate V_pf_state_z handling with pfsync

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

(cherry picked from commit 803dfe3da0e30520227a791ba5c2b93da16e1cf5)

2 years agopf: fix error-case leaks in pf_create_state
Mateusz Guzik [Mon, 28 Jun 2021 18:29:58 +0000 (20:29 +0200)]
pf: fix error-case leaks in pf_create_state

The hand-rolled clean up failed to free counters.

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

(cherry picked from commit 7f025db57c7879bfa43ac74ecd95903439fdd1d0)

2 years agopf: assert that sizeof(struct pf_state) <= 312
Mateusz Guzik [Mon, 28 Jun 2021 12:49:40 +0000 (14:49 +0200)]
pf: assert that sizeof(struct pf_state) <= 312

To prevent accidentally going over a threshold which makes UMA fit only
12 objects per page instead of 13.

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

(cherry picked from commit e6dd0e2e8d4f59275fb576a9ccb9d356d36457bb)

2 years agopf: factor out state allocation into pf_alloc_state
Mateusz Guzik [Mon, 28 Jun 2021 12:22:31 +0000 (14:22 +0200)]
pf: factor out state allocation into pf_alloc_state

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

(cherry picked from commit ccb17a21041e9206b80fa9f64b6ec20233df6403)

2 years agopf: add pf_release_staten and use it in pf_unlink_state
Mateusz Guzik [Mon, 28 Jun 2021 12:18:43 +0000 (14:18 +0200)]
pf: add pf_release_staten and use it in pf_unlink_state

Saves one atomic op.

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

(cherry picked from commit d09388d013300fc4aa1ee1a6bc24260cd400aff3)

2 years agopf: Add endline to all DPFPRINTF()
Kristof Provost [Sun, 24 Nov 2019 13:53:36 +0000 (13:53 +0000)]
pf: Add endline to all DPFPRINTF()

DPFPRINTF() doesn't automatically add an endline, so be consistent and
always add it.

(cherry picked from commit 492f3a312a2617899809285cdb6a32baf6836b13)

2 years agotests/libalias: Bugfix in used variables
Lutz Donnerhacke [Fri, 2 Jul 2021 21:58:16 +0000 (23:58 +0200)]
tests/libalias: Bugfix in used variables

Fix two copy and waste errors (referencing the wrong variable).

(cherry picked from commit b3dc6f137b8d626c4415a5fa9c9874ac4ca78658)

2 years agofusefs: delete dead code
Alan Somers [Tue, 15 Jun 2021 19:34:01 +0000 (13:34 -0600)]
fusefs: delete dead code

Delete two fields in the per-mountpoint struct that have never been
used.

Sponsored by: Axcient

(cherry picked from commit d63e6bc256016c7f5223ff5541671e5a96c4c6c4)

2 years agoid: sanitize arguments better
Alan Somers [Fri, 11 Jun 2021 16:38:07 +0000 (10:38 -0600)]
id: sanitize arguments better

The -[AMc] flags ignore the user argument.  Better if id rejects
invocations that include a user argument along with any of those flags.

PR: 256554
Reviewed by: trasz
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D30734

(cherry picked from commit 4a06e9377398b34922f8a67d7cb3ea980b95bde8)

2 years agobhyvectl: print a better error message when vm_open() fails
Marko [Sun, 7 Mar 2021 06:19:30 +0000 (21:19 -0900)]
bhyvectl: print a better error message when vm_open() fails

libvmm: explicitly save and restore errno in vm_open()

Use errno to print a more descriptive error message when vm_open() fails

PR:             250671
Reviewed by: grehan
Differential Revision: https://reviews.freebsd.org/D29109

(cherry picked from commit 6bb140e3ca895a148f32c93d50f93619bf735f73)
(cherry picked from commit a7f81b488df2d4a5dcd785b4112e04ffb6ca0442)

2 years agolinux(4): Prevent integer overflow in futex_requeue.
Dmitry Chagin [Thu, 10 Jun 2021 11:23:11 +0000 (14:23 +0300)]
linux(4): Prevent integer overflow in futex_requeue.

To prevent a signed integer overflow in futex_requeue add a sanity check
to catch negative values of nrwake or nrrequeue.

(cherry picked from commit 25b09d6f398ea8a260ee8e2e8209fd76c61e13ee)

2 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)

2 years agoUPDATING: Add an entry for commit 6ae32cc8182f
Rick Macklem [Sat, 26 Jun 2021 23:53:13 +0000 (16:53 -0700)]
UPDATING: Add an entry for commit 6ae32cc8182f

This is a direct commit.

2 years agoparam.h: Bump __FreeBSD_version for commit 6ae32cc8182f
Rick Macklem [Sat, 26 Jun 2021 23:47:59 +0000 (16:47 -0700)]
param.h: Bump __FreeBSD_version for commit 6ae32cc8182f

Commit 6ae32cc8182f changed the internal KAPI between the krpc and
nfsd modules.  As such, both need to be rebuilt from sources.
Bump __FreeBSD_version to 1202508.

This is a direct commit.

2 years agokrpc: Acquire ref count of CLIENT for backchannel use
Rick Macklem [Fri, 11 Jun 2021 23:57:14 +0000 (16:57 -0700)]
krpc: Acquire ref count of CLIENT for backchannel use

Michael Dexter <editor@callfortesting.org> reported
a crash in FreeNAS, where the first argument to
clnt_bck_svccall() was no longer valid.
This argument is a pointer to the callback CLIENT
structure, which is free'd when the associated
NFSv4 ClientID is free'd.

This appears to have occurred because a callback
reply was still in the socket receive queue when
the CLIENT structure was free'd.

This patch acquires a reference count on the CLIENT
that is not CLNT_RELEASE()'d until the socket structure
is destroyed. This should guarantee that the CLIENT
structure is still valid when clnt_bck_svccall() is called.
It also adds a check for closed or closing to
clnt_bck_svccall() so that it will not process the callback
RPC reply message after the ClientID is free'd.

(cherry picked from commit e1a907a25cfa422c0d1acaf9f91352ada04f4bca)

2 years agonfscl: Fix generation of va_fsid for a tree of NFSv4 server file systems
Rick Macklem [Mon, 7 Jun 2021 20:48:25 +0000 (13:48 -0700)]
nfscl: Fix generation of va_fsid for a tree of NFSv4 server file systems

Pre-r318997 the code looked like:
if (vp->v_mount->mnt_stat.f_fsid.val[0] != (uint32_t)np->n_vattr.na_filesid[0])
         vap->va_fsid = (uint32_t)np->n_vattr.na_filesid[0];
Doing this assignment got lost by r318997 and, as such, NFSv4 mounts
of servers with trees of file systems on the server is broken, due to duplicate
fileno values for the same st_dev/va_fsid.

Although I could have re-introduced the assignment, since the value of
na_filesid[0] is not guaranteed to be unique across the server file systems,
I felt it was better to always do the hash for na_filesid[0,1].
Since dev_t (st_dev/va_fsid) is now 64bits, I switched to a 64bit hash.

There is a slight chance of a hash conflict where 2 different na_filesid
values map to same va_fsid, which will be documented in the BUGS
section of the man page for mount_nfs(8).  Using a table to keep track
of mappings to catch conflicts would not easily scale to 10,000+ server file
systems and, when the conflict occurs, it only results in fts(3) reporting
a "directory cycle" under certain circumstances.

(cherry picked from commit 03c81af24920e14bd977f34edcd3eb7fb122db19)

2 years agoamd64: typo fix: memcmpy -> memcmp in a comment
Mateusz Guzik [Sat, 26 Jun 2021 03:57:47 +0000 (05:57 +0200)]
amd64: typo fix: memcmpy -> memcmp in a comment

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

(cherry picked from commit 9a8e4527f07dbb356bb1942efc09888f957df056)

2 years agoamd64: stop re-reading curpc in suword
Mateusz Guzik [Sun, 12 May 2019 06:34:58 +0000 (06:34 +0000)]
amd64: stop re-reading curpc in suword

Plugs re-reads missed in r341719

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 8eae2be460aebfcba63cf5cdc11fa6fd0962470e)

2 years agoamd64: fixup MEMMOVE comment (10 -> r10)
Mateusz Guzik [Sun, 12 May 2019 06:42:17 +0000 (06:42 +0000)]
amd64: fixup MEMMOVE comment (10 -> r10)

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 45372f1a6f7a43d235b083e51c9265574201ad26)

2 years agoamd64: move memcmp checks upfront
Mateusz Guzik [Sun, 31 Jan 2021 15:46:18 +0000 (16:46 +0100)]
amd64: move memcmp checks upfront

This is a tradeoff which saves jumps for smaller sizes while making
the 8-16 range slower (roughly in line with the other cases).

Tested with glibc test suite.

For example size 3 (most common with vfs namecache) (ops/s):
before: 407086026
after: 461391995

The regressed range of 8-16 (with 8 as example):
before: 540850489
after: 461671032

(cherry picked from commit f1be262ec11c1c35e6485f432415b5b52adb505d)

2 years agoamd64: tidy up pagezero*/pagecopy (movq -> movl)
Mateusz Guzik [Sun, 12 May 2019 07:11:44 +0000 (07:11 +0000)]
amd64: tidy up pagezero*/pagecopy (movq -> movl)

Sponsored by: The FreeBSD Foundation

(cherry picked from commit b72515e129f6320eb43e0ee853fcbb099b300e57)

2 years agoamd64: add missing ALIGN_TEXT to loops in memset and memmove
Mateusz Guzik [Fri, 29 Jan 2021 15:09:14 +0000 (16:09 +0100)]
amd64: add missing ALIGN_TEXT to loops in memset and memmove

(cherry picked from commit 164c3b81848bc81dc200b12370999474225447a3)

2 years agolinker_set: fix globl/weak symbol redefinitions to work on clang 12
Greg V [Tue, 20 Apr 2021 00:47:15 +0000 (01:47 +0100)]
linker_set: fix globl/weak symbol redefinitions to work on clang 12

In clang 12.0.0.rc2, going from weak to global is now a hard error:

```
/usr/src/stand/libsa/amd64/_setjmp.S:67:25: error: _longjmp changed binding to STB_GLOBAL
.text; .p2align 4,0x90; .globl _longjmp; .type _longjmp,@function; _longjmp:; .cfi_startproc
```

And the other way is a warning, but we have -Werror:

```
error: __start_set_Xcommand_set changed binding to STB_WEAK [-Werror,-Winline-asm]
error: __stop_set_Xcommand_set changed binding to STB_WEAK [-Werror,-Winline-asm]
```

ref: https://reviews.llvm.org/D90108

Reviewed By: arichardson
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29159

(cherry picked from commit 32231805fbe2b9438c2de50c229b43c016207a08)

2 years agosys/dev/md: Drop unncessary __GLOBL(mfs_root)
Alex Richardson [Tue, 30 Mar 2021 13:53:41 +0000 (14:53 +0100)]
sys/dev/md: Drop unncessary __GLOBL(mfs_root)

LLVM12 complains if you change the symbol binding:
error: mfs_root_end changed binding to STB_WEAK [-Werror,-Winline-asm]
error: mfs_root changed binding to STB_WEAK [-Werror,-Winline-asm]

(cherry picked from commit 69e18c9b7b12e7fd97a740d8748d8718021a1e34)

2 years agopf: store L4 headers in pf_pdesc
Kristof Provost [Fri, 4 Jun 2021 08:52:07 +0000 (10:52 +0200)]
pf: store L4 headers in pf_pdesc

Rather than pointers to the headers store full copies. This brings us
slightly closer to what OpenBSD does, and also makes more sense than
storing pointers to stack variable copies of the headers.

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

(cherry picked from commit d38630f6192a40934912fbffc52c9650776c2b53)

2 years agopf: Mark struct pf_pdesc as kernel only
Kristof Provost [Wed, 3 Mar 2021 09:28:14 +0000 (10:28 +0100)]
pf: Mark struct pf_pdesc as kernel only

This structure is only used by the kernel module internally. It's not
shared with user space, so hide it behind #ifdef _KERNEL.

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

(cherry picked from commit 29698ed904737ebfd139a21e39e5421cf81badd8)

2 years agoWork around bogus old gcc "initializer element is not constant" error
Dimitry Andric [Fri, 25 Jun 2021 18:42:38 +0000 (20:42 +0200)]
Work around bogus old gcc "initializer element is not constant" error

After df3b437c1e073eb83e9a93af1c417f3ee8d0de3b, older gcc's such as
4.2.1 (still used on earlier branches for e.g. mips and powerpc) and
6.3.0 (still used for some cross-builds) started throwing bogus errors
like:

In file included from /workspace/src/lib/msun/src/s_llround.c:11:0:
/workspace/src/lib/msun/src/s_lround.c:54:31: error: initializer element is not constant
 static const type dtype_min = type_min - 0.5;
                               ^~~~~~~~
/workspace/src/lib/msun/src/s_lround.c:55:31: error: initializer element is not constant
 static const type dtype_max = type_max + 0.5;
                               ^~~~~~~~

Since 'type_min' and 'type_max' are constants declared just above these
lines this error is nonsensical, but older gcc's are not smart enough.

Work around the error by reusing the (type)DTYPE_MIN and (type)DTYPE_MAX
macros, so I can MFC this right away, unbreaking a few stable builds.

(cherry picked from commit 0bcd49c13ada1461bcea85e0466811ddcb290b5e)

2 years agoFix failures in libm's lround_test after clang 12 import
Dimitry Andric [Tue, 22 Jun 2021 16:38:27 +0000 (18:38 +0200)]
Fix failures in libm's lround_test after clang 12 import

It turned out that the (type)DTYPE_MAX conversions at the top of
s_lround.c are now emitted as cvtsi2sd instructions, at least on SSE
capable CPUs. This caused the FE_INEXACT flag to always be set, at least
for the double and float variants. Under clang 11, the whole INRANGE()
comparisons were still optimized away, but this has "improved" in clang
12, due to stricter adherence to the -ffp-exception-behavior=maytrap
compiler flag.

To avoid run-time integer to float conversions, use static constants
instead, so they are computed at compile time, and the INRANGE()
statements are optimized away again, if applicable.

While here, use an integer instead of a floating type to store the test
results in lround_test.c, as this is more appropriate, and we can also
drop the volatile hack.

Reported by: arichardson

(cherry picked from commit df3b437c1e073eb83e9a93af1c417f3ee8d0de3b)

2 years agoDisable llvm generating 128-bit multiply libcalls on 32-bit ARM
Dimitry Andric [Tue, 22 Jun 2021 20:26:13 +0000 (22:26 +0200)]
Disable llvm generating 128-bit multiply libcalls on 32-bit ARM

Merge commit 789708617d20 from llvm git (Koutheir Attouchi):

  Do not generate calls to the 128-bit function __multi3() on 32-bit ARM

  Re-applying this patch after bots failures. Should be fine now.

  The function __multi3() is undefined on 32-bit ARM, so a call to it should
  never be emitted. Instead, plain instructions need to be generated to
  perform 128-bit multiplications.

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

Reported by: mmel

(cherry picked from commit 014a40f8f643a5dad6a6ba5c4bf6ea5d4f445fe6)

2 years agoFix clang assertion while building recent www/chromium
Dimitry Andric [Mon, 21 Jun 2021 18:46:34 +0000 (20:46 +0200)]
Fix clang assertion while building recent www/chromium

Merge commit c8227f06b335 from llvm git (by Arthur Eubanks):

  [clang] Don't assert in EmitAggregateCopy on trivial_abi types

  Fixes PR42961.

  Reviewed By: rnk

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

PR: 256721, 255570
Reported by: jbeich

(cherry picked from commit e7e517981a6591c79fb49cd8810361b0f3ad5983)

2 years agojail: Don't allow substitution of valueless jail parameters.
Jamie Gritton [Fri, 18 Jun 2021 16:44:37 +0000 (09:44 -0700)]
jail: Don't allow substitution of valueless jail parameters.
PR: 256544
Reported by: cryptogranny at gmail.com

(cherry picked from commit 5bf6dca2c6dbf63d382e97905e205ded3e8525d2)

2 years agotests/netgraph: Fix build error due to missing directory
Lutz Donnerhacke [Thu, 24 Jun 2021 11:54:54 +0000 (13:54 +0200)]
tests/netgraph: Fix build error due to missing directory

While MFCing the tests into stable/11 the test directory needs to be
added, because earlier netgraph tests were not MFCed to this train.

PR: 256773
Reported by: Arrigo Marchiori
Submitted by: Arrigo Marchiori
Tested by: Arrigo Marchiori

This is a direct commit into the stable/12 branch.

2 years agobsnmp: Fix incorrect use of libpfctl
Kristof Provost [Tue, 15 Jun 2021 08:50:32 +0000 (10:50 +0200)]
bsnmp: Fix incorrect use of libpfctl

When we introduced libpfctl in bnsmpd this was done incorrectly, and a
GETRULE call was replaced by pfctl_add_rule().
Change it to pfctl_get_rule().

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

(cherry picked from commit 67cef6d411cef0c3dfcf768ff890b4f97cf513b6)

2 years agokern.mk: fix -Wno-error style to fix build with Clang 12
Greg V [Wed, 10 Mar 2021 22:17:09 +0000 (17:17 -0500)]
kern.mk: fix -Wno-error style to fix build with Clang 12

Clang 12 no longer supports -Wno-error-..., only the -Wno-error=...
style (which is already used everywhere else in the tree).

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

(cherry picked from commit 15565e0a2177f53b086609fecd48991c52dad5eb)

2 years agoRemove a use of a negative array index from fxp(4).
Mark Johnston [Wed, 19 Dec 2018 04:54:32 +0000 (04:54 +0000)]
Remove a use of a negative array index from fxp(4).

This fixes a warning seen when compiling amd64 GENERIC with clang 7.
Also remove the workaround added in r337324.  clang 7 and gcc 4.2
generate the same code with or without the code change.

Reviewed by: imp (previous version)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D18603

(cherry picked from commit 0e4a3d93eefdc9730f572e8277b100eff6cf3491)

2 years agoExport various 128 bit long double functions from libgcc_s.so.1
Dimitry Andric [Mon, 14 Jun 2021 19:17:05 +0000 (21:17 +0200)]
Export various 128 bit long double functions from libgcc_s.so.1

These were already compiled for some time on aarch64 and riscv, by
including lib/libcompiler_rt/Makefile.inc, but never exported in the
shared library. Since gcc exports these under version GCC_4.6.0, we do
the same.

This review should replace D11482 for now. For e.g. amd64 more work is
still to be done, as compiler-rt does not seem to support 128 bit long
double math for that architecture.

Reviewed by: cem
Differential Revision: https://reviews.freebsd.org/D28690

(cherry picked from commit 790a6be5a1699291c6da87871426d0c56dedcc89)

2 years agocpucontrol: fix extended signature matching code to avoid fallthough
Dan Nelson [Mon, 14 Jun 2021 19:28:16 +0000 (15:28 -0400)]
cpucontrol: fix extended signature matching code to avoid fallthough

PR: 256502

(cherry picked from commit 87799c5f85dc0aed7e53ca841504e3b2ffc88498)

2 years agostand: Fix __elfN(loadimage) return value
Mark Johnston [Sun, 6 Jun 2021 20:40:25 +0000 (16:40 -0400)]
stand: Fix __elfN(loadimage) return value

Caller functions expect __elfN(loadimage) to return a value of zero on
failure and the file size on success.

PR: 256390
Reviewed by: markj

(cherry picked from commit 1ea87e2a70c31454a8696ab2979d13d21c5575d2)

2 years agobsdconfig: add a new mirror in Bulgaria
Philip Paeps [Thu, 17 Jun 2021 13:07:37 +0000 (21:07 +0800)]
bsdconfig: add a new mirror in Bulgaria

Provided by Telepoint Mirror Service.

Reported by: Valentin Nikolov <mirror@telepoint.bg>

(cherry picked from commit 1c9605fe1e190197b3846e01dce1e491bef0ec34)

2 years agobsdinstall: add a new mirror in Bulgaria
Philip Paeps [Thu, 17 Jun 2021 13:07:37 +0000 (21:07 +0800)]
bsdinstall: add a new mirror in Bulgaria

Provided by Telepoint Mirror Service.

Reported by: Valentin Nikolov <mirror@telepoint.bg>

(cherry picked from commit 7daa45becfd32cb38933bfdc87e8a10fc982d188)

2 years agoipfw.8: synopsis misses nat show form
Lutz Donnerhacke [Mon, 10 May 2021 16:30:42 +0000 (18:30 +0200)]
ipfw.8: synopsis misses nat show form

Document the existing behavior, which is currently only available by
reading third party documentation or the source code itself.

PR: 254617
Submitted by: Oliver Kiddle
Differential Revision: https://reviews.freebsd.org/D30189

(cherry picked from commit c8250c5ada85fec8936e8eb8695d7cb80a3ce8ab)

2 years agopf: don't hold a lock during copyout()
Kristof Provost [Mon, 14 Jun 2021 12:04:02 +0000 (14:04 +0200)]
pf: don't hold a lock during copyout()

copyout() can trigger page faults, so it may potentially sleep.

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

(cherry picked from commit 8b5f4e692b1d1585ecfc6690552650114e3e704e)

2 years agodummynet: free(NULL, M_DUMMYNET); is safe
Kristof Provost [Fri, 21 May 2021 14:55:07 +0000 (16:55 +0200)]
dummynet: free(NULL, M_DUMMYNET); is safe

There's no need to check pointers for NULL before free()ing them.

No functional change.

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

(cherry picked from commit 1b2dbe37fa32d7255faf7d1feec7bb31414a8102)

2 years agodummynet: Fix schedlist and aqmlist locking
Kristof Provost [Fri, 21 May 2021 12:26:49 +0000 (14:26 +0200)]
dummynet: Fix schedlist and aqmlist locking

These are global (i.e. shared across vnets) structures, so we need
global lock to protect them.  However, we look up entries in these lists
(find_aqm_type(), find_sched_type()) and return them. We must ensure
that the returned structures cannot go away while we are using them.

Resolve this by using NET_EPOCH(). The structures can be safely accessed
under it, and we postpone their cleanup until we're sure they're no
longer used.

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

(cherry picked from commit 51d73df18e4d120f6f062062c18efae3ed5193a6)

2 years agoVNETify dummynet
Tom Jones [Sat, 15 May 2021 12:36:45 +0000 (14:36 +0200)]
VNETify dummynet

This moves dn_cfg and other parameters into per VNET variables.

The taskqueue and control state remains global.

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

(cherry picked from commit fe3bcfbda30e763a3ec56083b3a19cebbeaf8952)

2 years agoDo not forward datagrams originated by link-local addresses
Zhenlei Huang [Tue, 18 May 2021 20:51:37 +0000 (22:51 +0200)]
Do not forward datagrams originated by link-local addresses

The current implement of ip_input() reject packets destined for
169.254.0.0/16, but not those original from 169.254.0.0/16 link-local
addresses.

Fix to fully respect RFC 3927 section 2.7.

PR: 255388
Reviewed by: donner, rgrimes, karels
Differential Revision: https://reviews.freebsd.org/D29968
Reviewed by: rgrimes, donner, karels, marcus, emaste
Differential Revision: https://reviews.freebsd.org/D30374

(cherry picked from commit 3d846e48227e2e78c1e7b35145f57353ffda56ba)
(cherry picked from commit 03b0505b8fe848f33f2f38fe89dd5538908c847e)

2 years agonetgraph/bridge: malloc without flags
Lutz Donnerhacke [Sun, 13 Jun 2021 22:00:35 +0000 (00:00 +0200)]
netgraph/bridge: malloc without flags

During tests an assert was triggered and pointed to missing flags in
the newlink function of ng_bridge(4).

Reported by: markj
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D30759

(cherry picked from commit 4c3280e58727e900d4c217054fe655e3512380f1)

2 years agoLinuxKPI: add fault_flag_allow_retry_first
Greg V [Wed, 9 Jun 2021 23:09:16 +0000 (19:09 -0400)]
LinuxKPI: add fault_flag_allow_retry_first

Used by drm 5.7.

Reviewed by: bz, hselasky, nc
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30673

(cherry picked from commit 597cc550e7b98294617cdd41800e9f132b6bcad9)

2 years agotests/netgraph: Tests for ng_vlan_rotate
Lutz Donnerhacke [Sun, 6 Jun 2021 23:56:12 +0000 (01:56 +0200)]
tests/netgraph: Tests for ng_vlan_rotate

Test functionality of ng_vlan_rotate(4):
 - Rotate 1 to 9 stagged vlans in any possible direction and length
 - Rotate random combinations of ethertypes (8100, 88a8, 9100)
 - Automatic reverse rotating for backward data flow
 - Test too many and too few vlans

Reviewed by: kp (earlier version)
Differential Revision: https://reviews.freebsd.org/D30670

(cherry picked from commit 6b08e68be111d50931b0d30145f8b7e3402decaf)

2 years agotests/netgraph: Tests for ng_hub
Lutz Donnerhacke [Thu, 3 Jun 2021 22:22:29 +0000 (00:22 +0200)]
tests/netgraph: Tests for ng_hub

Test functionality of ng_hub(4):
 - replicting traffic to anything but the sending hook
 - persistence
 - an unrestricted loop
 - implementation limits with many hooks.

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

(cherry picked from commit 7863faa78ae271017c404c635b2a9d07379d4316)

2 years agotests/netgraph: Tests for ng_bridge
Lutz Donnerhacke [Fri, 4 Jun 2021 10:59:00 +0000 (12:59 +0200)]
tests/netgraph: Tests for ng_bridge

Test functionality of ng_bridge(4):
 - replicating traffic to anything but the sending hook
 - persistence
 - detect loops
 - unicast to only one link of many
 - stretch to implementation limits on broadcast

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

(cherry picked from commit 61814702398ce29430b2bef75cbdd6fd2c07ad12)
(cherry picked from commit 5554abd9cc9702af30af90925b33c5efff4e7d88)

2 years agotests/netgraph: Inital framework for testing libnetgraph
Lutz Donnerhacke [Wed, 2 Jun 2021 22:29:46 +0000 (00:29 +0200)]
tests/netgraph: Inital framework for testing libnetgraph

Provide a framework of functions to test various netgraph modules.
Tests contain:
 - creating, renaming, and destroying nodes
 - connecting and removing hooks
 - sending and receiving data
 - sending ASCII messages and receiving binary responses
 - errors can be passed for indiviual inspection or fail the test

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D30629
Differential Revision: https://reviews.freebsd.org/D30657
Differential Revision: https://reviews.freebsd.org/D30671
Differential Revision: https://reviews.freebsd.org/D30699

(cherry picked from commit 24ea1dbf257aa6757f469bcd859f90e9ad851e59)
(cherry picked from commit 09307dbfb888a98232096c751a96ecb3344aa77c)
(cherry picked from commit 9021c46603bf29b9700f24b8dce8796b434d7c8f)
(cherry picked from commit 5554abd9cc9702af30af90925b33c5efff4e7d88)

Also contains some fixups:
 - indent all files correctly
 - finish factoring out
 - remove debugging code
 - check for renaming issues reported in PR241954

PR: 241954
Differential Revision: https://reviews.freebsd.org/D30692
Differential Revision: https://reviews.freebsd.org/D30714
Differential Revision: https://reviews.freebsd.org/D30713

(cherry picked from commit a664ade93972ce617f0888ff79e715dff9cf0f87)
(cherry picked from commit 0afa9be03937d60cb5aeba64c81e3e2165bd3737)
(cherry picked from commit 43e4821315c31db067e23564b9bfafb519e77b2b)

2 years agotests/netgraph: Prebuild tests directory
Lutz Donnerhacke [Wed, 16 Jun 2021 11:37:51 +0000 (13:37 +0200)]
tests/netgraph: Prebuild tests directory

(partially cherry picked from commit e8db04c38959c882fe17e7c2b26fbabe74f26311)

2 years agorc.d: liberate powerd from ACPI dependency
Andriy Gapon [Tue, 8 Jun 2021 17:08:10 +0000 (20:08 +0300)]
rc.d: liberate powerd from ACPI dependency

For instance, many non-ACPI ARM systems have CPU power / frequency
levels.

(cherry picked from commit 20eb6bd8c598fdbf4e96ed4ca64a609be255ccba)

2 years agolibcasper: fix descriptors numbers
Mariusz Zaborski [Wed, 9 Jun 2021 21:46:51 +0000 (23:46 +0200)]
libcasper: fix descriptors numbers

Casper services expect that the first 3 descriptors (stdin/stdout/stderr)
will point to /dev/null. Which Casper will ensure later. The Casper
services are forked from the original process. If the initial process
closes one of those descriptors, Casper may reuse one of them for it on
purpose. If this is the case, then renumarate the descriptors used by
Casper to higher numbers. This is done already after the fork, so it
doesn't break the parent process.

PR: 255339
Reported by: Borja Marcos <borjam (at) sarenet.es>
Tested by: jkim@

(cherry picked from commit aa310ebfba3d49a0b6b03a103b969731a8136a73)

2 years agoiwn: adjust EEPROM read timeout for Intel 4965AGN M2
Radosław Chmielarz [Sun, 6 Jun 2021 20:42:10 +0000 (16:42 -0400)]
iwn: adjust EEPROM read timeout for Intel 4965AGN M2

Reading EEPROM from Intel 4965AGN M2 takes 60 us which was causing panic
on system startup.

PR: 255465
Reviewed by: markj

(cherry picked from commit 03d4b58feee396d392668f192ecdde08ecc8036c)

2 years agongatm: Handle errors from uni_msg_extend()
Mark Johnston [Sun, 6 Jun 2021 20:42:16 +0000 (16:42 -0400)]
ngatm: Handle errors from uni_msg_extend()

uni_msg_extend() may fail due to a memory allocation failure.  In this
case, though, the message is freed, so callers shouldn't touch it.

PR: 255861
Reviewed by: harti
Sponsored by: The FreeBSD Foundation

(cherry picked from commit e755e2776ddff729ae4102f3273473aa33b00077)

2 years agopf: Convenience function for optional (numeric) arguments
Kristof Provost [Sat, 15 May 2021 11:45:55 +0000 (13:45 +0200)]
pf: Convenience function for optional (numeric) arguments

Add _opt() variants for the uint* functions. These functions set the
provided default value if the nvlist doesn't contain the relevant value.
This is helpful for optional values (e.g. when the API is extended to
add new fields).

While here simplify the header by also using macros to create the
prototypes for the macro-generated function implementations.

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

(cherry picked from commit 7c4342890bf17b72f0d79ada1326d9cbf34e736c)

2 years agoLinuxKPI: add pr_err_once
Greg V [Mon, 7 Jun 2021 14:30:18 +0000 (10:30 -0400)]
LinuxKPI: add pr_err_once

Reviewed by: hselasky, emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30672

(cherry picked from commit 05c2d94a081d5948560a01c26c7f432960cde606)

2 years agoums(4): Do not stop USB xfers on FIFO close when evdev is still active
Vladimir Kondratyev [Sun, 23 May 2021 22:38:53 +0000 (01:38 +0300)]
ums(4): Do not stop USB xfers on FIFO close when evdev is still active

This fixes lose of evdev events after moused has been killed.

While here use bitwise operations for UMS_EVDEV_OPENED flag.

Reviewed by: hselasky
Differential revision: https://reviews.freebsd.org/D30342

(cherry picked from commit 05ab03a31798d4cc96c22a8f30b1d9a0d7a3dd35)

2 years agoums(4): Start USB xfers on opening of evdev node unconditionally.
Vladimir Kondratyev [Sun, 23 May 2021 22:41:17 +0000 (01:41 +0300)]
ums(4): Start USB xfers on opening of evdev node unconditionally.

This fixes inability to start USB xfers in a case when FIFO has been
already open()-ed but no read() or poll() calls has been issued yet.

Differential revision: https://reviews.freebsd.org/D30343

(cherry picked from commit 47791339f0cfe3282a6f64b5607047f7bca968ad)

2 years agobectl(8): don't allow creation of boot environments with spaces
Robert Wing [Thu, 3 Jun 2021 16:36:11 +0000 (08:36 -0800)]
bectl(8): don't allow creation of boot environments with spaces

Boot environment datasets that contain spaces are not bootable.

When a user attempts to create a boot environment with a space, abort
the creation and print an error message.

PR:             254441
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D30194

(cherry picked from commit 0e6549c8745049e3d6fba3ad748034de2d5cbd2a)

2 years agoAdd freeze/thaw description to devctl(8)
Li-Wen Hsu [Tue, 1 Jun 2021 04:33:12 +0000 (12:33 +0800)]
Add freeze/thaw description to devctl(8)

This is a follow-up to 5fa29797910346fc0c54829bd979856e83b9b7ea .

PR: 256311
Reviewed by: imp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D29867

(cherry picked from commit 315674fb6acc4fa54cf82de3863c349c5a71f498)

2 years agoFix test case header function name
Math Ieu [Wed, 2 Jun 2021 04:09:55 +0000 (12:09 +0800)]
Fix test case header function name

This restores the expected behavior (skip) when running with non-root user

MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D30584

(cherry picked from commit 847b7d505490ae407a5c876e14e7788a4add7737)

2 years agonetgraph/ng_base: Renaming a node to the same name is a noop
Lutz Donnerhacke [Tue, 4 May 2021 19:20:39 +0000 (21:20 +0200)]
netgraph/ng_base: Renaming a node to the same name is a noop

Detailed analysis in https://github.com/genneko/freebsd-vimage-jails/issues/2
brought the problem down to a double call of ng_node_name() before and
after a vnet move.  Because the name of the node is already known
(occupied by itself), the second call fails.

PR: 241954
Reported by: Paul Armstrong
Differential Revision: https://reviews.freebsd.org/D30110

(cherry picked from commit 0345fd891fe13a191fc0fae9463ea9458bfaff5a)

2 years agoGet rid of i386 ref here as linux64 is a 64-bit module.
Dmitry Chagin [Wed, 24 Mar 2021 15:56:46 +0000 (18:56 +0300)]
Get rid of i386 ref here as linux64 is a 64-bit module.

Reviewed By: emaste, imp
Differential Revision: https://reviews.freebsd.org/D29412

(cherry picked from commit 88588c4b7611a39cdf965c3c07d8fcc13ed553b4)

2 years agolinux: silence renameat2 flags warning
Mateusz Guzik [Mon, 26 Oct 2020 18:03:50 +0000 (18:03 +0000)]
linux: silence renameat2 flags warning

Hogs the console while building the Linux kernel in a Ubuntu Focal jail.

(cherry picked from commit fe76bef462048f9beb3bffd448ae1adb01969594)

2 years agolinux_renameat2: improve flag checks
Ed Maste [Thu, 7 Nov 2019 15:51:44 +0000 (15:51 +0000)]
linux_renameat2: improve flag checks

In the cases where Linux returns an error (e.g. passing in an undefined
flag) there's no need for us to emit a message.  (The target of this
message is a developer working on the linuxulatorm, not the author of
presumably broken Linux software).

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21606

(cherry picked from commit 01b9ee4c509e2882147af35eea4772d06ecd4150)

2 years agolinux_common: retire extra module version.
Dmitry Chagin [Wed, 26 May 2021 05:34:32 +0000 (08:34 +0300)]
linux_common: retire extra module version.

The second 'linuxcommon' line was added by c66f5b079d2a259c3a65b1efe0f2143cd030dc52
but Linuxulator's modules dependend on 'linux_common'.
To avoid such mistakes in the future rename moduledata name and module
name to  'linux_common' and retire 'linuxcommon' line.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D30409
MFC after: 2 weeks

(cherry picked from commit 5184e2da41921dfec5a3668756890b5c073fbad9)

2 years agoMove V4L feature declarations and DTrace provider definitions from
Tijl Coosemans [Sun, 6 Dec 2020 10:58:55 +0000 (10:58 +0000)]
Move V4L feature declarations and DTrace provider definitions from
linux_common.c to linux_util.c so they become available on i386.

linux_common.c defines the linux_common kernel module but this module does
not exist on i386 and linux_common.c is not included in the linux module.
linux_util.c is included in the linux_common module on amd64 and the linux
module on i386.

Remove linux_common.c from files.i386 again.  It was added recently in
r367433 when the DTrace provider definitions were moved.

The V4L feature declarations were moved to linux_common in r283423.

(cherry picked from commit 77fb6b6644446beb0ea45085b953f464c729c049)

2 years agoFix i386 linux module after r367395.
Tijl Coosemans [Sat, 5 Dec 2020 14:53:24 +0000 (14:53 +0000)]
Fix i386 linux module after r367395.

In r367395 parts of machine dependent linux_dummy.c were moved to a new
machine independent file sys/compat/linux/linux_dummy.c and the existing
linux_dummy.c was renamed to linux_dummy_machdep.c.

Add linux_dummy_machdep.c to the linux module for i386.
Rename sys/amd64/linux32/linux_dummy.c for consistency.
Add the new linux_dummy.c to the linux module for i386.

(cherry picked from commit df4ca45cf943fb62c7771e479f5f999570ec6928)

2 years agolinux(4): Fix loadable modules after r367395
Conrad Meyer [Fri, 6 Nov 2020 22:04:57 +0000 (22:04 +0000)]
linux(4): Fix loadable modules after r367395

Move dtrace SDT definitions into linux_common module code.  Also, build
linux_dummy.c into the linux_common kld -- we don't need separate
versions of these stubs for 32- and 64-bit emulation.

Reported by: several
PR: 250897
Discussed with: emaste, trasz
Tested by: John Kennedy, Yasuhiro KIMURA, Oleg Sidorkin
X-MFC-With: r367395
Differential Revision: https://reviews.freebsd.org/D27124

(cherry picked from commit 76b2bfeda42bbb686c74d3608dbc9b84b8e22e29)

2 years agoDirect commit:
Dmitry Chagin [Thu, 10 Jun 2021 09:22:43 +0000 (12:22 +0300)]
Direct commit:
MFC r367395 (e9b13c6612fea4e74f0c9c543e21d29d91a24dff) by cem:

linux(4): Deduplicate unimpl/dummy syscall handlers

No functional change.

Reviewed by:    emaste, trasz
Differential Revision:  https://reviews.freebsd.org/D27099

2 years agortwn_usb(4): Add a USB ID for the TP-Link Archer T2U v3.
Dmitry Chagin [Thu, 27 May 2021 18:52:10 +0000 (21:52 +0300)]
rtwn_usb(4): Add a USB ID for the TP-Link Archer T2U v3.

PR: 256203
Submitted by: Steve Kargl sgk at troutmask.apl.washington.edu

(cherry picked from commit 434c46c00602e16115cfb19344e4c45135b68b09)

2 years agolibcrypto: Add symbol versions for symbols added since 1.1.1d.
John Baldwin [Fri, 28 May 2021 22:18:15 +0000 (15:18 -0700)]
libcrypto: Add symbol versions for symbols added since 1.1.1d.

While here, trim a spurious local: I missed when added SSL_sendfile.

PR: 255277
Reported by: yuri
Reviewed by: jkim
Differential Revision: https://reviews.freebsd.org/D30483

(cherry picked from commit 7ad70d22c667173586c04fc13dd315995d78fbbf)

2 years agoetcupdate: Add -D destdir to usage for 'extract'.
John Baldwin [Mon, 26 Apr 2021 16:49:34 +0000 (09:49 -0700)]
etcupdate: Add -D destdir to usage for 'extract'.

Reported by: Mark Millard <marklmi@yahoo.com>

(cherry picked from commit 5eb9c93a20d7320b24635ed09eba4908951bdeb2)

2 years agoetcupdate: Add a revert mode to restore one or more stock files.
John Baldwin [Tue, 20 Apr 2021 20:22:35 +0000 (13:22 -0700)]
etcupdate: Add a revert mode to restore one or more stock files.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D29846

(cherry picked from commit ba30215ae0efeb49e5e9ca2469d95edaea78680d)

2 years agoetcupdate: Trim trailing whitespace.
John Baldwin [Tue, 20 Apr 2021 20:22:24 +0000 (13:22 -0700)]
etcupdate: Trim trailing whitespace.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D29845

(cherry picked from commit ada7fd17d57fac3dbafff5a1b3268afb872c8b0b)

2 years agoetcupdate: Gracefully handle SIGINT when building trees.
John Baldwin [Tue, 20 Apr 2021 20:22:11 +0000 (13:22 -0700)]
etcupdate: Gracefully handle SIGINT when building trees.

Run the 'build_tree' function inside of a subshell and trap SIGINT to
return an error to the caller.  This allows callers to gracefully
cleanup a partially created tree.

While here, redirect stdout/stderr of the subshell to the log file
instead of applying redirections individually to each command executed
while building the tree.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D29844

(cherry picked from commit 1f7afa9364805a912270c9d6a70dc4a889d47a4e)

2 years agoetcupdate: Always extract to a temporary tree.
John Baldwin [Tue, 20 Apr 2021 20:21:42 +0000 (13:21 -0700)]
etcupdate: Always extract to a temporary tree.

etcupdate has had a somewhat nasty race condition since its creation
in that its state machine can get very confused if it is interrupted
while building the tree to compare against.  This is exacerbated by
the fact that etcupdate doesn't emit any output while building the
tree which can take several seconds (especially in recent years with
the addition of the tree-wide buildconfig/installconfig passes).

To mitigate this, always install a new tree into a temporary directory
created via mktemp as was previously done only for dry-runs via -n.
The existing trees are only rotated and the new tree installed as
/var/db/etcupdate/current after the update command has completed.

Reported by: dim, np (and many others)
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D29843

(cherry picked from commit 0611aec3cf3a373e6a06f103699dbc91c3d6d472)
(cherry picked from commit b0df36580d5b0df67a0f58ded8f6356b268f7f71)

2 years agopciconf: Fix up pciconf -lc output
David Bright [Mon, 24 May 2021 19:02:43 +0000 (14:02 -0500)]
pciconf: Fix up pciconf -lc output

The pciconf command fails to emit newlines when particular ecap field
values are seen. Fix them up. This has been seen on several systems at
$JOB. The documentation for PCI capabilities says that capability
type 0 should not be used once the spec for PCI capabilities was
published, but that seems more wishful-thinking than reality. pciconf
also chooses not to print fields related to field values that are
zero, but it seems several of these fields are zero on actual
hardware.

Sponsored by: Dell EMC Isilon
Submitted by: Robert Herndon (Robert.Herndon@dell.com)

(cherry picked from commit 2f176a2b20107f7a9132242223e9eef657400514)

2 years agolibsa: Fix infinite loop in bzipfs & gzipfs
David Bright [Mon, 24 May 2021 17:12:15 +0000 (12:12 -0500)]
libsa: Fix infinite loop in bzipfs & gzipfs

A bug in the loader's bzipfs & gzipfs filesystems caused compressed
kernel and modules not to work on EFI systems with a veriexec-enabled
loader. Since the size of files in these filesystems are not known
_a priori_ `stat` would initialize the size to -1 and the loader would
then hang in an infinite loop while trying to seek (read) to the end
of file since the loop termination condition compares the current
offset to that negative target position.

Sponsored by: Dell EMC Isilon

(cherry picked from commit 3df4c387d2e3ca4c2391fb837540b048f60a11c2)

2 years agortwn_usb(4): add revision number for D-Link DWA-121 (N150 Nano).
Dmitry Chagin [Wed, 26 May 2021 06:47:30 +0000 (09:47 +0300)]
rtwn_usb(4): add revision number for D-Link DWA-121 (N150 Nano).

(cherry picked from commit 17dafdc0de7e8ab0c750d1339e4debc78262e19b)

2 years agortwn_usb(4): add D-Link DWA-121 (N150 Nano) to the rtwn_usb hardware list
Dmitry Chagin [Wed, 26 May 2021 05:01:04 +0000 (08:01 +0300)]
rtwn_usb(4): add D-Link DWA-121 (N150 Nano) to the rtwn_usb hardware list

(cherry picked from commit 962b3a092616c95c68c0b0a844f4660675aa40f6)

2 years agortwn_usb(4): add Mercusys MW150US (N150 Nano) to the rtwn_usb hardware list.
Dmitry Chagin [Wed, 26 May 2021 07:13:08 +0000 (10:13 +0300)]
rtwn_usb(4): add Mercusys MW150US (N150 Nano) to the rtwn_usb hardware list.

(cherry picked from commit 399bad7b9a105930b8203ad0a1fd154681bc16b8)

2 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)

"boot smoke test" dropped from task name for the MFC, because Cirrus
runs a build test only on stable/12 (see 05b9673637fe for details).