]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoDo not reference returned ifa in in6_ifawithifp().
Alexander V. Chernikov [Sun, 14 Feb 2021 10:11:06 +0000 (10:11 +0000)]
Do not reference returned ifa in in6_ifawithifp().

The only place where in6_ifawithifp() is used is ip6_output(),
 which uses the returned ifa to bump traffic counters.
Given ifa stability guarantees is provided by epoch, do not refcount ifa.

This eliminates 2 atomic ops from IPv6 fast path.

Reviewed By: rstone
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28649

3 years agoprocstat: distinguish vm map guards in procstat vm output.
Konstantin Belousov [Sun, 14 Feb 2021 00:37:24 +0000 (02:37 +0200)]
procstat: distinguish vm map guards in procstat vm output.

Requested and reviewed by: rwatson (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28658

3 years agoAdd metor -> mentee information (docs)
Fernando ApesteguĂ­a [Sat, 13 Feb 2021 18:18:03 +0000 (19:18 +0100)]
Add metor -> mentee information (docs)

As per Committers Guide Step 5

Reviewed by: 0mp

Accepted By: 0mp (mentor)

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

3 years agohidraw: Make HIDIOCGRDESCSIZE ioctl return report descriptor size
Vladimir Kondratyev [Sat, 13 Feb 2021 18:19:02 +0000 (21:19 +0300)]
hidraw: Make HIDIOCGRDESCSIZE ioctl return report descriptor size

defined by hardware rather than cached one to match HIDIOCGRDESC ioctl.
This fixes errors reported by hid-tools being run against /dev/hidraw#
device node belonging to driver which overloads report descriptor.

MFC after: 1 week

3 years agohkbd: Fix handling of keyboard ErrorRollOver reports
Vladimir Kondratyev [Sat, 13 Feb 2021 18:18:07 +0000 (21:18 +0300)]
hkbd: Fix handling of keyboard ErrorRollOver reports

Ignore fantom keyboard state reports entirelly rather than ignore
RollOver states for each key separatelly.  Latter results in spurious
release/push pairs of events on each fantom keyboard state report.

Reported by: Jan Martin Mikkelsen <janm_AT_transactionware_DOT_com>
Submitted by: Jan Martin Mikkelsen (initial version)
PR: 253249
MFC after: 1 week

3 years agoukbd: Fix handling of keyboard ErrorRollOver reports
Vladimir Kondratyev [Sat, 13 Feb 2021 18:12:56 +0000 (21:12 +0300)]
ukbd: Fix handling of keyboard ErrorRollOver reports

Ignore fantom keyboard state reports entirelly rather than ignore
RollOver states for each key separatelly.  Latter results in spurious
release/push pairs of events on each fantom keyboard state report.

Reported by: Jan Martin Mikkelsen <janm_AT_transactionware_DOT_com>
Submitted by: Jan Martin Mikkelsen (initial version)
PR: 253249
MFC after: 1 week

3 years agotools/build/make.py: drop workaround for cc --version not being parsed
Alex Richardson [Sat, 13 Feb 2021 13:54:20 +0000 (13:54 +0000)]
tools/build/make.py: drop workaround for cc --version not being parsed

Previously bsd.compiler.mk was not able to detect the compiler type for
Ubuntu's /usr/bin/cc unless we were invoking the /usr/bin/gcc symlink.
This problem has been fixed by 9c6954329a9285547881ddd60e393b7c55ed30c4
so we can drop the workaround from make.py.

Reviewed By: jrtc27
Differential Revision: https://reviews.freebsd.org/D28323

3 years agobin/pkill: Fix {pgrep,pkill}-j_test.sh
Alex Richardson [Sat, 13 Feb 2021 13:53:50 +0000 (13:53 +0000)]
bin/pkill: Fix {pgrep,pkill}-j_test.sh

The POSIX sh case statement does not allow for pattern matching using the
regex + qualifier so this case statement never matches. Instead just check
for a string starting with a digit followed by any character.

While touching these files also fix various shellcheck warnings.

`kyua -v parallelism=4 test` failed before, succeeds now.

Reviewed By: imp
Differential Revision: https://reviews.freebsd.org/D28480

3 years agolib/libc/tests/rpc: Correctly set timeout
Alex Richardson [Sat, 13 Feb 2021 13:52:59 +0000 (13:52 +0000)]
lib/libc/tests/rpc: Correctly set timeout

The rpc_control() API does not accept the CLCR_SET_RPCB_TIMEOUT command,
it only accepts RPC_SVC_CONNMAXREC_GET/RPC_SVC_CONNMAXREC_SET, so it was
not doing anything.
Instead of incorrectly calling this API, use clnt_create_timed() instead.

I noticed this because the test was timing out after 120s in the CheriBSD CI.

Reviewed By: ngie
Differential Revision: https://reviews.freebsd.org/D28478

3 years agoUpdate Subversion to 1.14.1 LTS. See contrib/subversion/CHANGES for a
Dimitry Andric [Sat, 13 Feb 2021 13:38:51 +0000 (14:38 +0100)]
Update Subversion to 1.14.1 LTS. See contrib/subversion/CHANGES for a
summary of changes, or for a more thorough overview:

https://subversion.apache.org/docs/release-notes/1.14

NOTE 1: There is no need to dump and reload repositories, and the
working copy format is still the same as Subversion 1.8 through 1.13.

NOTE 2: The upstream release also contains a fix for a security issue in
mod_dav_svn (CVE-2020-17525), but since we do not build or use any
Apache modules, it is not an issue for the FreeBSD base system.

Relnotes: yes
MFC after: 3 days

3 years agoRegenerate src.conf(5) after FMTREE default change
Kyle Evans [Wed, 10 Feb 2021 15:11:55 +0000 (09:11 -0600)]
Regenerate src.conf(5) after FMTREE default change

3 years agobuild: turn off FMTREE by default to prepare for removal
Kyle Evans [Wed, 10 Feb 2021 14:57:25 +0000 (08:57 -0600)]
build: turn off FMTREE by default to prepare for removal

nmtree is derived from fmtree, and has been the default mtree(8) since
6adfbbbf161, a little over a year after its introduction.

fmtree has not seen any substantial work since then, except for build
fixes and runtime issues that were diagnosed in nmtree and backported
because this was still in the tree.

Turn it off by default.

Reviewed by: bdrewery, brooks, cy, emaste
Differential Revision: https://reviews.freebsd.org/D28573

3 years agofmtree: add a deprecation notice to the manpage
Kyle Evans [Wed, 10 Feb 2021 15:10:52 +0000 (09:10 -0600)]
fmtree: add a deprecation notice to the manpage

Note that this mtree(8) is actually installed as fmtree(8), while
mtree(8) is located in ^/contrib/mtree -- thus, the reference to
mtree(8) makes a lot more sense in the context in which folks would
actually notice it. Shout-out to Ravi for pointing out that this may
not be an obvious fact.

MFC after: 3 days
Reviewed by: bdrewery, brooks, cy, emaste
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D28573

3 years agofusefs: set d_off during VOP_READDIR
Alan Somers [Fri, 12 Feb 2021 01:01:10 +0000 (18:01 -0700)]
fusefs: set d_off during VOP_READDIR

This allows d_off to be used with lseek to position the file so that
getdirentries(2) will return the next entry.  It is not used by
readdir(3).

PR: 253411
Reported by: John Millikin <jmillikin@gmail.com>
Reviewed by: cem
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28605

3 years agoFix ifa refcount leak during route addition.
Alexander V. Chernikov [Fri, 12 Feb 2021 20:56:52 +0000 (20:56 +0000)]
Fix ifa refcount leak during route addition.

Reported by: rstone
Reviewed by: rstone
MFC after: 1 day

3 years agogit-arc(1): Fix nits pointed out in final review
Daniel Ebdrup Jensen [Fri, 12 Feb 2021 22:39:00 +0000 (23:39 +0100)]
git-arc(1): Fix nits pointed out in final review

Pointy hat to: me

3 years agogit-arc(1): Add manual page
Daniel Ebdrup Jensen [Fri, 12 Feb 2021 22:35:02 +0000 (23:35 +0100)]
git-arc(1): Add manual page

Add manual page based on the usage in the script with a few changes and
hook it up to the build.

Reviewed by: 0mp, markj
Differential Revision: https://reviews.freebsd.org/D28519

3 years agogit-arc: Use a separate message file
Mark Johnston [Fri, 12 Feb 2021 20:58:17 +0000 (15:58 -0500)]
git-arc: Use a separate message file

Rather than putting revision metadata in .git/arc/create-message, create
a tmpfile and use that.  Otherwise arc diff always prompts about it and
in some cases complains because its standard input is piped.

Reported by: imp
Differential Revision: https://reviews.freebsd.org/D28614

3 years agoFix various NOINET* builds broken by 145bf6c0af48.
Alexander V. Chernikov [Fri, 12 Feb 2021 20:36:20 +0000 (20:36 +0000)]
Fix various NOINET* builds broken by 145bf6c0af48.

Reported by: mjg, bdragon

3 years agoFix interface route addition with net/bird.
Alexander V. Chernikov [Thu, 11 Feb 2021 23:24:27 +0000 (23:24 +0000)]
Fix interface route addition with net/bird.

The case of adding interface route by specifying interface
 address as the gateway was missed during code refactoring.
Re-add it back by copying non-AF_LINK gateway data when RTF_GATEWAY
 is not set.

Reviewed by: donner
MFC after: 3 days

3 years agoinetd: fix unix sockaddr's length assignment
Kyle Evans [Fri, 12 Feb 2021 19:19:43 +0000 (13:19 -0600)]
inetd: fix unix sockaddr's length assignment

unsz was always exactly '1' here due to an unfortunate mispositioning
of closing parenthesis. While it's generally irrelevant because bind(2)
is passed the (accurate) sep->se_ctrladdr_size instead, it's not very
helpful for anything locally that wants to use it rather than assuming
that sep->se_ctrladdr_size perfectly fits the end of sun_path.

Just drop unsz entirely and use the result of SUN_LEN() for it.

MFC-after: 3 days

3 years agomount_nullfs: rename a local variable
Alan Somers [Fri, 12 Feb 2021 18:30:52 +0000 (11:30 -0700)]
mount_nullfs: rename a local variable

The "source" variable was introduced in r26072, probably as the
traditional counterpart to "target".  But the "source"/"target" names
suggest the opposite of their actual meaning.  With ln, for example, the
source is the real file and the target is the newly created link.  In
mount_nullfs the meaning is the opposite: the target is the existing
file system and the source is the newly created mountpoint.  Better to
use "target"/"mountpoint" terminology, which matches the man page.

MFC after: 6 weeks
Sponsored by: Axcient

3 years agossh: remove ssh-hpn leftovers
Ed Maste [Fri, 12 Feb 2021 14:09:00 +0000 (09:09 -0500)]
ssh: remove ssh-hpn leftovers

This was introduced in 8998619212f3a, and left behind when the hpn-ssh
patches were removed in 60c59fad8806.  Although Being able to log
SO_RCVBUF in debug mode might have some small value on its own, it's
not worth carrying an extra diff against upstream.

Reviewed by: kevans
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28610

3 years agoAdding PRR sysctls to tcp(4) man page
Richard Scheffenegger [Fri, 12 Feb 2021 11:32:48 +0000 (12:32 +0100)]
Adding PRR sysctls to tcp(4) man page

Summary:
Documenting the newly added, and enabled by default,
Proportional Rate Reduction algorithm's governing sysctls.

MFC: 3 days

Reviewed By: kbowling, rgrimes

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

3 years agoFix bug 253158 - Panic: snapacct_ufs2: bad block - mksnap_ffs(8) crash
Kirk McKusick [Fri, 12 Feb 2021 05:31:16 +0000 (21:31 -0800)]
Fix bug 253158 - Panic: snapacct_ufs2: bad block - mksnap_ffs(8) crash

The panic reported in 253158 arises because the /mnt/.snap/.factory
snapshot allocated the last block in the filesystem. The snapshot
code allocates the last block in the filesystem as a way of setting
its length to be the size of the filesystem. Part of taking a
snapshot is to remove all the earlier snapshots from the image of
the newest snapshot so that newer snapshots will not claim the blocks
of the earlier snapshots. The panic occurs when the new snapshot
finds that both it and an earlier snapshot claim the same block.

The fix is to set the size of the snapshot to be one block after
the last block in the filesystem. This block can never be allocated
since it is not a valid block in the filesystem. This extra block
is used as a place to store the initial list of blocks that the
snapshot has already copied and is used to avoid a deadlock in and
speed up the ffs_copyonwrite() function.

Reported by:  Harald Schmalzbauer
Tested by:    Peter Holm
PR:           253158
Sponsored by: Netflix

3 years agossh: remove unused variable
Ed Maste [Fri, 12 Feb 2021 03:21:40 +0000 (22:21 -0500)]
ssh: remove unused variable

This was introduced in 03f6c5cd93ec, which added use of
sysctl net.inet.ip.portrange.reservedhigh instead of IPPORT_RESERVED,
but it appears the rest of that change was lost in some subsequent
update.

The change should probably be restored, but until then there is no
reason to leave an unused variable around.

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

3 years agossh: diff reduction against OpenBSD, remove unused includes
Ed Maste [Fri, 12 Feb 2021 01:41:02 +0000 (20:41 -0500)]
ssh: diff reduction against OpenBSD, remove unused includes

These appear to be leftovers from ca86bcf2531c7 and f7167e0ea0bf5

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

3 years agofifo: minor comment and assert improvements.
Konstantin Belousov [Mon, 1 Feb 2021 10:43:16 +0000 (12:43 +0200)]
fifo: minor comment and assert improvements.

In particular, replace a note that reload through vget() is obsoleted,
with explanation why this code is required.

Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoffs_unlock: assert that IN_ENDOFF is not leaked past locked scope
Konstantin Belousov [Sun, 31 Jan 2021 19:01:17 +0000 (21:01 +0200)]
ffs_unlock: assert that IN_ENDOFF is not leaked past locked scope

This catches both missed processing of IN_ENDOFF and missed application
of VOP_VPUT_PAIR() after VOP that created an entry in the directory.

Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoffs softdep: Force processing of VI_OWEINACT vnodes when there is inode shortage
Konstantin Belousov [Sun, 31 Jan 2021 18:39:49 +0000 (20:39 +0200)]
ffs softdep: Force processing of VI_OWEINACT vnodes when there is inode shortage

Such vnodes prevent inode reuse, and should be force-cleared when ffs_valloc()
is unable to find a free inode.

Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agosoftdep_request_cleanup: wait for softdep_request_clean_flush() to pass
Konstantin Belousov [Wed, 3 Feb 2021 23:58:05 +0000 (01:58 +0200)]
softdep_request_cleanup: wait for softdep_request_clean_flush() to pass

if we noted a parallel request is active and declined to overflow the
system with parallel redundant sync of the vnodes.  But we need to wait
for the flush to finish to see if there are any freed resources.

Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoufs_inactive(): stop hiding ERELOOKUP from ffs_truncate(), return it.
Konstantin Belousov [Sat, 30 Jan 2021 19:18:22 +0000 (21:18 +0200)]
ufs_inactive(): stop hiding ERELOOKUP from ffs_truncate(), return it.

VFS should retry inactivation when possible, then. This should provide
timely removal of unlinked unreferenced inodes.

Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoStop ignoring ERELOOKUP from VOP_INACTIVE()
Konstantin Belousov [Sat, 30 Jan 2021 19:17:29 +0000 (21:17 +0200)]
Stop ignoring ERELOOKUP from VOP_INACTIVE()

When possible, relock the vnode and retry inactivation.  Only vunref() is
required not to drop the vnode lock, so handle it specially by not retrying.

This is a part of the efforts to ensure that unlinked not referenced vnode
does not prevent inode from reusing.

Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoufs vnops: brace softdep_prelink() with DOINGSUJ instead of DOINGSOFTDEP
Konstantin Belousov [Sat, 23 Jan 2021 23:12:39 +0000 (01:12 +0200)]
ufs vnops: brace softdep_prelink() with DOINGSUJ instead of DOINGSOFTDEP

because softdep_prelink() is reverted to NOP for non-J case.  There is no
need to do anything before ufs_direnter() in SU/non-J case, everything
required to sync the directory is done in VOP_VPUT_PAIR().

Suggested by: mckusick
Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 week
Sponsored by: The FreeBSD Foundation

3 years agoffs softdep: remove will_direnter argument of softdep_prelink()
Konstantin Belousov [Sat, 23 Jan 2021 22:40:19 +0000 (00:40 +0200)]
ffs softdep: remove will_direnter argument of softdep_prelink()

Originally this was done in 8a1509e442bc9a075 to forcibly cover cases
where a hole in the directory could be created by extending into
indirect block, since dependency of writing out indirect block is not
tracked.  This results in excessive amount of fsyncing the directories,
where all creation of new entry forced fsync before it.  This is not needed,
it is enough to fsync when IN_NEEDSYNC is set, and VOP_VPUT_PAIR() provides
the required hook to only perform required syncing.

The series of changes culminating in this commit puts the performance of
metadata-intensive loads back to that before 8a1509e442bc9a075.

Analyzed by: mckusick
Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoufs_direnter: directory truncation does not need special case for rename
Konstantin Belousov [Fri, 29 Jan 2021 12:31:52 +0000 (14:31 +0200)]
ufs_direnter: directory truncation does not need special case for rename

In ufs_rename case, tdvp is locked from the place where ufs_direnter()
is done till VOP_VPUT_PAIR(), which means that we no longer need to specially
handle rename in ufs_direnter().  Truncation, if possible, is done in the
same way in ffs_vput_pair() both for rename and other VOPs calling
ufs_direnter().  Remove isrename argument and set IN_ENDOFF if
ufs_direnter() succeeded and directory needs truncation.

In ffs_vput_pair(), stop verifying the condition that directory needs
truncation when IN_ENDOFF is set, instead assert that the condition is
true.

Suggested by: mckusick
Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoufs_rename: use VOP_VPUT_PAIR and rely on directory sync/truncation there
Konstantin Belousov [Thu, 28 Jan 2021 13:34:56 +0000 (15:34 +0200)]
ufs_rename: use VOP_VPUT_PAIR and rely on directory sync/truncation there

Suggested by: mckusick
Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoufs_direnter: move directory truncation to ffs_vput_pair().
Konstantin Belousov [Wed, 27 Jan 2021 20:34:14 +0000 (22:34 +0200)]
ufs_direnter: move directory truncation to ffs_vput_pair().

VOP_VPUT_PAIR() provides the hook to do the truncation right before
unlock, which is required since truncation might need to fsync(), which
itself might unlock the directory vnode.

Set new flag IN_ENDOFF which indicates that i_endoff is valid and should
be checked against inode size. Excessive size is chomped, but this
operation is advisory and failure to truncate should not result in the
failure of the main VOP.

Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoffs_vput_pair(): try harder to recover from the vnode reclaim
Konstantin Belousov [Wed, 27 Jan 2021 18:10:51 +0000 (20:10 +0200)]
ffs_vput_pair(): try harder to recover from the vnode reclaim

In particular, if unlock_vp is false, save vp's inode number and
generation. If ffs_inotovp() can re-create the vnode with the same
number and generation after we finished with handling dvp, then we most
likely raced with unmount, and were able to restore atomicity of open.
We use FFSV_REPLACE_DOOMED there, to drop the old vnode.

This additional recovery is not strictly required, but it improves the
quality of the implementation.

Suggested by: mckusick
Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoFFS: implement special VOP_VPUT_PAIR().
Konstantin Belousov [Wed, 27 Jan 2021 18:09:53 +0000 (20:09 +0200)]
FFS: implement special VOP_VPUT_PAIR().

It cleans IN_NEEDSYNC flag on dvp before returning, by applying
ffs_syncvnode() until success or an error different from ERELOOKUP.
IN_NEEDSYNC cleanup is required to avoid creating holes in the directories
when extended into indirect block.

Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agonfsserver: use VOP_VPUT_PAIR().
Konstantin Belousov [Sun, 24 Jan 2021 13:02:27 +0000 (15:02 +0200)]
nfsserver: use VOP_VPUT_PAIR().

Apply VOP_VPUT_PAIR() to the end of vnode operations after the
VOP_MKNOD(), VOP_MKDIR(), VOP_LINK(), VOP_SYMLINK(), VOP_CREATE().

Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoffs_snapshot: use VOP_VPUT_PAIR after VOP_CREATE.
Konstantin Belousov [Sun, 24 Jan 2021 13:56:05 +0000 (15:56 +0200)]
ffs_snapshot: use VOP_VPUT_PAIR after VOP_CREATE.

If the snapshot embrio was reclaimed under us, return error outright.

Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoUse VOP_VPUT_PAIR() for eligible VFS syscalls.
Konstantin Belousov [Thu, 28 Jan 2021 22:31:30 +0000 (00:31 +0200)]
Use VOP_VPUT_PAIR() for eligible VFS syscalls.

The current list is limited to the cases where UFS needs to handle
vput(dvp) specially. Which means VOP_CREATE(), VOP_MKDIR(), VOP_MKNOD(),
VOP_LINK(), and VOP_SYMLINK().

Reviewed by: chs, mkcusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agonullfs: provide special bypass for VOP_VPUT_PAIR
Konstantin Belousov [Sun, 24 Jan 2021 13:22:48 +0000 (15:22 +0200)]
nullfs: provide special bypass for VOP_VPUT_PAIR

Generic bypass cannot understand the rules of liveness for the VOP.

Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoAdd VOP_VPUT_PAIR() with trivial default implementation.
Konstantin Belousov [Thu, 28 Jan 2021 22:30:53 +0000 (00:30 +0200)]
Add VOP_VPUT_PAIR() with trivial default implementation.

The VOP is intended to be used in situations where VFS has two
referenced locked vnodes, typically a directory vnode dvp and a vnode
vp that is linked from the directory, and at least dvp is vput(9)ed.
The child vnode can be also vput-ed, but optionally left referenced and
locked.

There, at least UFS may need to do some actions with dvp which cannot be
done while vp is also locked, so its lock might be dropped temporary.
For instance, in some cases UFS needs to sync dvp to avoid filesystem
state that is currently not handled by either kernel nor fsck. Having
such VOP provides the neccessary context for filesystem which can do
correct locking and handle potential reclamation of vp after relock.

Trivial implementation does vput(dvp) and optionally vput(vp).

Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agovn_open(): If the vnode is reclaimed during open(2), do not return error.
Konstantin Belousov [Wed, 3 Feb 2021 11:02:18 +0000 (13:02 +0200)]
vn_open(): If the vnode is reclaimed during open(2), do not return error.

Most future operations on the returned file descriptor will fail
anyway, and application should be ready to handle that failures.  Not
forcing it to understand the transient failure mode on open, which is
implementation-specific, should make us less special without loss of
reporting of errors.

Suggested by: chs
Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoufs_direnter/SU: unconditionally UFS_UPDATE inode when extending directory
Konstantin Belousov [Sat, 23 Jan 2021 21:52:10 +0000 (23:52 +0200)]
ufs_direnter/SU: unconditionally UFS_UPDATE inode when extending directory

for all kinds of async/SU mount variants.

Submitted by: mckusick
Reviewed by: chs
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoffs_syncvnode: only clear IN_NEEDSYNC after successfull sync
Konstantin Belousov [Sat, 23 Jan 2021 21:50:55 +0000 (23:50 +0200)]
ffs_syncvnode: only clear IN_NEEDSYNC after successfull sync

If it is cleaned before the sync, other threads might see the inode without
the flag set, because syncing could unlock it.

Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoMerge ufs_fhtovp() into ffs_inotovp().
Konstantin Belousov [Thu, 28 Jan 2021 12:20:48 +0000 (14:20 +0200)]
Merge ufs_fhtovp() into ffs_inotovp().

The function alone was not used for anything but ffs_fstovp() for long time.

Suggested by: mckusick
Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoffs_inotovp(): interface to convert (ino, gen) into alive vnode
Konstantin Belousov [Tue, 26 Jan 2021 11:52:59 +0000 (13:52 +0200)]
ffs_inotovp(): interface to convert (ino, gen) into alive vnode

It generalizes the VFS_FHTOVP() interface, making it possible to fetch
the inode without faking filehandle.  Also it adds the ffs flags argument
which allows to control ffs_vgetf() call.

Requested by: mckusick
Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoffs: Add FFSV_REPLACE_DOOMED flag to ffs_vgetf()
Konstantin Belousov [Tue, 26 Jan 2021 11:35:21 +0000 (13:35 +0200)]
ffs: Add FFSV_REPLACE_DOOMED flag to ffs_vgetf()

It specifies that caller requests a fresh non-doomed vnode.  If doomed
vnode is found in the hash, it should behave similarly to FFSV_REPLACE.
Or, to put it differently, the flag is same as FFSV_REPLACE, but only
when the found hashed vnode is doomed.

Reviewed by: chs, mkcusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoffs: call ufsdirhash_dirtrunc() right after setting directory size
Konstantin Belousov [Thu, 28 Jan 2021 18:33:58 +0000 (20:33 +0200)]
ffs: call ufsdirhash_dirtrunc() right after setting directory size

Later processing of ffs_truncate() might temporary unlock the directory
vnode, causing unsychronized dirhash and inode sizes if update is
postponed to UFS_TRUNCATE() callers.

Reviewed by: chs, mkcusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agobuf SU hooks: track buf_start() calls with B_IOSTARTED flag
Konstantin Belousov [Sat, 30 Jan 2021 02:10:34 +0000 (04:10 +0200)]
buf SU hooks: track buf_start() calls with B_IOSTARTED flag

and only call buf_complete() if previously started.  Some error paths,
like CoW failire, might skip buf_start() and do bufdone(), which itself
call buf_complete().

Various SU handle_written_XXX() functions check that io was started
and incomplete parts of the buffer data reverted before restoring them.
This is a useful invariant that B_IO_STARTED on buffer layer allows to
keep instead of changing check and panic into check and return.

Reported by: pho
Reviewed by: chs, mckusick
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundations

3 years agoffs_vnops.c: Move opt_*.h includes to the top.
Konstantin Belousov [Thu, 28 Jan 2021 18:30:35 +0000 (20:30 +0200)]
ffs_vnops.c: Move opt_*.h includes to the top.

as it is done in other places.  Header files might need options defined
for correct operation.

Reviewed by: chs, mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

3 years agopkg(7): address minor nits (mostly clang-analyze complaints)
Kyle Evans [Fri, 12 Feb 2021 00:58:27 +0000 (18:58 -0600)]
pkg(7): address minor nits (mostly clang-analyze complaints)

- One (1) spurious whitespace.
- One (1) occurrence of "random(3) bad, arc4random(3)" good.
- Three (3) writes that will never be seen.

The latter two points are complaints from clang-analyze. Switching to
arc4random(3) is decidedly a good idea because we weren't doing any kind
of PRNG seeding anyways. The discarded assignments are arguably good
for future-proofing, but it's better to improve the S/N ratio from
clang-analyze.

Reviewed by: bapt, manu
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28525

3 years agopkg(7): add an -r reponame option for bootstrap and add
Kyle Evans [Fri, 12 Feb 2021 00:58:26 +0000 (18:58 -0600)]
pkg(7): add an -r reponame option for bootstrap and add

This is limited to bootstrap/add because some real pkg(8) commands
have -r flags with an incompatible meaning/usage, e.g., pkg-audit.
pkg(7) will still commence the search as it has, but it will ignore any
repo objects without the given name so that overrides and whatnot still
work as expected.

The use of it for add is noted in the manpage; notably, that the
signature config for that repository will be used over global config if
it's specified. i.e., pkg(7) should assume that the given pkg did come
from that repository and treat it appropriately.

Reviewed by: bapt, manu
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28524

3 years agoyacc: Regen test cases for the previous commit
Jung-uk Kim [Thu, 11 Feb 2021 23:41:28 +0000 (18:41 -0500)]
yacc: Regen test cases for the previous commit

3 years agoyacc: Use NULL instead of 0 for pointers
Jung-uk Kim [Thu, 11 Feb 2021 23:40:00 +0000 (18:40 -0500)]
yacc: Use NULL instead of 0 for pointers

Note araujo tried to fix it in r298241 but he only touched generated
files for bootstrap.  This commit properly fixes the problem.

3 years agolex: Use NULL instead of 0 for pointers
Jung-uk Kim [Thu, 11 Feb 2021 23:31:53 +0000 (18:31 -0500)]
lex: Use NULL instead of 0 for pointers

Note araujo tried to fix it in r298241 but he only touched generated
files for bootstrap.  This commit properly fixes the problem.

3 years agoefibootmgr: Check for efi supported after parsing args
Warner Losh [Thu, 11 Feb 2021 23:06:30 +0000 (16:06 -0700)]
efibootmgr: Check for efi supported after parsing args

Move the check for efi variables being supported to after parsing the args. This
allows '-h' to produce both as a normal user as well as on all systems.

3 years agoFix blackhole/reject routes.
Alexander V. Chernikov [Mon, 8 Feb 2021 23:29:05 +0000 (23:29 +0000)]
Fix blackhole/reject routes.

Traditionally *BSD routing stack required to supply some
 interface data for blackhole/reject routes. This lead to
 varieties of hacks in routing daemons when inserting such routes.
With the recent routeing stack changes, gateway sockaddr without
 RTF_GATEWAY started to be treated differently, purely as link
 identifier.

This change broke net/bird, which installs blackhole routes with
 127.0.0.1 gateway without RTF_GATEWAY flags.

Fix this by automatically constructing necessary gateway data at
 rtsock level if RTF_REJECT/RTF_BLACKHOLE is set.

Reported by: Marek Zarychta <zarychtam at plan-b.pwste.edu.pl>
Reviewed by: donner
MFC after: 1 week

3 years agocam: Properly find the sim in the assertion in xpt_pollwait().
John Baldwin [Mon, 8 Feb 2021 23:02:14 +0000 (15:02 -0800)]
cam: Properly find the sim in the assertion in xpt_pollwait().

I had missed merging this fixup into
447b3557a9cc5f00a301be8404339f21a9a0faa8 before pushing it.

Pointy hat to: jhb
MFC after: 2 weeks

3 years agoiscsi: Mark iSCSI CAM sims as non-pollable.
John Baldwin [Thu, 11 Feb 2021 21:51:20 +0000 (13:51 -0800)]
iscsi: Mark iSCSI CAM sims as non-pollable.

Previously, iscsi_poll() just panicked.  This meant if you got a panic
on a box when using the iSCSI initiator, the attempt to shutdown would
trigger a nested panic and never write out a core.  Now, CCB's sent to
iSCSI devices (such as the sychronize-cache request in dashutdown())
just fail with a timeout during a panic shutdown.

Reviewed by: scottl, mav
MFC after: 2 weeks
Sponsored by: Chelsio
Differential Revision: https://reviews.freebsd.org/D28455

3 years agocam: Don't permit crashdumps on non-pollable devices.
John Baldwin [Thu, 11 Feb 2021 21:51:01 +0000 (13:51 -0800)]
cam: Don't permit crashdumps on non-pollable devices.

If a disk's SIM doesn't support polling, then it can't be used to
store crashdumps.  Leave d_dump NULL in that case so that dumpon(8)
fails gracefully rather than having dumps fail at crash time.

Reviewed by: scottl, mav, imp
MFC after: 2 weeks
Sponsored by: Chelsio
Differential Revision: https://reviews.freebsd.org/D28454

3 years agocam: Permit non-pollable sims.
John Baldwin [Thu, 11 Feb 2021 21:49:43 +0000 (13:49 -0800)]
cam: Permit non-pollable sims.

Some CAM sim drivers do not support polling (notably iscsi(4)).
Rather than using a no-op poll routine that always times out requests,
permit a SIM to set a NULL poll callback.  cam_periph_runccb() will
fail polled requests non-pollable sims immediately as if they had
timed out.

Reviewed by: scottl, mav (earlier version)
Reviewed by: imp
MFC after: 2 weeks
Sponsored by: Chelsio
Differential Revision: https://reviews.freebsd.org/D28453

3 years agoWiden ifnet_detach_sxlock coverage
Kristof Provost [Mon, 8 Feb 2021 09:04:27 +0000 (10:04 +0100)]
Widen ifnet_detach_sxlock coverage

Widen the ifnet_detach_sxlock to cover the entire vnet sysuninit code.
This ensures that we can't end up having the vnet_sysuninit free the UDP
pcb while the detach code is running and trying to purge the UDP pcb.

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28530

3 years agorelease.sh: fix OSVERSION and UNAME_r overrides
Glen Barber [Thu, 11 Feb 2021 15:46:38 +0000 (10:46 -0500)]
release.sh: fix OSVERSION and UNAME_r overrides

Add PBUILD_FLAGS and UNAME_r overrides to extra_chroot_setup()
to fix building ports for 14-CURRENT builds on 13.x.

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

3 years agomlx4, mthca: Silence warnings about no-op alignment operations
Mark Johnston [Thu, 11 Feb 2021 15:16:59 +0000 (10:16 -0500)]
mlx4, mthca: Silence warnings about no-op alignment operations

Since commit 8fa6abb6f4f64f ("Expose clang's alignment builtins and use
them for roundup2/rounddown2"), clang emits warnings for several
alignment operations in these drivers because the operation is a no-op.
The compiler is arguably being too strict here, but in the meantime
let's silence the warnings by conditionally compiling the alignment
operations.

Reviewed by: arichardson, hselasky
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D28576

3 years agoVOP_ADVLOCK(9): fix a typo
Guangyuan Yang [Thu, 11 Feb 2021 00:25:58 +0000 (00:25 +0000)]
VOP_ADVLOCK(9): fix a typo

Submitted by: Ka Ho Ng <khng300@gmail.com>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28575

3 years agoFix lib/msun/test builds on platforms without 80-bit long doubles
Dimitry Andric [Thu, 11 Feb 2021 11:01:10 +0000 (12:01 +0100)]
Fix lib/msun/test builds on platforms without 80-bit long doubles

After d3338f3355a612cf385632291f46c5777bba8d18, the lib/msun test case
'hypotl_near_underflow' would fail to compile on platforms where long
doubles weren't 80 bit, like on x86. Disable this particular test on
such platforms for now.

PR: 253313
MFC after: 1 week
X-MFC-With:     d3338f3355a612cf385632291f46c5777bba8d18

3 years ago[udp] fix possible mbuf and lock leak in udp_input().
Andrey V. Elsukov [Thu, 11 Feb 2021 08:55:39 +0000 (11:55 +0300)]
[udp] fix possible mbuf and lock leak in udp_input().

In error case we can leave `inp' locked, also we need to free
mbuf chain `m' in the same case. Release the lock and use `badunlocked'
label to exit with freed mbuf. Also modify UDP error statistic to
match the IPv6 code.

Remove redundant INP_RUNLOCK() from the `if (last == NULL)' block,
there are no ways to reach this point with locked `inp'.

Obtained from: Yandex LLC
MFC after: 3 days
Sponsored by: Yandex LLC

3 years ago[udp6] fix possible panic due to lack of locking.
Andrey V. Elsukov [Thu, 11 Feb 2021 08:38:41 +0000 (11:38 +0300)]
[udp6] fix possible panic due to lack of locking.

The lookup for a IPv6 multicast addresses corresponding to
the destination address in the datagram is protected by the
NET_EPOCH section. Access to each PCB is protected by INP_RLOCK
during comparing. But access to socket's so_options field is
not protected. And in some cases it is possible, that PCB
pointer is still valid, but inp_socket is not. The patch wides
lock holding to protect access to inp_socket. It copies locking
strategy from IPv4 UDP handling.

PR: 232192
Obtained from: Yandex LLC
MFC after: 3 days
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D28232

3 years agoMerge bmake-20210206
Simon J. Gerraty [Thu, 11 Feb 2021 06:01:59 +0000 (22:01 -0800)]
Merge bmake-20210206

Changes of interest

  o unit-tests: use private TMPDIR to avoid errors from other users
  o avoid strdup in mkTempFile
  o always use vfork
  o job.c: do not create empty shell files in jobs mode
    reduce unnecessary calls to waitpid
  o cond.c: fix debug output for comparison operators in conditionals

3 years agokldload(8): Improve phrasing
Daniel Ebdrup Jensen [Thu, 11 Feb 2021 05:01:49 +0000 (06:01 +0100)]
kldload(8): Improve phrasing

Mountroot isn't documented in the extant manual pages - so this
phrasing, while less absolute and concise, still conveys which
modules are recommended to be handled via loader.conf(5), and it also
does a better job of elucidating that the modules can include filesystem
drivers.

Submitted by: kevans (earlier version)
Reported by: imp, kevans, eugen
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D28542

3 years agousleep(3): replace 'process' with 'calling thread'
Konstantin Belousov [Thu, 11 Feb 2021 03:49:25 +0000 (05:49 +0200)]
usleep(3): replace 'process' with 'calling thread'

PR: 253395
Reported by: zegang.luo@qq.com
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

3 years agorelease: fix overriding UNAME_r
Glen Barber [Thu, 11 Feb 2021 02:23:58 +0000 (21:23 -0500)]
release: fix overriding UNAME_r

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

3 years agoImport bmake-20210206
Simon J. Gerraty [Thu, 11 Feb 2021 01:51:11 +0000 (17:51 -0800)]
Import bmake-20210206

Changes of interest

  o unit-tests: use private TMPDIR to avoid errors from other users
  o avoid strdup in mkTempFile
  o always use vfork
  o job.c: do not create empty shell files in jobs mode
    reduce unnecessary calls to waitpid
  o cond.c: fix debug output for comparison operators in conditionals

3 years agoFix incorrect hypotl(3) result with subnormal numbers
Dimitry Andric [Wed, 10 Feb 2021 22:28:43 +0000 (23:28 +0100)]
Fix incorrect hypotl(3) result with subnormal numbers

This adjusts the factor used to scale the subnormal numbers, so it
becomes the right value after adjusting its exponent. Thanks to Steve
Kargl for finding the most elegant fix.

Also enable the hypot tests, and add a test case for this bug.

PR: 253313
MFC after: 1 week

3 years agoarm64: if_dwc is also needed by intel stratix10 platform
Emmanuel Vadot [Thu, 4 Feb 2021 16:07:17 +0000 (17:07 +0100)]
arm64: if_dwc is also needed by intel stratix10 platform

MFC after: 3 days

3 years agoarm64: Add a SOC_BRCM_NS2 option
Emmanuel Vadot [Thu, 4 Feb 2021 14:40:54 +0000 (15:40 +0100)]
arm64: Add a SOC_BRCM_NS2 option

Only compile files needed for this platform if the option is enabled in the
kernel config file.
Add the option to GENERIC.

MFC after: 3 days

3 years agoarm64: Make thunderx vnic file depend on soc_cavm_thunderx
Emmanuel Vadot [Thu, 4 Feb 2021 14:31:23 +0000 (15:31 +0100)]
arm64: Make thunderx vnic file depend on soc_cavm_thunderx

MFC after: 3 days

3 years agoarm64: Order sys/conf/files.arm64
Emmanuel Vadot [Thu, 4 Feb 2021 13:54:22 +0000 (14:54 +0100)]
arm64: Order sys/conf/files.arm64

This is now easier to read and see what's compiled-in

No functional changes intended.

MFC after: 3 days

3 years agonetgraph/ng_bridge: Add counters for the first link, too
Lutz Donnerhacke [Wed, 10 Feb 2021 10:47:38 +0000 (11:47 +0100)]
netgraph/ng_bridge: Add counters for the first link, too

For broadcast, multicast and unknown unicast, the replication loop
sends a copy of the packet to each link, beside the first one. This
special path is handled later, but the counters are not updated.
Factor out the common send and count actions as a function.

Reviewed by: kp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28537

3 years agosystat.1: Fix synopsis
Mateusz Piotrowski [Wed, 10 Feb 2021 17:02:14 +0000 (18:02 +0100)]
systat.1: Fix synopsis

systat does not have a "-display" flag. Use Ar to indicate that
"display" is meant to be substituted with an actual display command.

MFC after: 1 week

3 years agosystat.1: Remove Tn macros
Mateusz Piotrowski [Sat, 6 Feb 2021 13:14:20 +0000 (14:14 +0100)]
systat.1: Remove Tn macros

They are no longer supported by mdoc(7).

MFC after: 1 week

3 years agolocaledef: Fix bootstrapping on Ubuntu 16.04
Jessica Clarke [Wed, 10 Feb 2021 16:41:35 +0000 (16:41 +0000)]
localedef: Fix bootstrapping on Ubuntu 16.04

Glibc's stdlib.h defines various prototypes for GNU extensions that take
a locale_t. Newer versions use locale_t directly and include an internal
bits/types/locale_t.h in order to get its definition, but older versions
include xlocale.h for that, for which our bootstrap version is empty.
Moreover it expects to use the glibc-specific __locale_t type. Thus,
provide dummy definitions of both types in order to ensure the
prototypes don't give any errors, and guard against the header being
inadvertently included between the bootstrapping namespace.h and
un-namespace.h, where locale_t is #define'd.

This header is not used when bootstrapping on FreeBSD and exists solely
to stub out glibc's, so this should have no impact on FreeBSD hosts.

Reviewed by: arichardson, emaste (comment only)
Differential Revision: https://reviews.freebsd.org/D28317

3 years agovm: Honour the "noreuse" flag to vm_page_unwire_managed()
Mark Johnston [Wed, 10 Feb 2021 16:10:27 +0000 (11:10 -0500)]
vm: Honour the "noreuse" flag to vm_page_unwire_managed()

This flag indicates that the page should be enqueued near the head of
the inactive queue, skipping the LRU queue.  It is used when unwiring
pages from the buffer cache following direct I/O or after I/O when
POSIX_FADV_NOREUSE or _DONTNEED advice was specified, or when
sendfile(SF_NOCACHE) completes.  For the direct I/O and sendfile cases
we only enqueue the page if we decide not to free it, typically because
it's mapped.

Pass "noreuse" through to vm_page_release_toq() so that we actually
honour the desired LRU policy for these scenarios.

Reported by: bdrewery
Reviewed by: alc, kib
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D28555

3 years agoAlways build the sanitizer runtimes when compiling with clang
Alex Richardson [Wed, 10 Feb 2021 15:25:14 +0000 (15:25 +0000)]
Always build the sanitizer runtimes when compiling with clang

This allows instrumenting e.g. test binaries even when compiling with an
external clang (e.g. CROSS_TOOLCHAIN=llvm11). I have some upcoming patches
that allow building the entire base system with ASan/UBSan/etc.
instrumentation and this is required in preparation for this.

Reviewed By: dim, emaste
Differential Revision: https://reviews.freebsd.org/D28532

3 years agousr.sbin/makefs: fix use-after-free in read_mtree_keywords()
Alex Richardson [Wed, 10 Feb 2021 15:23:23 +0000 (15:23 +0000)]
usr.sbin/makefs: fix use-after-free in read_mtree_keywords()

The st variable is used as a shortcut for &node->inode->st, but in one
branch just before the exit we update node->inode without changing st.

Reported by: AddressSanitizer
Reviewed By: emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28570

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

Update unbound 1.13.0 --> 1.13.1.

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

MFC after: 1 month

3 years agoFix non-IPv6 build post 57785538c6e0d7e8ca0f161ab95bae10fd304047.
Cy Schubert [Wed, 10 Feb 2021 01:13:01 +0000 (17:13 -0800)]
Fix non-IPv6 build post 57785538c6e0d7e8ca0f161ab95bae10fd304047.

57785538c6e0d7e8ca0f161ab95bae10fd304047 change the test for FreeBSD
from __FreeBSD_version to __FreeBSD__. However this test was performed
before sys/param.h was included, therefore __FreeBSD_version was never
defined. As the test was never true opt_random_ip_id.h was never included.

Submitted by: bdragon
Reported by: bdragon
MFC after: 1 week
X-MFC with: 57785538c6e0d7e8ca0f161ab95bae10fd304047

3 years agolibsysdecode: fix decoding of TCP_NOPUSH and TCP_MD5SIG
Michael Tuexen [Tue, 9 Feb 2021 22:35:55 +0000 (23:35 +0100)]
libsysdecode: fix decoding of TCP_NOPUSH and TCP_MD5SIG

TCP_FASTOPEN_MIN_COOKIE_LEN was incorrectly registered as a name of
a IPPROTO_TCP level socket option, which overwrote TCP_NOPUSH.
TCP_FASTOPEN_PSK_LEN was incorrectly registered as a name of an
IPPROTO_TCP level socket option, which overwrote TCP_MD5SIG.

MFC after: 3 days
Sponsored by: Netflix, Inc.

3 years agoAdd test case for 93fc67896550 (incorrect powf(3) result)
Dimitry Andric [Tue, 9 Feb 2021 22:37:08 +0000 (23:37 +0100)]
Add test case for 93fc67896550 (incorrect powf(3) result)

This adds the test case to contrib/netbsd-tests/lib/libm/t_pow.c, as it
is currently the only place testing pow(3) and friends.

MFC after: 1 week

3 years agobsd.compiler.mk: Detect distribution-provided GCC when executed as cc
Jessica Clarke [Tue, 9 Feb 2021 21:40:24 +0000 (21:40 +0000)]
bsd.compiler.mk: Detect distribution-provided GCC when executed as cc

Clang always prints "clang $VERSION" regardless of the name used to
execute it, whereas GCC prints "$progname $VERSION", meaning if CC is
set to cc and cc is GCC it will print "cc $VERSION". We are able to
detect some of those cases since it then prints "($PKGVERSION)", where
the default is "GCC", but many distributions override that to print
their name and the package version number (e.g. "Debian 10.2.1-6"), so
nothing tells us it's GCC other than the fact that it's not Clang (and
that there's an FSF copyright disclaimer).

However, GCC's -v option will always print "gcc version $VERSION", so
fall back on using that to detect GCC. Whilst Clang also supports this
option, we should never get here, so Clang handling is not added.

Reviewed by: brooks, emaste, arichardson
Differential Revision: https://reviews.freebsd.org/D28315

3 years agoFix lib/msun's ctrig_test/test_inf_inputs test case with clang >= 10
Dimitry Andric [Tue, 9 Feb 2021 21:06:51 +0000 (22:06 +0100)]
Fix lib/msun's ctrig_test/test_inf_inputs test case with clang >= 10

This sprinkles a few strategic volatiles in an attempt to defeat clang's
optimization interfering with the expected floating-point exception
flags.

Reported by: lwhsu
PR: 244732
MFC after: 3 days

3 years agoVendor import of Unbound 1.13.1.
Cy Schubert [Tue, 9 Feb 2021 20:59:02 +0000 (12:59 -0800)]
Vendor import of Unbound 1.13.1.

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

3 years agonetgraph/ng_bridge: Document staleness in multithreaded operation
Lutz Donnerhacke [Tue, 9 Feb 2021 11:32:46 +0000 (12:32 +0100)]
netgraph/ng_bridge: Document staleness in multithreaded operation

In the data path of ng_bridge(4), the only value of the host struct,
which needs to be modified, is the staleness, which is reset every
time a frame is received.  It's save to leave the code as it is.

This patch is part of a series to make ng_bridge(4) multithreaded.

Reviewed by: kp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D28546

3 years agonetgraph/ng_bridge: Merge internal structures
Lutz Donnerhacke [Mon, 8 Feb 2021 21:36:46 +0000 (22:36 +0100)]
netgraph/ng_bridge: Merge internal structures

In a earlier version of ng_bridge(4) the exernal visible host entry
structure was a strict subset of the internal one.  So internal view
was a direct annotation of the external structure.  This strict
inheritance was lost many versions ago.  There is no need to
encapsulate a part of the internal represntation as a separate
structure.

This patch is a preparation to make the internal structure read only
in the data path in order to make ng_bridge(4) multithreaded.

Reviewed by: kp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D28545

3 years agoSet file mode during zfs_write
Antonio Russo [Mon, 8 Feb 2021 17:15:05 +0000 (10:15 -0700)]
Set file mode during zfs_write

Apply https://github.com/openzfs/zfs/pull/11576

Direct commit from upstream openzfs. Full commit message below:

Set file mode during zfs_write

3d40b65 refactored zfs_vnops.c, which shared much code verbatim between
Linux and BSD.  After a successful write, the suid/sgid bits are reset,
and the mode to be written is stored in newmode.  On Linux, this was
propagated to both the in-memory inode and znode, which is then updated
with sa_update.

3d40b65 accidentally removed the initialization of newmode, which
happened to occur on the same line as the inode update (which has been
moved out of the function).

The uninitialized newmode can be saved to disk, leading to a crash on
stat() of that file, in addition to a merely incorrect file mode.

Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Antonio Russo <aerusso@aerusso.net>
Closes #11474
Closes #11576

Obtained from: openzfs/zfs@f8ce8aed0
MFC after: 0 days
Sponsored by: iXsystems, Inc.

3 years agousr.bin/grep: Fix Address OOB read error
Alex Richardson [Tue, 19 Jan 2021 11:35:07 +0000 (11:35 +0000)]
usr.bin/grep: Fix Address OOB read error

I found this when compiling all the bootstrap tools with -fsanitize=addres:

==65590==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x62d000008400 at pc 0x000000473053 bp 0x7ffc1c7dd910 sp 0x7ffc1c7dd0b8
READ of size 32769 at 0x62d000008400 thread T0
    #0 0x473052 in regexec (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x473052)
    #1 0x4c9cf3 in procline /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:539:8
    #2 0x4c8687 in procfile /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:379:18
    #3 0x4c6596 in main /local/scratch/alr48/cheri/freebsd/usr.bin/grep/grep.c:714:8

0x62d000008400 is located 0 bytes to the right of 32768-byte region [0x62d000000400,0x62d000008400)
allocated by thread T0 here:
    #0 0x493d5d in malloc (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x493d5d)
    #1 0x4cad75 in grep_malloc /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c:656:13
    #2 0x4c8129 in procfile /local/scratch/alr48/cheri/freebsd/usr.bin/grep/util.c
    #3 0x4c6596 in main /local/scratch/alr48/cheri/freebsd/usr.bin/grep/grep.c:714:8

SUMMARY: AddressSanitizer: heap-buffer-overflow (/local/scratch/alr48/cheri/build/freebsd-amd64-build/local/scratch/alr48/cheri/freebsd/amd64.amd64/tmp/legacy/bin/grep+0x473052) in regexec

Reviewed By: kevans
MFC after: 1 week