]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoMFC r357827: lualoader: disable autoboot on high-level interpreter errors
Kyle Evans [Fri, 21 Feb 2020 04:25:10 +0000 (04:25 +0000)]
MFC r357827: lualoader: disable autoboot on high-level interpreter errors

If we hit an error at this level, we are almost certainly not in any kind
of sane state where autoboot can do the right thing. Instead of letting it
try and probably failing, disable autoboot so they immediately get kicked
into a loader prompt for manual remediation/diagnosis.

4 years agoMFC r358069:
Cy Schubert [Fri, 21 Feb 2020 04:23:54 +0000 (04:23 +0000)]
MFC r358069:

strchr() returns a pointer not an int.

Reported by: bjk
Approved by: des (blanket, implicit)

4 years agoMFC r358067:
Cy Schubert [Fri, 21 Feb 2020 04:22:29 +0000 (04:22 +0000)]
MFC r358067:

There is no pam(8) man page, it is pam(3).

Approved by: des (implicit, blanket)

4 years agoMFC r358068:
Cy Schubert [Fri, 21 Feb 2020 04:20:10 +0000 (04:20 +0000)]
MFC r358068:

Add missing SYNOPSIS section.

Reported by: ports/textproc/igor

4 years agoMFC: r356963
Jung-uk Kim [Fri, 21 Feb 2020 00:33:21 +0000 (00:33 +0000)]
MFC: r356963

Install man5 and man7 for OpenSSL.

4 years agoMFC r357846
Vincenzo Maffione [Thu, 20 Feb 2020 21:52:36 +0000 (21:52 +0000)]
MFC r357846

bhyve: move virtio-net header processing to pci_virtio_net

This patch cleans up the API between the net frontends (e1000,
virtio-net) and the net backends (tap and netmap).
We move the virtio-net header stripping/prepending to the
virtio-net code, where this functionality belongs.
In this way, the netbe_send() and netbe_recv() signatures
can have const struct iov * rather than struct iov *.

Reviewed by:    grehan, bcr, aleksandr.fedorov@itglobal.com
Differential Revision:  https://reviews.freebsd.org/D23342

4 years agoMFC r356523
Vincenzo Maffione [Thu, 20 Feb 2020 21:48:36 +0000 (21:48 +0000)]
MFC r356523

bhyve: add wrapper for debug printf statements

Add printf() wrapper to use CR/CRLF terminators depending on whether
stdio is mapped to a tty open in raw mode.
Try to use the wrapper everywhere.
For now we leave the custom DPRINTF/WPRINTF defined by device
models, but we may remove them in the future.

Reviewed by:    grehan, jhb
Differential Revision:  https://reviews.freebsd.org/D22657

4 years agoMFC r357871:
Konstantin Belousov [Thu, 20 Feb 2020 01:45:55 +0000 (01:45 +0000)]
MFC r357871:
hyperv: Add Hygon Dhyana support.

4 years agoMFC r357870:
Konstantin Belousov [Thu, 20 Feb 2020 01:44:50 +0000 (01:44 +0000)]
MFC r357870:
ecc_inject: Add Hygon Dhyana support.

4 years agoMFC r357869:
Konstantin Belousov [Thu, 20 Feb 2020 01:42:11 +0000 (01:42 +0000)]
MFC r357869:
amdsbwd, intpm: Add Hygon Dhyana support.

4 years agoMFC r357868:
Konstantin Belousov [Thu, 20 Feb 2020 01:41:12 +0000 (01:41 +0000)]
MFC r357868:
amdpm: Add Hygon Dhyana support.

4 years agoMFC r357866:
Konstantin Belousov [Thu, 20 Feb 2020 01:39:48 +0000 (01:39 +0000)]
MFC r357866:
bhyve, bhyvectl: Add Hygon Dhyana support.

4 years agoMFC r357865:
Konstantin Belousov [Thu, 20 Feb 2020 01:38:56 +0000 (01:38 +0000)]
MFC r357865:
vmm: Add Hygon Dhyana support.

4 years agoMFC r358022:
Konstantin Belousov [Thu, 20 Feb 2020 01:34:29 +0000 (01:34 +0000)]
MFC r358022:
pciconf: List names of all known extended PCIe capabilities.

4 years agoMFC r357895, r357910:
Konstantin Belousov [Thu, 20 Feb 2020 01:27:35 +0000 (01:27 +0000)]
MFC r357895, r357910:
Handle non-plt IRELATIVE relocations, at least for x86.

4 years agoMFC r357894:
Konstantin Belousov [Thu, 20 Feb 2020 01:23:39 +0000 (01:23 +0000)]
MFC r357894:
Return success, instead of ESRCH, from pthread_cancel(3) applied to the
exited but not yet joined thread.

4 years agoMFC r358021:
Konstantin Belousov [Thu, 20 Feb 2020 01:16:42 +0000 (01:16 +0000)]
MFC r358021:
Fix typo.

4 years agoMFC r357639: Reduce number of atomic_add() calls in aggsum.
Alexander Motin [Thu, 20 Feb 2020 01:03:44 +0000 (01:03 +0000)]
MFC r357639: Reduce number of atomic_add() calls in aggsum.

Previous code used 4 atomics to do aggsum_flush_bucket() and 2 more to
re-borrow after the flush.  But since asc_borrowed and asc_delta are
accessed only while holding asc_lock, it makes no any sense to modify
as_lower_bound and as_upper_bound in multiple steps.  Instead of that
the new code uses only 2 atomics in all the cases, one per as_*_bound
variable.  I think even that is overkill, simple atomic store and
load could be used here, since all modifications are done under the
as_lock, but there are no such primitives in ZFS code now.

While there, make borrow code consider previous borrow value, so that
on mixed request patterns reduce chance of needing to borrow again if
much larger request follows tiny one that needed borrow.

Also reduce as_numbuckets from uint64_t to u_int.  It makes no sense
to use so large division operation on every aggsum_add().

4 years agoMFC r357576:
Mark Johnston [Wed, 19 Feb 2020 16:17:51 +0000 (16:17 +0000)]
MFC r357576:
Fix a use of an uninitialized pointer in xdr_rpcbs_rmtcalllist().

PR: 243759

4 years agoMFC r352385:
Baptiste Daroussin [Wed, 19 Feb 2020 14:51:39 +0000 (14:51 +0000)]
MFC r352385:

Do not use our custom completion function, it is not needed anymore

4 years agoMFC r352136, r352204, r352275, r352341
Baptiste Daroussin [Wed, 19 Feb 2020 14:49:32 +0000 (14:49 +0000)]
MFC r352136, r352204, r352275, r352341

r352136:
Import libedit 2019-09-10

Compared to current version in base:
- great improvements on the Unicode support
- full support for filename completion including quoting
  which means we do not need anymore our custom addition)
- Improved readline compatiblity

Upgrading libedit has been a pain in the past, because somehow we never
managed to properly cleanup the tree in lib/libedit and each merge has always
been very painful. After years of fighting give up and refresh a merge from
scrarch properly in contrib.

Note that the switch to this version will be done in another commit.

r352204:
Readd _el_fn_sh_complete for backward compatibility

This function is not needed anymore, it allows old sh binary to continue
to run and avoid breaking backward compatibility.
Note that is now just calls the regular _el_fn_complete which does a proper
job at quoting.

Discussed with: jilles

r352275:
Update libedit to a snapshot from 2019-09-10

This version bring many fixes regarding unicode support
It also adds proper support for filename completion (we do not need our custom
patches anymore)
Improves the libreadline compatibility

Note that the same work was done by Yuichiro Naito in
https://reviews.freebsd.org/D21196 the main difference is in this case we have
reimported libedit in contrib to fix a long standing mess in the previous merges
which prevented a proper update workflow. (discussed long ago with pfg@)

The only difference with upstream libedit is we have added a compatibility shim
for the _elf_fn_sh_complete function which we previously added to support quoting
in filename completion and is not needed anymore.
This was added to continue supported old /bin/sh binaries and not break backward
compatibility (as discussed with jilles@)

Reviewed by: Yuichiro Naito <naito.yuichiro_gmail.com>
Differential Revision: https://reviews.freebsd.org/D21584

r352341:
Fix arm and aarch64 builds of libedit after r352275

On arm and arm64, where chars are unsigned by default, buildworld dies
with:

--- terminal.o ---
/usr/src/contrib/libedit/terminal.c:569:41: error: comparison of
integers of different signs: 'wint_t' (aka 'int') and 'wchar_t' (aka
'unsigned int') [-Werror,-Wsign-compare]
                                     el->el_cursor.v][where & 0370] !=
                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/usr/src/contrib/libedit/terminal.c:659:28: error: comparison of
integers of different signs: 'wint_t' (aka 'int') and 'wchar_t' (aka
'unsigned int') [-Werror,-Wsign-compare]
                                     [el->el_cursor.h] == MB_FILL_CHAR)
                                     ~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~

Fix this by making MB_FILL_CHAR a wint_t, so no casting is needed.

Note that in https://reviews.freebsd.org/D21584 this was also proposed
by Yuichiro Naito <naito.yuichiro_gmail.com>.

Reviewed by: bapt
Subscribers: naito.yuichiro_gmail.com, ml_vishwin.info
X-MFC-With: r352275
Differential Revision: https://reviews.freebsd.org/D21657

4 years agoMFC r352242, r352249
Baptiste Daroussin [Wed, 19 Feb 2020 14:42:21 +0000 (14:42 +0000)]
MFC r352242, r352249

r352242:
Remove usesless readline compat includes which will reinclude readline.h
itself.

This simplifies the upcoming update to newer libedit.

r352249:
Get the readline header from the installed header instead of the from the source
location.

4 years agoMFC r352247-r352248
Baptiste Daroussin [Wed, 19 Feb 2020 14:37:56 +0000 (14:37 +0000)]
MFC r352247-r352248

r352247:
Remove useless extra definition of libedit flags

Note that all the line editor part is done in the libntp

r352248:
Get the readline header from the installed header instead of the from the source
location.

With newer import of libedit, the path to be able to access readline/readline.h
will also include header which name will conflict with some expected by ntp in
another path and end up breaking the build.

4 years agoMFC r352274:
Baptiste Daroussin [Wed, 19 Feb 2020 14:29:47 +0000 (14:29 +0000)]
MFC r352274:

Insert proper copyright/license headers

Those scripts are without copyright and license assignement since their creation
After grabbing information from The various authors and contributors assign
proper license header and copyrights.

This has been reported by yuripv in his work on integrating those in Illumos!

Reported by: yuripv
Discussed with: marino, edwin

4 years agoMFC r356918:
Baptiste Daroussin [Wed, 19 Feb 2020 14:26:27 +0000 (14:26 +0000)]
MFC r356918:

The ports tree now accepts /usr/local/share/man as a directory for manpage
and will slowly transition from /usr/local/man to it. To reflect this remove
the documentation of the manpages being an exception in the layout of /usr/local

Reported by: Dan Nelson <dnelson_1901@yahoo.com> (via IRC)

4 years agoMFC r353100:
Baptiste Daroussin [Wed, 19 Feb 2020 14:24:05 +0000 (14:24 +0000)]
MFC r353100:

Do not remove the locale directory when building a system without locales

This directory is actually needed during make installworld and will prevent
to reinstall a system after make delete-old is done.

PR: 226137
Reported by: rakuco

4 years agoMFC r356212,r356366,r356416,r357785
Martin Matuska [Wed, 19 Feb 2020 01:46:43 +0000 (01:46 +0000)]
MFC r356212,r356366,r356416,r357785
Update libarchive to version 3.4.2

Relevant vendor changes (r356212):
  Issue #351: Refactor and implement private state logic for write filters
  PR #1252: RAR5 reader - verify window size for solid files (OSS-Fuzz 15482)
  PR #1255: zip writer - don't append unused NUL for directories
  PR #1260: Fix sparse file offset overflow on 32-bit systems
  PR #1263: UNICODE filename support for reading lha/lzh format
  Issue #1276: Bugfix and optimize archive_wstring_append_from_mbs()
  PR #1288: Add the "xattrhdr" option to pax write options
  PR #1295: 7z reader - fix reading archives with digests in PackInfo
  PR #1296: RAR5 reader - verify window size for multivolume archives
  PR #1297: ZIP reader - support LZMA_STREAM_END marker in 'lzma alone' files
  Issue #1298: Fix a heap-buffer-overflow in archive_string_append_from_wcs()
  OSS-Fuzz 19360, 19362: LHA reader - plug two memory leaks on error
  Fix possible off-by-one when dealing with readlink(2)

Relevant vendor changes (r356366):
  Issue #1302: Plug memory leak on failure of archive_write_client_open()

Relevant vendor changes (r356416):
  Issue #1302: Re-do fix for archive_write_client_open()

Relevant vendor changes (r357785):
  PR #1289: atomic extraction support (bsdtar -x --safe-writes)
  PR #1308: big endian fix for UTF16 support in LHA reader
  PR #1326: reject RAR5 files that declare invalid header flags
  Issue #987: fix support 7z archive entries with Delta filter
  Issue #1317: fix compression output buffer handling in XAR writer
  Issue #1319: fix uname or gname longer than 32 characters in pax writer
  Issue #1325: fix use after free when archiving hardlinks in ISO9660 or XAR
  Use localtime_r() and gmtime_r() instead of localtime() and gmtime()

4 years agoMFC r357788:
Brooks Davis [Tue, 18 Feb 2020 21:36:54 +0000 (21:36 +0000)]
MFC r357788:

Mark hme(4) as deprecated.

It was saved from the initial purge of drivers in fcp-101 due to being
the onboard Ethernet device on a number of sparc64 machines.  Now that
sparc64 is gone, it serves little purpose (PCI cards exist, but are rare
and are unlikely to have been deployed outside Sun systems).

4 years agoMFC r357976:
Dimitry Andric [Tue, 18 Feb 2020 18:17:03 +0000 (18:17 +0000)]
MFC r357976:

Merge r357970 from the clang1000-import branch:

Fix the following -Werror warning from clang 10.0.0 in hptmv(4):

sys/dev/hptmv/ioctl.c:240:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
                        _vbus_p=pArray->pVBus;
                        ^
sys/dev/hptmv/ioctl.c:237:10: note: previous statement is here
                if(!mIsArray(pArray))
                ^

This is because the return statement after the if statement was not
indented.  (Note that this file has been idented assuming 4-space tabs.)

4 years agoMFC r357873:
Dimitry Andric [Tue, 18 Feb 2020 18:15:33 +0000 (18:15 +0000)]
MFC r357873:

Merge r357864 from the clang1000-import branch:

Fix the following -Werror warning from clang 10.0.0 in sconfig:

sbin/sconfig/sconfig.c:909:5: error: misleading indentation; statement is not part of the previous 'else' [-Werror,-Wmisleading-indentation]
                                exit (-1);
                                ^
sbin/sconfig/sconfig.c:907:6: note: previous statement is here
                        } else
                          ^

The intent was to group the exit() call with the previous fprintf()
call.

4 years agoMFC r357874:
Dimitry Andric [Tue, 18 Feb 2020 18:13:08 +0000 (18:13 +0000)]
MFC r357874:

Merge r357872 from the clang1000-import branch:

Disable new clang 10.0.0 warnings about misleading indentation in ce(4)
and cp(4).

These are false positives, since some of the driver source has been
deliberately obfuscated.

4 years agoMFC r357661:
Dimitry Andric [Tue, 18 Feb 2020 18:03:04 +0000 (18:03 +0000)]
MFC r357661:

Correctly recognize linker versions greater than 10.0.

4 years agoMFC r357502: Few microoptimizations to dbuf layer.
Alexander Motin [Tue, 18 Feb 2020 01:21:56 +0000 (01:21 +0000)]
MFC r357502: Few microoptimizations to dbuf layer.

Move db_link into the same cache line as db_blkid and db_level.
It allows significantly reduce avl_add() time in dbuf_create() on
systems with large RAM and huge number of dbufs per dnode.

Avoid few accesses to dbuf_caches[].size, which is highly congested
under high IOPS and never stays in cache for a long time.  Use local
value we are receiving from zfs_refcount_add_many() any way.

Remove cache_size_bytes_max bump from dbuf_evict_one().  I don't see
a point to do it on dbuf eviction after we done it on insertion in
dbuf_rele_and_unlock().

4 years agoMFC r357453: Unblock kstat.zfs.misc.dbufstats sysctls.
Alexander Motin [Tue, 18 Feb 2020 01:19:32 +0000 (01:19 +0000)]
MFC r357453: Unblock kstat.zfs.misc.dbufstats sysctls.

It is not so much broken to hide it after we wasted time to collect it.

4 years agoMFC r357850:
Ryan Moeller [Tue, 18 Feb 2020 00:01:18 +0000 (00:01 +0000)]
MFC r357850:
Add myself (freqlabs) as a src committer

Approved by:    mav (mentor)

4 years agoMFC: r357149
Rick Macklem [Mon, 17 Feb 2020 19:32:54 +0000 (19:32 +0000)]
MFC: r357149
Fix a crash in the NFSv4 server.

The PR reported a crash that occurred when a file was removed while
client(s) were actively doing lock operations on it.
Since nfsvno_getvp() will return NULL when the file does not exist,
the bug was obvious and easy to fix via this patch. It is a little
surprising that this wasn't found sooner, but I guess the above
case rarely occurs.

PR: 242768

4 years agoMFC r357450, r357462:
Mark Johnston [Mon, 17 Feb 2020 18:40:00 +0000 (18:40 +0000)]
MFC r357450, r357462:
addr2line: Cache CU DIEs upon a successful address lookup.

4 years agoMFC r350515:
Mark Johnston [Mon, 17 Feb 2020 18:39:38 +0000 (18:39 +0000)]
MFC r350515:
Capsicumize addr2line(1).

4 years agoMFC r356597:
Hans Petter Selasky [Mon, 17 Feb 2020 09:58:55 +0000 (09:58 +0000)]
MFC r356597:
Define the XHCI endpoint states.

Sponsored by: Mellanox Technologies

4 years agoMFC r357726:
Hans Petter Selasky [Mon, 17 Feb 2020 09:57:03 +0000 (09:57 +0000)]
MFC r357726:
Add USB host controller PCI ID's for Hygon.

Differential Revision: https://reviews.freebsd.org/D23564
Sponsored by: Mellanox Technologies

4 years agoMFC r357801:
Hans Petter Selasky [Mon, 17 Feb 2020 09:53:23 +0000 (09:53 +0000)]
MFC r357801:
Add support for disabling and polling MSIX interrupts in mlx5core.

Sponsored by: Mellanox Technologies

4 years agoSkip sys.geom.class.multipath.misc.fail_on_error on stable/12
Li-Wen Hsu [Sun, 16 Feb 2020 09:13:05 +0000 (09:13 +0000)]
Skip sys.geom.class.multipath.misc.fail_on_error on stable/12

The required feature is not in stable/12 yet.

PR: 244158
Sponsored by: The FreeBSD Foundation

4 years agoMFC r356000: Remove unused includes.
Xin LI [Sun, 16 Feb 2020 07:06:25 +0000 (07:06 +0000)]
MFC r356000: Remove unused includes.

4 years agoMFC r357420: Remove unused include.
Xin LI [Sun, 16 Feb 2020 06:34:45 +0000 (06:34 +0000)]
MFC r357420: Remove unused include.

4 years agoMFC r357663
Vincenzo Maffione [Sat, 15 Feb 2020 11:42:13 +0000 (11:42 +0000)]
MFC r357663

netmap: improve netmap(4) and vale(4) man pages

Clean up obsolete sysctl descriptions and add missing ones.

PR:             243838
Reviewed by:    bcr
Differential Revision:  https://reviews.freebsd.org/D23546

4 years agoMFC r357813:
Konstantin Belousov [Sat, 15 Feb 2020 00:48:44 +0000 (00:48 +0000)]
MFC r357813:
Fix indent.

4 years agoMFC r357670:
Konstantin Belousov [Fri, 14 Feb 2020 13:26:45 +0000 (13:26 +0000)]
MFC r357670:
pmc: Add Hygon Dhyana support.

4 years agoMFC r357669:
Konstantin Belousov [Fri, 14 Feb 2020 13:25:37 +0000 (13:25 +0000)]
MFC r357669:
acpi_hpet: Add Hygon Dhyana support.

4 years agoMFC r357668:
Konstantin Belousov [Fri, 14 Feb 2020 13:10:52 +0000 (13:10 +0000)]
MFC r357668:
linux futex_put(): do not touch futex after dropping our reference.

4 years agoMFC r353022:
Colin Percival [Fri, 14 Feb 2020 02:31:20 +0000 (02:31 +0000)]
MFC r353022:

Switch EC2 AMIs from using the dual-dhclient script to using the new
dual-dhclient-daemon daemon. This makes it possible to stop/restart
the dhclients.

4 years agoMFC r357756: backup-passwd: mask out all passwords in the diff
Kyle Evans [Fri, 14 Feb 2020 02:27:01 +0000 (02:27 +0000)]
MFC r357756: backup-passwd: mask out all passwords in the diff

The previous expression borked if a username had a plus or hyphen in it.
This is needlessly restrictive- at leSt a hyphen in the middle is valid.
Instead of playing this game, let's just assume the username can't contain a
colon and mask out the second field.

4 years agoMFC r357235:
Alan Somers [Thu, 13 Feb 2020 20:49:45 +0000 (20:49 +0000)]
MFC r357235:

Speed up "zpool import" in the presence of many zvols

By default, zpools may not be backed by zvols (that can be changed with the
"vfs.zfs.vol.recursive" sysctl). When that sysctl is set to 0, the kernel
does not attempt to read zvols when looking for vdevs. But the zpool command
still does. This change brings the zpool command into line with the kernel's
behavior. It speeds "zpool import" when an already imported pool has many
zvols, or a zvol with many snapshots.

PR: 241083
Reported by: Martin Birgmeier <d8zNeCFG@aon.at>
Reviewed by: mav, Ryan Moeller <ryan@freqlabs.com>
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D22077

4 years agoMFC r357211:
Alan Somers [Thu, 13 Feb 2020 20:46:05 +0000 (20:46 +0000)]
MFC r357211:

geli: add a test case for attaching multiple providers with 1 command

Reviewed by: cem
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D23400

4 years agoMFC r356809:
Alan Somers [Thu, 13 Feb 2020 20:45:32 +0000 (20:45 +0000)]
MFC r356809:

setextattr: Increase stdin buffer size to 4096

Extended attribute values can potentially be quite large. One test for ZFS
is supposed to set a 200MB xattr. However, the buffer size for reading
values from stdin with setextattr -i is so small that the test times out
waiting for tiny chunks of data to be buffered and appended to an sbuf.

Increasing the buffer size should help alleviate some of the burden of
reallocating larger sbufs when writing large extended attributes.

Submitted by: Ryan Moeller <ryan@freqlabs.com>
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D23211

4 years agoMFC r355488-r355489
Alan Somers [Thu, 13 Feb 2020 20:41:20 +0000 (20:41 +0000)]
MFC r355488-r355489

r355488:
lio_listio(2): add a HISTORY section

r355489:
clock_gettime(2): add a HISTORY section

4 years agoMFC r355430:
Alan Somers [Thu, 13 Feb 2020 20:40:36 +0000 (20:40 +0000)]
MFC r355430:

ses: sanitize illegal strings in SES element descriptors

The SES4r3 standard requires that element descriptors may only contain ASCII
characters in the range 0x20 to 0x7e.  Some SuperMicro expanders violate
that rule.  This patch adds a sanity check to ses(4).  Descriptors in
violation will be replaced by "<invalid>".

This patch fixes "sesutil --libxo xml" on such systems.  Previously it would
generate non-well-formed XML output.

PR: 241929
Reviewed by: allanjude
Sponsored by: Axcient

4 years agoMFC r355431:
Alan Somers [Thu, 13 Feb 2020 20:32:05 +0000 (20:32 +0000)]
MFC r355431:

gmultipath: add ATF tests

Add ATF tests for most gmultipath operations. Add some dtrace probes too,
primarily for configuration changes that happen in response to provider
errors.

PR: 178473
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D22235

4 years agoMFC r354234:
Alan Somers [Thu, 13 Feb 2020 18:26:07 +0000 (18:26 +0000)]
MFC r354234:

geli: raise WARNS to 6

Sponsored by: Axcient

4 years agoMFC r357284, r357419: stdio unlocked
Kyle Evans [Thu, 13 Feb 2020 03:13:29 +0000 (03:13 +0000)]
MFC r357284, r357419: stdio unlocked

r357284:
stdio: provide _unlocked variants of fflush, fputc, fputs, fread, fwrite

fflush_unlocked is currently desired in ports by sysutils/metalog, and
redefined as the locked fflush.

fputc_unlocked, fputs_unlocked, fread_unlocked, and fwrite_unlocked are
currently desired in ports by devel/elfutils, and redefined as the locked
fputs, fread, and fwrite respectively.

r357419:
libc: provide fputc_unlocked

Among the same justification as the other stdio _unlocked; in addition to an
inline version in <stdio.h>, we must provide a function in libc as well for
the functionality. This fixes the lang/gcc* builds, which want to use the
symbol from libc.

4 years agoMFC r356942:
Brooks Davis [Wed, 12 Feb 2020 18:40:29 +0000 (18:40 +0000)]
MFC r356942:

Correct a misleading indent.

This dates to before the beginning of our repo and was found by clang 10.

Sponsored by: DARPA

4 years agoMFC r357575:
Mark Johnston [Wed, 12 Feb 2020 15:51:29 +0000 (15:51 +0000)]
MFC r357575:
Improve validation of the sockaddr length in iruserok_sa().

PR: 243747

4 years agoMFC r357573:
Mark Johnston [Wed, 12 Feb 2020 15:46:33 +0000 (15:46 +0000)]
MFC r357573:
Fix map locking in the CLEAR_PKRU sysarch(2) handler.

4 years agoMFC r357665: geli taste: allow GELIBOOT tagged providers as well
Kyle Evans [Wed, 12 Feb 2020 02:17:20 +0000 (02:17 +0000)]
MFC r357665: geli taste: allow GELIBOOT tagged providers as well

Currently the installer will tag geliboot partitions with both BOOT and
GELIBOOT; the former allows the kernel to taste it at boot, while the latter
is what loaders keys off of.

However, it seems reasonable to assume that if a provider's been tagged with
GELIBOOT that the kernel should also take that as a hint to taste/attach at
boot. This would allow us to stop tagging GELIBOOT partitions with BOOT in
bsdinstall, but I'm not sure that there's a compelling reason to do so any
time soon.

4 years agoMFC r357563: env(1): grow -L user/class and -U user/class options
Kyle Evans [Wed, 12 Feb 2020 02:09:12 +0000 (02:09 +0000)]
MFC r357563: env(1): grow -L user/class and -U user/class options

This allows one to set the environment of the specified user either from
login.conf alone (-L) or both login.conf and ~/.login_conf if present (-U).

This is a supporting feature to allow service(8) to pull in the environment
of the "daemon" class before invoking the rc script.

4 years agoMFC r354450: Add -0 option to ENV(1)
Kyle Evans [Wed, 12 Feb 2020 02:07:37 +0000 (02:07 +0000)]
MFC r354450: Add -0 option to ENV(1)

With the -0 option added to ENV(1), some ports will no longer require genv
from sysutils/coreutils.

4 years agoMFC r357560, r357707: login.conf(5) mail capability
Kyle Evans [Wed, 12 Feb 2020 02:04:03 +0000 (02:04 +0000)]
MFC r357560, r357707: login.conf(5) mail capability

r357560:
login.conf(5): split MAIL env var out into a "mail" capability

This allows it to be easily suppressed in, e.g., the "daemon" class where it
will not be properly expanded.

This is a part of D21481.

Submitted by: Andrew Gierth <andrew_tao173.riddles.org.uk>

r357707:
login.conf(5): update commented-out standard, too

MAIL now has a mail capability, instead, as of r357560.

4 years agoMFC r357512:
Konstantin Belousov [Tue, 11 Feb 2020 12:14:22 +0000 (12:14 +0000)]
MFC r357512:
Add sys/systm.h to several places that use vm headers.

4 years agoMFC r357511:
Konstantin Belousov [Tue, 11 Feb 2020 12:13:21 +0000 (12:13 +0000)]
MFC r357511:
tmpfs_mount update: simplify, cache the value of VFS_TO_TMPFS() calculation.

4 years agoMFC r357678:
Konstantin Belousov [Tue, 11 Feb 2020 12:05:59 +0000 (12:05 +0000)]
MFC r357678:
Correct the function name in the comment.

4 years agoMFC r357537, r357538:
Mark Johnston [Tue, 11 Feb 2020 05:15:35 +0000 (05:15 +0000)]
MFC r357537, r357538:
elfcopy: Coverity fixups.

4 years agoMFC r357531, r357532, r357533, r357534:
Mark Johnston [Tue, 11 Feb 2020 05:14:36 +0000 (05:14 +0000)]
MFC r357531, r357532, r357533, r357534:
libdwarf: Coverity fixups.

4 years agoMFC r357542:
Mark Johnston [Tue, 11 Feb 2020 05:13:35 +0000 (05:13 +0000)]
MFC r357542:
readelf: Don't leak memory when dwarf_get_fde_info_for_all_regs() fails.

4 years agoMFC r357539:
Mark Johnston [Tue, 11 Feb 2020 05:11:52 +0000 (05:11 +0000)]
MFC r357539:
size: Avoid returning a stack pointer from xlatetom().

4 years agoMFC r357535, r357536:
Mark Johnston [Tue, 11 Feb 2020 05:11:27 +0000 (05:11 +0000)]
MFC r357535, r357536:
libelftc: Fix memory leaks in the C++ demanglers.

4 years agoMFC r357525:
Mark Johnston [Tue, 11 Feb 2020 03:37:42 +0000 (03:37 +0000)]
MFC r357525:
Correct the malloc tag used when freeing the temporary semop(2) buffer.

4 years agoMFC O_SEARCH: r357412, r357461, r357580, r357584, r357636, r357671, r357688
Kyle Evans [Sun, 9 Feb 2020 22:15:35 +0000 (22:15 +0000)]
MFC O_SEARCH: r357412, r357461, r357580, r357584, r357636, r357671, r357688

r357412:
Provide O_SEARCH

O_SEARCH is defined by POSIX [0] to open a directory for searching, skipping
permissions checks on the directory itself after the initial open(). This is
close to the semantics we've historically applied for O_EXEC on a directory,
which is UB according to POSIX. Conveniently, O_SEARCH on a file is also
explicitly undefined behavior according to POSIX, so O_EXEC would be a fine
choice. The spec goes on to state that O_SEARCH and O_EXEC need not be
distinct values, but they're not defined to be the same value.

This was pointed out as an incompatibility with other systems that had made
its way into libarchive, which had assumed that O_EXEC was an alias for
O_SEARCH.

This defines compatibility O_SEARCH/FSEARCH (equivalent to O_EXEC and FEXEC
respectively) and expands our UB for O_EXEC on a directory. O_EXEC on a
directory is checked in vn_open_vnode already, so for completeness we add a
NOEXECCHECK when O_SEARCH has been specified on the top-level fd and do not
re-check that when descending in namei.

[0] https://pubs.opengroup.org/onlinepubs/9699919799/

r357461:
namei: preserve errors from fget_cap_locked

Most notably, we want to make sure we don't clobber any capabilities-related
errors. This is a regression from r357412 (O_SEARCH) that was picked up by
the capsicum tests.

r357580:
O_SEARCH test: drop O_SEARCH|O_RDWR local diff

In FreeBSD's O_SEARCH implementation, O_SEARCH in conjunction with O_RDWR or
O_WRONLY is explicitly rejected. In this case, O_RDWR was not necessary
anyways as the file will get created with or without it.

This was submitted upstream as misc/54940 and committed in rev 1.8 of the
file.

r357584:
Record-only MFV of r357583: netbsd-tests: import upstreamed changes

The changes in question originated in FreeBSD/head; no further action is
required.

r357636:
MFV r357635: imnport v1.9 of the O_SEARCH tests

The RCSID data was wrong, so this is effectively a record-only merge
with correction of said data. No further changes should be needed in this
area, as we've now upstreamed our local changes to this specific test.

r357671:
O_SEARCH test: mark revokex an expected fail on NFS

The revokex test does not work when the scratch directory is created on NFS.
Given the nature of NFS, it likely can never work without looking like a
security hole since O_SEARCH would rely on the server knowing that the
directory did have +x at the time of open and that it's OK for it to have
been revoked based on POSIX specification for O_SEARCH.

This does mean that O_SEARCH is only partially functional on NFS in general,
but I suspect the execute bit getting revoked in the process is likely not
common.

r357688:
MFV r357687: Import NFS fix for O_SEARCH tests

The version that ended upstream was ultimately slightly different than the
version committed here; notably, statvfs() is used but it's redefined
appropriately to statfs() on FreeBSD since we don't provide the fstypename
for the former interface.

4 years agoMFC r357572: wc(1): account for possibility of file == NULL
Kyle Evans [Sun, 9 Feb 2020 19:20:20 +0000 (19:20 +0000)]
MFC r357572: wc(1): account for possibility of file == NULL

file could reasonably be NULL here if we we're using stdin. Albeit less
likely in normal usage, one could actually hit either of these warnings on
stdin.

4 years agoMFC r353678 (by avg):
Alexander Motin [Sat, 8 Feb 2020 21:55:56 +0000 (21:55 +0000)]
MFC r353678 (by avg):
provide a way to assign taskqueue threads to a kernel process

This can be used to group all threads belonging to a single logical
entity under a common kernel process.
I am planning to use the new interface for ZFS threads.

4 years agoMFC r357067: Drop "All Rights Reserved" from all libbe/bectl files
Kyle Evans [Fri, 7 Feb 2020 21:57:27 +0000 (21:57 +0000)]
MFC r357067: Drop "All Rights Reserved" from all libbe/bectl files

4 years agoMFC r357509-r357510: small psm cleanup
Kyle Evans [Fri, 7 Feb 2020 21:55:45 +0000 (21:55 +0000)]
MFC r357509-r357510: small psm cleanup

r357509:
psm: release resources on attach failure

In exactly 1/3 cases we'll release resources on failure; touch up the other
two to do so as well.

r357510:
psm: use make_dev_s instead of make_dev

This most importantly reduces duplication, but it also removes any potential
race with usage of dev->si_drv1 since it's now set prior to the device being
constructed enough to be accessible.

4 years agoMFC r355248: tty: implement TIOCNOTTY
Kyle Evans [Fri, 7 Feb 2020 19:00:43 +0000 (19:00 +0000)]
MFC r355248: tty: implement TIOCNOTTY

Generally, it's preferred that an application fork/setsid if it doesn't want
to keep its controlling TTY, but it could be that a debugger is trying to
steal it instead -- so it would hook in, drop the controlling TTY, then do
some magic to set things up again. In this case, TIOCNOTTY is quite handy
and still respected by at least OpenBSD, NetBSD, and Linux as far as I can
tell.

I've dropped the note about obsoletion, as I intend to support TIOCNOTTY as
long as it doesn't impose a major burden.

4 years agoMFC r357195, r357556: O_SEARCH test fixes
Kyle Evans [Thu, 6 Feb 2020 18:40:37 +0000 (18:40 +0000)]
MFC r357195, r357556: O_SEARCH test fixes

r357195:
netbsd-tests: libc: use correct modes in O_SEARCH tests

The current code clearly intended for these to be octal based on the values
used, but the octal prefix was forgotten. Add it now for correctness, but
note that we don't currently execute these tests.

This has been submitted upstream as misc/54902, so I've omitted the standard
FreeBSD markers that we tend to put into netbsd-tests for upstream-candidate
identification.

r357556:
O_SEARCH tests: plug trivial fd leak

Coverity correctly reports this as a resource leak. It's an admittedly minor
one, but plug it anyways.

This has been submitted upstream as misc/54939.

4 years agoMFC r357193: caroot: blacklisted: automatically pick up *.pem in the tree
Kyle Evans [Thu, 6 Feb 2020 18:37:38 +0000 (18:37 +0000)]
MFC r357193: caroot: blacklisted: automatically pick up *.pem in the tree

This kind of automagica got picked up in trusted/ prior to the initial
commit, but never got applied over in blacklisted. Ideally no one will be
using blacklisted/ to store arbitrary certs that they don't intend to
blacklist, so we should just install anything that's in here rather than
force consumer to first copy cert into place and then modify the file
listing in the Makefile.

Wise man once say: "it is better to restrict too much, than not enough.
sometimes."

4 years agoMFC r357393
Warner Losh [Thu, 6 Feb 2020 16:22:16 +0000 (16:22 +0000)]
MFC r357393

However, fix the wording to match the same that we used elsewhere in the NIC
deprecation efforts. It was bogus when I committed to to -current.

4 years agoBump FreeBSD version due to recent LinuxKPI changes.
Hans Petter Selasky [Thu, 6 Feb 2020 10:10:42 +0000 (10:10 +0000)]
Bump FreeBSD version due to recent LinuxKPI changes.

This is a direct commit.

Sponsored by: Mellanox Technologies

4 years agoMFC r357410-r357411: Avoid duplicating VEXEC checks in VOP_CACHEDLOOKUP
Kyle Evans [Wed, 5 Feb 2020 21:30:31 +0000 (21:30 +0000)]
MFC r357410-r357411: Avoid duplicating VEXEC checks in VOP_CACHEDLOOKUP

r357410: pseudofs: don't do VEXEC check in VOP_CACHEDLOOKUP

VOP_CACHEDLOOKUP should assume that the appropriate VEXEC check has been
done in the caller (vfs_cache_lookup), so it does not belong here.

r357411: zfs: light refactor to indicate cachedlookup in zfs_lookup

If we come from VOP_CACHEDLOOKUP, we must skip the VEXEC check as it will
have been done in the caller (vfs_cache_lookup). This is a part of D23247,
which may skip the earlier VEXEC check as well if the root fd was opened
with O_SEARCH.

This one required slightly more work as zfs_lookup may also be called
indirectly as VOP_LOOKUP or a couple of other places where we must do the
check.

4 years agoMFCr356928:
Mariusz Zaborski [Wed, 5 Feb 2020 21:11:40 +0000 (21:11 +0000)]
MFCr356928:
  When MK_CASPER=no is set remove files which are not needed to run system.

  PR:           242971

4 years agoMFCr356926:
Mariusz Zaborski [Wed, 5 Feb 2020 21:10:42 +0000 (21:10 +0000)]
MFCr356926:
  Even when the MK_CASPER is set to "no" we still want to install man pages
  and the headers. If the user decides to install the system without Casper
  support, then the Casper functions are mocked, but they still exist in
  the system.

  PR:           242971

4 years agoMFCr356925:
Mariusz Zaborski [Wed, 5 Feb 2020 21:05:52 +0000 (21:05 +0000)]
MFCr356925:
  Those files are already removed in ObsoleteFiles.
  There is no need to remove them twice.

  PR:           242971

4 years agoMFC r356949:
Cy Schubert [Wed, 5 Feb 2020 20:55:59 +0000 (20:55 +0000)]
MFC r356949:

Fix build when WITHOUT_WPA_SUPPLICANT_EAPOL option used.

The build failure was discoved by Michael Dexter's recent Build Options
Survey run, at https://callfortesting.org/results/bos-2020-01-16/\
WITHOUT_WPA_SUPPLICANT_EAPOL-small.txt.

Reported by: Michael Dexter <editor@callfortesting.org> via emaste

4 years agoMFC r354399: blacklist: update to NetBSD snapshot on 20191106
Ed Maste [Wed, 5 Feb 2020 18:24:28 +0000 (18:24 +0000)]
MFC r354399: blacklist: update to NetBSD snapshot on 20191106

Sponsored by: The FreeBSD Foundation

4 years agoMFC r356249-r356250, r356313, r356434, r356657, r357421
Xin LI [Wed, 5 Feb 2020 08:55:19 +0000 (08:55 +0000)]
MFC r356249-r356250, r356313, r356434, r356657, r357421

r356249-r356250, r356313:
Reduce memory footprint of fsck_msdosfs.

This utility was initially written for FAT12/16, which were inherently
small. When FAT32 support was added, the old data structure and
algorithms remain used with minimal changes.

With growing size of FAT32 media, the current data structure that
requires 4 32-bit variables per each FAT32 table entry would consume up
to 4 GiB of RAM, which can be too big for systems with limited RAM
available.

Address this by taking a different approach of validating the FAT.

The FAT is essentially a set of linked lists of chains that was
referenced by directory entries, and the checker needs to make sure that
the linked chains of clusters do not have cross-linked chains, and every
chain were referenced by one and only one directory entry.  Instead of
keeping track of the chain's 'head' cluster number, the size of the
chain, the used status of the chain and the "next" pointer which is
content of the FAT table, we create accessors for the FAT table data
for the "next" pointer, and keep only one bit to indicate if the
current cluster is a 'head' node of a cluster chain, in a bitmap.

We further overhaul the FAT checker to find out the possible head nodes
by excluding ones that are not (in other words, nodes that have some
other nodes claiming them as the next node) instead of marking the head
nodes for each node on the chain.  This approach greatly reduced the
complexiety of computation from O(N^2) worst case, to an O(N) scan for
worst case.  The file (cluster chain) length is not useful for the FAT
checker, so don't bother to calculate them in the FAT checker and
instead leave the task to the directory structure check, at which point
we would have non-crossed cluster chains, and we are guaranteed that
each cluster will be visited for at most one time.

When checking the directory structures, we use the head node indicator
to as the visited (used) flag: every cluster chain can only be
referenced by one directory entry, so we clear them when calculating
the length of the chain, and we can immediately tell if there are
anomalies in the directory entry.

As a result, the required RAM size is now 1 bit per each entry of
the FAT table, plus memory needed to hold the FAT table in memory,
instead of 16 bytes (=128 bits) per each entry.  For FAT12 and FAT16,
we will load the whole FAT table into memory as they are smaller than
128KiB, and for FAT32, we first attempt to mmap() it into memory, and
when that fails, we would fall back to a simple LRU cache of 4 MiB of
RAM.

sbin/fsck_msdosfs/boot.c:

 - Added additional sanity checks for valid FAT32/FAT16/FAT12 cluster
   number.
 - FAT32: check if root directory starts with a valid cluster number,
   moved from dir.c.  There is no point to proceed if the filesystem
   is already damaged beyond repair.

sbin/fsck_msdosfs/check.c:

 - Combine phase 1 and phase 2, now that the readfat() is able to
   detect cross chains.

sbin/fsck_msdosfs/dir.c:

 - Refactor code to use FAT accessor instead of accessing the internal
   representation of FAT table.
 - Make use of the cluster chain head bitmap.
 - Clarify and simplify directory entry check, remove unnecessary
   checks that are would be done at a later time (for example, whether
   the directory's second cluster is a valid one, which is examined
   more throughly in a later checkchain() and does not prevent us
   from proceeding further).

sbin/fsck_msdosfs/dosfs.h:

 - Remove internal representation of FAT table, which is replaced by
   the head bitmap that is opaque to other code.
 - Added a special CLUST_DEAD cluster type to indicate errors.

sbin/fsck_msdosfs/ext.h:

 - Added a flag that overrides mmap(2) setting.  The corresponding
   command line option, -M is intentionally undocumented as we do not
   expect users to need it.
 - Added accessors for FAT table and convert existing interface to use
   it.

sbin/fsck_msdosfs/fat.c:

 - Added head bitmap to represent whether a cluster is a head cluster.
 - Converted FAT internal representation to accessors.
 - Implemented a LRU cache for FAT32 when mmap(2) should not or can not
   be used.
 - _readfat: Attempt a mmap(2) and fall back to regular read for
   non-FAT32 file systems; use the LRU cache for FAT32 and prepopulate
   the cache with the first 4MiB of the entries.
 - readfat: Added support of head bitmap and use the population scan to
   detect bogus chains.
 - clusterdiff: removed, FATs are copied from the checked copy via
   writefat()/copyfat().
 - checkchain: calculates the length of a cluster chain and make sure
   that it ends with a valid EOF marker.
 - clearchain: follow and clear a chain and maintain the free cluster
   count.
 - checklost: convert to use head bitmap. At the end of all other scans,
   the remaining 'head' nodes are leaders of lost cluster chains.

sbin/fsck_msdosfs/fat.c:

 - Added a new -M option which is intentionally undocumented, to disable
   the use of mmap().

r356434:
fsck_msdosfs.8: document -M.

r356657:
Tighten FAT checks and fix off-by-one error in corner case.

sbin/fsck_msdosfs/fat.c:
 - readfat:
    * Only truncate out-of-range cluster pointers (1, or greater than
      NumClusters but smaller than CLUST_RSRVD), as the current cluster
      may contain some data. We can't fix reserved cluster pointers at
      this pass, because we do no know the potential cluster preceding
      it.
    * Accept valid cluster for head bitmap. This is a no-op, and mainly
      to improve code readability, because the 1 is already handled in
      the previous else if block.
 - truncate_at: absorbed into checkchain.
 - checkchain: save the previous node we have traversed in case that we
   have a chain that ends with a special (>= CLUST_RSRVD) cluster, or is
   free. In these cases, we need to truncate at the cluster preceding the
   current cluster, as the current cluster contains a marker instead of
   a next pointer and can not be changed to CLUST_EOF (the else case can
   happen if the user answered "no" at some point in readfat()).
 - clearchain: correct the iterator for next cluster so that we don't
   stop after clearing the first cluster.
 - checklost: If checkchain() thinks the chain have no cluster, it
   doesn't make sense to reconnect it, so don't bother asking.

r357421:
Diff reduction against NetBSD, no functional change.

Relnotes: yes

4 years agoMFC r356993: Update route MTUs for bridge, lagg and vlan interfaces.
Alexander Motin [Wed, 5 Feb 2020 00:47:03 +0000 (00:47 +0000)]
MFC r356993: Update route MTUs for bridge, lagg and vlan interfaces.

Those interfaces may implicitly change their MTU on addition of parent
interface in addition to normal SIOCSIFMTU ioctl path, where the route
MTUs are updated normally.

4 years agoMFC r357349:
Dimitry Andric [Tue, 4 Feb 2020 20:09:25 +0000 (20:09 +0000)]
MFC r357349:

Merge r357348 from the clang 10.0.0 import branch:

Disable new clang 10.0.0 warnings about converting the result of shift
operations to a boolean in tpm(4):

sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of '<<' to a boolean; did you mean '(1 << (0)) != 0'? [-Werror,-Wint-in-bool-context]
        WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
                                      ^
sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro 'TPM_CRB_CTRL_CANCEL_CMD'
#define TPM_CRB_CTRL_CANCEL_CMD         BIT(0)
                                        ^
sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT'
#define BIT(x) (1 << (x))
                  ^

Such warnings can be useful in C++ contexts, but not so much in kernel
drivers, where this type of bit twiddling is commonplace.  So disable it
for this case.

MFC r357366:

Revert r357349, since the clang 10.0.0 warning was actually correct, and
the ! operator should have been a ~ instead:

  Merge r357348 from the clang 10.0.0 import branch:

  Disable new clang 10.0.0 warnings about converting the result of
  shift operations to a boolean in tpm(4):

  sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of '<<' to a boolean; did you mean '(1 << (0)) != 0'? [-Werror,-Wint-in-bool-context]
  WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
^
  sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro 'TPM_CRB_CTRL_CANCEL_CMD'
  #define TPM_CRB_CTRL_CANCEL_CMD         BIT(0)
  ^
  sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT'
  #define BIT(x) (1 << (x))
    ^

  Such warnings can be useful in C++ contexts, but not so much in kernel
  drivers, where this type of bit twiddling is commonplace.  So disable
  it for this case.

Noticed by: cem

MFC r357367:

Fix new clang 10.0.0 warnings about converting the result of shift
operations to a boolean in tpm(4):

  sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of '<<' to a boolean; did you mean '(1 << (0)) != 0'? [-Werror,-Wint-in-bool-context]
  WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
^
  sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro 'TPM_CRB_CTRL_CANCEL_CMD'
  #define TPM_CRB_CTRL_CANCEL_CMD         BIT(0)
  ^
  sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT'
  #define BIT(x) (1 << (x))
    ^

In this case, the intent was to clear the zeroth bit, and leave the rest
unaffected.  Therefore, the ~ operator should be used instead.

Noticed by: cem

MFC r357388:

Amend r357367 by using register values from the TPM datasheet.

As Ian Lepore noted, writing ~1 to a register might have a completely
different effect than doing a regular read-modify-write operation.

Follow the TCG_PC_Client_Platform_TPM_Profile_PTP_2.0_r1.03_v22
datasheet instead, and use the actual values mentioned there:
(uint32_t)1 to cancel the command, (uint32_t)0 to clear the field.

MFC r357391 (by kib):

Fix build.

Sponsored by: The FreeBSD Foundation

4 years agoMFC r357346:
Dimitry Andric [Tue, 4 Feb 2020 19:51:26 +0000 (19:51 +0000)]
MFC r357346:

Merge r357342 from the clang1000-import branch:

Work around two -Werror warning issues in googletest, which have been
solved upstream in the mean time.

The first issue is because one of googletest's generated headers contain
classes with a user-declared copy assignment operator, but rely on the
generation by the compiler of an implicit copy constructor, which is now
deprecated:

/usr/obj/usr/src/amd64.amd64/tmp/usr/include/private/gtest/internal/gtest-param-util-generated.h:5284:8: error: definition of implicit copy constructor for 'CartesianProductHolder3<testing::internal::ParamGenerator<bool>, testing::internal::ValueArray3<int, int, int>, testing::internal::ValueArray4<cache_mode, cache_mode, cache_mode, cache_mode> >' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
  void operator=(const CartesianProductHolder3& other);
       ^
/usr/obj/usr/src/amd64.amd64/tmp/usr/include/private/gtest/gtest-param-test.h:1277:10: note: in implicit copy constructor for 'testing::internal::CartesianProductHolder3<testing::internal::ParamGenerator<bool>, testing::internal::ValueArray3<int, int, int>, testing::internal::ValueArray4<cache_mode, cache_mode, cache_mode, cache_mode> >' first required here
  return internal::CartesianProductHolder3<Generator1, Generator2, Generator3>(
         ^
/usr/src/tests/sys/fs/fusefs/io.cc:534:2: note: in instantiation of function template specialization 'testing::Combine<testing::internal::ParamGenerator<bool>, testing::internal::ValueArray3<int, int, int>, testing::internal::ValueArray4<cache_mode, cache_mode, cache_mode, cache_mode> >' requested here
        Combine(Bool(),                                 /* async read */
        ^

For now, silence the warning using -Wno-deprecated-copy.

The second issue is because one of the googlemock test programs attempts
to use "unsigned wchar_t" and "signed wchar_t", which are non-standard
and at best, hazily defined:

contrib/googletest/googlemock/test/gmock-actions_test.cc:111:37: error: 'wchar_t' cannot be signed or unsigned [-Wsigned-unsigned-wchar]
  EXPECT_EQ(0U, BuiltInDefaultValue<unsigned wchar_t>::Get());
                                    ^
contrib/googletest/googlemock/test/gmock-actions_test.cc:112:36: error: 'wchar_t' cannot be signed or unsigned [-Wsigned-unsigned-wchar]
  EXPECT_EQ(0, BuiltInDefaultValue<signed wchar_t>::Get());
                                   ^

For now, silence the warning using -Wno-signed-unsigned-wchar.

4 years agoMFC r357340:
Dimitry Andric [Tue, 4 Feb 2020 19:46:29 +0000 (19:46 +0000)]
MFC r357340:

Merge r357339 from the clang1000-import branch:

Fix the following -Werror warning from clang 10.0.0 in bsnmpd:

usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c:1661:4: error: misleading indentation; statement is not part of the previous 'else' [-Werror,-Wmisleading-indentation]
                        return (-1);
                        ^
usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c:1658:5: note: previous statement is here
                } else
                  ^

The intent was to group the return statement with the previous syslog()
call.

4 years agoMFC r357347:
Dimitry Andric [Tue, 4 Feb 2020 19:42:57 +0000 (19:42 +0000)]
MFC r357347:

Merge r357345 from the clang1000-import branch:

Disable new clang 10.0.0 warnings about misleading indentation in flex.

As this is contributed code with very messy indentation, which will
almost certainly never be upgraded, just disable the warning.

4 years agoMFC r357272:
Dimitry Andric [Tue, 4 Feb 2020 19:35:40 +0000 (19:35 +0000)]
MFC r357272:

Merge r357271 from the clang1000-import branch:

Fix the following -Werror warning from clang 10.0.0 in bsnmpd:

usr.sbin/bsnmpd/modules/snmp_bridge/bridge_port.c:1235:43: error: overlapping comparisons always evaluate to true [-Werror,-Wtautological-overlap-compare]
                            begemotBridgeStpPortEnable_enabled ||
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~

Work around it by casting the enum values to the type of val->v.integer.

4 years agoMFC r357268:
Dimitry Andric [Tue, 4 Feb 2020 19:31:01 +0000 (19:31 +0000)]
MFC r357268:

Merge r357260 from the clang1000-import branch:

Fix the following -Werror warning from clang 10.0.0 in procstat:

usr.bin/procstat/procstat_sigs.c:79:3: error: misleading indentation; statement is not part of the previous 'else' [-Werror,-Wmisleading-indentation]
                xo_close_container(name);
                ^
usr.bin/procstat/procstat_sigs.c:77:4: note: previous statement is here
        } else
          ^

The intent was to group the xo_close_container() call to the previous
snprintf() call.

4 years agoMFC r357269:
Dimitry Andric [Tue, 4 Feb 2020 19:24:10 +0000 (19:24 +0000)]
MFC r357269:

Merge r357267 from the clang1000-import branch:

Fix the following -Werror warning from clang 10.0.0 in tip:

usr.bin/tip/tip/tip.c:428:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
                        if (gch == EOF)
                        ^
usr.bin/tip/tip/tip.c:426:5: note: previous statement is here
                } else if (!cumode && gch == character(value(FORCE)))
                  ^

The intent was to have the EOF check grouped with the getchar() call
just above it.  This was accidentally introduced in r354624.