]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
23 months agotmpfs.5: Add fstab line example
Mateusz Piotrowski [Thu, 21 Jul 2022 18:06:32 +0000 (20:06 +0200)]
tmpfs.5: Add fstab line example

MFC after: 3 days

(cherry picked from commit 7c2ec6cdf575de11d5ed33109d92e757dd3d072c)

23 months agobeinstall.8: Update example distsites for BSDINSTALL_DISTSITE
Mateusz Piotrowski [Mon, 18 Jul 2022 10:22:42 +0000 (12:22 +0200)]
beinstall.8: Update example distsites for BSDINSTALL_DISTSITE

MFC after: 1 week

(cherry picked from commit aa35037ba565bf9f6d5946515ecdcc61a5b22ebb)

23 months agoblacklistd: Handle 0 sized messages
Ed Maste [Mon, 18 Jul 2022 00:43:52 +0000 (20:43 -0400)]
blacklistd: Handle 0 sized messages

Patch obtained from https://github.com/zoulasc/blocklist commit
ada75856bc6fcabbdd25ffbe08fbad5cf2a2c08a

PR: 264599
MFC after: 1 week

(cherry picked from commit b1e81e6ddee42efb0f0d49cfc6cebb48d52e3f08)

23 months agoeventtimer: Fix several races in the timer reload code
Mark Johnston [Thu, 30 Jun 2022 18:27:07 +0000 (14:27 -0400)]
eventtimer: Fix several races in the timer reload code

In handleevents(), lock the timer state before fetching the time for the
next event.  A concurrent callout_cc_add() call might be changing the
next event time, and the race can cause handleevents() to program an
out-of-date time, causing the callout to run later (by an unbounded
period, up to the idle hardclock period of 1s) than requested.

In cpu_idleclock(), call getnextcpuevent() with the timer state mutex
held, for similar reasons.  In particular, cpu_idleclock() runs with
interrupts enabled, so an untimely timer interrupt can result in a stale
next event time being programmed.  Further, an interrupt can cause
cpu_idleclock() to use a stale value for "now".

In cpu_activeclock(), disable interrupts before loading "now", so as to
avoid going backwards in time when calling handleevents().  It's ok to
leave interrupts enabled when checking "state->idle", since the race at
worst will cause handleevents() to be called unnecessarily.  But use an
atomic load to indicate that the test is racy.

PR: 264867
Reviewed by: mav, jhb, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit a889a65ba36985dfb31111ac1607be35ca2b2c8c)

23 months agocallout: Simplify the inner loop in callout_process() a bit
Mark Johnston [Fri, 1 Jul 2022 00:16:33 +0000 (20:16 -0400)]
callout: Simplify the inner loop in callout_process() a bit

- Use LIST_FOREACH_SAFE.
- Simplify control flow.

No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 46eab86035a1d5d2b8bfd5aae3581e2604d3ae68)

23 months agocallout: Remove a redundant parameter to callout_cc_add()
Mark Johnston [Thu, 30 Jun 2022 17:31:57 +0000 (13:31 -0400)]
callout: Remove a redundant parameter to callout_cc_add()

The passed cpuid is always equal to the one stored in the callout
structure.  No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit aac7c7ac545804889d3bc28fae4efbcc07bcb6d3)

23 months agovm_fault: Fix some nits in vm_fault_copy_entry()
Mark Johnston [Mon, 11 Jul 2022 19:27:54 +0000 (15:27 -0400)]
vm_fault: Fix some nits in vm_fault_copy_entry()

- Correct the description (vm_fault_copy_entry() does not create a
  shadow object).
- Move some initialization and assertions out of the scope of the object
  locks, when doing so makes sense.
- Merge a pair of conditional blocks.
- Use __unused when appropriate.

No functional change intended.

Reviewed by: alc
Sponsored by: The FreeBSD Foundation

(cherry picked from commit b57be759d079d40aa6ec75207faadce5ae1484a2)

23 months agouma: Use a taskqueue to execute uma_timeout()
Mark Johnston [Mon, 11 Jul 2022 19:45:36 +0000 (15:45 -0400)]
uma: Use a taskqueue to execute uma_timeout()

uma_timeout() has several responsibilities; it visits every UMA zone and
as of recently will drain underutilized caches, so is rather expensive
(>1ms in some cases).  Currently it is executed by softclock threads
and so will preempt most other CPU activity.  None of this work requires
a high scheduling priority, though, so defer it to a taskqueue so as to
avoid stalling higher-priority work.

Reviewed by: rlibby, alc, mav, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 93cd28ea82bb7b5e9489c8febfe1ae7ed2c044fb)

23 months agonfscl: Add a cred argument to nfscl_reqstart()
Rick Macklem [Fri, 8 Jul 2022 23:58:06 +0000 (16:58 -0700)]
nfscl: Add a cred argument to nfscl_reqstart()

To deal with broken session slots caused by the use of the
"soft" and/or "intr" mount options, nfsv4_sequencelookup()
will be modified to track the potentially broken session
slots.  Then, when all session slots are potentially
broken, do a DeleteSession operation, so that the NFSv4
server will reply NFSERR_BADSESSION to uses of the session.
These changes will be done in future commits.  However,
to do the DeleteSession RPC, a "cred" argument is needed
for nfscl_reqstart().  This patch adds this argument,
which is unused at this time.  If the argument is NULL,
it indicates that DeleteSession should not be done
(usually because the RPC does not use sessions).

This patch should not cause any semantics change.

PR: 260011
MFC after: 2 weeks

(cherry picked from commit 326bcf9394c74ac19afda7c741b3521d91b46b10)

23 months agoses: don't panic if disk elements have really weird descriptors
Alan Somers [Fri, 10 Jun 2022 22:44:59 +0000 (16:44 -0600)]
ses: don't panic if disk elements have really weird descriptors

SES allows element descriptors to contain characters like spaces and
quotes that devfs does not allow to appear in device aliases.  Since SES
element descriptors are outside of the kernel's control, we should
gracefully handle a failure to create a device physical path alias.

PR: 264513
Reported by: Yuri <yuri@aetern.org>
Reviewed by: imp, mav
Sponsored by: Axcient

(cherry picked from commit 5f438dd3acba47e54e63b13bfff31a49bcc6ddea)

23 months agobsdinstall: allow an install script to access packages on the DVD
Alan Somers [Thu, 26 May 2022 21:39:20 +0000 (15:39 -0600)]
bsdinstall: allow an install script to access packages on the DVD

If installing from the DVD, mount its packages in the chroot at
/dist/packages.  That way they'll be accessible to an install script.

MFC after: 2 weeks
Sponsored by: Axcient
Reviewed by: gjb
Differential Revision: https://reviews.freebsd.org/D35330

(cherry picked from commit 6a02539959cb36c4777f962d3d7ef4a76fbe0c24)

23 months agoReplace subversion with git in the installation DVD
Alan Somers [Thu, 26 May 2022 19:08:34 +0000 (13:08 -0600)]
Replace subversion with git in the installation DVD

I assume the original reason for Subversion's inclusion was to checkout
the base system.  But now we use git for that.

Reviewed by: gjb
Sponsored by: Axcient
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35329

(cherry picked from commit 55c8093f733242cd72341ba1126637047cf16ca3)

23 months agobsdinstall: fix prepopulating the ZFS disk menu with ZFSBOOT_DISKS
Alan Somers [Thu, 26 May 2022 22:20:03 +0000 (16:20 -0600)]
bsdinstall: fix prepopulating the ZFS disk menu with ZFSBOOT_DISKS

If the ZFSBOOT_DISKS variable is set to one or more disk names, then
those disks should be preselected in the disk menu.  However, the code
wasn't correctly setting the variable, leaving all disks unselected.

MFC after: 2 weeks
Sponsored by: Axcient
Reviewed by: dteske
Differential Revision: https://reviews.freebsd.org/D35331

(cherry picked from commit caf73e58579343fc1661f43554b30115bb940535)

Fix a memory leak from caf73e58579

Don't shadow an already-local variable with another local declaration.

Reported by: dteske
MFC after: 13 days
MFC with: caf73e58579343fc1661f43554b30115bb940535
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D35331

(cherry picked from commit 77d678b7a4075a056be621b46be50377f08bfc9e)

23 months agobsdinstall: use gpt/efiboot0 label in /etc/fstab
Alan Somers [Tue, 24 May 2022 18:24:12 +0000 (12:24 -0600)]
bsdinstall: use gpt/efiboot0 label in /etc/fstab

Otherwise, boot will hang if the numbering of disks has changed since
initial install.

MFC after: 2 weeks
Sponsored by: Axcient
Reviewed by: brd
Differential Revision: https://reviews.freebsd.org/D35309

(cherry picked from commit 7919c76dbdd20161247d1bfb647110d87ca5ee0f)

23 months agoAdjust iface_khandler_register() definition to avoid clang 15 warning
Dimitry Andric [Thu, 21 Jul 2022 19:28:03 +0000 (21:28 +0200)]
Adjust iface_khandler_register() definition to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    sys/netpfil/ipfw/ip_fw_iface.c:128:24: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    iface_khandler_register()
                           ^
                            void

This is because iface_khandler_register() is declared with a (void)
argument list, but defined with an empty argument list. Make the
definition match the declaration.

MFC after: 3 days

(cherry picked from commit edf1e1f78da8c2a19bcee90fe0f72cac2eb18e30)

23 months agoFix unused variable warning in fwohci.c
Dimitry Andric [Thu, 21 Jul 2022 17:59:08 +0000 (19:59 +0200)]
Fix unused variable warning in fwohci.c

With clang 15, the following -Werror warning is produced:

    sys/dev/firewire/fwohci.c:2762:23: error: variable 'pcnt' set but not used [-Werror,-Wunused-but-set-variable]
            int len, plen, hlen, pcnt, offset;
                                 ^

The 'pcnt' variable is eventually used only in an #if 0'd block,
obviously meant for debugging. Ensure that 'pcnt' is only declared and
used when COUNT_PACKETS is defined, so the debugging can be easily
turned on later, if desired.

MFC after: 3 days

(cherry picked from commit d7e0d962f39877b997454992a980f4122c6316e7)

23 months agoFix unused variable warning in if_re_netmap.h
Dimitry Andric [Thu, 21 Jul 2022 19:52:29 +0000 (21:52 +0200)]
Fix unused variable warning in if_re_netmap.h

With clang 15, the following -Werror warning is produced:

    sys/dev/netmap/if_re_netmap.h:179:8: error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable]
            u_int n;
                  ^

The 'n' variable appears to have been a debugging aid that has never
been used for anything, so remove it.

MFC after: 3 days

(cherry picked from commit 8bfedf5852bcb846bfdd2a54989d65cdbb16f7ef)

23 months agoAdjust ipfw_iface_{init,destroy}() definitions to avoid clang 15 warning
Dimitry Andric [Thu, 21 Jul 2022 19:37:09 +0000 (21:37 +0200)]
Adjust ipfw_iface_{init,destroy}() definitions to avoid clang 15 warning

With clang 15, the following -Werror warnings are produced:

    sys/netpfil/ipfw/ip_fw_iface.c:206:16: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    ipfw_iface_init()
                   ^
                    void
    sys/netpfil/ipfw/ip_fw_iface.c:219:19: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    ipfw_iface_destroy()
                      ^
                       void

This is because ipfw_iface_init() and ipfw_iface_destroy() are declared
with (void) argument lists, but defined with empty argument lists. Make
the definitions match the declarations.

MFC after: 3 days

(cherry picked from commit 1eea6b9097834484f2238298f550bb418901c313)

23 months agoFix unused variable warning in iflib.c
Dimitry Andric [Thu, 21 Jul 2022 19:19:28 +0000 (21:19 +0200)]
Fix unused variable warning in iflib.c

With clang 15, the following -Werror warning is produced:

    sys/net/iflib.c:993:8: error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable]
            u_int n;
                  ^

The 'n' variable appears to have been a debugging aid that has never
been used for anything, so remove it.

MFC after: 3 days

(cherry picked from commit 0294e95da4aa272906d4472137b1235d8d8a7180)

23 months agoFix unused variable warning in if_lagg.c
Dimitry Andric [Thu, 21 Jul 2022 18:51:23 +0000 (20:51 +0200)]
Fix unused variable warning in if_lagg.c

With clang 15, the following -Werror warning is produced:

    sys/net/if_lagg.c:2413:6: error: variable 'active_ports' set but not used [-Werror,-Wunused-but-set-variable]
            int active_ports = 0;
                ^

The 'active_ports' variable appears to have been a debugging aid that
has never been used for anything (ref https://reviews.freebsd.org/D549),
so remove it.

MFC after: 3 days

(cherry picked from commit fa267a329ffa3d0e02c3c3a52dd5df5231d92cba)

23 months agoAdjust ipfw_{init,destroy}_*() definitions to avoid clang 15 warning
Dimitry Andric [Thu, 21 Jul 2022 19:23:13 +0000 (21:23 +0200)]
Adjust ipfw_{init,destroy}_*() definitions to avoid clang 15 warning

With clang 15, the following -Werror warnings are produced:

    sys/netpfil/ipfw/ip_fw_sockopt.c:187:19: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    ipfw_init_counters()
                      ^
                       void
    sys/netpfil/ipfw/ip_fw_sockopt.c:196:22: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    ipfw_destroy_counters()
                         ^
                          void
    sys/netpfil/ipfw/ip_fw_sockopt.c:3241:23: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    ipfw_init_obj_rewriter()
                          ^
                           void
    sys/netpfil/ipfw/ip_fw_sockopt.c:3249:26: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    ipfw_destroy_obj_rewriter()
                             ^
                              void

This is because ipfw_init_counters(), ipfw_destroy_counters(),
ipfw_init_obj_rewriter(), and ipfw_destroy_obj_rewriter() are declared
with (void) argument lists, but defined with empty argument lists. Make
the definitions match the declarations.

MFC after: 3 days

(cherry picked from commit 62030bb8538cb3775f6259c81c2c30a533f3ab10)

23 months agoAdjust iface_khandler_deregister() definition to avoid clang 15 warning
Dimitry Andric [Thu, 21 Jul 2022 19:32:16 +0000 (21:32 +0200)]
Adjust iface_khandler_deregister() definition to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    sys/netpfil/ipfw/ip_fw_iface.c:159:26: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    iface_khandler_deregister()
                             ^
                              void

This is because iface_khandler_deregister() is declared with a (void)
argument list, but defined with an empty argument list. Make the
definition match the declaration.

MFC after: 3 days

(cherry picked from commit 4100dc46c78cef408369c0fc8dcfd1f87783a1ca)

23 months agoAdjust pmc_thread_descriptor_pool_drain() definition to avoid clang 15 warning
Dimitry Andric [Thu, 21 Jul 2022 18:31:56 +0000 (20:31 +0200)]
Adjust pmc_thread_descriptor_pool_drain() definition to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    sys/dev/hwpmc/hwpmc_mod.c:2462:33: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    pmc_thread_descriptor_pool_drain()
                                    ^
                                     void

This is because pmc_thread_descriptor_pool_drain() is declared with a
(void) argument list, but defined with an empty argument list. Make the
definition match the declaration.

MFC after: 3 days

(cherry picked from commit 555d2c9394fa673241fd26a95152adfb9d20952e)

23 months agoAdjust fbt_unload() definition to avoid clang 15 warning
Dimitry Andric [Thu, 21 Jul 2022 17:40:38 +0000 (19:40 +0200)]
Adjust fbt_unload() definition to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    sys/cddl/dev/fbt/fbt.c:1273:11: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    fbt_unload()
              ^
               void

This is because fbt_unload() is declared with a (void) argument list,
but defined with an empty argument list. Make the definition match the
declaration.

MFC after: 3 days

(cherry picked from commit 6339314c737f44477c1168819353087c2f4816eb)

23 months agoAdjust pcm_md_initialize() definition to avoid clang 15 warning
Dimitry Andric [Thu, 21 Jul 2022 18:23:19 +0000 (20:23 +0200)]
Adjust pcm_md_initialize() definition to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    sys/dev/hwpmc/hwpmc_x86.c:245:18: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    pcm_md_initialize()
                     ^
                      void

This is because pcm_md_initialize() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

(cherry picked from commit dc0cde7a21a6aab0a5e876d8f890764e32718932)

23 months agoAdjust ipfw_{init,destroy}_sopt_handler() definitions to avoid clang 15 warning
Dimitry Andric [Thu, 21 Jul 2022 19:30:05 +0000 (21:30 +0200)]
Adjust ipfw_{init,destroy}_sopt_handler() definitions to avoid clang 15 warning

With clang 15, the following -Werror warning are produced:

    sys/netpfil/ipfw/ip_fw_sockopt.c:3477:23: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    ipfw_init_sopt_handler()
                          ^
                           void
    sys/netpfil/ipfw/ip_fw_sockopt.c:3485:26: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    ipfw_destroy_sopt_handler()
                             ^
                              void

This is because ipfw_init_sopt_handler() and ipfw_destroy_sopt_handler()
are declared with (void) argument lists, but defined with empty argument
lists. Make the definitions match the declarations.

MFC after: 3 days

(cherry picked from commit d62830c5e493133b0212f39c7efdab4232f87abf)

23 months agoFix unused variable warning in ocs_cam.c
Dimitry Andric [Wed, 20 Jul 2022 19:36:20 +0000 (21:36 +0200)]
Fix unused variable warning in ocs_cam.c

With clang 15, the following -Werror warning is produced:

    sys/dev/ocs_fc/ocs_cam.c:2556:11: error: variable 'count' set but not used [-Werror,-Wunused-but-set-variable]
            uint32_t        count;
                            ^

The 'count' variable seems to be a left-over from some debugging code
that no longer exists, and can be removed without any functional change.

MFC after: 3 days

(cherry picked from commit 8d9e29284627f5e860b7fc194e9fedd6b21f7783)

23 months agoFix unused variable warnings in hwpmc_mod.c
Dimitry Andric [Thu, 21 Jul 2022 18:35:41 +0000 (20:35 +0200)]
Fix unused variable warnings in hwpmc_mod.c

With clang 15, the following -Werror warnings are produced:

    sys/dev/hwpmc/hwpmc_mod.c:4805:6: error: variable 'nfree' set but not used [-Werror,-Wunused-but-set-variable]
            int nfree;
                ^
    sys/dev/hwpmc/hwpmc_mod.c:4804:6: error: variable 'ncallchains' set but not used [-Werror,-Wunused-but-set-variable]
            int ncallchains;
                ^

The 'nfree' and 'ncallchains' variables were used in KASSERTs, but these
were removed due to refactoring in d9f1b8dbf29d. Remove the variables
since they no longer serve any purpose.

MFC after:      3 days

(cherry picked from commit 38a9b8a00ce933e99b4a643cdcc3220be82e7d62)

23 months agoAdjust tdsaContext_t::NvmdResponseSet declaration to avoid clang 15 warning
Dimitry Andric [Thu, 21 Jul 2022 19:49:47 +0000 (21:49 +0200)]
Adjust tdsaContext_t::NvmdResponseSet declaration to avoid clang 15 warning

With clang 15, the following -Werror warnings are produced:

    In file included from sys/dev/pms/freebsd/driver/ini/src/agtiapi.c:70:
    sys/dev/pms/RefTisa/tisa/sassata/common/tdsatypes.h:346:13: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
      volatile  NvmdResponseSet;
      ~~~~~~~~  ^
      int

The NvmdResponseSet member is effectively only used as a boolean in the
pms(4) driver, so it could be a single bit. But to avoid changing the
semantics at all in this unmaintained driver, simply declare it as a
volatile int.

MFC after: 3 days

(cherry picked from commit 95204d7a6368990e216db0ad51ef3e6018aed27c)

23 months agoAdjust pcmlog_{initialize,shutdown}() definitions to avoid clang 15 warning
Dimitry Andric [Thu, 21 Jul 2022 18:20:56 +0000 (20:20 +0200)]
Adjust pcmlog_{initialize,shutdown}() definitions to avoid clang 15 warning

With clang 15, the following -Werror warnings are produced:

    sys/dev/hwpmc/hwpmc_logging.c:1228:18: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    pmclog_initialize()
                     ^
                      void
    sys/dev/hwpmc/hwpmc_logging.c:1277:16: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    pmclog_shutdown()
                   ^
                    void

This is because pcmlog_{initialize,shutdown}() are declared with (void)
argument lists, but defined with empty argument lists. Make the
definitions match the declarations.

MFC after: 3 days

(cherry picked from commit ba95c556029357800d18a5bc5abd02a2b7d0c9de)

23 months agoAdjust vt_mouse_paste() definition to avoid clang 15 warning
Dimitry Andric [Thu, 21 Jul 2022 20:10:22 +0000 (22:10 +0200)]
Adjust vt_mouse_paste() definition to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    sys/dev/vt/vt_core.c:2129:15: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    vt_mouse_paste()
                  ^
                   void

This is because vt_mouse_paste() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

(cherry picked from commit b77a5e5f5835620ce27114fad9a211d960ed60aa)

23 months agoFix unused variable warning in ipsec_mbuf.c
Dimitry Andric [Thu, 21 Jul 2022 20:03:50 +0000 (22:03 +0200)]
Fix unused variable warning in ipsec_mbuf.c

With clang 15, the following -Werror warning is produced:

    sys/netipsec/ipsec_mbuf.c:93:24: error: variable 'alloc' set but not used [-Werror,-Wunused-but-set-variable]
                    int todo, len, done, alloc;
                                         ^

The 'alloc' variable appears to have been a debugging aid that has never
been used for anything, so remove it.

MFC after: 3 days

(cherry picked from commit df5d2841d507589af0de7301f6cee3d2b98a35be)

23 months agolibproc: replace home grown crc32 with zlib implementation.
Xin LI [Sun, 10 Jul 2022 23:31:35 +0000 (16:31 -0700)]
libproc: replace home grown crc32 with zlib implementation.

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

(cherry picked from commit 0bbf2702963a2fe6f7bb025d5d07ee4195856b8f)

23 months agonfscl: Fix setting of nfsess_defunct for nfscl_hasexpired()
Rick Macklem [Fri, 8 Jul 2022 14:37:36 +0000 (07:37 -0700)]
nfscl: Fix setting of nfsess_defunct for nfscl_hasexpired()

Commit a7bb120f8b87 added a printf for the case where recovery
has not marked the session defunct by setting nfsess_defunct
to 1.  It turns out that nfscl_hasexpired() calls
nfsrpc_setclient() directly, without setting nfsess_defunct.
This patch replaces the printf with code that sets
nfsess_defunct to 1 to handle this case.

If SIGTERM is issued to a process when it is doing I/O on
an "intr" mount, the NFSv4 server may reply NFSERR_BADSTATEID,
due to the Open being prematurely closed.
This can result in a call to nfscl_hasexpired() to do a
recovery.

This would explain at least one hang described in the PR.

PR: 260011
MFC after: 2 weeks

(cherry picked from commit be7b87de16ffbabb81989e13a4b19a178e3ab8ee)

23 months agoSuppress unused variable warning in if_mwl.c
Dimitry Andric [Tue, 19 Jul 2022 19:45:54 +0000 (21:45 +0200)]
Suppress unused variable warning in if_mwl.c

With clang 15, the following -Werror warning is produced:

    sys/dev/mwl/if_mwl.c:3445:8: error: variable 'ix' set but not used [-Werror,-Wunused-but-set-variable]
            u_int ix;
                  ^

Here, 'ix' is a variable that is only used when debugging. Mark the
variable as potentially unused, to suppress the warning.

MFC after: 3 days

(cherry picked from commit 52c80d495a1b9dc756452ebcbb945906ea3cf23a)

23 months agoAdjust nvd_{load,unload}() definitions to avoid clang 15 warnings
Dimitry Andric [Tue, 19 Jul 2022 20:05:42 +0000 (22:05 +0200)]
Adjust nvd_{load,unload}() definitions to avoid clang 15 warnings

With clang 15, the following -Werror warnings are produced:

    sys/dev/nvd/nvd.c:150:9: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    nvd_load()
            ^
             void
    sys/dev/nvd/nvd.c:166:11: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    nvd_unload()
              ^
               void

This is because nvd_load() and nvd_unload() are declared with a (void)
argument list, but defined with an empty argument list. Make the
definitions match the declarations.

MFC after: 3 days

(cherry picked from commit c46c9b3f5f1eb5575a5e42f52872dbea9cf7516f)

23 months agoFix unused variable warning in if_alc.c
Dimitry Andric [Sat, 16 Jul 2022 15:06:31 +0000 (17:06 +0200)]
Fix unused variable warning in if_alc.c

With clang 15, the following -Werror warning is produced:

    sys/dev/alc/if_alc.c:3441:6: error: variable 'prog' set but not used [-Werror,-Wunused-but-set-variable]
            int prog;
                ^

The 'prog' variable seems to be a left-over from some debugging code
that no longer exists, and can be removed without any functional change.

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

(cherry picked from commit 64741244fc4588eefd954948b77ddf2706448ecd)

23 months agoSuppress unused variable warning in ip_dummynet.c
Dimitry Andric [Tue, 19 Jul 2022 19:43:46 +0000 (21:43 +0200)]
Suppress unused variable warning in ip_dummynet.c

With clang 15, the following -Werror warning is produced:

    sys/netpfil/ipfw/ip_dummynet.c:802:6: error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable]
            int n = 0; /* only for stats */
                ^

Here, 'n' is a variable that is only used when debugging. Mark the
variable as potentially unused, to suppress the warning.

MFC after: 3 days

(cherry picked from commit 5c329f0a4d32cec54250ec2d3f61455e85137a6f)

23 months agoFix unused variable warning in acpica's nsaccess.c
Dimitry Andric [Wed, 20 Jul 2022 19:10:43 +0000 (21:10 +0200)]
Fix unused variable warning in acpica's nsaccess.c

With clang 15, the following -Werror warning is produced:

    sys/contrib/dev/acpica/components/namespace/nsaccess.c:452:29: error: variable 'NumCarats' set but not used [-Werror,-Wunused-but-set-variable]
        UINT32                  NumCarats;
                                ^

Here, 'NumCarats' is a variable that is only used when debugging. Since
acpica is contributed code, suppress the warning with a compile flag.

MFC after: 3 days

(cherry picked from commit 3c9a0112bae6408892123b04a6ba5c6ee0780937)

23 months agoSuppress unused variable warning in if_malo.c
Dimitry Andric [Tue, 19 Jul 2022 19:17:03 +0000 (21:17 +0200)]
Suppress unused variable warning in if_malo.c

With clang 15, the following -Werror warning is produced:

    sys/dev/malo/if_malo.c:1573:8: error: variable 'ix' set but not used [-Werror,-Wunused-but-set-variable]
            u_int ix;
                  ^

Here, 'ix' is a variable that is only used when MALO_DEBUG is defined.
Mark the variable as potentially unused, to suppress the warning.

MFC after: 3 days

(cherry picked from commit 218634014374de0032fcdd56656ed6b3650634d2)

23 months agoSuppress unused variable warning in mfi.c
Dimitry Andric [Tue, 19 Jul 2022 19:38:41 +0000 (21:38 +0200)]
Suppress unused variable warning in mfi.c

With clang 15, the following -Werror warnings are produced:

    sys/dev/mfi/mfi.c:3698:6: error: variable 'timedout' set but not used [-Werror,-Wunused-but-set-variable]
            int timedout;
                ^
    sys/dev/mfi/mfi.c:3742:6: error: variable 'timedout' set but not used [-Werror,-Wunused-but-set-variable]
            int timedout = 0;
                ^

Here, 'timedout' are variables that are only used when debugging,
requiring #if 0 statements to be modified. Mark the variables as
potentially unused, to suppress the warnings.

MFC after: 3 days

(cherry picked from commit 3dbe05f61b65a73582aefdc2ee5a50ad2b4390ef)

23 months agoAdjust prototype_unload() definition to avoid clang 15 warning
Dimitry Andric [Tue, 19 Jul 2022 20:10:03 +0000 (22:10 +0200)]
Adjust prototype_unload() definition to avoid clang 15 warning

With clang 15, the following -Werror warnings is produced:

    sys/cddl/dev/prototype.c:99:17: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    prototype_unload()
                    ^
                     void

This is because prototype_unload() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

(cherry picked from commit 9a979788832e1c31d58923e4c780a6c4b05335d0)

23 months agoAdjust t4_tracer_mod{load,unload}() definitions to avoid clang 15 warnings
Dimitry Andric [Tue, 19 Jul 2022 18:20:21 +0000 (20:20 +0200)]
Adjust t4_tracer_mod{load,unload}() definitions to avoid clang 15 warnings

With clang 15, the following -Werror warnings are produced:

    sys/dev/cxgbe/t4_tracer.c:234:18: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    t4_tracer_modload()
                     ^
                      void
    sys/dev/cxgbe/t4_tracer.c:243:20: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    t4_tracer_modunload()
                       ^
                        void

This is because t4_tracer_modload() and t4_tracer_modunload() are
declared with a (void) argument list, but defined with an empty argument
list. Make the definitions match the declarations.

MFC after: 3 days

(cherry picked from commit 54e5efb2643ec5f4bf40fef2a1937cd5449a58a0)

23 months agoAdjust db_flush_line() definition to avoid clang 15 warning
Dimitry Andric [Tue, 19 Jul 2022 18:31:08 +0000 (20:31 +0200)]
Adjust db_flush_line() definition to avoid clang 15 warning

With clang 15, the following -Werror warnings is produced:

    sys/ddb/db_lex.c:94:14: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    db_flush_line()
                 ^
                  void

This is because db_flush_line() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

(cherry picked from commit 939cb349b2ca4d3fcdc72ab1258eadee5e54881c)

23 months agoAdjust profile_unload() definition to avoid clang 15 warning
Dimitry Andric [Tue, 19 Jul 2022 18:42:52 +0000 (20:42 +0200)]
Adjust profile_unload() definition to avoid clang 15 warning

With clang 15, the following -Werror warnings is produced:

    sys/cddl/dev/profile/profile.c:640:15: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    profile_unload()
                  ^
                   void

This is because profile_unload() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

(cherry picked from commit 2d03b58f9a3d5ec1deb35de594fcee22d06bfbb2)

23 months agoRemove unnecessary const and volatile qualifiers from __fp_type_select()
Dimitry Andric [Thu, 14 Jul 2022 11:20:52 +0000 (13:20 +0200)]
Remove unnecessary const and volatile qualifiers from __fp_type_select()

Since https://github.com/llvm/llvm-project/commit/ca75ac5f04f2, clang 15
has a new warning about _Generic selection expressions, such as used in
math.h:

    lib/libc/gdtoa/_ldtoa.c:82:10: error: due to lvalue conversion of the controlling expression, association of type 'volatile float' will never be selected because it is qualified [-Werror,-Wunreachable-code-generic-assoc]
            switch (fpclassify(u.e)) {
                    ^
    lib/msun/src/math.h:109:2: note: expanded from macro 'fpclassify'
            __fp_type_select(x, __fpclassifyf, __fpclassifyd, __fpclassifyl)
            ^
    lib/msun/src/math.h:85:14: note: expanded from macro '__fp_type_select'
        volatile float: f(x),                                               \
                 ^

This is because the controlling expression always undergoes lvalue
conversion first, dropping any cv-qualifiers. The 'const', 'volatile',
and 'volatile const' associations will therefore never be used.

MFC after: 1 week
Reviewed by: theraven
Differential Revision: https://reviews.freebsd.org/D35815

(cherry picked from commit e50027e38d4f93887691f87b024e0abf37e98c78)

23 months agoAdjust dtnfsclient_unload() definition to avoid clang 15 warning
Dimitry Andric [Tue, 19 Jul 2022 18:41:24 +0000 (20:41 +0200)]
Adjust dtnfsclient_unload() definition to avoid clang 15 warning

With clang 15, the following -Werror warnings is produced:

    sys/fs/nfsclient/nfs_clkdtrace.c:544:19: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    dtnfsclient_unload()
                      ^
                       void

This is because dtnfsclient_unload() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

(cherry picked from commit 276099434d35b0abd09da946f06c8b8d9765452b)

23 months agoAdjust dtrace_getf_barrier() definition to avoid clang 15 warning
Dimitry Andric [Tue, 19 Jul 2022 18:46:18 +0000 (20:46 +0200)]
Adjust dtrace_getf_barrier() definition to avoid clang 15 warning

With clang 15, the following -Werror warnings is produced:

    sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c:17019:20: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    dtrace_getf_barrier()
       ^
void

This is because dtrace_getf_barrier() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

(cherry picked from commit bd0e3cc2e71079f54785b7a395faf3a66426936e)

23 months agoAdjust fbd_list() definition to avoid clang 15 warning
Dimitry Andric [Tue, 19 Jul 2022 18:35:37 +0000 (20:35 +0200)]
Adjust fbd_list() definition to avoid clang 15 warning

With clang 15, the following -Werror warnings is produced:

    sys/dev/fb/fbd.c:205:9: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    fbd_list()
            ^
             void

This is because fbd_list() is declared with a (void) argument list, but
defined with an empty argument list. Make the definition match the
declaration.

MFC after: 3 days

(cherry picked from commit 9863e501c8d482dc47e856a2778dc3cbf6eb6d22)

23 months agoAdjust dtmalloc_unload() definition to avoid clang 15 warning
Dimitry Andric [Tue, 19 Jul 2022 18:24:41 +0000 (20:24 +0200)]
Adjust dtmalloc_unload() definition to avoid clang 15 warning

With clang 15, the following -Werror warnings is produced:

    sys/cddl/dev/dtmalloc/dtmalloc.c:177:16: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    dtmalloc_unload()
                   ^
                    void

This is because dtmalloc_unload() is declared with a (void) argument
list, but defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

(cherry picked from commit a0c55bac79ef684db5f3645fdc1e0fd8da827985)

23 months agoAdjust dtrace_unload() definition to avoid clang 15 warning
Dimitry Andric [Tue, 19 Jul 2022 18:48:47 +0000 (20:48 +0200)]
Adjust dtrace_unload() definition to avoid clang 15 warning

With clang 15, the following -Werror warnings is produced:

    In file included from sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c:18440:
    sys/cddl/dev/dtrace/dtrace_unload.c:26:14: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    dtrace_unload()
                 ^
                  void

This is because dtrace_unload() is declared with a (void) argument list,
but defined with an empty argument list. Make the definition match the
declaration.

MFC after: 3 days

(cherry picked from commit 6f5f44562a72e739a39057a4661a56498e4c79b5)

23 months agotelnet: Fix telnet segfault when invalid set or help help commands
Cy Schubert [Thu, 14 Jul 2022 04:42:06 +0000 (21:42 -0700)]
telnet: Fix telnet segfault when invalid set or help help commands

Silently ignore invalid set ' ' and invalid help help commands.
This is the same fix applied by NetBSD in hg commit 1019940:4f248823eaff.

PR: 265097
Reported by: Simon Josefsson <simon@josefsson.org>
Obtained from: NetBSD hg commit 1019940:4f248823eaff
NetBSD PR/56918

(cherry picked from commit a7399ea2dd7810e76dcfd52248764cb8004d49a4)

23 months agorescure.8: Do not recommend release artifact disc2
Mateusz Piotrowski [Thu, 30 Jun 2022 11:28:00 +0000 (13:28 +0200)]
rescure.8: Do not recommend release artifact disc2

The FreeBSD project does not publish disc2 image anymore.

MFC after: 2 weeks

(cherry picked from commit 7963c02c9bc222e8ac8c1a3acb87451bd74b9733)

23 months agosysctl.conf.5: Document rc.d/sysctl and rc.d/sysctl_lastload
Mateusz Piotrowski [Thu, 30 Jun 2022 13:27:21 +0000 (15:27 +0200)]
sysctl.conf.5: Document rc.d/sysctl and rc.d/sysctl_lastload

Also, update the BUGS section. The example describes an issue, which is
not true anymore thanks to sysctl_lastload. Point readers to rcorder(8)
instead.

MFC after: 2 weeks

(cherry picked from commit 383ccaa4050e3cbbd8ce8163c8aebd07c3d94ab1)

23 months agorc.conf.5: Improve documentation of <name>_oomprotect
Mateusz Piotrowski [Thu, 7 Jul 2022 18:01:57 +0000 (20:01 +0200)]
rc.conf.5: Improve documentation of <name>_oomprotect

Apart from improving readability, this commit mentions that
<name>_oomprotect is ignored in a jail environment. Also, replace
${name}_cmd with the correct ${argument}_cmd and point the reader to
rc.subr(8).

MFC after: 1 week

(cherry picked from commit df1817a81e891c4850157e7f21f94b113d663bec)

23 months agorc.conf(5): Add _limits, _login_class, and _oomprotect
Daniel Ebdrup Jensen [Tue, 18 May 2021 12:46:41 +0000 (14:46 +0200)]
rc.conf(5): Add _limits, _login_class, and _oomprotect

Add a few very useful variables that might easily be overlooked, since
they're only documented in rc.subr(8) which might not be the first place
that people look.

At least _oomprotect has existed since 11.0-RELEASE, and doesn't appear
to be very well-known. While the others aren't as new, in my estimation,
a lot more people would use them if they knew about them.

While here, also add a reference to rc.subr(8) and login.conf(5), and
sort the variables alphabetically.

Reported by:  Daniel Dettlaff <dmilith at gmail.com>
Reviewed by: ceri, gbe, 0mp, ygy, a.wolk, pauamma

(cherry picked from commit bd6dce978c1a4d4472c98ff5685de3c2f2bd0203)

23 months agorc.conf.5: -Tlint fixes.
Ceri Davies [Thu, 1 Jul 2021 21:51:37 +0000 (22:51 +0100)]
rc.conf.5: -Tlint fixes.

(cherry picked from commit 2ce58512957ec373abfb71712687d7e7b6abea82)

23 months agorc.subr: Make sure oomprotect protects existing children
Mike Walker [Thu, 7 Jul 2022 20:28:37 +0000 (22:28 +0200)]
rc.subr: Make sure oomprotect protects existing children

The rc(8) framework support protecting services from OOM killer.
The current implementation applies the protection after the service has
already started. This works fine if only the main process is to be
protected (*_oomprotect=yes). However, the current implementation fails
to protect existing children when children are also to be protected
(*_oomprotect=all). This patch fixes that.

Note: it is not easy to apply the protectoin earlier because we want to
support both the services which use the "command" variable and those
that use the "start_cmd" variable.

PR: 256148
Approved by: adrian, osogbo
Tested by: Jamie Landeg-Jones <jamie@catflap.org>
Fixes: 3bead71e959d - Add a global option where we can protect
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D35747

(cherry picked from commit 68e035c0172b441db772de41ad0f8977679bfedc)

23 months agoprotect.1: Document that protect(1) does not work in jails
Mateusz Piotrowski [Mon, 11 Jul 2022 22:43:27 +0000 (00:43 +0200)]
protect.1: Document that protect(1) does not work in jails

The reason is that in order to protect a process procctl(2) needs
the PRIV_VM_MADV_PROTECT privilege, which is currently denied in jails
(see kern_jail.c).

MFC after: 1 week

(cherry picked from commit 6452fb1e87ed9d00b52fa1e63e7c3a7516c9586c)

23 months agoprotect.1: Improve synopsis
Mateusz Piotrowski [Thu, 7 Jul 2022 13:12:50 +0000 (15:12 +0200)]
protect.1: Improve synopsis

While here, make the list's -width argument a bit shorter for
readability.

MFC after: 3 days

(cherry picked from commit cb56f86025b88bc4174aa668b3966886b8420955)

23 months agoprotect(1): Correct typo and add newline
Daniel Ebdrup Jensen [Tue, 12 Apr 2022 10:38:50 +0000 (12:38 +0200)]
protect(1): Correct typo and add newline

Fix a typo, and move a sentence onto a new line in accordance with
mdoc(7) syntax.

While here, also remember to bump .Dd accordingly, as it was missed in
the prior commit.

Reported by: maxim@

(cherry picked from commit bd1eafcdd02a6f559844aafe0dd0df34a356259d)

23 months agoprotect.1: document existence of _oomprotect
Adam Wolk [Mon, 11 Apr 2022 22:23:43 +0000 (00:23 +0200)]
protect.1: document existence of _oomprotect

Improve discoverability of the functionality by mentioning in the
userland tool manual. Add a SEE ALSO entry to rc.conf(5) where more
details are provided.

Sponsored by:   Fudo Security (a.wolk)
Differential Revision: https://reviews.freebsd.org/D30334

(cherry picked from commit c8b6be0f7d1b92d11b279761685f61f6702700a1)

23 months agojail.8: Fix formatting of synopsis and some code examples
Mateusz Piotrowski [Mon, 18 Jul 2022 11:38:00 +0000 (13:38 +0200)]
jail.8: Fix formatting of synopsis and some code examples

MFC after: 3 days

(cherry picked from commit 203be0938dc5e1bd46b028f72077f8531e98a6cd)

23 months agoifconfig.8: Prefer consistent terminologies
Zhenlei Huang [Wed, 29 Jun 2022 06:55:36 +0000 (08:55 +0200)]
ifconfig.8: Prefer consistent terminologies

Reviewed by: pauamma_gundo.com, email_luiz.eng.br
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35384

(cherry picked from commit ccc48995c2cffd70256237e6f2d478c4c878db76)

23 months agoRewrite function definitions in the UFS/FFS code base with identifier lists.
Kirk McKusick [Wed, 13 Jul 2022 21:06:43 +0000 (14:06 -0700)]
Rewrite function definitions in the UFS/FFS code base with identifier lists.

No functional change to the code.

(cherry picked from commit 064e6b4303d8aec9cfd27653d4dd2abea829a6c7)

Fixes to build from 064e6b4:

(cherry picked from commit c792466f878a082a63683d3a8a1f7b468081d835)

(cherry picked from commit 2e66649e4f34188d92bd32b5ba7fde8d1e86ef40)

23 months agoFix clang 15 warning in cxgbe
Dimitry Andric [Sat, 16 Jul 2022 19:19:51 +0000 (21:19 +0200)]
Fix clang 15 warning in cxgbe

Clang 15 warns:

    sys/dev/cxgbe/cudbg/cudbg_lib.c:2949:6: error: variable 'i' set but not used [-Werror,-Wunused-but-set-variable]
            int i = 0;
                ^

Apparently 'i' was meant as the current retry counter, but '1' was used
in the while loop comparison instead, making the loop potentially
infinite, if 'busy' never gets reset.

MFC after: 3 days
Reviewed by: np
Differential Revision: https://reviews.freebsd.org/D35834

(cherry picked from commit fb0493d55998eeb9f062b15b40924ff722f3eba5)

23 months agoUnlock inp when handling TCP_MD5SIG socket options
Claudio Jeker [Thu, 23 Jun 2022 14:50:47 +0000 (15:50 +0100)]
Unlock inp when handling TCP_MD5SIG socket options

Unlock the inp when hanlding TCP_MD5SIG socket options. tcp_ipsec_pcbctl
handles locking the inp when the option is being modified.

This was found by Claudio Jeker while working on the OpenBGPd port.

On 14 we get a panic when trying to call getsockopt, on 13.1 the process
locks up using 100% CPU.

Reviewed by: rscheff (transport), tuexen
MFC after: 3 days
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D35532

(cherry picked from commit 97453e5e7258158042795740f2736cfca972269d)

23 months agoaio: Improve UMA usage
Mark Johnston [Mon, 20 Jun 2022 16:17:11 +0000 (12:17 -0400)]
aio: Improve UMA usage

- Remove the AIO proc zone.  This zone gets one allocation per AIO
  daemon process, which isn't enough to warrant a dedicated zone.  Plus,
  unlike other AIO structures, aiops are small (32 bytes with LP64), so
  UMA doesn't provide better space efficiency than malloc(9).  Change
  one of the malloc types in vfs_aio.c to make it more general.

- Don't set the NOFREE flag on the other AIO zones.  This flag means
  that memory allocated to the AIO subsystem is never freed back to the
  VM, so it's always preferable to avoid using it when possible.  NOFREE
  was set without explanation when AIO was converted to use UMA 20 years
  ago, but it does not appear to be required; all of the structures
  allocated from UMA (per-process kaioinfo, kaiocb, and aioliojob) keep
  track of references and get freed only when none exist.  Plus, these
  structures will contain dangling pointer after they're freed (e.g.,
  the "cred", "fd_file" and "uiop" fields of struct kaiocb), so
  use-after-frees are dangerous even when the structures themselves are
  type-stable.

Reviewed by: asomers
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 9553bc89dbc38a861a750ddc605cec0381788c5d)

23 months agotime: Make realitexpire() local to kern_time.c
Mark Johnston [Wed, 13 Jul 2022 13:57:28 +0000 (09:57 -0400)]
time: Make realitexpire() local to kern_time.c

Sponsored by: The FreeBSD Foundation

(cherry picked from commit ef221ff645322f0ec147c706652744869774e128)

23 months agoAdjust agp_find_device() definition in agp.c to avoid clang 15 warning
Dimitry Andric [Sat, 16 Jul 2022 14:46:21 +0000 (16:46 +0200)]
Adjust agp_find_device() definition in agp.c to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    sys/dev/agp/agp.c:910:16: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    agp_find_device()
                   ^
                    void

This is because agp_find_device() is declared with a (void) argument
list, and defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

(cherry picked from commit c0817e2aba26ceb683e9c649c22d7fcd9a921231)

23 months agoRemove unused but set variable in cxgb_sge
Dimitry Andric [Sat, 16 Jul 2022 18:16:36 +0000 (20:16 +0200)]
Remove unused but set variable in cxgb_sge

Clang 15 warns:

    sys/dev/cxgb/cxgb_sge.c:1290:21: error: variable 'txsd' set but not used [-Werror,-Wunused-but-set-variable]
            struct tx_sw_desc *txsd = &txq->sdesc[txqs->pidx];
                               ^

It appears 'txsd' is a leftover from a previous refactoring (see
3f345a5d09b6), but is no longer used for anything, and can be removed
without any functional change.

MFC after: 3 days
Reviewed by: np
Differential Revision: https://reviews.freebsd.org/D35833

(cherry picked from commit cab040039d6fe1b2a6de8f2ba2cc882c313d3c75)

23 months agoWPA_DISTDIR does not need to end in a slash
Dimitry Andric [Sat, 16 Jul 2022 15:45:26 +0000 (17:45 +0200)]
WPA_DISTDIR does not need to end in a slash

Since all uses of the macro also append a slash, this leads to double
slashes.

MFC after: 3 days

(cherry picked from commit 9917049b60f7cf7345a09d2bc22d51764a477984)

23 months agoAdjust parse() definition in boot2 to avoid clang 15 warning
Dimitry Andric [Fri, 15 Jul 2022 19:15:11 +0000 (21:15 +0200)]
Adjust parse() definition in boot2 to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    stand/i386/boot2/boot2.c:358:6: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]

This is because parse() is declared with a (void) argument list, and
defined with an empty argument list. Make the definition match the
declaration.

MFC after: 3 days

(cherry picked from commit e60f6384f9dbe3abe83e59acf0997c591752ff81)

23 months agoMerge fix for zfs readmmap test from CheriBSD
Dimitry Andric [Fri, 15 Jul 2022 19:10:09 +0000 (21:10 +0200)]
Merge fix for zfs readmmap test from CheriBSD

Merge commit 1737d8397a0 by Brooks Davis:

  time() is declared in time.h

This fixes a -Werror warning from clang 15:

  tests/sys/cddl/zfs/bin/readmmap.c:97:9: error: call to undeclared function 'time'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

Obtained from: https://github.com/CTSRD-CHERI/cheribsd/commit/1737d8397a0
MFC after: 3 days

(cherry picked from commit 47be48457393ba6747cc3144272b1f4d8b9077fb)

23 months agoqat(4): Fix a typo in a source code comment
Gordon Bergling [Sat, 16 Jul 2022 11:47:14 +0000 (13:47 +0200)]
qat(4): Fix a typo in a source code comment

- s/bufer/buffer/

Obtained from: NetBSD

(cherry picked from commit e4a203234add5c57e5081521a4f4018bae7e398d)

23 months agopfctl(8): Fix a typo in a source code comment
Gordon Bergling [Sat, 16 Jul 2022 11:48:30 +0000 (13:48 +0200)]
pfctl(8): Fix a typo in a source code comment

- s/bufer/buffer/

(cherry picked from commit c9856c4ffbda670f3fdc03d4c046a70e3e225f68)

23 months agoqat(4): Fix a typo in a source code comment
Gordon Bergling [Sat, 16 Jul 2022 12:26:24 +0000 (14:26 +0200)]
qat(4): Fix a typo in a source code comment

- s/mirco/micro/

Obtained from: NetBSD

(cherry picked from commit db1c3dbe82953edda57f85f2e6d65ded272e5b0d)

23 months agocrunchide(1): Fix a typo in a comment
Gordon Bergling [Sat, 16 Jul 2022 11:32:47 +0000 (13:32 +0200)]
crunchide(1): Fix a typo in a comment

- s/maek/make/

Obtained from: NetBSD

(cherry picked from commit d34de8d378b36c48b3ae46a0abf8d8eb041877ad)

23 months agolinux(4): Fix a typo in a source code comment
Gordon Bergling [Sat, 16 Jul 2022 11:39:17 +0000 (13:39 +0200)]
linux(4): Fix a typo in a source code comment

- s/alredy/already/

(cherry picked from commit d3d3b76c1b614b54d255e4248c45f43b20d519b8)

23 months agocxgbe(4): Fix a typo in a source code comment
Gordon Bergling [Sat, 16 Jul 2022 11:38:57 +0000 (13:38 +0200)]
cxgbe(4): Fix a typo in a source code comment

- s/alredy/already/

(cherry picked from commit 63303133a7f9cd616eeea410a45fd0ae4eef70e6)

23 months agox86: Check for APIC presence only if DEV_ATPIC is defined
Mark Johnston [Tue, 28 Dec 2021 22:42:12 +0000 (17:42 -0500)]
x86: Check for APIC presence only if DEV_ATPIC is defined

We only attempt to gracefully handle absence of an APIC if "device
atpic" is defined in the kernel configuration.

Suggested by: kib
Reviewed by: jhb, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit deca0138dc659747c9edd4648690cdfdb01f58e8)

23 months agotimecounter: Load the currently selected tc once in tc_windup()
Mark Johnston [Fri, 29 Oct 2021 18:29:22 +0000 (14:29 -0400)]
timecounter: Load the currently selected tc once in tc_windup()

Reported by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 26f76aea2d276aacb69a1f9d78558d6107155aed)

23 months agoktls: Zero out TLS_GET_RECORD control messages
Mark Johnston [Thu, 20 Jan 2022 20:42:46 +0000 (15:42 -0500)]
ktls: Zero out TLS_GET_RECORD control messages

Otherwise we end up copying one uninitialized byte into the socket
buffer.

Reported by: KMSAN
Reviewed by: jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6be8944d96d2cb5938b69c63b483efa616eafb56)

23 months agogeli: Add a chicken switch for unmapped I/O
Mark Johnston [Mon, 18 Apr 2022 21:16:10 +0000 (17:16 -0400)]
geli: Add a chicken switch for unmapped I/O

We have a report of a panic in GELI that appears to go away when
unmapped I/O is disabled.  Add a tunable to make such investigations
easier in the future.  No functional change intended.

PR: 262894
Reviewed by: asomers
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 081b4452a758dd81dcdc68ffb6f7bad901d53e3d)

23 months agorc: Fix quoting in the zpoolreguid script
Mark Johnston [Tue, 31 May 2022 14:51:28 +0000 (10:51 -0400)]
rc: Fix quoting in the zpoolreguid script

Reported by: 0mp
Fixes: 227caacc918a ("rc: Add a zpoolreguid rc.d script")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 89e58b955cf5d2187af5f2460d11b64f4d229c8a)

23 months agorc: Add a zpoolreguid rc.d script
Mark Johnston [Mon, 30 May 2022 14:43:44 +0000 (10:43 -0400)]
rc: Add a zpoolreguid rc.d script

If one boots up multiple copies of a template VM image containing a
zpool, the pool GUIDs will be identical, making it impossible to, e.g.,
share datasets between them.

This diff introduces a simple workaround for the problem: one can use
the script to, upon first boot, assign a new GUID to one or more zpools.
This will be useful when building ZFS-based VM images from release(7).

Reviewed by: mav, allanjude, asomers
Reviewed by: Pau Amma (docs)
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 227caacc918a8c9b32608cff42116e7d890b9ddc)

23 months agovm_object: Assert that overcommit charge is released in the object dtor
Mark Johnston [Tue, 12 Jul 2022 12:53:05 +0000 (08:53 -0400)]
vm_object: Assert that overcommit charge is released in the object dtor

Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit e1979b45b63725972d394562f95d89f8cc9a0bb4)

23 months agovm_map: Simplify a call to vm_object_allocate_anon()
Mark Johnston [Tue, 12 Jul 2022 12:53:17 +0000 (08:53 -0400)]
vm_map: Simplify a call to vm_object_allocate_anon()

vm_object_allocate_anon() automatically sets "charge" to 0 if no cred
reference is provided, so the caller doesn't need any conditional logic.

No functional change intended.

Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 70b2996120a7f96527ce5c676f938886e8aa292d)

23 months agoRevert "bsdinstall: add knob to set ASLR sysctls"
Marcin Wojtas [Fri, 12 Nov 2021 19:32:57 +0000 (20:32 +0100)]
Revert "bsdinstall: add knob to set ASLR sysctls"

This reverts commit 020f4112559ebf7e94665c9a69f89d21929ce82a.

Because now ASLR is enabled by default for 64-bit architectures
and the purpose of the installation menu is to allow choosing
additional 'mitigation'/'hardening' options that are originally
disabled, remove the ASLR knob from bsdinstall.

Discussed with: emaste
Obtained from: Semihalf
Sponsored by: Stormshield

(cherry picked from commit bf410c6eda515364db5f6ed74b765efdec0595ae)

23 months agoEnable ASLR by default for 64-bit executables
Marcin Wojtas [Sun, 24 Oct 2021 14:53:06 +0000 (16:53 +0200)]
Enable ASLR by default for 64-bit executables

Address Space Layout Randomization (ASLR) is an exploit mitigation
technique implemented in the majority of modern operating systems.
It involves randomly positioning the base address of an executable
and the position of libraries, heap, and stack, in a process's address
space. Although over the years ASLR proved to not guarantee full OS
security on its own, this mechanism can make exploitation more difficult.

Tests on the tier 1 64-bit architectures demonstrated that the ASLR is
stable and does not result in noticeable performance degradation,
therefore it should be safe to enable this mechanism by default.
Moreover its effectiveness is increased for PIE (Position Independent
Executable) binaries. Thanks to commit 9a227a2fd642 ("Enable PIE by
default on 64-bit architectures"), building from src is not necessary
to have PIE binaries. It is enough to control usage of ASLR in the
OS solely by setting the appropriate sysctls.

This patch toggles the kernel settings to use address map randomization
for PIE & non-PIE 64-bit binaries. It also disables SBRK, in order
to allow utilization of the bss grow region for mappings. The latter
has no effect if ASLR is disabled, so apply it to all architectures.

As for the drawbacks, a consequence of using the ASLR is more
significant VM fragmentation, hence the issues may be encountered
in the systems with a limited address space in high memory consumption
cases, such as buildworld. As a result, although the tests on 32-bit
architectures with ASLR enabled were mostly on par with what was
observed on 64-bit ones, the defaults for the former are not changed
at this time. Also, for the sake of safety keep the feature disabled
for 32-bit executables on 64-bit machines, too.

The committed change affects the overall OS operation, so the
following should be taken into consideration:
* Address space fragmentation.
* A changed ABI due to modified layout of address space.
* More complicated debugging due to:
  * Non-reproducible address space layout between runs.
  * Some debuggers automatically disable ASLR for spawned processes,
    making target's environment different between debug and
    non-debug runs.

In order to confirm/rule-out the dependency of any encountered issue
on ASLR it is strongly advised to re-run the test with the feature
disabled - it can be done by setting the following sysctls
in the /etc/sysctl.conf file:
kern.elf64.aslr.enable=0
kern.elf64.aslr.pie_enable=0

Co-developed by: Dawid Gorecki <dgr@semihalf.com>
Reviewed by: emaste, kib
Obtained from: Semihalf
Sponsored by: Stormshield
MFC after: 1 month
Differential revision: https://reviews.freebsd.org/D27666

(cherry picked from commit b014e0f15bc73d80ef49b64fd1f8c29f469467cb)

23 months agostand/uboot: setup archsw before probing devices
Albert Jakiela [Tue, 28 Jun 2022 15:28:35 +0000 (17:28 +0200)]
stand/uboot: setup archsw before probing devices

In some cases ubldr would try to mount a disk device before
the archsw struct was filled with functions pointers.
This would result in a NULL pointer derefrence of the arch_getdev field.
Fix that filling the archsw functions earlier.
Note that this matches the EFI behavoiur.

Reviewed by: imp, mw
Sponsored by: Stormshield
Obtained from: Semihalf
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35670

(cherry picked from commit 1323f0aa9cb0392d2946226bd76f14463e875a60)

23 months agolockstat: Fix construction of comparision predicates
Kornel Dulęba [Mon, 4 Jul 2022 06:48:52 +0000 (08:48 +0200)]
lockstat: Fix construction of comparision predicates

Passing "0x%p" to sprintf results in double "0x" being printed.
This causes a dtrace script compilation failure when "-d" flag
is specified.
Fix that by removing the extraneous "0x".

Reviewed by: markj
Approved by: mw(mentor)
Obtained from: Semihalf
Sponsored by: Alstom
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35690

(cherry picked from commit 9dbacce2d48abf04b4d65d2994586e1ff44b08fb)

23 months agoe6000sw: Fix direct register write logic
Kornel Dulęba [Mon, 4 Jul 2022 06:53:41 +0000 (08:53 +0200)]
e6000sw: Fix direct register write logic

When accessing a register directly from etherswitchcfg one must specify
a register group(e.g. registers of portN) and the register offset within
the group. The latter is passed as the 5 least significant bits.
Extract the former by dividing the register address by 32, not by 5.

Approved by: mw(mentor)
Obtained from: Semihalf
Sponsored by: Stormshield
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35672

(cherry picked from commit 66548259075788d2084e9da1c5df7b88f44c4b4d)

23 months agoigc: Change default duplex setting
Kornel Dulęba [Thu, 30 Jun 2022 11:57:58 +0000 (13:57 +0200)]
igc: Change default duplex setting

During media selection through ifconfig one might not specify
the duplex setting through the mediaopt flag.
In that case the igc driver would default to full-duplex.
The problem with this approach is that e1000(em/igb) driver
defaults to half-duplex.
Because of that if one connects both NICs and sets media to
e.g. 100baseTX on both of them no link will be found.
Fix that by matching igc behaviour with what e1000 does.

Reviewed by: grehan
Approved by: mw(mentor)
Obtained from: Semihalf
Sponsored by: Stormshield
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35673

(cherry picked from commit 3b8d04f845b416d29a258658b8a48d1afb4a2e81)

23 months agoDecode the arm64 SVE ID register
Andrew Turner [Tue, 28 Jun 2022 11:44:49 +0000 (11:44 +0000)]
Decode the arm64 SVE ID register

The field values are only valid when the ID_AA64PFR0_EL1.SVE or
ID_AA64PFR1_EL1.SME vields are non-zero. When this is not the case
the register is reserved as zero so is safe to read, but the SVEver
field will be incorrect so only print the decoded register when
the SVE or SME fields indicate it is valid.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit cb91f112a3dc6cb68fe618623f59cee576ce4d14)

23 months agoAllow use of the arm64 unnamed register form
Andrew Turner [Wed, 29 Jun 2022 16:34:41 +0000 (17:34 +0100)]
Allow use of the arm64 unnamed register form

On arm64 all registers have a name that encodes op0, op1, CRn, CRm, and
op2 that are used to encode the register in the instruction. As some
registers we need to access may not be supportedby older compilers, or
are only supported when specific extensions are enabled support this
alternative form.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 66ba742d2e6c950611fa3d557512133b0216daa7)

23 months agoSplit out vfp_new_thread
Andrew Turner [Fri, 24 Jun 2022 11:53:15 +0000 (11:53 +0000)]
Split out vfp_new_thread

To keep the vfp thread creation code in one place move into vfp.c. This
will also help with adding SVE support as it depends on VFP.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35615

(cherry picked from commit baf8f20a4af43283a1fbee49b0c2ad906074f20f)

23 months agoAdd the SVE reigster definitions
Andrew Turner [Fri, 24 Jun 2022 11:51:26 +0000 (11:51 +0000)]
Add the SVE reigster definitions

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 2f317e7312971812bde8b8b0d9da21a2c1d378a3)

23 months agoTrap SVE instructions until we have SVE support
Andrew Turner [Fri, 24 Jun 2022 11:50:28 +0000 (11:50 +0000)]
Trap SVE instructions until we have SVE support

When running on hardware that supports SVE send the correct signal when
an SVE instruction is run.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit ffa5bf8b600a77838be8fbf383382a2e7bafedc6)

23 months agoAdd the arm64 FPAC exception value
Andrew Turner [Mon, 4 Jul 2022 08:30:49 +0000 (09:30 +0100)]
Add the arm64 FPAC exception value

This is currently unused, but is useful to reduce conflicts when MFCing
patches from main.

Extracted from 85b7c566f15 ("Add arm64 pointer authentication support").

Sponsored by: The FreeBSD Foundation