]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 months agopdinit(): Fix comment
Olivier Certner [Tue, 26 Sep 2023 10:26:46 +0000 (12:26 +0200)]
pdinit(): Fix comment

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

(cherry picked from commit 56bb3ce091371ffd95711c65e1eff306a19435e2)

Approved by:    markj (mentor)

6 months agosetusercontext(): Apply personal settings only on matching effective UID
Olivier Certner [Tue, 30 May 2023 16:35:08 +0000 (18:35 +0200)]
setusercontext(): Apply personal settings only on matching effective UID

Commit 35305a8dc114 (r211393) added a check on whether 'uid' was equal
to getuid() before calling setlogincontext().  Doing so still allows
a setuid program to apply resource limits and priorities specified in
a user-controlled configuration file ('~/.login_conf') where
a non-setuid program could not.  Plug the hole by checking instead that
the process' effective UID is the target one (which is likely what was
meant in the initial commit).

PR:                     271750
Reviewed by:            kib, des
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40351

(cherry picked from commit 892654fe9b5a9115815c30a423b8db47185aebbd)

Approved by:    markj (mentor)

6 months agologin_cap.c: Don't set errno to ERANGE on memory allocation failure
Olivier Certner [Thu, 25 May 2023 11:48:40 +0000 (13:48 +0200)]
login_cap.c: Don't set errno to ERANGE on memory allocation failure

Modified functions: login_getcaptime(), login_getcapnum(),
login_getcapsize().

They all call cgetstr(), which returns -2 on such conditions and already
sets errno to ENOMEM, arguably the appropriate value for these functions
as well.

No in-tree consumer currently checks for errno on error reported by
these functions, so this change has no other code impact.

Reviewed by:            kib
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40342

(cherry picked from commit b8c1aadef9d80786daf731300c33d3a001261422)

Approved by:    markj (mentor)

6 months agosetusercontext(): Fix gap when setting a realtime-class priority
Olivier Certner [Thu, 25 May 2023 07:10:27 +0000 (09:10 +0200)]
setusercontext(): Fix gap when setting a realtime-class priority

The login.conf's "priority" capability allows to set priorities in the
idle or realtime classes in addition to the classical nice values (-20
to 20), through a natural extension where values greater than 20 put the
processes in the idle class (with priority adjusted within RTP_PRIO_MIN
and RTP_PRIO_MAX, 21 being converted to 0, 22 to 1, etc.) and values
lower than -20 put the process in the realtime class (with priority
adjusted within RTP_PRIO_MIN and RTP_PRIO_MAX, -21 being converted to
RTP_PRIO_MAX (31), -22 to 30, etc.).

Before this fix, in the latter case (realtime class), -21 was converted
to 30, and RTP_PRIO_MAX (31) could never be specified.

While here, change the priority computation for the idle-class case to
be symmetrical and use RTP_PRIO_MIN (in practice, this changes nothing
at all, since RTP_PRIO_MIN is 0; but this is the correct theoretical
formula, which would work as well with other values of RTP_PRIO_MIN).

PR:                     271727
Reviewed by:            imp, kib
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40339

(cherry picked from commit bd572be78436473a2ad4c1b78728b739c74ef238)

Approved by:    markj (mentor)

6 months agosysctl(8): Mention more security.bsd knobs; Refer to security(7)
Olivier Certner [Thu, 17 Aug 2023 23:54:49 +0000 (01:54 +0200)]
sysctl(8): Mention more security.bsd knobs; Refer to security(7)

Reviewed by:            mhorne, pauamma_gundo.com, emaste
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D41113

(cherry picked from commit 8d7a48d367ffde2a29419ef943c4099984e3af4d)

Approved by:    markj (mentor)

6 months agoptrace(2): Disabling: Describe influence of security.bsd.see_jail_proc
Olivier Certner [Thu, 17 Aug 2023 23:54:48 +0000 (01:54 +0200)]
ptrace(2): Disabling: Describe influence of security.bsd.see_jail_proc

Reviewed by:            mhorne, emaste, pauamma_gundo.com
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D41109

(cherry picked from commit d952820105d6a2ad87ddf3bdc6c5fc5215d13b87)

Approved by:    markj (mentor)

6 months agosecurity(7): security.bsd.see*: Be more accurate
Olivier Certner [Thu, 17 Aug 2023 23:54:48 +0000 (01:54 +0200)]
security(7): security.bsd.see*: Be more accurate

Reviewed by:            mhorne, pauamma_gundo.com
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D41108

(cherry picked from commit 61b6e00bee1d39e9c688e728fbf3a4efcdb61e66)

Approved by:    markj (mentor)

6 months agocr_canseeothergids(): Policy change's manual pages impact
Olivier Certner [Thu, 17 Aug 2023 23:54:46 +0000 (01:54 +0200)]
cr_canseeothergids(): Policy change's manual pages impact

See previous commit that made cr_canseeothergids() use the new
realgroupmember() function, taking into account real group IDs instead
of effective ones.

PR:                     272093
Reviewed by:            pauamma_gundo.com, mhorne
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40644

(cherry picked from commit 0452dd841336cea7cd979b13ef12b6ea5e992eff)

Approved by:    markj (mentor)

6 months agocr_canseeothergids(): Use real instead of effective group membership
Olivier Certner [Thu, 17 Aug 2023 23:54:45 +0000 (01:54 +0200)]
cr_canseeothergids(): Use real instead of effective group membership

Using the effective group and not the real one when testing membership
has the consequence that unprivileged processes cannot see setuid
commands they launch until these have relinquished their privileges.
This is also in contradiction with how the similar cr_canseeotheruids()
works, i.e., by taking into account real user IDs.

Fix this by substituting groupmember() with realgroupmember().  While
here, simplify the code.

PR:                     272093
Reviewed by:            mhorne
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40642

(cherry picked from commit 91658080f1a598ddda03943a783c9a941199f7d2)

Approved by:    markj (mentor)

6 months agorealgroupmember(9): Link to groupmember(9), document the function
Olivier Certner [Thu, 17 Aug 2023 23:54:46 +0000 (01:54 +0200)]
realgroupmember(9): Link to groupmember(9), document the function

Reviewed by:            bcr (older version), mhorne
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40643

(cherry picked from commit 5d9f38405a10fdcd9fc108c940dcf2642e9f1833)

Approved by:    markj (mentor)

6 months agoNew realgroupmember()
Olivier Certner [Thu, 17 Aug 2023 23:54:45 +0000 (01:54 +0200)]
New realgroupmember()

Like groupmember(), but taking into account the real group instead of
the effective group.  Leverages the new supplementary_group_member()
function.

Reviewed by:            mhorne
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40641

(cherry picked from commit 2a2bfa6ad92e9c82dcc55733ad2fd58fd2ea7559)

Approved by:    markj (mentor)

6 months agogroupmember(): Extract the supplementary group search in a separate function
Olivier Certner [Thu, 17 Aug 2023 23:54:44 +0000 (01:54 +0200)]
groupmember(): Extract the supplementary group search in a separate function

This is in preparation for the introduction of the new realgroupmember()
function, which does the same search into supplementary groups as
groupmember().

Reviewed by:            mhorne
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40640

(cherry picked from commit b725f232f3b09b4bcbc426854fe1545234c66965)

Approved by:    markj (mentor)

6 months agoprison_check(9): Bring up-to-date with hierarchical jails
Olivier Certner [Thu, 17 Aug 2023 23:54:44 +0000 (01:54 +0200)]
prison_check(9): Bring up-to-date with hierarchical jails

Reviewed by:            bcr, emaste, pauamma_gundo.com, mhorne
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40639

(cherry picked from commit e9fdd494537ca45b14e0917e8bb1595b6460f3a3)

Approved by:    markj (mentor)

6 months agop_candebug(9): cr_bsd_visible() impacts, misc fixes
Olivier Certner [Thu, 17 Aug 2023 23:54:43 +0000 (01:54 +0200)]
p_candebug(9): cr_bsd_visible() impacts, misc fixes

Mention cr_bsd_visible(9).  Remove references to cr_canseeothergids(9)
and cr_canseeotheruids(9), as well as indirect references not
immediately useful.

Fix description of credentials checks to match reality.

Re-order errors to match code's check order.

Reviewed by:            bcr, pauamma_gundo.com
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40638

(cherry picked from commit eb94f24fab4b44f13ca045370d9fcf12ca8835f2)

Approved by:    markj (mentor)

6 months agop_cansee(9): Bring up-to-date, misc fixes
Olivier Certner [Thu, 17 Aug 2023 23:54:43 +0000 (01:54 +0200)]
p_cansee(9): Bring up-to-date, misc fixes

Essentially defer to cr_cansee(9), except for the specifics.

Be more specific on the return codes.

Reviewed by:            bcr, pauamma_gundo.com
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40637

(cherry picked from commit 2ede38aff5d4c91a17ab6d093f2e8cce24b5418b)

Approved by:    markj (mentor)

6 months agocr_cansee(9): cr_bsd_visible() impacts, simplifications
Olivier Certner [Thu, 17 Aug 2023 23:54:42 +0000 (01:54 +0200)]
cr_cansee(9): cr_bsd_visible() impacts, simplifications

Remove references to cr_canseeothergids(9) and cr_canseeotheruids(9).
Defer to cr_bsd_visible() for controlling sysctl(8) variables.

Reviewed by:            bcr, mhorne
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40636

(cherry picked from commit 82f9bc9ea8ed660c61050ad1d92f1a64108c7004)

Approved by:    markj (mentor)

6 months agocr_canseeotheruids(9): Revamp, mark as internal
Olivier Certner [Thu, 17 Aug 2023 23:54:42 +0000 (01:54 +0200)]
cr_canseeotheruids(9): Revamp, mark as internal

Significantly clarify.  Replace references to cr_canseeothergids(9) by
ones to cr_bsd_visible(9).

Reviewed by:            bcr, mhorne
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40635

(cherry picked from commit 4ddd253b38dff8725555355cc1b5238b1bbfd380)

Approved by:    markj (mentor)

6 months agogroupmember(9): Detail which groups are considered, simplify
Olivier Certner [Thu, 17 Aug 2023 23:54:41 +0000 (01:54 +0200)]
groupmember(9): Detail which groups are considered, simplify

Reviewed by:            mhorne
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40634

(cherry picked from commit 75a45ca3b34062fe793ae326ad9da614a1a06df1)

Approved by:    markj (mentor)

6 months agocr_canseeothergids(9): Revamp, mark as internal
Olivier Certner [Thu, 17 Aug 2023 23:54:41 +0000 (01:54 +0200)]
cr_canseeothergids(9): Revamp, mark as internal

Significantly clarify.  Replace references to cr_canseeotheruids(9) by
ones to cr_bsd_visible(9).

Reviewed by:            pauamma_gundo.com, mhorne
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40633

(cherry picked from commit 3fe9ea4d2d04d48a249b2e6161d416bb4d5b364e)

Approved by:    markj (mentor)

6 months agocr_bsd_visible(9): New man page
Olivier Certner [Thu, 17 Aug 2023 23:54:40 +0000 (01:54 +0200)]
cr_bsd_visible(9): New man page

Reviewed by:            bcr, pauamma_gundo.com
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40632

(cherry picked from commit 0d6bf73c4f20e6ed719c29c1b382d24bb0a81a2f)

Approved by:    markj (mentor)

6 months agocr_canseejailproc(9): New man page
Olivier Certner [Thu, 17 Aug 2023 23:54:40 +0000 (01:54 +0200)]
cr_canseejailproc(9): New man page

Reviewed by:            pauamma_gundo.com, mhorne
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40631

(cherry picked from commit 29d863bb7ffc692998f21fa3e7a91afa1151cf1c)

Approved by:    markj (mentor)

6 months agocr_canseeotheruids(), cr_canseeothergids(): Man pages: Impacts of rename
Olivier Certner [Thu, 17 Aug 2023 23:54:39 +0000 (01:54 +0200)]
cr_canseeotheruids(), cr_canseeothergids(): Man pages: Impacts of rename

When these functions were renamed 7 years ago, their man pages were not.
Rename the latter in accordance and fix the names inside them.  Fix
references to them as well.  Add the old man pages to the list of
obsolete files.

Reviewed by:            mhorne
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40630

(cherry picked from commit c59ab75c04fa32bc6d292596ff5e4593a05a6b1b)

Approved by:    markj (mentor)

6 months agoFix 'security.bsd.see_jail_proc' by using cr_bsd_visible()
Olivier Certner [Thu, 17 Aug 2023 23:54:38 +0000 (01:54 +0200)]
Fix 'security.bsd.see_jail_proc' by using cr_bsd_visible()

As implemented, this security policy would only prevent seeing processes
in sub-jails, but would not prevent sending signals to, changing
priority of or debugging processes in these, enabling attacks where
unprivileged users could tamper with random processes in sub-jails in
particular circumstances (conflated UIDs) despite the policy being
enforced.

PR:                     272092
Reviewed by:            mhorne
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40628

(cherry picked from commit 5817169bc4a06a35aa5ef7f5ed18f6cb35037e18)

Approved by:    markj (mentor)

6 months agoNew cr_bsd_visible(): Whether BSD policies deny seeing subjects/objects
Olivier Certner [Thu, 17 Aug 2023 23:54:38 +0000 (01:54 +0200)]
New cr_bsd_visible(): Whether BSD policies deny seeing subjects/objects

This is a new helper function that leverages existing code: It calls
successively cr_canseeotheruids(), cr_canseeothergids() and
cr_canseejailproc() (as long as the previous didn't deny access).  Will
be used in a subsequent commit.

Reviewed by:            mhorne
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40627

(cherry picked from commit e4a7b4f99cfd4931468c0866da4ae8b49cf5badb)

Approved by:    markj (mentor)

6 months agocr_canseejailproc(): New privilege, no direct check for UID 0
Olivier Certner [Thu, 17 Aug 2023 23:54:37 +0000 (01:54 +0200)]
cr_canseejailproc(): New privilege, no direct check for UID 0

Use priv_check_cred() with a new privilege (PRIV_SEEJAILPROC) instead of
explicitly testing for UID 0 (the former has been the rule for almost 20
years).

As a consequence, cr_canseejailproc() now abides by the
'security.bsd.suser_enabled' sysctl and MAC policies.

Update the MAC policies Biba and LOMAC, and prison_priv_check() so that
they don't deny this privilege.  This preserves the existing behavior
(the 'root' user is not restricted, even when jailed, unless
'security.bsd.suser_enabled' is not 0) and is consistent with what is
done for the related policies/privileges (PRIV_SEEOTHERGIDS,
PRIV_SEEOTHERUIDS).

Reviewed by:            emaste (earlier version), mhorne
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40626

(cherry picked from commit 7974ca1cdbee949f5e453eea112be265b425c407)

Approved by:    markj (mentor)

6 months agox86: AMD Zen2: Zenbleed chicken bit mitigation
Olivier Certner [Mon, 11 Sep 2023 14:18:30 +0000 (16:18 +0200)]
x86: AMD Zen2: Zenbleed chicken bit mitigation

Applies only to bare-metal Zen2 processors.  The system currently
automatically applies it to all of them.

Tunable/sysctl 'machdep.mitigations.zenbleed.enable' can be used to
forcibly enable or disable the mitigation at boot or run-time.  Possible
values are:

    0: Mitigation disabled
    1: Mitigation enabled
    2: Run the automatic determination.

Currently, value 2 is the default and has identical effect as value 1.
This might change in the future if we choose to take into account
microcode revisions in the automatic determination process.

The tunable/sysctl value is simply ignored on non-applicable CPU models,
which is useful to apply the same configuration on a set of machines
that do not all have Zen2 processors.  Trying to set it to any integer
value not listed above is silently equivalent to setting it to value 2
(automatic determination).

The current mitigation state can be queried through sysctl
'machdep.mitigations.zenbleed.state', which returns "Not applicable",
"Mitigation enabled" or "Mitigation disabled".  Note that this state is
not guaranteed to be accurate in case of intervening modifications of
the corresponding chicken bit directly via cpuctl(4) (this includes the
cpucontrol(8) utility).  Resetting the desired policy through
'machdep.mitigations.zenbleed.enable' (possibly to its current value)
will reset the hardware state and ensure that the reported state is
again coherent with it.

Reviewed by:    kib
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D41817

(cherry picked from commit ebaea1bcd2eb0aa90937637ed305184b6fedc69b)

Approved by:    markj (mentor)

6 months agopf tests: fix typos in the abort_v6 test case head / cleanup function name
Kristof Provost [Thu, 14 Dec 2023 09:22:26 +0000 (10:22 +0100)]
pf tests: fix typos in the abort_v6 test case head / cleanup function name

MFC after: 1 week

(cherry picked from commit 8fab83d2c5c5e801105dbf25c28252fc97935b00)

6 months agompr, mps: Establish busdma boundaries for memory pools
Kenneth D. Merry [Thu, 14 Dec 2023 20:05:17 +0000 (15:05 -0500)]
mpr, mps:  Establish busdma boundaries for memory pools

Most all of the memory used by the cards in the mpr(4) and mps(4)
drivers is required, according to the specs and Broadcom developers,
to be within a 4GB segment of memory.

This includes:

System Request Message Frames pool
Reply Free Queues pool
ReplyDescriptorPost Queues pool
Chain Segments pool
Sense Buffers pool
SystemReply message pool

We got a bug report from Dwight Engen, who ran into data corruption
in the BAE port of FreeBSD:

> We have a port of the FreeBSD mpr driver to our kernel and recently
> I found an issue under heavy load where a DMA may go to the wrong
> address. The test system is a Supermicro X10SRH-CLN4F with the
> onboard SAS3008 controller setup with 2 enterprise Micron SSDs in
> RAID 0 (striped). I have debugged the issue and narrowed down that
> the errant DMA is one that has a segment that crosses a 4GB
> physical boundary.  There are more details I can provide if you'd
> like, but with the attached patch in place I can no longer
> re-create the issue.

> I'm not sure if this is a known limit of the card (have not found a
> datasheet/programming docs for the chip) or our system is just
> doing something a bit different. Any helpful info or insight would
> be welcome.

> Anyway, just thought this might be helpful info if you want to
> apply a similar fix to FreeBSD. You can ignore/discard the commit
> message as it is my internal commit (blkio is our own tool we use
> to write/read every block of a device with CRC verification which
> is how I found the problem).

The commit message was:

> [PATCH 8/9] mpr: fix memory corrupting DMA when sg segment crosses
> 4GB boundary

> Test case was two SSD's in RAID 0 (stripe). The logical disk was
> then partitioned into two partitions. One partition had lots of
> filesystem I/O and the other was initially filled using blkio with
> CRCable data and then read back with blkio CRC verify in a loop.
> Eventually blkio would report a bad CRC block because the physical
> page being read-ahead into didn't contain the right data. If the
> physical address in the arq/segs was for example 0x500003000 the
> data would actually be DMAed to 0x400003000.

The original patch was against mpr(4) before busdma templates were
introduced, and only affected the buffer pool (sc->buffer_dmat) in
the mpr(4) driver. After some discussion with Dwight and the
LSI/Broadcom developers and looking through the driver, it looks
like most of the queues in the driver are ok, because they limit
the memory used to memory below 4GB. The buffer queue and the chain
frames seem to be the exceptions.

This is pretty much the same between the mpr(4) and mps(4) drivers.

So, apply a 4GB boundary limitation for the buffer and chain frame pools
in the mpr(4) and mps(4) drivers.

Reported by: Dwight Engen <dwight.engen@gmail.com>
Reviewed by: imp
Obtained from: Dwight Engen <dwight.engen@gmail.com>
Differential Revision: <https://reviews.freebsd.org/D43008>

(cherry picked from commit 264610a86e14f8e123d94c3c3bd9632d75c078a3)

6 months agoig4: Add PCI IDs for Intel Ice Lake I2C controller.
Vladimir Kondratyev [Mon, 27 Nov 2023 15:25:48 +0000 (18:25 +0300)]
ig4: Add PCI IDs for Intel Ice Lake I2C controller.

PR: 275115
Tested by: Sam <sam3423.yntmr_AT_slmail_DOT_me>

(cherry picked from commit 789ffce392946d2f71a51bbac60db16dcdea2928)

6 months agoif_tun: check device name
Konstantin Belousov [Tue, 12 Dec 2023 00:13:59 +0000 (02:13 +0200)]
if_tun: check device name

PR: 266999

(cherry picked from commit 0365e5fc905b425313a0a2d89f0d8e2566924df2)

6 months agosshd: do not resolve refused client hostname
Gleb Smirnoff [Thu, 20 Jul 2023 21:56:20 +0000 (14:56 -0700)]
sshd: do not resolve refused client hostname

This is a compromise between POLA and practical reasoning.  We don't
want to block the main server loop in an attempt to resolve.  But we
need to keep the format of the logged message as is, for sake of
sshguard and other scripts.  So let's print just the IP address twice,
this is what libwrap's refuse() would do if it failed to resolve.

Reviewed by: philip
PR: 269456
Differential revision: https://reviews.freebsd.org/D40069

(cherry picked from commit 9ff45b8ed847f9cb7e1cd401278c7f6b30fe8225)

6 months agosshd: remove unneeded initialization of libwrap logging severities
Gleb Smirnoff [Thu, 20 Jul 2023 21:56:20 +0000 (14:56 -0700)]
sshd: remove unneeded initialization of libwrap logging severities

This part of ca573c9a177 proved to be unnecessary.  As the removed
comment says, we set them merely for logging syntax errors, as we log
refusals ourselves.  However, inside the libwrap the parser logs any
syntax errors with tcpd_warn() which has hardcoded LOG_WARNING inside.

Reviewed by: philip, emaste
Differential revision: https://reviews.freebsd.org/D40068

(cherry picked from commit 90f10db8a99659d1baea7b2609d9256c331f61ae)

6 months agoImplement "strict key exchange" in ssh and sshd.
Gordon Tetlow [Mon, 18 Dec 2023 16:22:22 +0000 (08:22 -0800)]
Implement "strict key exchange" in ssh and sshd.

This adds a protocol extension to improve the integrity of the SSH
transport protocol, particular in and around the initial key exchange
(KEX) phase.

Full details of the extension are in the PROTOCOL file.

OpenBSD-Commit-ID: 2a66ac962f0a630d7945fee54004ed9e9c439f14

Approved by: so (implicit)
Obtained from: https://anongit.mindrot.org/openssh.git/patch/?id=1edb00c58f8a6875fad6a497aa2bacf37f9e6cd5
Security: CVE-2023-48795

(cherry picked from commit 92f58c69a14c0afe910145f177c0e8aeaf9c7da4)

6 months agonfscl: Fix comment for commit 6aded1e6b2e5
Rick Macklem [Mon, 4 Dec 2023 00:12:14 +0000 (16:12 -0800)]
nfscl: Fix comment for commit 6aded1e6b2e5

Commit 6aded1e6b2e5 fixed a rare case when handling an NFSv4
Rename reply when delegations are in use.  This patch fixes the
associated comment.

(cherry picked from commit 0a958aa16fed1978879d64e3b225f1d232cc5a98)

6 months agonfscl: Fix processing of a rare Rename reply case
Rick Macklem [Sun, 3 Dec 2023 23:31:01 +0000 (15:31 -0800)]
nfscl: Fix processing of a rare Rename reply case

When delegations are enabled (they are not by default in
the FreeBSD NFSv4 server), rename will check for and return
delegations.  If the second of these DelegReturn operations
were to fail (they rarely do), then the code would not retry
the rename with returning delegations, as it is intended to do.

The patch fixes the problem, since the DelegReturn reply status
is the second iteration of the loop and not the first iteration.

As noted, this bug would have rarely manifested a problem, since
DelegReturn operations do not normally fail.

(cherry picked from commit 6aded1e6b2e5549120031032e1c7f8b002882327)

6 months agoiostat.8: Better wording for some use cases
Gordon Bergling [Sun, 26 Nov 2023 18:30:58 +0000 (19:30 +0100)]
iostat.8: Better wording for some use cases

The iostat(8) manual page should be more specific when using
options. Also extented the BUGS section.

PR: 153012
Reviewed by: bcr
Differential Revision: https://reviews.freebsd.org/D42633

(cherry picked from commit 502e8f44fcc18bfc6dadca56801d66cbce4c07ec)

6 months agoIncrease UFS/FFS maximum link count from 32767 to 65530.
Kirk McKusick [Sun, 3 Dec 2023 20:36:42 +0000 (12:36 -0800)]
Increase UFS/FFS maximum link count from 32767 to 65530.

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

(cherry picked from commit 35a301555bff2ac27a727c10641b7efb3f162988)

6 months agostrfmon.c: Use the restrict keyword directly
Konstantin Belousov [Sat, 9 Dec 2023 01:21:02 +0000 (03:21 +0200)]
strfmon.c: Use the restrict keyword directly

(cherry picked from commit 86e2bcbf47fb4c8dbd799f2f21c0ed338b2e8f1b)

6 months agostrfmon: style fixes
Jose Luis Duran [Thu, 30 Nov 2023 23:28:21 +0000 (23:28 +0000)]
strfmon: style fixes

(cherry picked from commit 56a0d5444d6f39302f3476b61c1b81ed39abe589)

6 months agostrfmon: Silence scan-build warning
Jose Luis Duran [Thu, 30 Nov 2023 23:30:50 +0000 (23:30 +0000)]
strfmon: Silence scan-build warning

(cherry picked from commit 6abee52e0d79f68fd725de748d7027ca8eef2294)

6 months agostrfmon.3: Cleanup example code
Jose Luis Duran [Fri, 1 Dec 2023 06:50:24 +0000 (06:50 +0000)]
strfmon.3: Cleanup example code

(cherry picked from commit 2a163c3649e59dd616e057994ec02092362f0ae7)

6 months agorc.conf: correct $ntp_leapfile_sources
Philip Paeps [Thu, 7 Dec 2023 05:48:13 +0000 (13:48 +0800)]
rc.conf: correct $ntp_leapfile_sources

IETF is no longer serving leap-seconds.list.  Point at IANA instead.

This fixes "service ntpd fetch".

(cherry picked from commit b1c95af45488bef649e9a84890e2414ff80b3a00)

6 months agogit hooks: add "Fixes" trailer to commit message template
Ed Maste [Sat, 20 Feb 2021 18:49:31 +0000 (13:49 -0500)]
git hooks: add "Fixes" trailer to commit message template

A number of projects use "Fixes: <hash>" to identify a commit that is
fixed by a given change.  Adopt that convention.

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

(cherry picked from commit aa8ae5fe17eb380b0f30f1641f17a0b3d83a68c3)

6 months agogit hooks: add "Tested by" to commit message template
Ed Maste [Tue, 2 Feb 2021 18:36:45 +0000 (13:36 -0500)]
git hooks: add "Tested by" to commit message template

Reported by: mjg
Reviewed by: imp
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 9d0f1092cf90c8bf161cb946584f703a9998f8cd)

6 months agortld: add a test for RTLD_DEEPBIND
Kyle Evans [Fri, 1 Dec 2023 01:26:09 +0000 (19:26 -0600)]
rtld: add a test for RTLD_DEEPBIND

This tests that with RTLD_DEEPBIND, symbols are looked up in all of the
object's needed objects before the global object.

ATF_REQUIRE_INTEQ was added after stable/13 branched, so we shim it out
here.

PR: 275393
Reviewed by: kib
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit d9c543b6b0cabea6e6679d70b4e701018e7eab80)

6 months agolockf: switch to strtonum() for parsing timeout
Kyle Evans [Sun, 26 Nov 2023 04:27:11 +0000 (22:27 -0600)]
lockf: switch to strtonum() for parsing timeout

Convert waitsec to a long long to be able to hold the full domain of
alarm(3) timeout on all platforms, and let strtonum(3) handle the input
validation.  strtonum(3) also happens to provide a neater interface for
error handling, and it already includes our pre-existing empty input
check.

Sponsored by: Klara, Inc.

(cherry picked from commit e4967d4d48b0a7d873e4f778c0a6e560e09d4dc3)

6 months agolockf: allow locking file descriptors
Kyle Evans [Wed, 22 Nov 2023 07:46:14 +0000 (01:46 -0600)]
lockf: allow locking file descriptors

This is most useful inside a shell script, allowing one to lock just
portions of a script rather than having to wrap the entire script in a
lock.

PR: 262738
Reviewed by: 0mp, allanjude (both previous versions)
Co-authored-by: Daniel O'Connor <darius@dons.net.au>
Sponsored by: Klara, Inc.

(cherry picked from commit 09a7fe0a5523d53ff6c26ddef9a947f293e18c22)

6 months agolockf: add some tests
Kyle Evans [Wed, 22 Nov 2023 05:09:11 +0000 (23:09 -0600)]
lockf: add some tests

Provide basic coverage for the existing options, nothing deeper (e.g.,
pipe closing behavior) is tested in this set.

Reviewed by: allanjude
Feedback from: des
Sponsored by: Klara, Inc.

(cherry picked from commit 296a5a4db1fc8203f5f6aa8f68321e6ab4652b56)

6 months agolockf: don't hold stdin/stdout/stderr open
Alexander Melkov [Wed, 22 Nov 2023 04:46:28 +0000 (22:46 -0600)]
lockf: don't hold stdin/stdout/stderr open

None of these are essential in the lockf monitor (parent post-fork), so
close them to maintain the illusion that lockf hasn't been inserted into
the pipeline.  This ensures that the correct effects happen on other
programs in the pipeline if the locked command closes or redirects these
elsewhere.

The original patch used -s to close stdout/stderr rather than closing
them unconditionally, but it's not clear that we really care that much.
kevans dropped that part when taking the patch, patch is otherwise by
listed author.

PR: 112379
Reviewed by: 0mp, allanjude (both earlier version), kevans
Feedback from: des
Sponsored by: Klara, Inc.

(cherry picked from commit 18425c19cae08cbe41801845457ed67285806688)

6 months agolockf: hide unavailable error with -n -s
Kyle Evans [Wed, 22 Nov 2023 04:41:36 +0000 (22:41 -0600)]
lockf: hide unavailable error with -n -s

The error message is expected, allow -s to suppress just that one since
it would loosely fall under the definition of "failure to acquire the
lock" described in the manpage for the -s option.

Reviewed by: 0mp, allanjude
Feedback from: des
Sponsored by: Klara, Inc.

(cherry picked from commit 3041e6950d07f0d11c9f91fefbf3c273cbbe4407)

6 months agolockf: correct omission in the usage statement
Kyle Evans [Wed, 22 Nov 2023 04:45:42 +0000 (22:45 -0600)]
lockf: correct omission in the usage statement

The -w flag was added without being noted in the usage statement; fix
that now.

While we're here, re-sort the getopt() string.

Reviewed by: 0mp, allanjude, des
Sponsored by: Klara, Inc.

(cherry picked from commit 35095fd23f071d03633312b91a5b460eaf811efa)

6 months agoarm64: lop off another 24MB of KVA for early device mappings
Kyle Evans [Thu, 23 Nov 2023 16:21:33 +0000 (10:21 -0600)]
arm64: lop off another 24MB of KVA for early device mappings

This grows the block enough to fit a 4K 32-bit depth framebuffer; some
firmware would present smaller GOP modes to be able to boot with a
smaller framebuffer on these devices, but the Windows Devkit firmware
is simply not that nice.  Instead, it offers exactly one GOP mode that
matches the current resolution of the attached display, so with limited
control over resolution on most of my displays it'd be nice if we could
Just Work(TM) at 4K.

andrew notes that he has some ideas for removing PMAP_MAPDEV_EARLY_SIZE
entirely, so this limitation could end up removed altogether in the
future.

Reviewed by: andrew, emaste

(cherry picked from commit a3ceeef26bc880b86f4e181bddd9924a2b5e0691)

6 months agolocaledef: add newlines to error messages
Kyle Evans [Sat, 2 Sep 2023 06:24:34 +0000 (01:24 -0500)]
localedef: add newlines to error messages

These won't be added elsewhere, so add a little bit of room to make
these messages a little easier to read.  The existing set is a mixed
bag, there are somewhere in the ballpark of 45, 46 printfs to stderr and
19 of those had newlines.

Reviewed by: yuripv
Sponsored by: Klara, Inc.

(cherry picked from commit 3141e51d2e38fa7b9e6d81477dfa860d087c514d)

6 months agolocaledef: expand the default charmap
Kyle Evans [Sat, 2 Sep 2023 06:13:02 +0000 (01:13 -0500)]
localedef: expand the default charmap

POSIX defines a number of other control characters as well as
alternative aliases for some that should be provided in the default set,
so let's go ahead and add those.

Reviewed by: bapt, yuripv
Sponsored by: Klara, Inc.

(cherry picked from commit 3a7ffe206ce7e4741fae26432f6d6e5159207f45)

6 months agolocaledef: correct definition of right-parenthesis in default charmap
Kyle Evans [Sat, 2 Sep 2023 05:56:31 +0000 (00:56 -0500)]
localedef: correct definition of right-parenthesis in default charmap

It turns out that right parentheses do exist and are different than
left parentheses, so let's switch to that.

Sponsored by: Klara, Inc.

(cherry picked from commit 07bc20e4740d09f554c3787bb1940fc503300822)

6 months agosort: Only build FreeBSD-specific ALTMON_x stuff when ATLMON_1 is defined
Warner Losh [Thu, 7 Dec 2023 20:27:07 +0000 (13:27 -0700)]
sort: Only build FreeBSD-specific ALTMON_x stuff when ATLMON_1 is defined

On MacOS, we bootstrap sort. Since ALTMON_* are not defined there, the
build blows up. Since we don't need this feature for the FreeBSD build
process, and since we won't use it unless we actually install the NL
files that have this data in it, just #ifdef it out for now. In the
extremely unlikely event that the FreeBSD bootstrap/build process grows
this dependency, we can evaluate the best solution then (which most
likely is going to be not depend on the local's month names).

Fixes: 3d44dce90a69 (MacOS builds and github CI)
Sponsored by: Netflix
Reviewed by: jrtc27, jlduran@gmail.com, markj
Differential Revision: https://reviews.freebsd.org/D42868

(cherry picked from commit bd234c0d4c8256db7e5a1fdda9ef311c9e0080e4)

6 months agosort: test against all month formats in month-sort
Christos Margiolis [Fri, 1 Dec 2023 00:30:10 +0000 (02:30 +0200)]
sort: test against all month formats in month-sort

The CLDR specification [1] defines three possible month formats:

- Abbreviation (e.g Jan, Ιαν)
- Full (e.g January, Ιανουαρίου)
- Standalone (e.g January, Ιανουάριος)

Many languages use different case endings depending on whether the month
is referenced as a standalone word (nominative case), or in date context
(genitive, partitive, etc.). sort(1)'s -M option currently sorts months
by testing input against only the abbrevation format, which is
essentially a substring of the full format. While this works fine for
languages like English, where there are no cases, for languages where
there is a different case ending between the abbreviation/full and
standalone formats, it is not sufficient.

For example, in Greek, "May" can take the following forms:

Abbreviation: Μαΐ (genitive case)
Full: Μαΐου (genitive case)
Standalone: Μάιος (nominative case)

If we use the standalone format in Greek, sort(1) will not able to match
"Μαΐ" to "Μάιος" and the sort will fail.

This change makes sort(1) test against all three formats. It also works
when the input contains mixed formats.

[1] https://cldr.unicode.org/translation/date-time/date-time-patterns

Reviewed by: markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D42847

(cherry picked from commit 3d44dce90a6946e2ef2ab30ffbf8e2930acf888b)

6 months agoAdd IBM TS1170 density codes and specs.
Kenneth D. Merry [Tue, 31 Oct 2023 19:20:36 +0000 (15:20 -0400)]
Add IBM TS1170 density codes and specs.

These were obtained from a drive, but they agree with the IBM
documentation.

The bpi/bpmm values are the same as TS1160, but the number of
tracks is much larger (18944 tracks vs 8704 for TS1160).  The tapes
are also longer, 1337m total.  (According to the MAM on a sample JF
tape.  I don't have a JE tape handy to compare.)  The end result
is a 50TB raw capacity (150TB compressed) for TS1170 with a JF
cartridge vs 20TB raw capacity (60TB compressed) for TS1160 with
a JE cartridge.

lib/libmt/mtlib.c:
Add the TS1170 density codes to the denstiy table in libmt.

usr.bin/mt/mt.1:
Add the TS1170 density codes and specs to the density table
in the mt(1) man page.  As usual for TS drives, there is an
encrypted and non-encrypted density code (0x79 and 0x59
respectively).

Sponsored by: Spectra Logic

(cherry picked from commit 83823d063ab57db8d3954c1530d036f1ccdceb41)

6 months agosysvipc: Fix 32-bit compat on !i386
Brooks Davis [Fri, 1 Dec 2023 20:48:29 +0000 (20:48 +0000)]
sysvipc: Fix 32-bit compat on !i386

The various time fields are time_t's which are only 32-bit on i386.

Fixing the old versions is probably of little use, but it's more correct
and in theory there could be powerpc binaries from 6.x.

PR: 240035
Fixes: fbb273bc05bef Properly support for FreeBSD 4 32bit System V shared memory.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D42870

(cherry picked from commit 957f014dc076a7f74ed0c8c8699e6f39b55785e7)

6 months agotty: Avoid a kernel memory discloure via kern.ttys
Mark Johnston [Mon, 11 Dec 2023 14:19:09 +0000 (09:19 -0500)]
tty: Avoid a kernel memory discloure via kern.ttys

Four pad bytes at the end of each xtty structure were not being cleared
before being copied out.  Fix this by clearing the whole structure
before populating fields.

MFC after: 3 days
Reported by: KMSAN

(cherry picked from commit 3c0fb026b2fc998fa9bea8aed76e96c58671aee3)

6 months agovnet: (read) lock the vnet list while iterating it
Kristof Provost [Tue, 5 Dec 2023 19:08:11 +0000 (20:08 +0100)]
vnet: (read) lock the vnet list while iterating it

Ensure that the vnet list cannot be modified while we're running through
it.

Reviewed by: mjg (previous version), zlei (previous version)
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D42927

(cherry picked from commit bd7b2f95019e9715150c34736279805de0818d09)

6 months agobsdinstall: Encode dists to valid variable names in checksum script
Jessica Clarke [Wed, 6 Dec 2023 21:37:32 +0000 (21:37 +0000)]
bsdinstall: Encode dists to valid variable names in checksum script

Currently we just strip the .txz of the dist name (and add a status_
prefix) to get the shell variable name for its status, but this doesn't
give a valid result for dists like base-dbg, kernel-dbg and lib32-dbg,
or even kernel.KERNCONF (or, combining the two, kernel.KERNCONF-dbg). As
a result, four things go wrong for such dists:

1. If there is a dot and/or a dash in the name, writing to the variable
   fails and spits an error out on stderr to the log
3. If there is a dot in the name before any dash, the syntax is always
   invalid, reading the variable fails, spits an error out on stderr to
   the log, the result is the empty string and that is interpreted as
   being 0%
2. If there is a dash in the name before any dot, and there is a dist
   whose name is the substring up to that first dash, and it has already
   had its status written to, reading the variable instead reads that
   dist's variable and so the status of that dist is displayed instead
3. If there is a dash in the name before any dot, and either there is
   not a dist whose name is the substring up to that first dash or there
   is such a dist but it has not already had its status written to,
   reading the varaible instead results in the substring after the first
   dash, including any additional string expansion syntax that follows
   (i.e. ${status_kernel-dbg:--11}, the expression used to read the
   variable, is interpreted as reading status_kernel with a default
   value of "dbg:--11")

For example, in a default install with base, kernel, kernel-dbg and
lib32, the following sequence of displays happens:

1. base is In Progress, kernel is Pending, kernel-dbg is 0% (what shows
   for the garbage input "dbg:--11") and lib32 is Pending
2. base is Passed, kernel is In Progress, kernel-dbg is In Progress
   (since kernel has now had its status written to) and lib32 is
   Pending
3. base is Passed, kernel is Passed, kernel-dbg is Passed (again, since
   that is the status of kernel, despite that kernel-dbg is being
   verified at this point) and lib32 is Pending
4. base is Passed, kernel is Passed, kernel-dbg is Passed and lib32 is
   In Progress

Fix this with a crude encoding scheme. More special characters can
easily be added if needed in future.

Note that, prior to bsddialog being used (and thus for branches this is
MFC'ed to where dialog is still used), the same problem existed but
displayed slightly differently due to a combination of different default
values and different behaviour for unintended inputs.

Fixes: b70047d41362 ("Add generation of an installation manifest containing SHA256 checksums as ...")
MFC after: 1 week

(cherry picked from commit 47d669f10ea3eb92a3783376549728b42c9e22b9)

6 months agotail: Fix heap overflow in -F case.
Dag-Erling Smørgrav [Wed, 29 Nov 2023 21:48:50 +0000 (22:48 +0100)]
tail: Fix heap overflow in -F case.

The number of events we track can vary over time, but we only allocate
enough space for the exact number of events we are tracking when we
first begin, resulting in a trivially reproducable heap overflow.  Fix
this by allocating enough space for the greatest possible number of
events (two per file) and clean up the code a bit.

Also add a test case which triggers the aforementioned heap overflow,
although we don't currently have a way to detect it.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: allanjude, markj
Differential Revision: https://reviews.freebsd.org/D42839

(cherry picked from commit 621f45532c5887c96b708ce232c52878d0053325)

tail: Clean up error messages.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D42842

(cherry picked from commit b70e57be2cfe83ec9f410e2f317ea38aaac61a98)

6 months agotail.1: Lint with mandoc(1)
Mateusz Piotrowski [Tue, 28 Nov 2023 16:10:12 +0000 (17:10 +0100)]
tail.1: Lint with mandoc(1)

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

(cherry picked from commit 51c27021b2818cc626500d7723dc82291e3eecaa)

6 months agotail: Verify correct behavior when input does not end in a newline.
Dag-Erling Smørgrav [Thu, 16 Mar 2023 15:36:49 +0000 (15:36 +0000)]
tail: Verify correct behavior when input does not end in a newline.

Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D39116

(cherry picked from commit fa3af3ce5010740f28faed22e0a1e819491f26b4)

6 months agotail: Retry kevent if the system call was interrupted
Warner Losh [Sun, 19 Feb 2023 03:04:29 +0000 (20:04 -0700)]
tail: Retry kevent if the system call was interrupted

kevent returns EINTR when I suspend / resume. This causes tail -f
and tail -F to exit with interrupt system call. Ignore this error
and try kevent again.

Sponsored by: Netflix

(cherry picked from commit ef6f20ce47613db7cc615b45f4b6fa1eb99ae0ba)

6 months agoImprove usability of head(1) and tail(1):
Xin LI [Wed, 13 Jul 2022 04:14:25 +0000 (21:14 -0700)]
Improve usability of head(1) and tail(1):

 - Consistently support -q (quiet) and -v (verbose)
 - Allow specifying numbers with SI prefixes supported by expand_number(3)
 - Remove 2^31 limit on lines for head(1)

MFC after: 2 weeks
Reviewed by: lwhsu, pauamma, gbe
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D35720

(cherry picked from commit 643ac419fafba89f5adda0e0ea75b538727453fb)

6 months agobitstring: Support large bit strings.
Dag-Erling Smørgrav [Wed, 22 Nov 2023 22:30:03 +0000 (23:30 +0100)]
bitstring: Support large bit strings.

Replace int with either size_t or ssize_t (depending on context) in
order to support bit strings up to SSIZE_MAX bits in length.  Since
some of the arguments that need to change type are pointers, we must
resort to light preprocessor trickery to avoid breaking existing code.

MFC after: 3 weeks
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D42698

(cherry picked from commit c56f45f2a9da7d989b79fd6c34b63100609ff9ae)

6 months agohesiod: Modernize.
Dag-Erling Smørgrav [Wed, 18 Oct 2023 14:05:37 +0000 (16:05 +0200)]
hesiod: Modernize.

Reviewed by: zlei
Differential Revision: https://reviews.freebsd.org/D42190

(cherry picked from commit 64fc8a936c868345a8f687fe2797474c5fcf35cb)

6 months agoping: Simplify protocol selection.
Dag-Erling Smørgrav [Tue, 10 Oct 2023 22:47:46 +0000 (00:47 +0200)]
ping: Simplify protocol selection.

* Interrupt the option loop as soon as we have an indication of which
  protocol is intended.
* If we end up having to perform a DNS lookup, loop over the entire
  result looking for either IPv4 or IPv6 addresses.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Reviewed by: rscheff, kevans, allanjude
Differential Revision: https://reviews.freebsd.org/D42137

(cherry picked from commit 7fd2c91a291bd518e012b438d6ca6fdd04d39dbf)

ping: Consistently use EX_NOHOST for DNS failures.

Traditionally, ping returned exit code EX_NOHOST if a DNS lookup failed.
That is still the case for the legacy code in the new merged ping, but
not for IPv6 targets, nor when a DNS lookup is performed in order to
determine which version of the tool to invoke.

While here, also make sure that the error message is consistent.

Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D42159

(cherry picked from commit c4ffb80ef18f6b581dc28c14bc579e0e7c73438c)

ping: Add missing ATF boilerplate.

Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D42161

(cherry picked from commit fc7143b48341fb16ef5b2262c7cd5b5c47056112)

6 months agolibfetch, fetch: Stop recommending the use of ca_root_nss.
Dag-Erling Smørgrav [Sun, 8 Oct 2023 04:35:15 +0000 (06:35 +0200)]
libfetch, fetch: Stop recommending the use of ca_root_nss.

MFC after: 3 days
Reviewed by: kevans, emaste
Differential Revision: https://reviews.freebsd.org/D42119

(cherry picked from commit 2821a7498f65d357c68166e1978b491abef1ca4a)

6 months agodaemon: Disable stdio buffering.
Dag-Erling Smørgrav [Fri, 6 Oct 2023 16:44:52 +0000 (18:44 +0200)]
daemon: Disable stdio buffering.

The daemon utility already does its own buffering and retransmits its
child's output line by line.  There's no need for stdio to add its own
buffering on top of this.

MFC after: 1 week
Sponsored by: Modirum MDPay
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D42111

(cherry picked from commit cec8e6ba64ccab7fb0d9fa531ebad9228233334d)

6 months agodaemon: EINTR from kevent(2) is not a fatal error
Kyle Evans [Fri, 5 May 2023 15:12:13 +0000 (10:12 -0500)]
daemon: EINTR from kevent(2) is not a fatal error

Simply resume waiting for events rather than exiting if we took a signal
here.

This at least fixes running programs under daemon(8) in the face of
suspend/resume, which I suspect hits us with a spurious EINTR rather
than a signal anyways.

Reported and tested by: manu
Fixes: 8935a3993219b ("daemon: use kqueue for all events")

(cherry picked from commit 494e7dfdbe6ecfe572228ed39f5c794954da068c)

6 months agodaemon: use kqueue for all events
Ihor Antonov [Fri, 14 Apr 2023 05:10:29 +0000 (00:10 -0500)]
daemon: use kqueue for all events

Refactor daemon to use kqueue/kevent instead of signals.

This changes allows to simplify the code in several ways:
- the execution flow is now linear, no async events.
- several variables became redundant and got removed.
- all event handling is now concentrated inside of the event loop, which
  makes code reading and comprehension easier.
- new kqueuex(2) call is used for CLOEXEC, but maintained closing the
  kq fd prior to execve() to ease later MFC

No UX/API changes are intended.

Reviewed by: kevans
Pull Request: https://github.com/freebsd/freebsd-src/pull/701

(cherry picked from commit 8935a3993219be76c7ea03e9ad4509657d08af6c)

6 months agogrowfs: make exit codes more consistent
Mina Galić [Thu, 5 Oct 2023 18:24:53 +0000 (20:24 +0200)]
growfs: make exit codes more consistent

We have overused err(1), so it's hard to distinguish when an error is
very, very serious, and when it's just a user-error, or even harmless.

This patch changes the current behaviour to distinguish between the
following three:

1 for usage errors
2 for recoverable errors
3 or higher for unrecoverable errors

Reviewed by: jilles, pauamma_gundo.com, des
Differential Revision: https://reviews.freebsd.org/D27161

(cherry picked from commit 70a0fb43f91cfe3d08db7cb443d9690f8bff065e)

6 months agoUpdate tzcode to 2023c.
Dag-Erling Smørgrav [Wed, 26 Apr 2023 09:46:18 +0000 (11:46 +0200)]
Update tzcode to 2023c.

MFC after:      3 weeks
Sponsored by:   Klara, Inc.
Reviewed by:    philip
Differential Revision:  https://reviews.freebsd.org/D39712

(cherry picked from commit 75411d157232ee3b4789b92c9205453e7d59a3d2)

6 months agonss_tacplus: Provide dummy setpwent(), getpwent_r(), endpwent().
Dag-Erling Smørgrav [Thu, 31 Aug 2023 07:49:41 +0000 (07:49 +0000)]
nss_tacplus: Provide dummy setpwent(), getpwent_r(), endpwent().

These aren't really needed, since TACACS+ does not support enumeration, but providing placeholders keeps nsdispatch() from complaining that they're missing.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D41658

(cherry picked from commit 56b74a2d856c4d65a4b5c72d1352067b6b469d3b)

6 months agonss_tacplus: Support setting the login class.
Dag-Erling Smørgrav [Tue, 13 Jun 2023 16:06:27 +0000 (16:06 +0000)]
nss_tacplus: Support setting the login class.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: thj
Differential Revision: https://reviews.freebsd.org/D40376

(cherry picked from commit 246aec9a3ce305272f35e6416910024f602a03c1)

6 months agoFix prebuild race between libpam and libtacplus.
Dag-Erling Smørgrav [Wed, 21 Jun 2023 20:58:54 +0000 (20:58 +0000)]
Fix prebuild race between libpam and libtacplus.

Fixes: 21850106fdda
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, emaste
Differential Revision: https://reviews.freebsd.org/D40702

(cherry picked from commit bd9049eeff458fc7ee256a891ba285519c6ce550)

6 months agolibtacplus: Allow additional AV pairs to be configured.
Dag-Erling Smørgrav [Tue, 13 Jun 2023 16:04:22 +0000 (16:04 +0000)]
libtacplus: Allow additional AV pairs to be configured.

* Replace hand-rolled input tokenizer with openpam_readlinev() which supports line continuations and has better quoting and escaping.
* Simplify string handling by merging struct clnt_str and struct srvr_str into just struct tac_str.
* Each server entry in the configuration file can now have up to 255 AV pairs which will be appended to the ones returned by the server in response to a successful authorization request.

This allows nss_tacplus(8) to be used with servers which do not provide identity information beyond confirming the existence of the user.

This adds a dependency on libpam, however libtacplus is currently only used by pam_tacplus(8) (which is already always used with libpam) and the very recently added nss_tacplus(8) (which is extremely niche).  In the longer term it might be a good idea to split this out into a separate library.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: pauamma_gundo.com, markj
Differential Revision: https://reviews.freebsd.org/D40285
Relnotes: yes

(cherry picked from commit 21850106fdda5269bc881f0e62839dff3d9edf47)

6 months agoAdd nss_tacplus, a TACACS+ NSS module.
Dag-Erling Smørgrav [Mon, 22 May 2023 10:00:48 +0000 (10:00 +0000)]
Add nss_tacplus, a TACACS+ NSS module.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D40133

(cherry picked from commit 6c5cdba1bafe77428b7721e49cc2b944885ec71a)

6 months agotaclib: 0 (not set) is a valid auth type in authorization requests.
Dag-Erling Smørgrav [Mon, 22 May 2023 10:00:42 +0000 (10:00 +0000)]
taclib: 0 (not set) is a valid auth type in authorization requests.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: rew
Differential Revision: https://reviews.freebsd.org/D40132

(cherry picked from commit 951beab15d397942b5306aae292cd16564abe9f9)

6 months agonfsclient: Propagate copyin() errors from nfsm_uiombuf()
Mark Johnston [Tue, 12 Dec 2023 01:04:56 +0000 (20:04 -0500)]
nfsclient: Propagate copyin() errors from nfsm_uiombuf()

Approved by: so
Security: SA-23:18.nfsclient
Reviewed by: rmacklem
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6fa843f6e647a1a1e0e42af1e7abc9e903699f31)

6 months agobsd-family-tree: add FreeBSD 14
Sergey A. Osokin [Thu, 7 Dec 2023 14:26:12 +0000 (09:26 -0500)]
bsd-family-tree: add FreeBSD 14

(cherry picked from commit 25f37779bdeba6856f92d0bc94f74582566fcb0f)

6 months agobsd-family-tree: add OpenBSD 7.4
Sergey A. Osokin [Mon, 16 Oct 2023 20:19:12 +0000 (16:19 -0400)]
bsd-family-tree: add OpenBSD 7.4

(cherry picked from commit 8c630381b43cc4d83c99305df3f732b0583ff8f2)

6 months agobsd-family-tree: add macOS 14
Sergey A. Osokin [Thu, 28 Sep 2023 21:42:08 +0000 (17:42 -0400)]
bsd-family-tree: add macOS 14

(cherry picked from commit 992ec09f37837a3f7d131bc70a66d6e41b814e9b)

6 months agoOpenZFS: Ensure that zfs_getattr() initializes the va_rdev field
Mark Johnston [Thu, 7 Dec 2023 16:20:11 +0000 (11:20 -0500)]
OpenZFS: Ensure that zfs_getattr() initializes the va_rdev field

Otherwise the field is left uninitialized, leading to a possible kernel
memory disclosure to userspace or to the network.  Use the same
initialization value we use in zfsctl_common_getattr().

Reported-by: KMSAN
Sponsored-by: The FreeBSD Foundation
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ed Maste <emaste@FreeBSD.org>
Signed-off-by: Mark Johnston <markj@FreeBSD.org>
(cherry picked from commit 11656234b560c401dec6a16e1bf048b20fd31aac)

6 months agoMFC: xz 5.4.5
Xin LI [Fri, 12 May 2023 22:49:34 +0000 (15:49 -0700)]
MFC: xz 5.4.5

(cherry picked from commit ca6a6373bdaed010d6cbfb27f7249ae96009409d)
(cherry picked from commit 1f3ced26d4946ff2e24472432a275efb9ba1f2ca)
(cherry picked from commit b333cd44de6db4d3182add2f80870c7a96d570d9)

6 months agopf tests: test that we validate sequence numbers on TCP RST
Kristof Provost [Wed, 29 Nov 2023 12:51:39 +0000 (13:51 +0100)]
pf tests: test that we validate sequence numbers on TCP RST

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

(cherry picked from commit 4c84c69ba308b7758d07dc8845b13922ed667e02)

6 months agouma: Micro-optimize memory trashing
Alexander Motin [Thu, 9 Nov 2023 18:07:46 +0000 (13:07 -0500)]
uma: Micro-optimize memory trashing

Use u_long for memory accesses instead of uint32_t.  On my tests on
amd64 this by ~30% reduces time spent in those functions thanks to
bigger 64bit accesses.  i386 still uses 32bit accesses.

MFC after: 1 month

(cherry picked from commit 7c566d6cfc7bfb913bad89d87386fa21dce8c2e6)

7 months agoDocument library types in the intro(3) manual page
Gordon Bergling [Thu, 16 Nov 2023 09:48:09 +0000 (10:48 +0100)]
Document library types in the intro(3) manual page

Add a paragraph about library types to the intro(3)
manual page. Document library types, locations
and versioning.

Reviewed by: emaste, jilles, mhorne, pauamma_gundo.com
Obtained from: OpenBSD (partial)
Differential Revision: https://reviews.freebsd.org/D36594

(cherry picked from commit 54611b7cc69cee34e7bcdc2324a9159e7543a125)

7 months agoRTLD_DEEPBIND: make lookup not just symbolic, but walk all refobj' DAGs
Konstantin Belousov [Wed, 29 Nov 2023 18:30:59 +0000 (20:30 +0200)]
RTLD_DEEPBIND: make lookup not just symbolic, but walk all refobj' DAGs

PR: 275393

(cherry picked from commit 9daf6cd0f46416d9c6eb0411ea6042cd42b8a9bc)

7 months agobusdma: emit a warning for use of filters
Mitchell Horne [Mon, 4 Dec 2023 15:46:48 +0000 (11:46 -0400)]
busdma: emit a warning for use of filters

Filter functions are deprecated, and unused in the tree. If either of
the filter or filterarg arguments to bus_dma_tag_create() are non-NULL,
print a warning.

This is a direct commit to stable/13.

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42897

7 months agopf: fix mem leaks upon vnet destroy
Igor Ostapenko [Wed, 29 Nov 2023 12:35:41 +0000 (13:35 +0100)]
pf: fix mem leaks upon vnet destroy

Add missing cleanup actions:
- remove user defined anchor rulesets
- remove user defined ether anchor rulesets
- remove tables linked to user defined anchors
- deal with wildcard anchor peculiarities to get them removed correctly

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

(cherry picked from commit 0626d30e41cba64b41667314c3a4f7611f0eb685)

7 months agoperiodic/daily/480.leapfile-ntpd: only attempt to refresh leap-seconds.list
Xin LI [Sun, 3 Dec 2023 07:00:32 +0000 (23:00 -0800)]
periodic/daily/480.leapfile-ntpd: only attempt to refresh leap-seconds.list
when ntpd is enabled.

The leap-seconds.list is used exclusively by ntpd, therefore, do not bother
to perform the fetch when ntpd is not enabled.

PR: conf/275419
Reviewed by: cy, michaelo, imp
Differential Revision: https://reviews.freebsd.org/D42875

(cherry picked from commit 3b3195f6767b39eb33b3523134ef988931c9c86d)

7 months agousbdevs: add quirk for WD MyPassport Ultra External HDD
Eugene Grosbein [Sun, 3 Dec 2023 16:48:34 +0000 (23:48 +0700)]
usbdevs: add quirk for WD MyPassport Ultra External HDD

WD MyPassport Ultra External HDD needs quirk
UQ_MSC_NO_TEST_UNIT_READY to attach.

(cherry picked from commit 970d73856b626a68597de19d37b68c376e2c0491)

7 months agorelease/Makefile.vm: Rework emulator-portinstall
Colin Percival [Sun, 3 Dec 2023 21:39:30 +0000 (13:39 -0800)]
release/Makefile.vm: Rework emulator-portinstall

The emulator-portinstall target now unconditionally ensures that qemu
is installed; but is only invoked if needed (aka. when cross building
VM images).

MFC After: 3 days
MFC With: 97bd53ef4d20 ("Fix duplicate rc.conf files")

(cherry picked from commit 7d0ee5ebd052d35e323f2d303e467c2cf305ca39)

7 months agoMakefile.vm: Fix duplicate rc.conf files
Colin Percival [Mon, 27 Nov 2023 21:29:05 +0000 (13:29 -0800)]
Makefile.vm: Fix duplicate rc.conf files

Two bugs in Makefile.vm resulted in disk images being "built" multiple
times, resulting in lines added to /etc/rc.conf being duplicated:

1. The vm-image target reused the same "staging tree" directory for all
of its builds (multiple disk image types and multiple filesystem types).

2. The cw-type-flavour-fs target depends on emulator-portinstall, which
did not have a 'touch ${.TARGET}' and thus re-ran every time -- and
caused the cw-type-flavour-fs target to be re-run.  This was triggered
by release builds running `make cloudware-release` (creating the disk
images) followed by `make ec2amis` (which re-created the disk images
prior to uploading them).

MFC After: 1 week
Sponsored by: https://www.patreon.com/cperciva

(cherry picked from commit 97bd53ef4d20b7d15e0b0976e885af9438f5637e)

7 months agopf: remove incorrect fragmentation check
Kristof Provost [Wed, 29 Nov 2023 18:06:31 +0000 (19:06 +0100)]
pf: remove incorrect fragmentation check

We do not need to check PFDESC_IP_REAS while tracking TCP state.
Moreover, this check incorrectly considers no-data packets (e.g. RST) to
be in-window when this flag is not set.

Sponsored by: Rubicon Communications, LLC ("Netgate")
Approved by: so
Security: FreeBSD-SA-23:17.pf

(cherry picked from commit 6284d5f76d6bd2d97fe287c5adabf59c79688eda)

7 months agovmstat: fix column names broken in c168508655720
Maxim Sobolev [Tue, 5 Dec 2023 01:39:21 +0000 (17:39 -0800)]
vmstat: fix column names broken in c168508655720

Loss of the trailing space in the multi-line format string has
resulted in column name being emitted as "FAILSLEEP", instead of
two columns "FAIL" and "SLEEP".

(cherry picked from commit 62d47a4db4579315d7b89002d7de696b44ae1415)