]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
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.

4 years agoMFC r357223:
Dimitry Andric [Tue, 4 Feb 2020 19:19:48 +0000 (19:19 +0000)]
MFC r357223:

Merge r357222 from the clang1000-import branch:

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

libexec/rbootd/rmpproto.c:335:49: error: multiple unsequenced modifications to 'filename' [-Werror,-Wunsequenced]
        filename = (filename = strrchr(filepath,'/'))? ++filename: filepath;
                 ~                                     ^

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

Merge r357225 from the clang1000-import branch:

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

sbin/newfs_msdos/newfs_msdos.c:181:2: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
        if (o.align) {
        ^
sbin/newfs_msdos/newfs_msdos.c:179:5: note: previous statement is here
    if (argc < 1 || argc > 2)
    ^

4 years agoMFC r357199, r357306:
Konstantin Belousov [Tue, 4 Feb 2020 17:12:09 +0000 (17:12 +0000)]
MFC r357199, r357306:
Save lower root vnode in nullfs mnt data instead of upper.

4 years agoMFC r357198:
Konstantin Belousov [Tue, 4 Feb 2020 17:08:00 +0000 (17:08 +0000)]
MFC r357198:
Provide support for fdevname(3) on linuxkpi-backed devices.

For merge, compat32 support was left out.  It is not yet present for
FIODGNAME over native cdevs yet.

Sponsored by: Mellanox Technologies

4 years agoMFC r357442:
Toomas Soome [Tue, 4 Feb 2020 07:15:33 +0000 (07:15 +0000)]
MFC r357442:

loader: bc_add can not use any other probes than ah=0x4b

CD boot is broken for some systems since bioscd and biosdisk merge. The issue is that we can not use anything else than int 13 ah=0x4b to query cd information.

The patch does restore the same probe as was originally used in bioscd.c. Additionally extra buffer padding is used to avoid memory corruption caused by some systems.

PR: 234031
Reported by: ultramage and others

4 years agoMFC r357234, r357365, r357375:
Kristof Provost [Tue, 4 Feb 2020 04:29:54 +0000 (04:29 +0000)]
MFC r357234, r357365, r357375:

tests: Test for an epair panic

if_epair abused the ifr_data field to insert its second interface in
IFC_IFLIST. If userspace provides a value for ifr_data it would get
dereferenced by the kernel leading to a panic.

Reported by: Ilja Van Sprundel <ivansprundel@ioactive.com>

4 years agoMFC 356913
George V. Neville-Neil [Tue, 4 Feb 2020 03:31:28 +0000 (03:31 +0000)]
MFC 356913

Add support for latest Intel I219 device, supported in Lenovo Carbon X1 v7

4 years agoMFC r356947:
Mark Johnston [Tue, 4 Feb 2020 02:06:21 +0000 (02:06 +0000)]
MFC r356947:
Add relocation handling required for -zifunc-noplt to work on arm64.

4 years agoMFC r357298:
Hans Petter Selasky [Mon, 3 Feb 2020 11:04:18 +0000 (11:04 +0000)]
MFC r357298:
Add missing mutex unlock in failure case.

Differential Revision: https://reviews.freebsd.org/D23430
Submitted by: cem
Reported by: Coverity
Coverity CID: 1368773
Sponsored by: Mellanox Technologies

4 years agoMFC r357077:
Hans Petter Selasky [Mon, 3 Feb 2020 10:59:27 +0000 (10:59 +0000)]
MFC r357077:
Implement mmget_not_zero() in the LinuxKPI.

Submitted by: Austin Shafer <ashafer@badland.io>
Sponsored by: Mellanox Technologies

4 years agoMFC r357041:
Hans Petter Selasky [Mon, 3 Feb 2020 10:53:03 +0000 (10:53 +0000)]
MFC r357041:
Fix build of stand/usb .

Sponsored by: Mellanox Technologies

4 years agoMFC r356952:
Hans Petter Selasky [Mon, 3 Feb 2020 10:49:18 +0000 (10:49 +0000)]
MFC r356952:
Add new USB ID to uslcom(4).

Submitted by: Oleg Sharoyko <osharoiko@gmail.com>
PR: 243494
Sponsored by: Mellanox Technologies

4 years agoMFC r356633:
Hans Petter Selasky [Mon, 3 Feb 2020 10:45:09 +0000 (10:45 +0000)]
MFC r356633:
Make sure the VNET is properly set when reaping mbufs in ipoib.
Else the following panic may happen:

panic()
icmp_error()
ipoib_cm_mb_reap()
linux_work_fn()
taskqueue_run_locked()
taskqueue_thread_loop()
fork_exit()
fork_trampoline()

Submitted by: Andreas Kempe <kempe@lysator.liu.se>
Sponsored by: Mellanox Technologies

4 years agoMFC r357292:
Philip Paeps [Sun, 2 Feb 2020 08:46:29 +0000 (08:46 +0000)]
MFC r357292:

  acpi_ibm: add support for ThinkPad PrivacyGuard

  ThinkPad PrivacyGuard is a built-in toggleable privacy filter that
  restricts viewing angles when on. It is an available on some new
  ThinkPad models such as the X1 Carbon 7th gen (as an optional HW
  upgrade).

  The privacy filter can be enabled/disabled via an ACPI call. This commit
  adds a sysctl under dev.acpi_ibm that allows for getting and setting the
  PrivacyGuard state.

Submitted by:   Kamila Součková <kamila@ksp.sk>
Reviewed By:    cem, philip
Differential Revision: https://reviews.freebsd.org/D23370

4 years agoMFC r357232:
Dimitry Andric [Fri, 31 Jan 2020 21:20:22 +0000 (21:20 +0000)]
MFC r357232:

Merge r357231 from the clang1000-import branch:

Work around assembler error from clang 10.0.0 in gptboot:

stand/i386/gptboot/gptldr.S:141:3: error: value of 36878 is too large for field of 2 bytes.
  jmp MEM_JMP # Start BTX
  ^

Use the same construct as in stand/i386/boot2/boot1.S, which ensures the
jump distance does not become too large.

4 years agoMFC r357226:
Dimitry Andric [Fri, 31 Jan 2020 20:04:32 +0000 (20:04 +0000)]
MFC r357226:

Merge r357224 from the clang1000-import branch:

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

contrib/binutils/bfd/peicode.h:1356:3: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
                if (efi)
                ^
contrib/binutils/bfd/peicode.h:1353:8: note: previous statement is here
              if (pe_arch (bfd_target_efi_arch (*target_ptr)) != arch)
              ^
contrib/binutils/bfd/peicode.h:1370:3: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
                if (!efi)
                ^
contrib/binutils/bfd/peicode.h:1367:8: note: previous statement is here
              if (pe_arch (bfd_target_pei_arch (*target_ptr)) != arch)
              ^

4 years agoMFC r354922
Warner Losh [Fri, 31 Jan 2020 13:18:25 +0000 (13:18 +0000)]
MFC r354922

> Author: imp <imp@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
> Date:   Wed Nov 20 23:45:31 2019 +0000
>
>    Create /etc/os-release file.
>
>    Each boot, regenerate /var/run/os-release based on the currently running
>    system. Create a /etc/os-release symlink pointing to this file (so that this
>    doesn't create a new reason /etc can not be mounted read-only).
>
>    This is compatible with what other systems do and is what the sysutil/os-release
>    port attempted to do, but in an incomplete way. Linux, Solaris and DragonFly all
>    implement this natively as well. The complete standard can be found at
>    https://www.freedesktop.org/software/systemd/man/os-release.html
>
>    Moving this to the base solves both the non-standard location problem with the
>    port, as well as the lack of update of this file on system update.
>
>    Bump __FreeBSD_version to 1300060
>
>    PR: 238953
>    Differential Revision:  https://reviews.freebsd.org/D22271

Execpt bump __FreeBSD_version to 1201511

4 years agoMFC r357043: Fix kernel-tags target.
Yoshihiro Takahashi [Fri, 31 Jan 2020 12:38:53 +0000 (12:38 +0000)]
MFC r357043: Fix kernel-tags target.

>  - A depend-file is broken up into .depend.*.o files. [1]
>  - Fix an assembly file support.
>
>  PR:           241746
>  Submitted by: leres [1]

4 years agoMFC r357233:
Kristof Provost [Fri, 31 Jan 2020 10:34:36 +0000 (10:34 +0000)]
MFC r357233:

epair: Do not abuse params to register the second interface

if_epair used the 'params' argument to pass a pointer to the b interface
through if_clone_create().
This pointer can be controlled by userspace, which means it could be abused to
trigger a panic. While this requires PRIV_NET_IFCREATE
privileges those are assigned to vnet jails, which means that vnet jails
could panic the system.

Reported by: Ilja Van Sprundel <ivansprundel@ioactive.com>

4 years agoMFC r356707: Map ECKSUM and EFRAGS from ZFS onto real errnos.
Alexander Motin [Thu, 30 Jan 2020 16:38:40 +0000 (16:38 +0000)]
MFC r356707: Map ECKSUM and EFRAGS from ZFS onto real errnos.

Make it less confusing when, for example, stat sets errno to 122 because a
checksum failed in ZFS:

Before: getfacl: /foo/bar: stat() failed: Unknown error: 122
After: getfacl: /foo/bar: stat() failed: Integrity check failed

Submitted by: Ryan Moeller <ryan@ixsystems.com>

4 years agoMFC r343111,343113-343115 (by mckusick):
Alexander Motin [Thu, 30 Jan 2020 16:11:19 +0000 (16:11 +0000)]
MFC r343111,343113-343115 (by mckusick):
Create new EINTEGRITY error with message "Integrity check failed".

An integrity check such as a check-hash or a cross-correlation failed.
The integrity error falls between EINVAL that identifies errors in
parameters to a system call and EIO that identifies errors with the
underlying storage media. EINTEGRITY is typically raised by intermediate
kernel layers such as a filesystem or an in-kernel GEOM subsystem when
they detect inconsistencies. Uses include allowing the mount(8) command
to return a different exit value to automate the running of fsck(8)
during a system boot.

These changes make no use of the new error, they just add it. Later
commits will be made for the use of the new error number and it will
be added to additional manual pages as appropriate.

Approved by: mckusick

4 years agoMFC r357048:
Mark Johnston [Thu, 30 Jan 2020 15:00:41 +0000 (15:00 +0000)]
MFC r357048:
arm64: Don't enable interrupts in init_secondary().

4 years agoMFC r356816:
Kristof Provost [Thu, 30 Jan 2020 09:56:56 +0000 (09:56 +0000)]
MFC r356816:

Fix pfdenied not returning any results

When _a is empty we end up with an invalid invocation of pfctl, and no output.
We must add quotes to make it clear to pfctl that we're passing an empty anchor
name.

PR: 224415
Submitted by: sigsys AT gmail.com

4 years agoMFC r357159
Vincenzo Maffione [Wed, 29 Jan 2020 22:55:59 +0000 (22:55 +0000)]
MFC r357159

netmap_mem_unmap: fix NULL pointer dereference

4 years agoMFC r354637:
Roger Pau Monné [Wed, 29 Jan 2020 09:33:40 +0000 (09:33 +0000)]
MFC r354637:

xen: fix dispatching of NMIs

4 years agoMFC 357212.
Gordon Tetlow [Tue, 28 Jan 2020 18:40:55 +0000 (18:40 +0000)]
MFC 357212.

Fix urldecode buffer overrun.

Reported by: Duncan Overbruck
Approved by: so
Security: FreeBSD-SA-20:01.libfetch
Security: CVE-2020-7450

4 years agoMFC r356527-356528:
Bjoern A. Zeeb [Tue, 28 Jan 2020 18:08:53 +0000 (18:08 +0000)]
MFC r356527-356528:

  vnet: virtualise more network stack sysctls.

  Virtualise tcp_always_keepalive, TCP and UDP log_in_vain.  All three are
  set in the netoptions startup script, which we would love to run for VNETs
  as well.

  While virtualising the log_in_vain sysctls seems pointles at first for as
  long as the kernel message buffer is not virtualised, it at least allows
  an administrator to debug the base system or an individual jail if needed
  without turning the logging on for all jails running on a system.

  Run netoptions startup script in vnet jails.

  People use rc.conf inside vnet jails to configure networking setups.
  Presumably because some sysctl were not virtualised up until r356527 the
  script was not run for vnet jails leaving the rc.conf options without
  effect for non-obvious reasons.  Run the netoptions startup script also
  for VNET jails now to make the rc.conf options work.

PR: 243193

4 years agoMFC r356662:
Bjoern A. Zeeb [Tue, 28 Jan 2020 17:48:14 +0000 (17:48 +0000)]
MFC r356662:

  nd6_rtr: constantly use __func__ for nd6log()

  Over time one or two hard coded function names did not match the
  actual function anymore.  Consistently use __func__ for nd6log() calls
  and re-wrap/re-format some messages for consitency.

4 years agoMFC r353026,353030,354244 (glebius), r356386:
Bjoern A. Zeeb [Tue, 28 Jan 2020 17:39:03 +0000 (17:39 +0000)]
MFC r353026,353030,354244 (glebius), r356386:

  Remove the compile time limit for number of links a ng_bridge node
  can handle.  Instead using an array on node private data, use per-hook
  private data.

  Reestablish old ABI.

PR: 240787
Submitted by: Lutz Donnerhacke (lutz donnerhacke.de)

4 years agoMFC r356940:
Konstantin Belousov [Tue, 28 Jan 2020 11:33:12 +0000 (11:33 +0000)]
MFC r356940:
Add support for Hygon Dhyana Family 18h processor.

4 years agoMFC r356629, r356636
Xin LI [Tue, 28 Jan 2020 07:49:52 +0000 (07:49 +0000)]
MFC r356629, r356636

r356629:
Apply typo fix from NetBSD, we have already applied all NetBSD changes so
update the NetBSD tag while I'm there.

r356636:
Correct off-by-two issue when determining FAT type.

In the code we used NumClusters as the upper (non-inclusive) boundary
of valid cluster number, so the actual value was 2 (CLUST_FIRST) more
than the real number of clusters. This causes a FAT16 media with
65524 clusters be treated as FAT32 and might affect FAT12 media with
4084 clusters as well.

To fix this, we increment NumClusters by CLUST_FIRST after the type
determination.

PR: 243179

4 years agoMFC r357084: caroot: use bsd.obj.mk, not bsd.prog.mk
Kyle Evans [Tue, 28 Jan 2020 02:58:39 +0000 (02:58 +0000)]
MFC r357084: caroot: use bsd.obj.mk, not bsd.prog.mk

This directory stages certdata into .OBJDIR and processes it, but does not
actually build a prog-shaped object; bsd.obj.mk provides the minimal support
that we actually need, an .OBJDIR and descent into subdirs. This is
admittedly the nittiest of nits.

4 years agoMFC r357103-r357104: unbreak local.lua, add a modules.loaded hook
Kyle Evans [Tue, 28 Jan 2020 02:42:33 +0000 (02:42 +0000)]
MFC r357103-r357104: unbreak local.lua, add a modules.loaded hook

r357103:
loader.lua: re-arrange to load local.lua *after* config loading

The major problem with the current ordering is that loader.conf may contain
all of the magic we need to actually setup the console, so loading local.lua
prior to that can make it excessively difficult and annoying to debug
(whoops, sorry Ravi & Warner).

The new ordering has some implications, but I suspect they are a non-issue.
The first is that it's no longer possible for the local module to inject any
logic prior to loading config -- I suspect no one has relied on this. The
second implication is that the config.loaded hook is now useless, as the
local module will always be included after that hook would have fired.

For config.loaded, I will opt to leave it in, just in case we add an early
point for local lua to get injected or in case one wants to schedule some
deferred logic in a custom loader.lua. The overhead of having it if no hooks
will be invoked is relatively minimal.

r357104:
lua: add modules.loaded hook

This may be used for the local module to hook in and load any additional
modules that it wants, since it can't modify the modules table internal to
config. We may consider adding API to do so at a later time, but I suspect
it will be more complicated to use with little return.

status is captured but ignored for the purpose of loading the hook. status
will be false if *any* module failed to load, but we typically don't let
that halt the boot so there's no reason to let it halt hooks. Some vendors
or setups may have expected fails that would be actively thwarted by
checking it.

We may, at a later date, consider adding an API for letting non-config
modules check which modules have successfully (or not) loaded in case an
unexpected failure *should* halt whatever they are doing.

4 years agoMFC r356994: Mark rfork(2) as __returns_twice
Kyle Evans [Mon, 27 Jan 2020 22:13:42 +0000 (22:13 +0000)]
MFC r356994: Mark rfork(2) as __returns_twice

rfork is not generally a built-in that would be recognized as behaving like
vfork/fork; provide the hint.

4 years agoMFC r356919,r357054:
Konstantin Belousov [Mon, 27 Jan 2020 13:12:40 +0000 (13:12 +0000)]
MFC r356919,r357054:
x86: Wait for curpcb to be set up as an indicator that the boot stack
is no longer used.

4 years agoMFC r356929:
Dimitry Andric [Mon, 27 Jan 2020 07:03:57 +0000 (07:03 +0000)]
MFC r356929:

Merge commit bc4bc5aa0 from llvm git (by Justin Hibbits):

  Add 8548 CPU definition and attributes

  8548 CPU is GCC's name for the e500v2, so accept this in clang.  The
  e500v2 doesn't support lwsync, so define __NO_LWSYNC__ for this as
  well, as GCC does.

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

Merge commit ff0311c4b from llvm git (by Justin Hibbits):

  [PowerPC]: Add powerpcspe target triple subarch component

  Summary:
  This allows the use of '-target powerpcspe-unknown-linux-gnu' or
  'powerpcspe-unknown-freebsd' to be used, instead of '-target
  powerpc-unknown-linux-gnu -mspe'.

  Reviewed By: dim
  Differential Revision: https://reviews.llvm.org/D72014

Merge commit ba91dffaf from llvm git (by Fangrui Song):

  [Driver][PowerPC] Move powerpcspe logic from cc1 to Driver

  Follow-up of D72014. It is more appropriate to use a target feature
  instead of a SubTypeArch to express the difference.

  Reviewed By: #powerpc, jhibbits

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

commit 36eedfcb3 from llvm git (by Justin Hibbits):

  [PowerPC] Fix powerpcspe subtarget enablement in llvm backend

  Summary:

  As currently written, -target powerpcspe will enable SPE regardless
  of disabling the feature later on in the command line.  Instead,
  change this to just set a default CPU to 'e500' instead of a generic
  CPU.

  As part of this, add FeatureSPE to the e500 definition.

  Reviewed By: MaskRay
  Differential Revision: https://reviews.llvm.org/D72673

These are needed to unbreak the build for powerpcspe.

Requested by: jhibbits

4 years agoMFC r356789 (by arichardson):
Dimitry Andric [Mon, 27 Jan 2020 07:02:52 +0000 (07:02 +0000)]
MFC r356789 (by arichardson):

Merge commit 894f742acb from llvm git (by me):

  [MIPS][ELF] Use PC-relative relocations in .eh_frame when possible

  When compiling position-independent executables, we now use
  DW_EH_PE_pcrel | DW_EH_PE_sdata4. However, the MIPS ABI does not define a
  64-bit PC-relative ELF relocation so we cannot use sdata8 for the large
  code model case. When using the large code model, we fall back to the
  previous behaviour of generating absolute relocations.

  With this change clang-generated .o files can be linked by LLD without
  having to pass -Wl,-z,notext (which creates text relocations).
  This is simpler than the approach used by ld.bfd, which rewrites the
  .eh_frame section to convert absolute relocations into relative references.

  I saw in D13104 that apparently ld.bfd did not accept pc-relative relocations
  for MIPS ouput at some point. However, I also checked that recent ld.bfd
  can process the clang-generated .o files so this no longer seems true.

  Reviewed By: atanasyan
  Differential Revision: https://reviews.llvm.org/D72228

Merge commit 8e8ccf47 from llvm git (by me)

  [MIPS] Don't emit R_(MICRO)MIPS_JALR relocations against data symbols

  The R_(MICRO)MIPS_JALR optimization only works when used against functions.
  Using the relocation against a data symbol (e.g. function pointer) will
  cause some linkers that don't ignore the hint in this case (e.g. LLD prior
  to commit 5bab291) to generate a relative branch to the data symbol
  which crashes at run time. Before this patch, LLVM was erroneously emitting
  these relocations against local-dynamic TLS function pointers and global
  function pointers with internal visibility.

  Reviewers: atanasyan, jrtc27, vstefanovic
  Reviewed By: atanasyan
  Differential Revision: https://reviews.llvm.org/D72571

These two changes should allow using lld for MIPS64 (and maybe also MIPS32)
by default.
The second commit is not strictly necessary for clang+lld since LLD9 will
not perform the R_MIPS_JALR optimization (it was only added for 10) but it
is probably required in order to use recent ld.bfd.

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

4 years agoMFC r355553
Don Lewis [Sun, 26 Jan 2020 01:42:47 +0000 (01:42 +0000)]
MFC r355553

Fix a logic bug in error handling code.  It is an error if p == NULL.
The linelen tests are only meaningful when p != NULL.

Reported by: Coverity
Coverity CID: 1368655

4 years agoMFC r356863: ifa_maintain_loopback_route: adjust debugging output
Eugene Grosbein [Sat, 25 Jan 2020 09:12:20 +0000 (09:12 +0000)]
MFC r356863: ifa_maintain_loopback_route: adjust debugging output

Correction after r333476:

- write this as LOG_DEBUG again instead of LOG_INFO;
- get back function name into the message;
- error may be ESRCH if an address is removed in process (by carp f.e.),
  not only ENOENT;
- expression complexity grows, so try making it more readable.

4 years agoRegenerate ibcs2 sysent targets, NFC
Kyle Evans [Sat, 25 Jan 2020 05:52:31 +0000 (05:52 +0000)]
Regenerate ibcs2 sysent targets, NFC

Direct commit; these hadn't been regenerated in a wihle, and it's nice to
see no diff going forward in case these get tweaked a little bit more for
conventions. Unlikely.

4 years agoMFC r355473, r356540, r356604, r356868, r356937: sysent improvements
Kyle Evans [Sat, 25 Jan 2020 05:47:56 +0000 (05:47 +0000)]
MFC r355473, r356540, r356604, r356868, r356937: sysent improvements

The main motivation here being .ORDER to render -jN > 1 harmless; svr4/ibcs2
targets were also refactored a bit, but both are irregular and cannot use
sysent.mk as-is due to differences in files generated. I have no interest in
refactoring, since these are gone in head anyways.

r355473: sysent: Reduce duplication and improve readability.

Use the power of variable to avoid spelling out source and generated
files too many times.  The previous Makefiles were hard to read, hard to
edit, and badly formatted.

r356540:
kern/Makefile: systrace_args.c is also generated

r356604:
Set .ORDER for makesyscalls generated files

When either makesyscalls.lua or syscalls.master changes, all of the
${GENERATED} targets are now out-of-date. With make jobs > 1, this means we
will run the makesyscalls script in parallel for the same ABI, generating
the same set of output files.

Prior to r356603 , there is a large window for interlacing output for some
of the generated files that we were generating in-place rather than staging
in a temp dir. After that, we still should't need to run the script more
than once per-ABI as the first invocation should update all of them. Add
.ORDER to do so cleanly.

r356868:
sysent targets: further cleanup and deduplication

r355473 vastly improved the readability and cleanliness of these Makefiles.
Every single one of them follows the same pattern and duplicates the exact
same logic.

Now that we have GENERATED/SRCS, split SRCS up into the two parameters we'll
use for ${MAKESYSCALLS} rather than assuming a specific ordering of SRCS and
include a common sysent.mk to handle the rest. This makes it less tedious to
make sweeping changes.

Some default values are provided for GENERATED/SYSENT_*; almost all of these
just use a 'syscalls.master' and 'syscalls.conf' in cwd, and they all use
effectively the same filenames with an arbitrary prefix. Most ABIs will be
able to get away with just setting GENERATED_PREFIX and including
^/sys/conf/sysent.mk, while others only need light additions. kern/Makefile
is the notable exception, as it doesn't take a SYSENT_CONF and the generated
files are spread out between ^/sys/kern and ^/sys/sys, but it otherwise fits
the pattern enough to use the common version.

r356937:
sysent.mk: split interpreter out of target command

The main objective here is to make it easy to identify what needs to change
in order to use a different sysent generator than the current Lua-based one,
which may be used to MFC some of the changes that have happened so we can
avoid parallel accidents in stable branches, for instance.

As a secondary objective, it's now feasible to override the generator on a
per-Makefile basis if needed, so that one could refactor their Makefile to
use this while pinning generation to the legacy makesyscalls.sh. I don't
anticipate any consistent need for such a thing, but it's low-effort to
achieve.

4 years agoMFC r354968, r354976: Introduce, but do not use, bsd.sysdir.mk
Kyle Evans [Sat, 25 Jan 2020 05:17:44 +0000 (05:17 +0000)]
MFC r354968, r354976: Introduce, but do not use, bsd.sysdir.mk

[Some sysent bits use bsd.sysdir.mk now, but I don't see a point in
converting existing stuff]

MFC r354968: Introduce bsd.sysdir.mk to consolidate looking for the kernel.

MFC r354976: Install bsd.sysdir.mk

4 years agoMFC 356951: posix_spawn: mark error as volatile
Kyle Evans [Fri, 24 Jan 2020 17:15:31 +0000 (17:15 +0000)]
MFC 356951: posix_spawn: mark error as volatile

In the case of an error, the RFSPAWN'd thread will write back to psa->error
with the correct exit code. Mark this as volatile as the return value is
being actively dorked up for erroneous exits on !x86.

This fixes the following tests, tested on aarch64 (only under qemu, at the
moment):

- posix_spawn/spawn_test:t_spawn_missing
- posix_spawn/spawn_test:t_spawn_nonexec
- posix_spawn/spawn_test:t_spawn_zero

4 years agoMFC r352948-r352951, r353002, r353066, r353070: caroot infrastructure
Kyle Evans [Fri, 24 Jan 2020 15:29:33 +0000 (15:29 +0000)]
MFC r352948-r352951, r353002, r353066, r353070: caroot infrastructure

Infrastructure only -- no plans in place currently to commit any certs to
these branches.

r352948:
[1/3] Initial infrastructure for SSL root bundle in base

This setup will add the trusted certificates from the Mozilla NSS bundle
to base.

This commit includes:
- CAROOT option to opt out of installation of certs
- mtree amendments for final destinations
- infrastructure to fetch/update certs, along with instructions

A follow-up commit will add a certctl(8) utility to give the user control
over trust specifics. Another follow-up commit will actually commit the
initial result of updatecerts.

This work was done primarily by allanjude@, with minor contributions by
myself.

r352949:
[2/3] Add certctl(8)

This is a simple utility to hash all trusted on the system into
/etc/ssl/certs. It also allows the user to blacklist certificates they do
not trust.

This work was done primarily by allanjude@, with minor contributions by
myself.

r352950:
[3/3] etcupdate and mergemaster support for certctl

This commit add support for certctl in mergemaster and etcupdate. Both will
either rehash or prompt for rehash as new certificates are
trusted/blacklisted.

This work was done primarily by allanjude@, with minor contributions by
myself.

r352951:
caroot: add @generated tags to extracted .pem

As is the current trend; while these files are manually curated, they are
still generated.  If they end up in a review, it would be helpful to also
take the hint and hide them.

r353002:
Unbreak etcupdate(8) and mergemaster(8) after r352950

r352950 introduced improper case fall-through for shell scripts. Fix it with
a pipe.

r353066:
certctl(8): realpath the file before creating the symlink

Otherwise we end up creating broken relative symlinks in
/etc/ssl/blacklisted.

r353070:
certctl(8): let one blacklist based on hashed filenames

It seems reasonable to allow, for instance:

$ certctl list
# reviews output -- ah, yeah, I don't trust that one
$ certctl blacklist ce5e74ef.0
$ certctl rehash

We can unambiguously determine what cert "ce5e74ef.0" refers to, and we've
described it to them in `certctl list` output -- I see little sense in
forcing another level of filesystem inspection to determien what cert file
this physically corresponds to.

Relnotes: yes

4 years agoMFC r355647:
Eitan Adler [Fri, 24 Jan 2020 14:22:09 +0000 (14:22 +0000)]
MFC r355647:
[showmount] implement long options

add long options support to showmount. Where mappings exist use the GNU
names for said options.

Relnotes: yes

4 years agoMFC r356836: src.opts.mk: force DMAGENT off under WITHOUT_OPENSSL
Ed Maste [Fri, 24 Jan 2020 01:00:28 +0000 (01:00 +0000)]
MFC r356836: src.opts.mk: force DMAGENT off under WITHOUT_OPENSSL

dma(8) depends on OpenSSL unconditionally.

4 years agoMFC r356563:
Mark Johnston [Thu, 23 Jan 2020 14:01:03 +0000 (14:01 +0000)]
MFC r356563:
UMA: Don't destroy zones after the system shutdown process starts.

PR: 242427

4 years agoMFC of 356714
Kirk McKusick [Thu, 23 Jan 2020 06:20:57 +0000 (06:20 +0000)]
MFC of 356714

Fix DIRCHG panic

4 years agoMFC of 356763
Kirk McKusick [Thu, 23 Jan 2020 06:11:25 +0000 (06:11 +0000)]
MFC of 356763

Remove call to VFS_SYNC() to avoid unmount livelock

4 years agoMFC of 356739
Kirk McKusick [Thu, 23 Jan 2020 06:02:52 +0000 (06:02 +0000)]
MFC of 356739

Optimize quota sync'ing

4 years agoMFC r356876-r356877: add zfs_mount_at
Kyle Evans [Wed, 22 Jan 2020 22:51:55 +0000 (22:51 +0000)]
MFC r356876-r356877: add zfs_mount_at

r356876:
libzfs: add zfs_mount_at

This will be used in libbe in place of the internal zmount(); libbe only
wants to be able to mount a dataset at an arbitrary mountpoint without
altering dataset/pool properties. The natural way to do this in a portable
way is by creating a zfs_mount_at() interface that's effectively zfs_mount()
+ a mountpoint parameter. zfs_mount() is now a light wrapper around the new
method.

The interface and implementation have already been accepted into ZFS On
Linux, and the next commit to switch libbe() over to this new interface will
solve the last compatibility issue with ZoL.  The next sysutils/openzfs
rebase against ZoL should be able to build libbe/bectl with only minor
adjustments to build glue.

r356877:
libbe: use the new zfs_mount_at()

More background is available in r356876, but this new interface is more
portable across ZFS implementations and cleaner for what libbe is attempting
to achieve anyways.

4 years agoMFC r356849: bcm2835_vcbus: unifdef all platform definitions
Kyle Evans [Wed, 22 Jan 2020 22:08:02 +0000 (22:08 +0000)]
MFC r356849:  bcm2835_vcbus: unifdef all platform definitions

Raspberry Pi are all over the board, and the reality is that there's no harm
in including all of the definitions by default but plenty of harm in the
current situation. This change is safe because we match a definition by root
/compatible in the FDT, so there will be no false-positives because of it.

The main array of definitions grows, but it's only walked exactly once to
determine which we need to use.

4 years agoMFC of 356627
Kirk McKusick [Wed, 22 Jan 2020 01:28:37 +0000 (01:28 +0000)]
MFC of 356627

Reset link counts after directory update failures

4 years agoMFC r342873:
Pawel Jakub Dawidek [Wed, 22 Jan 2020 01:10:23 +0000 (01:10 +0000)]
MFC r342873:

In r316006 the getstrfromtype_locked() function was modified to return
an empty string, instead of NULL, if an entry is missing in the audit_control
file. Because of that change the getachost() function started to return
success even if the host name was not defined in the audit_control.
This in turn led to auditd_hostlen always being set (for an empty host it was
set to 0). If auditd_hostlen was not equal to -1 we were trying to append
the host name to trail file name. All this led to situation where when host
name is not defined in audit_control, auditd will create trail files with
a leading '.', which breaks auditdistd as it doesn't work with longer audit
trail file names.

Fix this by appending host name to the trail file name only if the host name
is not empty.

Sponsored by: Fudo Security

4 years agoMFC r356474, r356480, r356482, r356506:
Alexander Motin [Wed, 22 Jan 2020 01:08:27 +0000 (01:08 +0000)]
MFC r356474, r356480, r356482, r356506:
Add Host Memory Buffer support to nvme(4).

This allows cheapest DRAM-less NVMe SSDs to use some of host RAM (about
1MB per 1GB on the devices I have) for its metadata cache, significantly
improving random I/O performance.  Device reports minimal and preferable
size of the buffer.  The code limits it to 5% of physical RAM by default.
If the buffer can not be allocated or below minimal size, the device will
just have to work without it.

4 years agoMFC r351357 (by imp): Document RST support in nvme(4) and ahci(4).
Alexander Motin [Wed, 22 Jan 2020 01:04:26 +0000 (01:04 +0000)]
MFC r351357 (by imp): Document RST support in nvme(4) and ahci(4).

4 years agoMFC r347967 (by cem): nvd.4: Reference nda(4)
Alexander Motin [Wed, 22 Jan 2020 01:03:24 +0000 (01:03 +0000)]
MFC r347967 (by cem): nvd.4: Reference nda(4)

Fix a totally minor typo in nvme.4 while here.

4 years agoMFC r341709 (by imp): Add nda(4) cross reference to nvme(4)
Alexander Motin [Wed, 22 Jan 2020 00:52:42 +0000 (00:52 +0000)]
MFC r341709 (by imp): Add nda(4) cross reference to nvme(4)

4 years agoMFC r355774 (by mmel): Properly synchronize completion DMA buffers.
Alexander Motin [Wed, 22 Jan 2020 00:48:54 +0000 (00:48 +0000)]
MFC r355774 (by mmel): Properly synchronize completion DMA buffers.

Within command completion processing the callback function may access
DMAed data buffer. Synchronize it before use, not after.
This allows to use NVMe disk on non-DMA coherent arm64 system.

4 years agoMFC r355721 (by imp): Move to using bool instead of boolean_t
Alexander Motin [Wed, 22 Jan 2020 00:46:09 +0000 (00:46 +0000)]
MFC r355721 (by imp): Move to using bool instead of boolean_t

While there are subtle semantic differences between bool and boolean_t, none of
them matter in these cases. Prefer true/false when dealing with bool
type. Preserve a couple of TRUEs since they are passed into int args into CAM.
Preserve a couple of FALSEs when used for status.done, an int.

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

4 years agoMFC r355631 (by imp): Move reset to the interrutp processing stage
Alexander Motin [Wed, 22 Jan 2020 00:43:51 +0000 (00:43 +0000)]
MFC r355631 (by imp): Move reset to the interrutp processing stage

This trims the boot time a bit more for AWS and other platforms that have nvme
drives. There's no reason too do this inline. This has been in my tree a while,
but IIRC I talked to Jim Harris about this at one of our face to face meetings.

4 years agoMFC r355465 (by imp): trackers always know what qpair they are on
Alexander Motin [Wed, 22 Jan 2020 00:41:18 +0000 (00:41 +0000)]
MFC r355465 (by imp): trackers always know what qpair they are on

Don't needlessly pass around qpair pointers when the tracker knows what
qpair it's on.  This will simplify code and make it easier to split
submission and completion queues in the future.

Signed-off-by: John Meneghini <johnm@netapp.com>
4 years agoMFC r356760:
Mark Johnston [Wed, 22 Jan 2020 00:30:27 +0000 (00:30 +0000)]
MFC r356760:
Handle a NULL thread pointer in linux_close_file().

PR: 242913

4 years agoMFC r356477:
Mark Johnston [Tue, 21 Jan 2020 15:07:23 +0000 (15:07 +0000)]
MFC r356477:
Use a deterministic hash for USDT symbol names.

4 years agoMFC r356703
Vincenzo Maffione [Mon, 20 Jan 2020 22:15:33 +0000 (22:15 +0000)]
MFC r356703

vmx: fix initialization of TSO related descriptor fields

Fix a mistake introduced by r343291, which ported the vmx(4)
driver to iflib.
In case of TSO, the hlen field of the (first) tx descriptor must
be initialized to the cumulative length of Ethernet, IP and TCP
headers. The length of the TCP header was missing.

PR:             236999
Reported by:    pkelsey
Reviewed by:    avg
Differential Revision:  https://reviews.freebsd.org/D22967

4 years agoMFC r356792:
Glen Barber [Mon, 20 Jan 2020 15:38:05 +0000 (15:38 +0000)]
MFC r356792:
 Update release(7) to note OSRELEASE is only relevant when the
 'install' target is invoked.

 While here, bump the sample output version name, and explicitly
 add the 'obj' target to avoid polluting the src checkout.

PR: 243287 (related)
Sponsored by: Rubicon Communications, LLC (netgate.com)

4 years agoMFC r356676:
Cy Schubert [Mon, 20 Jan 2020 13:46:09 +0000 (13:46 +0000)]
MFC r356676:

Unbound's config.h is manually maintained, using a ./configure produced
config.h as a guide. In practice contributed software maintains a copy
of config.h within its build directory tree containing its Makefile.
usr.sbin/unbound is the home for its config.h.

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

4 years agoMFC 356561: Add stricter checking on mac key lengths.
John Baldwin [Mon, 20 Jan 2020 11:54:00 +0000 (11:54 +0000)]
MFC 356561: Add stricter checking on mac key lengths.

Negative lengths are always invalid.  The key length should also
be zero for hash algorithms that do not accept a key.

admbugs: 949

4 years agoMFC 356507,356520: Add a reference count to cryptodev sessions.
John Baldwin [Mon, 20 Jan 2020 11:19:55 +0000 (11:19 +0000)]
MFC 356507,356520: Add a reference count to cryptodev sessions.

356507:
Add a reference count to cryptodev sessions.

This prevents use-after-free races with crypto requests (which may
sleep) and CIOCFSESSION as well as races from current CIOCFSESSION
requests.

356520:
Remove no-longer-used function prototype.

admbugs: 949
Sponsored by: Chelsio Communications