Commit Graph

256641 Commits

Author SHA1 Message Date
Konstantin Belousov
49c117c193 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
2021-02-12 03:02:20 +02:00
Konstantin Belousov
ee965dfa64 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
2021-02-12 03:02:20 +02:00
Konstantin Belousov
08c2dc2841 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
2021-02-12 03:02:20 +02:00
Konstantin Belousov
1de1e2bfbf 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
2021-02-12 03:02:20 +02:00
Konstantin Belousov
89fd61d955 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
2021-02-12 03:02:20 +02:00
Konstantin Belousov
5952c86c78 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
2021-02-12 03:02:20 +02:00
Konstantin Belousov
f16c26b1c0 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
2021-02-12 03:02:20 +02:00
Konstantin Belousov
e94f2f1be3 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
2021-02-12 03:02:19 +02:00
Konstantin Belousov
bf0db19339 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
2021-02-12 03:02:19 +02:00
Konstantin Belousov
0281f88e5d 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
2021-02-12 03:02:19 +02:00
Kyle Evans
b2c4ca8d28 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
2021-02-11 18:58:27 -06:00
Kyle Evans
18418e1936 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
2021-02-11 18:58:26 -06:00
Jung-uk Kim
bf80e08ed5 yacc: Regen test cases for the previous commit 2021-02-11 18:41:28 -05:00
Jung-uk Kim
80f3143274 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.
2021-02-11 18:40:00 -05:00
Jung-uk Kim
34e67bb597 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.
2021-02-11 18:31:53 -05:00
Warner Losh
7fe2f504f8 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.
2021-02-11 16:09:51 -07:00
Alexander V. Chernikov
145bf6c0af 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
2021-02-11 23:08:55 +00:00
John Baldwin
e6405c8c37 cam: Properly find the sim in the assertion in xpt_pollwait().
I had missed merging this fixup into
447b3557a9 before pushing it.

Pointy hat to:	jhb
MFC after:	2 weeks
2021-02-11 14:06:58 -08:00
John Baldwin
47769bc557 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
2021-02-11 13:52:18 -08:00
John Baldwin
e07ac3f2fd 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
2021-02-11 13:52:18 -08:00
John Baldwin
447b3557a9 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
2021-02-11 13:52:12 -08:00
Kristof Provost
6d2a10d96f 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
2021-02-11 16:12:29 +01:00
Glen Barber
6462113b70 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:	c511a5ab53
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-02-11 10:46:38 -05:00
Mark Johnston
29ed53850e mlx4, mthca: Silence warnings about no-op alignment operations
Since commit 8fa6abb6f4 ("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
2021-02-11 10:16:59 -05:00
Guangyuan Yang
c03ccb991d 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
2021-02-11 14:02:43 +00:00
Dimitry Andric
2512066228 Fix lib/msun/test builds on platforms without 80-bit long doubles
After d3338f3355, 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:     d3338f3355
2021-02-11 12:01:10 +01:00
Andrey V. Elsukov
c6ded47d0b [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
2021-02-11 12:08:41 +03:00
Andrey V. Elsukov
3c782d9c91 [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
2021-02-11 12:00:25 +03:00
Simon J. Gerraty
dba7b0ef92 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
2021-02-10 22:03:22 -08:00
Daniel Ebdrup Jensen
2a7d4d9545 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
2021-02-11 06:03:53 +01:00
Konstantin Belousov
4956af2a8f usleep(3): replace 'process' with 'calling thread'
PR:	253395
Reported by:	zegang.luo@qq.com
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2021-02-11 05:52:55 +02:00
Glen Barber
c511a5ab53 release: fix overriding UNAME_r
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-02-10 21:23:58 -05:00
Simon J. Gerraty
8b6f73e37b 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
2021-02-10 17:51:11 -08:00
Dimitry Andric
d3338f3355 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
2021-02-10 23:28:43 +01:00
Emmanuel Vadot
a6dc68c0e0 arm64: if_dwc is also needed by intel stratix10 platform
MFC after:	3 days
2021-02-10 21:15:59 +01:00
Emmanuel Vadot
3b721b4495 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
2021-02-10 21:15:50 +01:00
Emmanuel Vadot
b81439d1eb arm64: Make thunderx vnic file depend on soc_cavm_thunderx
MFC after:	3 days
2021-02-10 21:15:40 +01:00
Emmanuel Vadot
ea3b6abf3f 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
2021-02-10 21:15:19 +01:00
Lutz Donnerhacke
3c958f5fdf 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
2021-02-10 19:05:37 +01:00
Mateusz Piotrowski
e6f59be239 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
2021-02-10 18:09:49 +01:00
Mateusz Piotrowski
fcbaf46b76 systat.1: Remove Tn macros
They are no longer supported by mdoc(7).

MFC after:	1 week
2021-02-10 18:09:27 +01:00
Jessica Clarke
01d07b03ef 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
2021-02-10 16:41:35 +00:00
Mark Johnston
5c18744ea9 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
2021-02-10 11:10:27 -05:00
Alex Richardson
7676b388ad 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
2021-02-10 15:25:14 +00:00
Alex Richardson
12ad8bdb34 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
2021-02-10 15:24:25 +00:00
Cy Schubert
f44e67d120 MFV d60fa10fd8:
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
2021-02-09 20:27:25 -08:00
Cy Schubert
1e811efbc5 Fix non-IPv6 build post 57785538c6.
57785538c6 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:	57785538c6
2021-02-09 17:18:25 -08:00
Michael Tuexen
f25266bee7 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.
2021-02-09 23:42:27 +01:00
Dimitry Andric
51af033287 Add test case for 93fc678965 (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
2021-02-09 23:37:18 +01:00
Jessica Clarke
9c6954329a 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
2021-02-09 21:40:24 +00:00