Compare commits

...
Author SHA1 Message Date
Mark Johnston 5fb0f8e9e6 Add UPDATING entries and bump patch version
Approved by:	so
2026-01-26 20:42:23 +00:00
Gordon Tetlow 02f448fe5c openssl: Fix multiple vulnerabilities
This is a rollup commit from upstream to fix:
  Improper validation of PBMAC1 parameters in PKCS#12 MAC verification (CVE-2025-11187)
  Stack buffer overflow in CMS AuthEnvelopedData parsing (CVE-2025-15467)
  NULL dereference in SSL_CIPHER_find() function on unknown cipher ID (CVE-2025-15468)
  "openssl dgst" one-shot codepath silently truncates inputs >16MB (CVE-2025-15469)
  TLS 1.3 CompressedCertificate excessive memory allocation (CVE-2025-66199)
  Heap out-of-bounds write in BIO_f_linebuffer on short writes (CVE-2025-68160)
  Unauthenticated/unencrypted trailing bytes with low-level OCB function calls (CVE-2025-69418)
  Out of bounds write in PKCS12_get_friendlyname() UTF-8 conversion (CVE-2025-69419)
  Missing ASN1_TYPE validation in TS_RESP_verify_response() function (CVE-2025-69420)
  NULL Pointer Dereference in PKCS12_item_decrypt_d2i_ex function (CVE-2025-69421)
  Missing ASN1_TYPE validation in PKCS#12 parsing (CVE-2026-22795)
  ASN1_TYPE Type Confusion in the PKCS7_digest_from_attributes() function (CVE-2026-22796)

See https://openssl-library.org/news/secadv/ for additional details.

Approved by:	so
Obtained from:	OpenSSL
Security:	FreeBSD-SA-26:01.openssl
Security:	CVE-2025-11187
Security:	CVE-2025-15467
Security:	CVE-2025-15468
Security:	CVE-2025-15469
Security:	CVE-2025-66199
Security:	CVE-2025-68160
Security:	CVE-2025-69418
Security:	CVE-2025-69419
Security:	CVE-2025-69420
Security:	CVE-2025-69421
Security:	CVE-2026-22795
Security:	CVE-2026-22796
2026-01-26 19:00:49 +00:00
Konstantin Belousov bb150039c0 vm_fault: only rely on PG_ZERO when the page was newly allocated
Approved by:	so
Security:	FreeBSD-EN-26:03.vm

(cherry picked from commit cff67bc43d)
(cherry picked from commit 3c0942f992)
2026-01-26 16:48:40 +00:00
Konstantin Belousov 6e279feb40 vm_object_page_remove(): clear pager even if there is no resident pages
Approved by:	so
Security:	FreeBSD-EN-26:03.vm

(cherry picked from commit 72a447d0bc)
(cherry picked from commit 10f12fbe67)
2026-01-26 15:26:21 +00:00
Andrew Turner 679b1a810e arm64: Correctly align the SVE signal context
The SVE signal context needs to be correctly aligned. Fix this by
creating a new macro to calculate the needed size to provide this
alignment, and use it when setting and checking the saved SVE signal
context.

Approved by:	so
Security:	FreeBSD-EN-26:02.arm64
Reported by:	cperciva
Reviewed by:	cperciva, markj
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D54396

(cherry picked from commit a9e77eb701)
(cherry picked from commit 683decf362)
2026-01-26 14:43:40 +00:00
John Baldwin 6a192c14d2 Revert "devinfo: Add support for libxo"
This broke the human output formatting in several ways.

This reverts commit 4cf5878d27.
This reverts commit e8d6b58ef5.
This reverts commit c759aca606.

Approved by:	so
Security:	FreeBSD-EN-26:01.devinfo
PR:		291511
Reviewed by:	imp, des
Differential Revision:	https://reviews.freebsd.org/D54196

(cherry picked from commit 43b07bdbc5)
(cherry picked from commit ed6612dea2)
2026-01-26 14:43:28 +00:00
Mark Johnston 63a5b645b2 Add UPDATING entries and bump version.
Approved by:	so
2025-12-16 23:42:39 +00:00
Mark Johnston 408f5c6182 rtsold: Validate entries in domain search lists
Reported by:	Kevin Day <[email protected]>
Approved by:	so
Security:	FreeBSD-SA-25:12.rtsold
Security:	CVE-2025-14558
2025-12-16 23:42:34 +00:00
Bojan Novković 04e9f1aab8 amd64/vmm.c: Fix an incorrect memory segment check in vm_iommu_{un}map
This change fixes two checks that conflated memory mapping and memory
segment idenitifers. In both cases the code iterates over all memory
mappings but passes the index to `vm_memseg_sysmem`, which is wrong.

Fix this by passing the memory mapping's segment identifier instead.

Differential Revision:	https://reviews.freebsd.org/D54210
Reviewed by:	markj
Fixes:	c76c2a19ae
PR:	290920
Approved by:	so
Security:	FreeBSD-EN-25:20.vmm

(cherry picked from commit f1809eab82)
(cherry picked from commit 4f7436bf29)
2025-12-16 16:01:22 +00:00
Mark Johnston ff6b9c7c1c zfs: Merge commit 86b064469d from OpenZFS
FreeBSD: Fix a potential null dereference in zfs_freebsd_fsync()

  In general it's possible for a vnode to not have an associated VM
  object.  This happens in particular with named pipes, which have
  some distinct VOPs, defined in zfs_fifoops.  Thus, this chunk of
  zfs_freebsd_fsync() needs to check for the FIFO case, like other
  vm_object_mightbedirty() callers do.

  (Note that vn_flush_cached_data() calls are predicated on
  zn_has_cached_data() returning true, and it checks for a NULL v_object
  pointer already.)

  Fixes: ef4058fcdc
  Reported-by: Collin Funk <[email protected]>
  Reviewed-by: Sean Eric Fagan <[email protected]>
  Reviewed-by: Brian Behlendorf <[email protected]>
  Reviewed-by: Alexander Motin <[email protected]>
  Signed-off-by: Mark Johnston <[email protected]>
  Closes #18015

MFC after:	3 days
Approved by:	so
Security:	FreeBSD-EN-25:19.zfs

(cherry picked from commit fa259d156d)
(cherry picked from commit d988a0c1fc)
2025-12-16 16:01:07 +00:00
Colin Percival 7aedc8de64 Update in preparation for 15.0-RELEASE
- Bump BRANCH to RELEASE
- Add the anticipated RELEASE announcement date
- Set a static __FreeBSD_version

Approved by:	re (implicit)
2025-11-28 00:00:00 +00:00
Colin Percival 463cec10a5 pkg: Move FreeBSD-base to pkg.freebsd.org
Rather than fetching packages directly from the CDN which currently
backs pkgbase.freebsd.org, requests will go to pkg.freebsd.org mirrors
and be 302ed to the correct servers.  This adds ~70 seconds to the
process of installing or upgrading a pkgbase system; it also orphans
systems with 15.0-{PRERELEASE,ALPHA*,BETA*} installed since they are
expecting to see pkgbase files signed with the pkg keys, not the new
pkgbase signing keys.

Approved by:	re (cperciva)
Reviewed by:	dch, philip
MFC after:	immediately (for 15.0-RELEASE)
With hat:	re
Requested by:	clusteradm, core
Differential Revision:	https://reviews.freebsd.org/D53964

(cherry picked from commit a3b0902d73)
(cherry picked from commit 0c87d29a54)
2025-11-27 14:40:59 -08:00
Olivier Certner 20ebb6ec5a mdo.1: Document group-related and fine-grained control functionalities
This is a manual page update describing the functionality that was added
to mdo(1) in commit 3ca1e69028 ("mdo(1): Add support and shortcuts for
fully specifying users and groups").  Please either refer to that commit
or the new manual page's content for more information.

While here:
- Add to the introduction a description of process credentials and some
  specific vocabulary that is used throughout the page, as well as the
  relationship between mdo(1) and mac_do(4).
- Update the HISTORY section.
- Add AUTHORS and SECURITY CONSIDERATIONS sections.

Approved by:	re (cperciva)
Reviewed by:    ziaee
MFC after:      1 minute
Sponsored by:   The FreeBSD Foundation
Sponsored by:   Google LLC (GSoC 2025)
Co-authored-by: Kushagra Srivastava <[email protected]>
Differential Revision:  https://reviews.freebsd.org/D53905

(cherry picked from commit 73dd00f2fd)
(cherry picked from commit dc75034792)
2025-11-26 17:57:24 -08:00
Colin Percival f73d78e3ff bsdinstall: Ignore -p[0-9]+ in determining BRANCH
The patch level is not part of the branch per se and should not be
used in constructing the FreeBSD-base.conf file used by bsdinstall.

Approved by:	re (cperciva)
MFC after:	1 day

(cherry picked from commit d45816f369)
(cherry picked from commit 56275b7b06)
2025-11-26 17:57:20 -08:00
Gordon Tetlow c7ccd5b3f8 Add UPDATING entry and bump version number.
Approved by:	so
Approved by:	re (cperciva)
2025-11-26 08:12:45 -08:00
Gordon Tetlow dabd406d99 Mitigate YXDOMAIN and nodata non-referral answer poisoning.
Add a fix to apply scrubbing of unsolicited NS RRSets (and their
respective address records) for YXDOMAIN and nodata non-referral
answers. This prevents a malicious actor from exploiting a possible
cache poison attack.

Approved by:	so
Approved by:	re (cperciva)
Obtained from:	NLnet Labs
Security:	FreeBSD-SA-25:10.unbound
Security:	CVE-2025-11411
2025-11-26 08:04:39 -08:00
Chuck Silvers 4f2d5bcdbf nda: fix setting of unmappedio flag
The upstream refactoring of ndaregister() to split out ndasetgeom()
accidentally used an uninitialed variable to decide whether or not
to set DISKFLAG_UNMAPPED_BIO.  Fix this by moving that portion of
ndasetgeom() back up to ndaregister().  The check for PIM_UNMAPPED
is not really needed because nvme devices always have that set,
so it cannot change in the other path that ndasetgeom() is now called.

Approved by:	re (cperciva)
Reviewed by:	cperciva, gallatin, imp
Fixes:		dffd882d12
Sponsored by:	Netflix
MFC After:	1 minute
(cherry picked from commit 2b4dbad2db)
(cherry picked from commit e271f9327f)
2025-11-25 15:41:38 -08:00
Minsoo Choo 020e15a901 jemalloc: apply freebsd changes to jemalloc 5.3.0 man page
Approved by:	re (cperciva)
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1890

(cherry picked from commit 80ec82aba9)
(cherry picked from commit cbe0ccde66)
2025-11-25 14:58:58 -08:00
Minsoo Choo cda51d06f9 jemalloc: import jemalloc 5.3.0 man page
Approved by:	re (cperciva)
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1890

(cherry picked from commit bf4c7487f2)
(cherry picked from commit 6162f863ce)
2025-11-25 14:58:55 -08:00
Colin Percival 91e2d7b9b2 15.0: Update to RC4
This will hopefully be the final RC build before the release.

Approved by:	re (implicit)
2025-11-24 09:42:12 -08:00
Mark Johnston 76883b793d inotify: Work around the vput() bug directly
For 15.0, apply a minimal fix which at least ensures that inotify can't
trigger the latent race described in commit 99cb3dca47 ("vnode: Rework
vput() to avoid holding the vnode lock after decrementing").

Approved by:	re (cperciva)
Reviewed by:	olce, kib
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D53774

(cherry picked from commit ebc17879f0)
(cherry picked from commit 1f6e3abf41)
2025-11-24 09:31:16 -08:00
Dag-Erling Smørgrav bada4c39b2 pam_krb5: Fix manual page in MIT case
* Always install the manual page as pam_krb5(8) regardless of which
  version we're using.
* Regenerate it using pod2mdoc instead of pod2man so it doesn't claim
  to be part of “User Contributed Perl Documentation”.
* Put the correct section number in the header and footer.
* Don't cross-reference non-existent pam(7) manual page.

Approved by:	re (cperciva)
Reviewed by:	cperciva
Differential Revision:	https://reviews.freebsd.org/D53885

(cherry picked from commit 961b934407)
(cherry picked from commit 4166181675)
2025-11-23 22:23:11 -08:00
Dag-Erling Smørgrav 8fdafb3966 pam_krb5: Restore allow_kdc_spoof option
Not only does the new pam_krb5 module not have the same allow_kdc_spoof
option that the old one had, its behavior in this matter defaults to
insecure.  Reimplement allow_kdc_spoof and switch the default back.

Approved by:	re (cperciva)
Reviewed by:	cy
Differential Revision:	https://reviews.freebsd.org/D53884

(cherry picked from commit fe5c8baf25)
(cherry picked from commit 2eb030d1c8)
2025-11-23 22:23:08 -08:00
Colin Percival 9f43dc502c release: Ship DVD with only emacs@nox flavour
Contrary to the claim made in a previous commit, removing KDE and
adding all of vim and emacs results in an image which does not fit
into 4.7 GB; to be specific, it lands at 4.722 GB rather than the
claimed 4.689 GB.  (This descrepancy resulted from doing test DVD
image builds using an out-of-date tree, and became visible when the
15.0-RC3 images were built.)

Limit the emacs packages shipped on the DVD to the "nox" flavor;
this brings the disk image down to 4.407 GB, aka under the 4.7 GB
limit for standard DVDs.

Approved by:	re (cperciva)
Fixes:	6cc6beb4c8 ("release: Remove KDE from dvd1.iso")
MFC after:	1 day (for 15.0-RC4)

(cherry picked from commit c8cf5a99f8)
(cherry picked from commit 815f085600)
2025-11-23 22:23:02 -08:00
Gordon Tetlow fb9252e667 Add backup pkgbase signing key held by security-officer.
This key was generated by gordon@ (aka security-officer@) on an offline
system as a backup key should anything happen to the AWS Key
Management Service that is currently in use for signing pkgbase
repositories for FreeBSD 15.x.

Approved by:	re (cperciva)
Reviewed by:	cperciva
With hat:	so

(cherry picked from commit 12ec49d8fa)
(cherry picked from commit 696b0e2209)
2025-11-23 08:38:52 -08:00
Dag-Erling Smørgrav 54808d5041 cp: Fix copying the root directory
When the source of the copy operation is the root directory, we should
neither append it to the destination path on FTS_D nor trim it back off
on FTS_DP.

Approved by:	re (cperciva)
PR:		291132
MFC after:	3 days
Fixes:          82fc0d09e8 ("cp: Partly restore symlink folllowing.")
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D53863

(cherry picked from commit fe836c5012)
(cherry picked from commit c4843e5805)
2025-11-23 08:38:48 -08:00
Alexander Ziaee d84de55c15 loader.8: Document module commands
Begin documenting module loader commands in loader(8), where the reader
would look for them. Segregate them by their availability in individual
loader implementations, like build(7) targets.
These details were graciously donated by kevans.

Approved by:	re (cperciva)
MFC after:		3 days
Reviewed by:		kevans
Co-authored-by:		Kyle Evans <[email protected]>
Differential Revision:	https://reviews.freebsd.org/D50727

(cherry picked from commit 6fb0d67819)
(cherry picked from commit 513b9db1a8)
2025-11-23 08:38:45 -08:00
Alexander Ziaee bba7812141 loader manuals: Clarify console and boot_serial
console=comconsole is for the loader and boot_serial is for the kernel.

I think we should centralize documentation on the loader settings in one
manual, such a loader.8. The current proliferation is not obvious where
to find the documentation. To the user, these are all set in loader.conf
or at the loader prompt.

Approved by:	re (cperciva)
MFC after:		3 days
Differential Revision:	https://reviews.freebsd.org/D53695

(cherry picked from commit 09ffaa4e07)
(cherry picked from commit 3035855815)
2025-11-23 08:38:41 -08:00
Alexander Ziaee f7fd040e3b freebsd-tips: Add a shell function for laptops
Approved by:	re (cperciva)
MFC after:		3 days
Reviewed by:		pauamma_gundo.com
Differential Revision:	https://reviews.freebsd.org/D53748

(cherry picked from commit 42d9ae4945)
(cherry picked from commit f0bb9d28eb)
2025-11-23 08:38:38 -08:00
Alexander Ziaee 56f49dd3a0 vt.4: Document increasing scrollback size
Approved by:	re (cperciva)
MFC:			immediately as 2 llms say this is impossible
Reviewed by:		adrian, emaste
Differential Revision:	https://reviews.freebsd.org/D53860

(cherry picked from commit a8740ba860)
(cherry picked from commit 2da71ee296)
2025-11-23 08:38:34 -08:00
Alexander Ziaee a14c4d0708 dmesg.8: Index kern.msgbuf_show_timestamp
This is the only place this important debugging tunable is documented.
Mark it up with the Va macro according to style.mdoc(5) so that people
can find it via `apropos Va=kern.msg`, the standard syntax to search
the FreeBSD manual for sysctls and tunables.

Approved by:	re (cperciva)
Fixes:	6910fee62e (dmesg: Document kern.msgbuf_show_timestamp)
(cherry picked from commit e13664f6a4)
(cherry picked from commit 1c0668c5b3)
2025-11-23 08:38:28 -08:00
Colin Percival 4579378a95 15.0: Update to RC3
Approved by:	re (implicit)
2025-11-21 00:00:00 +00:00
Colin Percival 07b7bd2311 release: Remove KDE from dvd1.iso
Prior to this commit, we were shipping 2155 MB of packages (from the
ports tree, not counting pkgbase) on dvd1.iso.  Due to the amount of
space required by shipping pkgbase packages *and* distribution sets
on the DVD images, we only have 1696 MB available if we want to fit
into the 4.7 GB limit for DVDs.  Many users have indicated that this
is indeed important.

It is practically impossible to hit this target without removing KDE;
while KDE and its dependencies narrowly fit (1550 MB), we exceed the
limit as soon as we include either of freebsd-doc-all or gnome.  While
we would pick KDE over GNOME (surveys regularly indicate that KDE is
the more widely used of the two), we believe that documentation is the
most important thing to include.

Since removing KDE leaves a bit of extra space, add editors/emacs and
editors/vim.  This takes the 15.0 amd64 dvd1.iso up to 4.689 GB. [1]

Approved by:	re (cperciva)
Requested by:	adamw [1]
MFC after:	immediately (for 15.0-RC3)
Differential Revision:	https://reviews.freebsd.org/D53800

(cherry picked from commit 6cc6beb4c8)
(cherry picked from commit 142df248ac)
2025-11-19 13:37:24 -08:00
Wanpeng Qian e4416d1e95 nvme_sim: signal namespace depature
Signal when the namespace is gone so we can tear down the disk when a
nvme drive is removed.

Approved by:	re (cperciva)
Reviewed by: 		imp
Differential Revision:	https://reviews.freebsd.org/D33032

(cherry picked from commit 4640f50089)
(cherry picked from commit b7ffac0454)
2025-11-19 13:37:21 -08:00
Wanpeng Qian da71efa95d nvd: handle namespace changes
Signal the new media size when the namespace changes size.

Approved by:	re (cperciva)
Reviewed by: 		imp
Differential Revision:	https://reviews.freebsd.org/D33032

(cherry picked from commit bd769e73d8)
(cherry picked from commit 96a7ed1e7f)
2025-11-19 13:37:19 -08:00
Wanpeng Qian ecfb0e51b2 nda: React to namespace change events
Register for AC_GETDEV_CHANGED. When we receive a namespace
notification, we only create a new device if it was unconfigured. If it
was configured, generate this async event. Rely on the fact that we
reconstruct namespace to just get the data from the identify data and
call disk_resised.

Approved by:	re (cperciva)
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D33032

(cherry picked from commit 86d3ec359a)
(cherry picked from commit 9a465b37ea)
2025-11-19 13:37:15 -08:00
Wanpeng Qian 0ccc71de62 nvme: Refactor geom setting to function.
Refactor setting of geometry for the disk to its own function. No
functional changes.

Approved by:	re (cperciva)
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D33032

(cherry picked from commit dffd882d12)
(cherry picked from commit 31412fda9f)
2025-11-19 13:37:12 -08:00
Wanpeng Qian 2c5edd4860 nvme: Notify namespace changes better
When we get a namespace notification, we have to reconstrut the
namespace to get the new identification data from the namespace. For
each namespace in the AEN, we will reconstrict it before we call the
notification. We also flag it as changed for the duration of the change
callback (prior versions of the patch needed to keep track, but we no
longer do, so this bit may be removed). Note when we've seen the
namespace so we can notify when it goes away.

Approved by:	re (cperciva)
Co-authored-by: imp
Differential Revision: https://reviews.freebsd.org/D33032

(cherry picked from commit 20e94950c5)
(cherry picked from commit fe6ee00d17)
2025-11-19 13:37:09 -08:00
Warner Losh 7b31e6a121 nvme: Fix backwards sense of error condition
b21e67875b tested for the good condition, not the error condition, so
we'd never do anything else in this function. This was causing certain
logging not to happen, and also prevented forthcoming namespace size
change code from working as well.

Approved by:	re (cperciva)
Fixes: b21e67875b
Sponsored by: Netflix
(cherry picked from commit 27481c2689)
(cherry picked from commit fd737810a1)
2025-11-19 13:37:05 -08:00
Martin Matuska c30f4ada16 zfs: fix aarch64 build after zfs-2.4.0-rc4
Approved by:	re (cperciva)

(cherry picked from commit fb709935d6)
(cherry picked from commit 484fa40ca7)
2025-11-19 13:37:03 -08:00
Martin Matuska d10ce383bc zfs: update zfs_config.h and zfs_gitrev.h to zfs-2.4.0-rc4
While here, fix compilation be unhiding zfs_tunables hidden in 5714090fb

Approved by:	re (cperciva)

(cherry picked from commit 7128544353)
2025-11-19 13:36:59 -08:00
Martin Matuska 7b5b0f43eb zfs: merge openzfs/zfs@099f69ff5 (zfs-2.4-release) into stable/15
OpenZFS 2.4.0 rc4

Notable upstream pull request merges:
 #17477 1e8c96d7d Add knob to disable slow io notifications
 #17792 5582e8b08 Update dnode_next_offset_level to accept blkid
                  instead of offset
 #17872 584762617 Pass flags to more DMU write/hold functions
 #17875 178a8be21 BRT: Round bv_entcount up to BRT_BLOCKSIZE
 #17875 e3acd0a72 Fix caching of DDT log and BRT
 #17877 67fc49433 Cleanup ZIO_FLAG_IO_RETRY vs TRYHARD usage
 #17824 dda711dbb Fix gang write late_arrival bug
 #17890 41878d57e Add BRT support to zpool prefetch command
 #17903 aaf374bd4 ZIO: Set minimum number of free issue threads to 32
 #17906 ac0bc4cc0 spa_misc: add an API for spa_namespace_lock
 #17908 583db4003 FreeBSD: Add support for _PC_CASE_INSENSITIVE
 #17911 -multiple Update library ABI versions for v2.4.0
 #17915 e305c7d59 BRT: Fix ranges to blocks conversion math
 #17916 002bc3da6 BRT: Increase block size from 4KB to 8KB
 #17921 e895c7619 ZAP: Remove dmu_object_info_from_dnode() call

Approved by:	re (cperciva)
Obtained from:	OpenZFS
OpenZFS commit:	099f69ff5d
OpenZFS tag:	zfs-2.4.0-rc4

(cherry picked from commit 155d5b8a19)
2025-11-19 13:36:55 -08:00
Poul-Henning Kamp d02a08f899 iichid: The IICHID spec defines the response to the RESET command as two bytes of zeros.
Our recent changes to iichid.c has caused us to attempt to read a
full REPORT instead, and at least one keyboard hangs solid when we
do that.

This patch changes us to be spec-compliant.

Approved by:	re (cperciva)
Differential Revision: https://reviews.freebsd.org/D53803
MFC after: 1 day
Approved by: re(ccperciva)

(cherry picked from commit 5d53462af1)
(cherry picked from commit d61be9d994)
2025-11-19 13:36:49 -08:00
Colin Percival 476aca4985 UPDATING: Document FreeBSD-base pkg .conf shuffle
Approved by:	re (cperciva)
Reminded by:	yasu
MFC after:	3 days

(cherry picked from commit 6ccdd2fc23)
(cherry picked from commit fa546e9d18)
2025-11-19 13:36:44 -08:00
Colin Percival 7bd80d8ee0 15.0: Update to RC2
Approved by:	re (implicit)
2025-11-17 18:22:00 -08:00
Colin Percival f66279332f release: Add a MISSING_METALOGS hack to VMs
The packages for 15.0-RELEASE built without the bug fix needed to make
files created via @sample get properly listed in METALOG.  Fix the
cloudware which contain @sample-using packages by adding the necessary
files to METALOG manually.

This should be reverted after the next full package build, and live on
only in releng/15.0.

Approved by:	re (cperciva)
Reviewed by:	markj
MFC after:	immediately (15.0-RC2)
Differential Revision:	https://reviews.freebsd.org/D53797

(cherry picked from commit f6e9474ebd)
(cherry picked from commit 96468730a2)
2025-11-17 18:20:38 -08:00
Colin Percival 0f4c3dcd1e GCE: Add /usr/src and /usr/ports to METALOG
We ship these in order to comply with GCE Marketplace rules about
providing source code and licenses for all the software we ship as
part of images.

Approved by:	re (cperciva)
Reviewed by:	markj
MFC after:	immediately (15.0-RC2)
Differential Revision:	https://reviews.freebsd.org/D53796

(cherry picked from commit 0dbb00733c)
(cherry picked from commit 10ef3bf823)
2025-11-17 18:20:35 -08:00
Colin Percival fb51f37070 release: Add /boot/loader.conf to some cloudware
These were forgotten during the METALOGization process earlier.

Approved by:	re (cperciva)
Reviewed by:	markj
MFC after:	immediately (for 15.0-RC2)
Differential Revision:	https://reviews.freebsd.org/D53795

(cherry picked from commit 86c63597f2)
(cherry picked from commit 0e737642f2)
2025-11-17 18:20:30 -08:00
Colin Percival c87b89d053 vmimage.subr: Log correct paths into METALOG
Paths all need to start with "./" because that's what newfs wants.

Approved by:	re (cperciva)
Fixes:	e0c41af925 ("vmimage.subr: Enable FreeBSD-base repo if pkgbase")
MFC after:	immediately

(cherry picked from commit aa33b6b820)
(cherry picked from commit e1560c8ba6)
2025-11-16 09:14:46 -08:00
Colin Percival da0c913638 15.0: Update to RC1
Approved by:	re (implicit)
2025-11-15 19:37:00 -08:00
Colin Percival acf90099fe 15.0: Switch from "quarterly" to "release" pkgs
Approved by:	re (implicit)
2025-11-15 19:36:43 -08:00
Colin Percival 1ef6b8e068 vmimage.subr: Don't log missing files from pkgs
When installing "extra" packages (aka those built from the ports tree),
we record everything being installed in METALOG.pkg; the contents of
that file is appended to METALOG before we generate the filesystem.

There are two cases when files recorded in METALOG.pkg will no longer
exist by the time we create the final disk image:
1. If a pkg bug results in false dependencies being installed which
are later removed by "pkg autoremove", and
2. If the pkg we build and install from /usr/ports is older than the
pkg on pkg.freebsd.org, and pkg gets upgraded automatically as part of
installing extra packages.

The ultimate issue in both cases is that there's no mechanism for
removing entries from METALOG when we run 'pkg delete'.

Address this build breakage by checking, line by line, if filesystem
objects mentioned in METALOG.pkg exist before appending them to METALOG.

Approved by:	re (cperciva)
Fixes:	6a13aeac3c ("vmimage.subr: pkg autoremove after pkg install")
MFC after:	immediately (needed for 15.0-RC1)

(cherry picked from commit 78fa6965e9)
(cherry picked from commit 0ff7c92517)
2025-11-15 19:11:26 -08:00
Colin Percival 6ac6550a91 vmimage.subr: autoremove -y
Running 'pkg autoremove' without -y results in VM image builds failing
when (bogusly installed) packages are removed.

Approved by:	re (cperciva)
Fixes:	6a13aeac3c ("vmimage.subr: pkg autoremove after pkg install")
MFC after:	immediately (needed for 15.0-RC1)

(cherry picked from commit 509dfd3690)
(cherry picked from commit 9600598a5c)
2025-11-15 19:11:23 -08:00
Colin Percival 93c5db9e9c vmimage.subr: Enable FreeBSD-base repo if pkgbase
When creating a VM image using pkgbase, create a configuration file in
/usr/local/etc/pkg/repos/FreeBSD.conf which enables the FreeBSD-base
repository.  (This repository is defined in /etc/pkg/FreeBSD.conf as
being disabled by default.)

Approved by:	re (cperciva)
Reported by:	Mark Millard
MFC after:	immediately (needed for 15.0-RC1)

(cherry picked from commit e0c41af925)
(cherry picked from commit aade340587)
2025-11-15 19:11:20 -08:00
Colin Percival 9835413fb0 bsdinstall: Enable FreeBSD-base repo when pkgbase
When performing a pkgbase install, create a configuration file in
/usr/local/etc/pkg/repos/FreeBSD.conf which enables the FreeBSD-base
repository.  (This repository is defined in /etc/pkg/FreeBSD.conf as
being disabled by default.)

Approved by:	re (cperciva)
Reported by:	Mark Millard
Reviewed by:	markj
MFC after:	immediately (needed for 15.0-RC1)
Differential Revision:	https://reviews.freebsd.org/D53777

(cherry picked from commit a96230e032)
(cherry picked from commit 5d9062f258)
2025-11-15 19:11:17 -08:00
Colin Percival dbe26fafc6 vmimage.subr: Log pkg/local.sqlite if pkgbase
We were doing this in vm_extra_install_packages but VM images without
any extra packages installed would not get this installed.  This
results in a pkgbase system which thinks it doesn't have any packages
installed (even though all the files are right there).

Add a "metalog_add_data ./var/db/pkg/local.sqlite" call to the pkgbase
install code path, and make the call from vm_extra_install_packages
conditional on !PKGBASE.

Approved by:	re (cperciva)
Reported by:	Michael Dexter
MFC after:	immediately (needed for 15.0-RC1)

(cherry picked from commit 10a4f2d016)
(cherry picked from commit 6b15dc234d)
2025-11-15 19:11:14 -08:00
Colin Percival 567ba10572 GCE: Don't .error on unsupported targets
We ingest Makefile.gce even when we're not trying to create GCE images
so we don't want to .error here.  Instead, set GCE_ARCH to a dummy
value which should make the problem clear to anyone who attempts to
create GCE images on an unsupported architecture.

Approved by:	re (cperciva)
Reported by:	Jenkins
Fixes:		0a8ecca4e3 ("GCE: Specify the architecture of images")

(cherry picked from commit 787d09753f)
(cherry picked from commit 375f8df26b)
2025-11-15 19:11:10 -08:00
Andrew Jorgensen c0a98d7f9d GCE: Specify the architecture of images
Without a specified architecture, a user can attempt to create an
arm64 instance with an amd64 image or vice versa. With the change
the API will prevent that mismatch.

Approved by:	re (cperciva)

(cherry picked from commit 0a8ecca4e3)
(cherry picked from commit 93769d225f)
2025-11-15 19:11:07 -08:00
Andrew Jorgensen 75ee49d2ed GCE: Add TARGET and FS to image family
GCE image family is meant to be unique per set of image characteristics
so that a user can create instances using the image family instead of the
image name to reliably get a similar image with updated software, but no
other changes.

Without this change, the instances create API would select the most recent
non-deprecated image matching the name, regardless of architecture or
filesystem.

Approved by:	re (cperciva)

(cherry picked from commit fc83e6c5e1)
(cherry picked from commit 0005bb76e2)
2025-11-15 19:11:03 -08:00
Colin Percival 5d832135a9 pkg: Add FreeBSD-base to /etc/pkg/FreeBSD.conf
On -CURRENT and -STABLE this gets bits from pkg.freebsd.org; but we get
base system bits from pkgbase.freebsd.org for BETA/RC/RELEASE.

Note that this repository is disabled by default, but can still be used
by explicitly specifying it, e.g. "pkg upgrade -r FreeBSD-base".

Approved by:	re (cperciva)
With hat:	re
MFC after:	8 hours (needed in 15.0-RC1)

(cherry picked from commit 8e0b1a1c03)
(cherry picked from commit 91e1c18012)
2025-11-15 19:11:00 -08:00
Colin Percival 1b859fdfc7 bsdinstall: Don't install FreeBSD-base.conf
When installing e.g. 15.0-RC1, we want to get files from the 15.0-RC1
pkgbase repository; but running 'pkg upgrade' after installation should
get the latest bits build from releng/15.0.

Approved by:	re (cperciva)
With hat:	re
MFC after:	8 hours (needed in 15.0-RC1)

(cherry picked from commit bdfc223c7a)
(cherry picked from commit e4bc038ef8)
2025-11-15 19:10:57 -08:00
Colin Percival f852655889 bsdinstall: Use pkgbase.f.o for BETA/RC/RELEASE
For BETA/RC/RELEASE builds, fetch files from the appropriate repository
on pkgbase.freebsd.org, using the appropriate signing keys.  Note that
there is a separate repository for each BETA and RC; this ensures that
someone installing from e.g. a 15.0-RC1 ISO will get 15.0-RC1 bits and
not whatever happens to be the most recent build from releng/15.0.

Approved by:	re (cperciva)
With hat:	re
MFC after:	8 hours (needed in 15.0-RC1)

(cherry picked from commit 51184e38c9)
(cherry picked from commit 2ce97e8003)
2025-11-15 19:10:54 -08:00
Colin Percival a13564a16f Add pkgbase signing keys for FreeBSD 15
These keys were generated by cperciva@ using the AWS Key Management
Service.  They will not be used for signing anything other than
FreeBSD 15.x pkgbase repositories.

Keys will be generated for FreeBSD 16 at a later date, and likely in
a different way.

Approved by:	re (cperciva)
With hat:	re
MFC after:	8 hours (needed in 15.0-RC1)
Differential Revision:	https://reviews.freebsd.org/D53768

(cherry picked from commit b05f38262b)
(cherry picked from commit 01ba48e113)
2025-11-15 19:10:51 -08:00
Colin Percival d347f4a2ee bsdinstall: Copy in all keys
The keys used for pkgbase signing are going to be placed in
/usr/share/keys/pkgbase-N where N is the FreeBSD major version
number; as such it's not sufficient to copy /usr/share/keys/pkg
into the install chroot, but instead we need /usr/share/keys/*.

Approved by:	re (cperciva)
With hat:	re
MFC after:	8 hours (needed in 15.0-RC1)
Differential Revision:	https://reviews.freebsd.org/D53753

(cherry picked from commit 6b0909f940)
(cherry picked from commit 7c98b725a7)
2025-11-15 19:10:46 -08:00
Mark Johnston 4f0b477080 arm64/vmm: Fix handling of MDCR_EL2.TDE
TDE (make EL2 the target EL for debug exceptions) is set both when
setting guest breakpoints and when single-stepping the guest.  In some
cases we may configure both capabilities, and when subsequently
disabling one of them we need to take care to avoid clearing TDE if the
other is still configured.

Approved by:	re (cperciva)
MFC after:	3 days
Fixes:		75cb949228 ("arm64/vmm: Add breakpoint and single-stepping support")
Sponsored by:	CHERI Research Centre (EPSRC grant UKRI3001)

(cherry picked from commit b6f25aca11)
(cherry picked from commit 295f7255a3)
2025-11-15 18:00:36 -08:00
Mark Johnston a44a95b001 arm64/vmm: Don't set MDSCR_EL1.KDE when enabling single-stepping
When VHE mode is enabled, this results in a hang on the host.  In
particular, when MDSCR_EL2.KDE is set to 1 and the CPU is executing at
EL_D, i.e., EL2, debug exceptions are enabled. In non-VHE mode, we call
into the guest by trapping to EL2, which implicitly masks debug
exceptions by setting PSTATE.D. However, in VHE mode, PSTATE.D remains
clear, so when the guest's MDSCR_EL1 value is loaded, we immediately
begin single-stepping.

In non-VHE mode there is no need to set KDE either, so just stop setting
it.

Approved by:	re (cperciva)
Reviewed by:	andrew
MFC after:	3 days
Sponsored by:	CHERI Research Centre (EPSRC grant UKRI3001)
Differential Revision:	https://reviews.freebsd.org/D48965

(cherry picked from commit ac0032344c)
(cherry picked from commit 47fdacee69)
2025-11-15 18:00:30 -08:00
Olivier Certner b0447186a6 setcred(): Fix 32-bit compatibility copy-in
For 32-bit processes on 64-bit architectures, a difference of 'int'
pointers was wrongly used as a number of bytes to copy in a memcpy()
used to internally construct a 64-bit 'struct setcred' from the 32-bit
variant, leading to copying only part of the 32-bit structure, and thus
to requesting credentials with garbage IDs except for the real and
effective user IDs.

This bug was spotted by jhb@, who produced a slightly more invasive fix
in D53757 (a switch to using CP() on all fields).  In the interest of
minimizing the diff for possible inclusion in 15.0, the commit here just
limits itself to fixing the number of bytes to copy.

Tested successfully on a VM with 32-bit mdo(1) (and in passing also
tested that the same executable on a kernel without this change exhibits
the bug in practice, in the form of setcred() failing with EINVAL).

Reported by:    jhb
Reviewed by:    jhb
Fixes:          ddb3eb4efe ("New setcred() system call and associated MAC hooks")
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D53767

(cherry picked from commit 4872b48b17)

For the insta-MFC to stable/15:
Approved by:    re (cperciva)

(cherry picked from commit 190e6d6795)
2025-11-15 07:05:11 -08:00
Lexi Winter e13fa6418f libpam: Don't put man8 in the dev package
These are user-facing manpages, but were installed in the runtime-dev
package since the PAM modules use bsd.lib.mk.  Use MANNODEV instead of
MAN to put them in the base runtime package instead.

Approved by:	re (cperciva)
Fixes:  031e711647 ("packages: Install development manpages in the -dev package")
MFC after:	3 days
Reviewed by:	bapt
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53601

(cherry picked from commit b1972bd9a0)
2025-11-15 06:43:09 -08:00
Kyle Evans 81f61990b2 lam: fix using stdin more than once
Historically, lam(1) closes stdin once we've hit EOF the first time,
which would stop it from doing anything else on subsequent gatherline()
calls with another openfile.  However, this doesn't seem to be strictly
necessary- the EOF flag on FILEs is quite sticky, so we can assume that
a subsequent fgetc(stdin) will flag EOF properly.

This 'fixes' the below-referenced commit in the sense that it surfaced
this problem as a fatal error, but the issue was pre-existing.  If we
do `lam - -`, then one gatherline() will fclose(stdin) and set `ip->eof`
for *that* openfile, while the next one will then observe that
STDIN_FILENO has been closed and turn it into an EBADF.

Add a few tests that were easy to snipe while I'm here, but I haven't
aimed for anything close to exhaustive because I think re@ would prefer
this fix go in sooner rather than later to land in 15.0.

Minor style adjustment for the previous commit while we're here.

Approved by:	re (cperciva)
Reported by:	cperciva
Discussed with:	jrtc27
Reviewed by:	des, jlduran
Fixes:	4472fd66d0 ("lam: fail on I/O errors")
Sponsored by:	Klara, Inc.

(cherry picked from commit 6a9452c837)
(cherry picked from commit 1d678ba575)
2025-11-15 06:43:05 -08:00
Muhammad Moinur Rahman 279213eb62 Retire pccard(4)
pccard has been declared obsolete for a long time and also the
support has been removed but the man page still exists. It mentions
being scheduled to be removed before 13.0 but it still exists in the
tree.

[Extracted from review D53434]

Approved by:	re (cperciva)
Reviewed by: emaste
Fixes: 31b35400c ("pccard: Remove more of the PC Card infrastructure")

(cherry picked from commit 5b9fba1cb0)
(cherry picked from commit 8bafd2f052)
2025-11-15 06:42:56 -08:00
Jiacong Fang f1d3ed77c9 mpr.4: Add Broadcom LSI 3808 to HARDWARE
The product brief "MegaRAID 9500 PCIe Gen 4.0 Tri-Mode Storage Adapters"
confirms that the LSI 3808 are supported in FreeBSD.

https://docs.broadcom.com/doc/MegaRAID-9500-Tri-Mode-Storage-Adapters

Approved by:	re (cperciva)
MFC after:		3 days (squashed with fixup commit)
Reviewed by:		imp, ziaee
Differential Revision:	https://reviews.freebsd.org/D52760

(cherry picked from commit 744c8d5544)
(cherry picked from commit 8caf467784)
(cherry picked from commit 00008dae20)
2025-11-13 18:35:05 -08:00
Yogesh Bhosale 9ca96ef84f ix.4: Add E610 to HARDWARE section
Approved by:	re (cperciva)
MFC after:		3 days
Reviewed by:		ziaee
Fixes:			dea5f973d0 (new Intel Ethernet E610 family)
Differential Revision:	https://reviews.freebsd.org/D52990

(cherry picked from commit abd53b16c0)
(cherry picked from commit 1a1e30b355)
2025-11-13 18:35:03 -08:00
Alexander Ziaee 9465b903fb sbp.4: Add a hardware section, fix markup nits
+ tag SPDX
+ add sysctl to apropos database
+ fix markup of examples and reflow a overly long line
+ add a hardware section for hw relnotes

Approved by:	re (cperciva)
MFC after:	3 days

(cherry picked from commit dee8e38f52)
(cherry picked from commit ccf4b4fc42)
2025-11-13 18:35:00 -08:00
Alexander Ziaee 1eebc3a372 mx25l.4: Add n25q64 to hardware list
Approved by:	re (cperciva)
MFC after:	3 days
Fixes:		76735c7439 (flash: Add "n25q64" to mx25l driver)

(cherry picked from commit 595fcd71a8)
(cherry picked from commit bf2345bce5)
2025-11-13 18:34:56 -08:00
Alexander Ziaee 480f0a1d0f mx25l.4: Describe better and tag spdx
Approved by:	re (cperciva)
MFC after:	3 days

(cherry picked from commit 6f73950475)
(cherry picked from commit 9b00b95b21)
2025-11-13 18:34:53 -08:00
Muhammad Moinur Rahman 95fcade817 pcic.4: Remove stale manual
Approved by:	re (cperciva)
MFC after:	2 days (squashed with fixup commit)
Reviewed by:	ziaee
Fixes:		31b35400c (pccard: Remove more of the PC Card)
Discussed with:	bsdimp, emaste, jhb
Extracted from:	https://reviews.freebsd.org/D53434

(cherry picked from commit 1d9f2db7c0)
(cherry picked from commit 6aaf184dc4)
(cherry picked from commit feb8971db4)
2025-11-13 18:34:51 -08:00
Alexander Ziaee 893e5b7020 hgame.4: Polish
Explain driver loading and application access in the body of the manual.
Crossreference other game controller driver manuals, and devfs.rules to
hint about how to configure application access. Add a common dongle to
supported hardware. Add evdev a few places to make it really clear how
it works.

Approved by:	re (cperciva)
MFC after:		immediately for inclusion in 15.0R
Reviewed by:		wulf
Differential Revision:	https://reviews.freebsd.org/D53290

(cherry picked from commit c0c8d812b5)
(cherry picked from commit 31e7ee6bd5)
2025-11-13 18:34:48 -08:00
Alexander Ziaee 14ada82543 jail.8: Add creating a jail from package base
Approved by:	re (cperciva)
MFC after:		immediately for inclusion in 15.0R
Reported by:		ivy
Differential Revision:	https://reviews.freebsd.org/D53745

(cherry picked from commit 477799750a)
(cherry picked from commit f467eb078f)
2025-11-13 18:34:46 -08:00
Alexander Ziaee 16d599da7b jail.8: Add creating a jail from distribution set
Approved by:	re (cperciva)
PR:			200803
MFC after:		3 days
Reviewed by:		jamie
Differential Revision:	https://reviews.freebsd.org/D53631

(cherry picked from commit d59903481d)
(cherry picked from commit 5d7cd576d9)
2025-11-13 18:34:41 -08:00
Robert Clausecker cb9075718b aio: fix alignment of struct (o)aiocb32 on non-amd64
Only i386 has a four-byte alignment for uint64_t, others have
eight-byte alignment.  This causes the structure to mismatch
on armv7 binaries running under aarch64, breaking the aio interface.

Approved by:	re (cperciva)
Fixes:		3858a1f4f5
Approved by:	markj (mentor)
Reported by:	Mark Millard <[email protected]>
Discussed with:	jrtc27
PR:		290962
MFC after:	immediately (for 15.0)

(cherry picked from commit ea26fd52a9)
2025-11-13 18:27:28 -08:00
Mark Johnston c70f6e4f4b stand: Teach the zfs loader about dynamic gang headers
There is a pool feature, dynamic_gang_header, that is enabled by default
in new pools.  When this feature is active, gang headers may be larger
than 512 bytes.  The loader needs to be taught to cope with that.

Try using the vdev ashift to pick the gang block header size.  If the
checksum fails, fall back to the old gang block header size.

This is based on a patch by Paul Dagnelie, with testing, bug-fixing and
some simplifications from me.

Approved by:	re (cperciva)
PR:		289690
Co-authored by:	Paul Dagnelie <[email protected]>
Reviewed by:	imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D53578

(cherry picked from commit 4d6801a6b5)
(cherry picked from commit ae17780c71)
2025-11-13 12:12:21 -08:00
Colin Percival bee506b883 Azure: Fix image names
We need to specify the correct image names -- *.vhdf, not *.vhd -- in
order for them to upload.

15.0 candidate

Approved by:	re (cperciva)
Reviewed by:	lwhsu
MFC after:	2 days
Differential Revision:	https://reviews.freebsd.org/D53684

(cherry picked from commit df84867e8a)
(cherry picked from commit eee338692b)
2025-11-12 10:46:18 -08:00
Bjoern A. Zeeb f490eae83f LinuxKPI: 802.11: clear CONF_IDLE earlier
When starting to scan and ending a scan we clear/set the hardware to
idle.  Similarly we set the hw to idle when we remove the channel
context but when starting we only set it to non-idle when we went from
assoc to run.  This apparently was not a problem most of the time
as the switch from a failed hardware scan to a software scan was
racing against net80211.  ad4ddc83eb fixed that specifically for
rtw88 and while we were more consistently scanning, this broke
authentication as the setting of idle at the end of the scan was
now happening reliably.  Move the unsetting of idle from assoc_to_run
to scan_to_auth for when we  create the chanctx to keep it
symmetrical.  This makes authentication work again for rtw88 (though
not for everyone due to other possible problems with net80211).

This likely also fixes the problems in the listed PRs.

iwlwifi(4) mvm and mld driver parts do not use this information at
all and were never affected.

Approved by:	re (cperciva)
Sponsored by:	The FreeBSD Foundation
PR:		290850, 288186, 281979
PR:		272145 (the non skb-mem-limit parts)

(cherry picked from commit b568711f8e)
(cherry picked from commit a77abd53e8)
2025-11-12 10:46:14 -08:00
Ed Maste c5977a934c bsdinstall: Use fat32 EFI system partition for ZFS
This is consistent with other operating systems and with bsdinstall's
UFS config and with bsdinstall's ZFS config prior to commit
0b7472b3d8.

Approved by:	re (cperciva)
PR:		290857
Fixes: 0b7472b3d8 ("Mount the EFI system partition (ESP) on newly-installed systems.")
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53642

(cherry picked from commit 4109cdf0f8)
(cherry picked from commit 65e347d315)
2025-11-12 10:46:12 -08:00
Michael Tuexen c50312b774 vtnet: fix enabling/disabling tso
Transmit segment offloading depends on transmit checksum offloading.
Enforce that constraint. This also fixes a bug, since if_hwassist bits
are from the CSUM_ space, not from the IFCAP_ space.

Approved by:	re (cperciva)
PR:			290773
Reviewed by:		Timo Völker
Tested by:		[email protected]
Differential Revision:	https://reviews.freebsd.org/D53629

(cherry picked from commit 4c50ac6816)
(cherry picked from commit 0fb0ba51d8)
2025-11-12 10:46:09 -08:00
Michael Tuexen b91bf9f0e2 vtnet: don't provide VIRTIO_NET_HDR_F_DATA_VALID
According to section 5.1.6.2.1 of version 1.3 of the virtio
specification, the driver MUST NOT set VIRTIO_NET_HDR_F_DATA_VALID in
the flags. So don't do that.

Approved by:	re (cperciva)
Reviewed by: 		Timo Völker
Differential Revision:	https://reviews.freebsd.org/D53650

(cherry picked from commit 836b3cd9d7)
(cherry picked from commit 0ef06b5bcc)
2025-11-12 10:46:06 -08:00
Michael Tuexen bd4cf77ba2 tcp: drop SYN ACK segment for listening sockets
When a SYN ACK is received for a listening socket, just drop it
instead of killing the SYN-cache entry and send a RST.
This closes the possibility to kill a TCP connection during its
handling in the SYN-cache.

Approved by:	re (cperciva)
Reviewed by:		Nick Banks, Peter Lei
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D53540

(cherry picked from commit 239464e993)
(cherry picked from commit e082156ae1)
2025-11-12 10:46:02 -08:00
Ed Maste e55b2f0321 bsdinstall: Fix newfs bsddialog menu
The second and third members of struct bsddialog_menuitem are `bool on`
and `unsigned int depth`. The newfs dialog options in bsdinstall's
partition tool had these two swapped, so the default selection did not
work.

Approved by:	re (cperciva)
PR: 290857
Reviewed by: asiciliano
Fixes: 50e244964e ("bsdinstall/partedit: Replace libdialog with libbsddialog")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53639

(cherry picked from commit 4e36942420)
(cherry picked from commit 980aa8d4cf)
2025-11-10 11:00:15 -08:00
Ed Maste dd1ed088f0 openssh: Handle localtime_r() failure by return "UNKNOWN-TIME"
Apply openssh-portable commit 8b6c1f402feb by [email protected]

Approved by:	re (cperciva)
Obtained from:	openssh-portable
PR:		288773
Reported by:	wosch
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit ce03706ab2)
(cherry picked from commit 0a45aa9e95)
2025-11-10 11:00:10 -08:00
David E. O'Brien 0339b24f8d random: Have RANDOM_PURE_START be a cross-platform source
and one that will be with us in the long-term future.
(this helps reduce diffs in the future and for down-stream users
that trim entropy sources).  Also, move deprecated (removed in 16.0)
sources to the bottom of the list to reduce changes to 15.x.

Approved by:	re (cperciva)
Reviewed by:	glebius
Obtained from:	Juniper Networks
Differential Revision:	https://reviews.freebsd.org/D53311
(cherry picked from commit 9f3886347c1750cf80a82314470fc7186088eb9a)
(cherry picked from commit e224f2c1b9)
2025-11-10 10:54:37 -08:00
Bruno Silvestre 40056e8abc netlink: plug lock leak in genl_register_family()
Approved by:	re (cperciva)
PR:		290893
(cherry picked from commit 335fc09ab8)
(cherry picked from commit a3cd3a4fd6)
2025-11-10 10:49:11 -08:00
Mark Johnston ee234a8f17 freebsd-update: Swap pkg(8) flags in check_pkgbase()
Unbootstrapped pkg will ignore -N if -r is specified first.  Flip the
order.

Prior to commit 66c75fa63a this worked by accident.

Approved by:	re (cperciva)
PR:		290393
Reported by:	olgeni
MFC after:	3 days
Fixes:		66c75fa63a ("freebsd-update: Fix the pkgbase check")

(cherry picked from commit 645352316b)
(cherry picked from commit addc0556ce)
2025-11-10 10:49:08 -08:00
Colin Percival 854651d47e release: Add WITHOUT_QEMU to IMAKE
We have NO_ROOT here, so we need WITHOUT_QEMU to avoid problems.

15.0 candidate.

Approved by:	re (cperciva)
Reviewed by:	emaste, markj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D53637

(cherry picked from commit f89aa18848)
(cherry picked from commit 2e2a460f9a)
2025-11-10 10:49:04 -08:00
Mark Johnston 69c726c150 virtio: Fix polling in virtqueue_dequeue()
The access of vq->vq_ring.used->idx needs to be volatile-qualified,
otherwise the compiler may optimize virtqueue_poll() into an infinite
loop if there is no data available upon the first poll.

Prior to commit ad17789a85 this wasn't a problem since an external
function call after each poll inhibited the optimization.

Approved by:	re (cperciva)
PR:		289930
MFC after:	3 days
Sponsored by:	Klara, Inc.
Fixes:		ad17789a85 ("virtio: Remove the unused poll method")

(cherry picked from commit f999ffdce3)
(cherry picked from commit 72c7604754)
2025-11-07 15:12:02 -08:00
Lexi Winter 3447fc070c atf: Move the tests back to the tests package
Commit 9065390ddc moved atf to its own package, but mistakenly moved
the tests as well.  Put the tests back into the test package.

Approved by:	re (cperciva)
Fixes:	9065390ddc ("packages: Remove the tests-dev package")
MFC after:	1 day
Reviewed by:	emaste
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53594

(cherry picked from commit 4b342830ab)
(cherry picked from commit cdfa913977)
2025-11-06 21:46:58 -08:00
Lexi Winter 5bee2fda67 libcrypto: Install tests in the tests package
libcrypto's Makefile.inc used PACKAGE=openssl, which overrides the
PACKAGE=tests in libcrypto/tests/Makefile.  Use PACKAGE?=openssl
instead to avoid this.  This puts the OpenSSL tests in the tests
package where they belong.

Approved by:	re (cperciva)
MFC after:	1 day
Reviewed by:	manu, ngie
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53595

(cherry picked from commit c3b853fe52)
(cherry picked from commit 4e672f6ff0)
2025-11-06 21:46:49 -08:00
Colin Percival db99e6ce3e 15.0: Update to BETA5
Approved by:	re (implicit)
Sponsored by:	https://www.patreon.com/cperciva
2025-11-06 21:16:10 -08:00
Li-Wen Hsu 58f208591b release: Comply with Azure Marketplace requirements for aarch64
Azure requires the first 1 MB (2,048 sectors) of the OS disk to remain
empty for VM images:

  https://learn.microsoft.com/partner-center/marketplace-offers/azure-vm-certification-faq#vm-images-must-have-1-mb-of-free-space

Also append the BOOTPARTSOFFSET suffix for aarch64 images, which only
has an ESP partition for booting.

Co-authored-by:	Brad Davis <[email protected]>
Approved by:	re (cperciva)
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53628

(cherry picked from commit 36095c9420)
(cherry picked from commit 72617603a2)
2025-11-06 21:15:59 -08:00
Alexander Ziaee 715cc30d29 sysrc.8: Rewrite examples for mdoc conformance
Tag SPDX while here. This is not a content change, so do not bump date.

Approved by:	re (cperciva)
PR:		274164
MFC after:	3 seconds

(cherry picked from commit 3f0dd77246)
(cherry picked from commit 9a6e6e9edc)
2025-11-06 20:19:35 -08:00
Alexander Ziaee c66b978205 ciss.4: Add p440ar to HARDWARE
Approved by:	re (cperciva)
PR:		290425
MFC after:	3 seconds, this fixes the HW relnotes
Reported by:	jwb

(cherry picked from commit a41ffaa330)
(cherry picked from commit 801f10b8c7)
2025-11-06 20:19:33 -08:00
Felix Johnson 776626f09e dumpon(8): Add a SYSCTL VARIABLES section
Document debug.minidump and machdep.dump_retry_count sysctl variables.

Approved by:	re (cperciva)
PR:			259393
MFC after:		3 seconds
Reviewed by:		gbe (previous), markj, ziaee
Differential Revision:	https://reviews.freebsd.org/D32618

(cherry picked from commit 850841edf6)
(cherry picked from commit 2608020ac8)
2025-11-06 20:19:30 -08:00
Alexander Ziaee 3a63ca9620 ice.4: Add ToC and E835 and editorial pass
This manual is large enough and well structured enough that we can have
a clickable table of contents. Use that to move some subsections which
should not appear in Hardware Release Note to the description section.
Adjust subsection names so this will work, preserving parentheticals
for search by moving them to the bodies just below.

Strip unnecessary copyright symbols and escaped hyphens. Copyright
symbols never appear in the content of manual pages, including other
Intel manual pages, and appear to break the Hardware Release Notes.
Escaped hyphens were necessary decades ago for manual pages written
in man(7), but this page is written in mdoc(7). Also misc touchups.

Add the recently added E835 devices to the supported HARDWARE list.
Add the speed ranges to description like the other ethernet drivers.

Approved by:	re (cperciva)
PR:		290778
MFC after:      1 day
Fixes:		09b48f811b (Add support for E835-XXV-4 adapter)
Fixes:		b202176dc7 (Add PCI IDs for E835 devices)
Reviewed by:	kgalazka (previous version)
Reported by:	kgalazka (additional hardware has been added)
Reported by:	[email protected] (HW Relnote is truncating)

(cherry picked from commit f30335c5cb)
(cherry picked from commit 71bd17b879)
2025-11-06 20:19:26 -08:00
Brad Davis d1ee21dc55 ice.4: Avoid first person language
Approved by:	re (cperciva)
Approved by:	ziaee
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D52896

(cherry picked from commit 85531add28)
(cherry picked from commit 0ee1546565)
2025-11-06 20:19:24 -08:00
Alexander Ziaee 02eabc44ed bhyve.8: Correct description for -c flag, tag spdx
The examples only show the usage of `-c <numcpus>`, as did the flag
description, however the -c flag supports more complex cpu topology
specifiers. These were documented correctly in SYNOPSIS, add them to
the body of the DESCRIPTION as well. Someone could go further and do
and example with using them.

Approved by:	re (cperciva)
MFC after:	3 days (there was a merge conflict with the date)
Event:		OpenZFS Developer Summit '25
Reported by:	Levi Worley <[email protected]>

(cherry picked from commit 205af037e3)
(cherry picked from commit 772837c632)
2025-11-06 20:19:21 -08:00
Alexander Ziaee 5f6d85cb1b gshsec.8: Fix list alignment, tag spdx
Approved by:	re (cperciva)
MFC after:	3 days

(cherry picked from commit 05d4858460)
(cherry picked from commit 6d6132d8ca)
2025-11-06 20:19:18 -08:00
William Carrel 6efc9b0e6a ifconfig.8: Mention max name length
Approved by:	re (cperciva)
PR:		289113
MFC after:	3 days

(cherry picked from commit 832cd05905)
(cherry picked from commit e2a87c0817)
2025-11-06 20:19:16 -08:00
David E. O'Brien 7d106aaa93 random: CTASSERT check sizeof random_source_descr[]
Ensure that the number of elements of random_source_descr[]
and fxrng_ent_char[] matches that of enum random_entropy_source.

Approved by:	re (cperciva)
Reviewed by:	cem
Differential Revision: https://reviews.freebsd.org/D53255
(cherry picked from commit 8bd9a9e9e4)
(cherry picked from commit d53618d582)
2025-11-06 20:19:13 -08:00
David E. O'Brien 08515bdecc random: fenestrasX: Add missing entropy sources
Approved by:	re (cperciva)
Reviewed by: cem
Fixes: 1492c8c0d qcom_rnd: add initial qualcomm prng driver.
Fixes: 9eecef052 Add an Armv8 rndr random number provider
Fixes: b2f8b2dc8 sys: Add an SMCCC Random Number Generator driver
Differential Revision:	https://reviews.freebsd.org/D53292
(cherry picked from commit 93b02f69a6)
(cherry picked from commit 3a9bcf8dee)
2025-11-06 20:19:11 -08:00
David E. O'Brien 3d598826e1 Add FENESTRASX to LINT to avoid breakage
Approved by:	re (cperciva)

(cherry picked from commit c1e7e8f5cb)
(cherry picked from commit a3fcb7bfea)
2025-11-06 19:36:33 -08:00
Lexi Winter 18602717de etc/mtree/BSD.include.dist: Remove libipt-dev
This package only exists on amd64, which means on other platforms we
produce an empty package containing nothing but this directory, and
without a base package (libipt) that package fails to install due to
a missing dependency.

For now, fix this by removing the libipt-dev package tag, which moves
this directory to clibs.

Approved by:	re (cperciva)
Fixes: 436618a427 ("etc/mtree: Add package tags for /usr/include")
Reported by:	cperciva
MFC after:	3 seconds

(cherry picked from commit 2a8a6179eb)
(cherry picked from commit ccd948829c)
2025-11-06 15:11:31 -08:00
Colin Percival 4291f032c4 release: Make fetch happen in GCE images
We want to fetch distfiles, regardless of whether they contain known
vulnerabilities or we're building images for a different version of
FreeBSD.

Approved by:	re (cperciva)
Reviewed by:	ivy
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D53569

(cherry picked from commit 8234c1899b)
(cherry picked from commit 3b01c7da327853e9f3347ff0cae9d075460f5a27)
2025-11-06 15:11:28 -08:00
Colin Percival dab5efb726 release: Don't try to fetch distfiles for pkgbase
In order to comply with the require that GCE images must include their
source code, we fetch distfiles for all of the packages installed into
GCE images.  This fails for obvious reasons for packages with an origin
of base/*; filter those out to generate the list to fetch.

Approved by:	re (cperciva)
Reviewed by:	ivy
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D53568

(cherry picked from commit 05b3a45cd0)
(cherry picked from commit 92ab9516c8a5d196b60ac8f6df777de745aaa219)
2025-11-06 15:11:26 -08:00
Colin Percival f512ec40bb release: GCE builds depend on ftp
GCE images are required by Google to include their source code; we do
this by extracting {src,ports}.txz into the images, from the (legacy)
distribution sets.

Make sure those distribution sets actually exist.

Approved by:	re (cperciva)
Reviewed by:	ivy
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D53567

(cherry picked from commit 7f536b1c11)
(cherry picked from commit a1b00e368926198a163015bfe21171f2d582c703)
2025-11-06 15:11:23 -08:00
Colin Percival f438cf7428 vmimage.subr: pkg autoremove after pkg install
A bug in pkg, which somehow only surfaced as a consequence of pkgbase,
results in pkg install sometimes pulling in false dependencies.  This
problem might be limited to cases when the lib32 pkgbase packages are
not installed.  In the case of EC2 "small" images, installing the
ebsnvme-id package results in binutils, gcc12-devel, gmp, indexinfo,
liblz4, mpc, mpfr, and zstd packages being installed.

These false dependencies are however not recorded as dependencies --
at some level pkg does understand that they're not needed -- so running
pkg autoremove immediately after pkg install cleans them up.

Note: This does not remove lines from METALOG corresponding to these
packages, and makefs emits an error when it attempts to create the
filesystem but cannot find the files listed in METALOG -- but makefs
does seem to complete normally despite the error messages.

This change should be reverted once the pkg issue has been located and
fixed.

Approved by:	re (cperciva)
Reviewed by:	ivy
MFC after:	3 days
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D53543

(cherry picked from commit 6a13aeac3c)
(cherry picked from commit a21cff76c57089cd357473128d42410d189ca149)
2025-11-06 15:11:18 -08:00
Colin Percival 299dfb3cec Makefile.incl1: .WAIT before distribute in etc
In order to make sure that man pages are all installed before we run
makewhatis to generate mandoc.db files, we have long placed etc at the
end of the list of subdirectories being recursed into by the build.
In order to support installworld -jN, a .WAIT was more recently added
here.

With the recent adoption by the release engineering team of parallel
*release* builds (aka 'make release -jN') it is now also necessary to
add the same .WAIT before recursing for the 'distribute' target, as we
otherwise end up with distribution sets containing incomplete mandoc.db
files.

Approved by:	re (cperciva)
Reviewed by:	bdrewery
PR:		289683
MFC after:	3 days
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D53533

(cherry picked from commit dcb6706ba4)
(cherry picked from commit 48dbf763337aea30e29971e751d3aa1044a555ef)
2025-11-06 15:11:15 -08:00
Colin Percival 0888e32663 release: Spell metalog_add_data conventionally
Approved by:	re (cperciva)
Reviewed by:	markj
MFC after:	3 days
Fixes: f1995d6fc1 ("release: Prepare GCE cloudware images for building as non-root")
Differential Revision:	https://reviews.freebsd.org/D53530

(cherry picked from commit c3a3af1346)
(cherry picked from commit 6e47589eb067e5a22cce9f351ecf12bd2ffa9e4d)
2025-11-06 15:11:13 -08:00
Olivier Certner 76fb5c23dc setcred(): Fix RACCT resource accounting on credentials change
When credentials are changed, we need to adjust the sum of resources
associated to the initial and new process' user IDs (and old and new
login classes and jails, but setcred() does not change them) for them to
stay consistent.

Approved by:	re (cperciva)
PR:             290352
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D53457

(cherry picked from commit 2be5127c4a)
(cherry picked from commit 2e76660cb7)
2025-11-06 15:11:10 -08:00
Olivier Certner c3a27fa066 kern: Fix credentials leaks on RACCT but no RCTL
Affected system calls: setuid(), setreuid(), setresuid(), jail_attach(),
setloginclass().

In these system calls, the crhold() calls that, on RACCT, make the
just-installed process credentials survive a concurrent change of the
same credentials just after PROC_UNLOCK() were not matched by
a corresponding crfree() when RCTL is off.  In fact, in that latter
case, they are simply not necessary, so wrap them with '#ifdef RCTL'
stances.  'kern_rctl.c' causes a compile error if RACCT is not defined
but RCTL is, so ease reading by not nesting '#ifdef's.

Approved by:	re (cperciva)
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D53456

(cherry picked from commit f4315ff8b3)
(cherry picked from commit 4db768b01c)
2025-11-06 15:11:08 -08:00
Kristof Provost 1e5405d6b5 pf: improve DIOCRCLRTABLES validation
Unterminated strings in the anchor or name could cause crashes.
Validate them, and add a test case.

Approved by:	re (cperciva)
Reported by:	Ilja Van Sprundel <[email protected]>
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 1da3c0ca5b)
(cherry picked from commit 909528f8a1)
2025-11-06 15:11:05 -08:00
Kristof Provost 05c3c8c0ab pf: improve add state validation
Both for the DIOCADDSTATE ioctl and for states imported through pfsync packets.
Add a test case to exercise this code path.

Approved by:	re (cperciva)
Reported by:	Ilja Van Sprundel <[email protected]>
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit faacc0d968)
(cherry picked from commit 4891e6f1c0)
2025-11-06 15:11:02 -08:00
Alan Somers 06edf53ab5 fusefs: Fix intermittency in the BadServer.ShortWrite test case
We were using the m_quit bit for two similar but distinct uses:

* To instruct the server to quit
* To cope with the kernel forcibly unmounting the fs

Fix the intermittent test failure by adding a separate bit,
m_expect_unmount, to handle cases like the latter.

Approved by:	re (cperciva)
Reported by:	Siva Mahadevan <[email protected]>
MFC after:	1 week
Revied by:	Siva Mahadevan <[email protected]>
Differential Revision: https://reviews.freebsd.org/D53357

(cherry picked from commit d86025c1d4)
(cherry picked from commit f0cf086c05)
2025-11-06 15:10:59 -08:00
Alan Somers 914064cf19 fusefs: fix intermittency in the BadServer.ShortWrite test
This test implicitly depended on the order in which two threads
completed.  If the test thread finished first, the test would pass.  But
if the mock file system thread did, it would attempt to read from an
unmounted file system, and fail.  As a result, the test would randomly
fail once out of every several thousand executions.  Fix it by telling
the mock file system's event loop to exit without attempting to read any
more events.

Approved by:	re (cperciva)
Reported by:	Siva Mahadevan <[email protected]>
MFC after:	1 week
Reviewed by:	Siva Mahadevan <[email protected]>
Differential Revision: https://reviews.freebsd.org/D53080

(cherry picked from commit d1bd541b38)
(cherry picked from commit a1c3537148)
2025-11-06 15:10:55 -08:00
Alan Somers a711949115 fusefs: respect the server's FUSE_SETXATTR_EXT flag
FUSE protocol 7.33 extended the FUSE_SETXATTR request format.  But the
extension is optional.  The server must opt-in by setting the
FUSE_SETXATTR_IN flag during FUSE_INIT.  We were wrongly using the
extended format for any server using protocol 7.33 or later.

Approved by:	re (cperciva)
PR:		290547
Co-authored-by:	CismonX <[email protected]>
Fixes:		d5e3cf41e8 ("fusefs: Upgrade FUSE protocol to version 7.33")
MFC after:	3 days

(cherry picked from commit e8449c0e0f)
(cherry picked from commit a23bd71dea)
2025-11-06 15:10:51 -08:00
Lexi Winter ba5626d398 etc/mtree: Add package tags for /usr/include
Set the default package to clibs-dev, since that's where the vast
majority of include files comes from.  Add explicit package tags
for the directories which are installed in their own package.

Approved by:	re (cperciva)
MFC after:	1 day
Reviewed by:	emaste
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53577

(cherry picked from commit 436618a427)
(cherry picked from commit 736771f631)
2025-11-06 15:10:49 -08:00
Lexi Winter 011bfe6aae packages: Make set-base-dbg depend on set-optional-dbg
As set-base depends on set-optional, so should set-base-dbg depend on
set-optional-dbg.  Otherwise, people who install set-base-dbg will be
missing a bunch of debug packages.

Approved by:	re (cperciva)
MFC after:	1 day
Reviewed by:	emaste
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53575

(cherry picked from commit 3bcb297770)
(cherry picked from commit 5f1d2ef1f5)
2025-11-06 15:10:46 -08:00
Lexi Winter 190e1cd5a6 libkadm5clnt: Fix library symlink install
libkadm5clnt_mit installs a symlink from libkadm5clnt.so for backward
compatibility, but it neglected to include the package tags, so the
symlink was missing from pkgbase builds.  Add ${DEV_TAG_ARGS} to the
install command.

Approved by:	re (cperciva)
Reported by:	Mark Millard <[email protected]>
MFC after:	1 day
Reviewed by:	emaste
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53574

(cherry picked from commit 707507c27f)
(cherry picked from commit dd9ba3201b)
2025-11-06 15:10:43 -08:00
Lexi Winter 2e2e70bee7 libcasper: Move everything to the libcasper package
The libcasper package exists to contain libcasper, but for some reason
only the libcap_net service was in the package, with libcasper itself
and the rest of the services being in runtime.  Move everything to the
libcasper package, except tests which stay in the tests package.

Approved by:	re (cperciva)
MFC after:	1 day
Reviewed by:	emaste
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53576

(cherry picked from commit b8697ac70e)
(cherry picked from commit 25eb50f68b)
2025-11-06 15:10:36 -08:00
John Baldwin 054da4a6d0 riscv: Treat pointer register as an input in fpe_store
The contents of the memory is an output, but the pointer to that memory
is an input. This was correct in the original version of D45697, but
when adding appropriate clobbers, the pointer operand was incorrectly
switched to an output rather than left an input for fpe_store.

Approved by:	re (cperciva)
Reviewed by:	jrtc27
Obtained from:	CheriBSD
Fixes:		44d4ee7f3d ("riscv: add FPE code.")
MFC after:	1 day
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D53441

(cherry picked from commit 91f66f9b37)
(cherry picked from commit 0b5e4af65d)
2025-11-05 12:18:00 -08:00
Enji Cooper f7717bbe13 OpenSSL: install .pc files from the exporters subdir
The .pc files generated in the root directory are used as part of the
build; they should never be installed. Use the versions from the
exporters subdirectory--which should be installed--as the .pc files
which are distributed with FreeBSD. This avoids the need for "fixing up"
these files after the fact (see `crypto/openssl/BSDmakefile` for more
details as part of this change).

Garbage collect `secure/lib/libcrypto/Makefile.version`, et al,
as they're orphaned files. They were technically unused prior to this
change as the vendor process properly embeds the version numbers in
various files, but this commit formalizes the removal.

This correction/clarification on the .pc files will be made in an
upcoming release of OpenSSL [1].

References:
1. https://github.com/openssl/openssl/issues/28803

Approved by:	re (cperciva)
Suggested by:	Richard Levitte (OpenSSL project)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D53043

(cherry picked from commit 97388e7215)
(cherry picked from commit 9b84a17c0a)
2025-11-05 11:37:11 -08:00
Enji Cooper 1b0202b4b6 crypto/openssl: remove autogenerated files
These files contain build host paths and other configuration details
that can be regenerated via the standard vendor import process. Don't
clutter up the FreeBSD tree with these files.

Add the paths to .gitignore to prevent them from accidentally being
added in a future update.

Approved by:	re (cperciva)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D53044

(cherry picked from commit d271d2ce15)
(cherry picked from commit 0d5ef734e9)
2025-11-05 11:37:07 -08:00
Enji Cooper a7c692e022 openssl: add a simple smoke test for the legacy provider
This change adds a simple smoke test for the legacy provider to ensure
that the provider doesn't break in the future when performing updates.

This is not a functional or system test; the OpenSSL test suite does a
much better job at doing this than we can.

Approved by:	re (cperciva)
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D53045

(cherry picked from commit 3b6442370a)
(cherry picked from commit 9b3c89ce8b)
2025-11-05 11:37:03 -08:00
Enji Cooper af0eda4f33 crypto/openssl: update generated files to match 3.5.4 artifacts
Approved by:	re (cperciva)
MFC with:	046c625e93
Fixes:		046c625e93 ("crypto/openssl: update to 3.5.4")
Reported by:	Herbert J. Skuhra <[email protected]>

(cherry picked from commit d4033e6d37)
(cherry picked from commit 505aec2bf3)
2025-11-05 11:36:59 -08:00
Enji Cooper c0366f908f crypto/openssl: update to 3.5.4
This change includes all necessary changes required to update to OpenSSL
3.5.4.

More information about the 3.5.4 release can be found in the relevant
release notes (see 8e12a5c4eb for more details).

Merge commit '8e12a5c4eb3507846b507d0afe87d115af41df40'

Approved by:	re (cperciva)

(cherry picked from commit 046c625e93)
(cherry picked from commit 57d1d2c497)
2025-11-05 11:36:54 -08:00
Enji Cooper 27ae9da27a crypto/openssl: update build artifacts for the 3.5.3 release
This change updates the build artifacts to match the 3.5.3 release. Much
of the change involves updating version numbers and release dates to
match the release version's metadata.

Approved by:	re (cperciva)
MFC after:	1 week
MFC with:	88b8b7f0c4

(cherry picked from commit d9cc3d558d)
(cherry picked from commit 41955f207f)
2025-11-05 11:36:52 -08:00
Enji Cooper 136987f898 crypto/openssl: update component to 3.5.3
This change updates the sources for crypto/openssl. The subsequent
commit will update the build artifacts to match the 3.5.3 release.

More details about the update can be found in the related vendor branch
commits.

Approved by:	re (cperciva)
MFC after:	1 week
Merge commit 'aed904c48f330dc76da942a8ee2d6eef9d11f572'

(cherry picked from commit 779e075df9)
2025-11-05 11:36:48 -08:00
Enji Cooper 2e31b9635c crypto/openssl: apply polish to new vendor import process
This change does the following 2 things:
- Makes the build more repeatable by isolating the environment. This
  prevents bmake from leaking variables into gmake and makes the overall
  process a bit more robust.
- Add debug printouts to make the process more straightforward to the
  reader and whoever is executing doing the current vendor import.

Approved by:	re (cperciva)
MFC after: 1 month
Differential Revision:	https://reviews.freebsd.org/D52420

(cherry picked from commit d18058b7b8)
(cherry picked from commit 22382d9e70)
2025-11-05 11:36:44 -08:00
Enji Cooper 8b1dd80fd2 Update the installed manpages to match OpenSSL 3.5.1
Approved by:	re (cperciva)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D52008

(cherry picked from commit fdb3b695a4)
(cherry picked from commit 3e979746ab)
2025-11-05 11:36:41 -08:00
Kyle Evans 508f9b6837 ipfw: pmod: avoid further rule processing after tcp-mod failures
m_pullup() here will have freed the mbuf chain, but we pass back an
IP_FW_DENY without any signal that the outer loop should finish.  Thus,
rule processing continues without an mbuf and there's a chance that we
conclude that the packet may pass (but there's no mbuf remaining)
depending on the rules that follow it.

Approved by:	re (cperciva)
PR:		284606
Reviewed by:	ae

(cherry picked from commit c0382512bf)
(cherry picked from commit 21d55ae111)
2025-11-05 11:36:38 -08:00
Dag-Erling Smørgrav 290b9b6b26 id: Fix WITHOUT_AUDIT build
Rather than add more ifdefs, trust the compiler to optimize Aflag away.

Approved by:	re (cperciva)
Fixes:		70b72ede98 ("id: Clean up")
PR:		290740
MFC after:	3 days

(cherry picked from commit 92a533ed1d)
(cherry picked from commit 05a3f80efe)
2025-11-05 11:36:35 -08:00
Konrad Witaszczyk 4e80f9f643 dtrace/arm64: properly traverse the symbol table
LINKER_EACH_FUNCTION_NAMEVAL() stops processing the symbol table if a
callback function returns a non-zero value.

The fbt_provide_module_function() callback should not return 1 when
ignoring symbols. Instead, always return 0, as in dtrace/x86.

Approved by:	re (cperciva)
Fixes:		30b68ecda8 ("Changes that improve DTrace FBT reliability on freebsd/arm64:")
Reviewed by:	markj, oshogbo
Approved by:	oshogbo (mentor)
Obtained from:	CheriBSD
Differential Revision: https://reviews.freebsd.org/D53399

(cherry picked from commit 2acdec9e4d)
(cherry picked from commit 76a0a5f91d)
2025-11-05 11:36:32 -08:00
Andrey V. Elsukov 72777e9bf6 mld6: Properly initialize MLD packet options
After commit 530c2c30b0 we need to set flags to ensure that hop-by-hop
and hop limit options are included.

Approved by:	re (cperciva)
PR:		290407
Reviewed by:	zlei, markj
MFC after:	3 days
Fixes:		530c2c30b0 ("ip6_output: Reduce cache misses on pktopts")

(cherry picked from commit 5568fba657)
(cherry picked from commit 5c4144fe1f)
2025-11-05 11:36:29 -08:00
Jose Luis Duran 6e1d4406f1 mtree: Remove stray atm directory
ATM support for netgraph was removed in af0cc0b223 ("NgATM: Remove
netgraph ATM support")

Remove the directory from the mtree specification.

Approved by:	re (cperciva)
Reviewed by:	emaste
Fixes:	21735dfaeb ("include: Remove no longer existing netgraph/atm")
MFC after:	5 days
Differential Revision:	https://reviews.freebsd.org/D53260

(cherry picked from commit 8e8ee8bbe2)
(cherry picked from commit 002ce2c9d0)
2025-11-05 11:36:26 -08:00
Jose Luis Duran eef41b04b3 mtree: Remove stray wi directory
Approved by:	re (cperciva)
Reviewed by:	imp, emaste
Fixes:	a21def4d56 ("pccard: Remove wi(4) driver")
MFC after:	5 days
Differential Revision:	https://reviews.freebsd.org/D53264

(cherry picked from commit f942a74654)
(cherry picked from commit 0b45751456)
2025-11-05 11:36:24 -08:00
Jose Luis Duran 433730c1cb mtree: Remove stray an (Aironet) directory
Approved by:	re (cperciva)
Reviewed by:	imp
Fixes:	663b174b5b ("an: Remove driver")
MFC after:	5 days
Differential Revision:	https://reviews.freebsd.org/D53265

(cherry picked from commit f7ccf05101)
(cherry picked from commit 3281756a24)
2025-11-05 11:36:21 -08:00
Lexi Winter 593f5b29ef static_libpam: Don't install pam.d.5 twice
static_libpam's Makefile includes libpam's Makefile after setting some
variables (like MAN) to empty to avoid installing the manpages twice.
After commit 031e711647, it neglected to do this for MANNODEVLINKS,
causing pam.d.5.gz to be installed twice.  This is harmless for
installworld, but breaks some things that rely on METALOG (NO_ROOT
installs) since it causes two METALOG entries to be generated for
the same file.

Approved by:	re (cperciva)
Fixes:	031e711647 ("packages: Install development manpages in the -dev package")
MFC after:	3 days
PR:		290708
Reported by:	emaste
Reviewed by:	emaste
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53512

(cherry picked from commit a1806e6ff3)
(cherry picked from commit 92a081bc2d)
2025-11-05 11:36:18 -08:00
Lexi Winter 88c5a4996b ifconfig: Fix invalid free() in ifbridge
parse_vlans() does 's = strdup(str)', then calls strsep(&s, ...), then
attempts to free(s) at the end of the function.  For the success case,
this is fine (s is NULL, so it's a trivial memory leak), but in the
error case, we will attempt to free an invalid pointer.

Fix this by storing the original return value from strdup() and freeing
that instead.

Approved by:	re (cperciva)
MFC after:	3 seconds
Reported by:	David Gwynne <[email protected]>
Reviewed by:	zlei, kevans
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53545

(cherry picked from commit 0899f7a3b7)
(cherry picked from commit fe2e534433)
2025-11-05 11:36:12 -08:00
Alfonso S. Siciliano 0595e10ec7 contrib/bsddialog: Import version 1.0.5
Version for change and feature requests.

* Improve documentation for --alternate-screen and --normal-screen.
  Request: https://bugs.freebsd.org/285459. (This PR is not about
  bsddialog itself but is used as an example for an official FreeBSD
  documentation request.)

* Reduce the number of screen refreshes to improve performance over a
  115200 UART connection.
  Request: https://gitlab.com/alfix/bsddialog/-/issues/8.

* Change textbox buttons to return distinct values (previously always
  returned OK).
  Request: https://reviews.freebsd.org/D48668; already committed in
  contrib/ 96a241a359

* Change forms navigation key behavior for ENTER and TAB.
  Request: https://bugs.freebsd.org/287592.

Refer to /usr/src/contrib/bsddialog/CHANGELOG to know more.

PR:		287592
Reported by:	adrian
Approved by:	re (cperciva)
Sponsored by:	The FreeBSD Foundation

Merge commit '653f765f05b8c7e3908ae92e9bf61522a50cefc9' into YYY

(cherry picked from commit 3e42d7194b)
(cherry picked from commit aa2fe36f5e)
2025-11-04 19:30:32 +01:00
Jasper Tran O'Leary 1445291480 nvme: Add handling for bar5
The NVMe spec allows the Table BIR (TBIR) and PBA DIR (PBIR) to
be 0, 4, or 5. The existing NVMe driver basically only has support
for 4, perhaps under the assumption that BAR4 is 64-bit and also
occupies BAR5.

This change adds support for BAR5, covering the case where BAR4
and BAR5 might both be present and 32-bit, where the Table BIR
might be 4 and the PBA BIR might be 5, or vice versa.

The NVMe spec (in the SR-IOV section) also permits VFs to use BIR=2,
so I haven't added stricter checks on which BIR will be permitted
by the driver.

This enables FreeBSD on Google Compute Engine C4 Machines.

Approved by:	re (cperciva)
MFC after:		3 days
Reviewed by:		imp
Sponsored by:		Google
Co-authored-by:		Matt Delco <[email protected]>
Signed-off-by:		Jasper Tran O'Leary <[email protected]>
Differential Revision:	https://reviews.freebsd.org/D53140

(cherry picked from commit 7b32f4f0a7)
(cherry picked from commit 6c321dc15d)
2025-11-03 16:29:52 -08:00
Krzysztof Galazka 83a23ceb40 ice(4): Add support for E835-XXV-4 adapter
Add subdevice ID and branding string for E835-XXV-4
adapter.

Signed-off-by: Krzysztof Galazka <[email protected]>

Approved by:	re (cperciva)
Approved by:	kbowling (mentor), erj (mentor)
Sponsored by:   Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D53319

(cherry picked from commit 09b48f811b)
(cherry picked from commit b59a9230a6)
2025-11-03 12:29:26 -08:00
Krzysztof Galazka 99fdcac549 ice(4): Add PCI IDs for E835 devices
Add device IDs and branding strings for E835 adapters.
This is a follow up for E830 adapters with Security Protocol
and Data Model (SPDM) support and RDMA support available
on 100 and 200Gbps links.

Signed-off-by: Krzysztof Galazka <[email protected]>

Approved by:	re (cperciva)
Approved by:	kbowling (mentor), erj (mentor)
Sponsored by:   Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D52782

(cherry picked from commit b202176dc7)
(cherry picked from commit 16004d2a9e)
2025-11-03 12:29:23 -08:00
Bhosale, Yogesh 97fa2bfeab ixl(4): fix multicast promiscuous mode state tracking and filter management
This change reapplies the improvements from commit 89e7335 and adds
additional fixes and code optimizations on top of it.

The ixl driver supports up to 128 multicast filters in hardware. When this
limit is exceeded, the driver should enable multicast promiscuous mode.
When the count drops below 128, it should disable promiscuous mode and
restore individual filters.

The driver previously had problems that could corrupt multicast filters list.
The main issue was that ixl_dis_multi_promisc() would attempt to disable
promiscuous mode without checking if it was actually enabled, potentially
corrupting existing filters. There was also no state tracking across driver
functions, leading to redundant operations.

This change adds an IXL_FLAGS_MC_PROMISC flag to track the multicast
promiscuous mode state. The flag is set when enabling promiscuous mode and
cleared when disabling it. Early return checks prevent redundant operations
when the mode is already in the desired state, avoiding filter corruption
and unnecessary hardware calls.

Signed-off-by: Yogesh Bhosale [email protected]

Approved by:	re (cperciva)
PR:		283820
Approved by:	kbowling (mentor)
Tested by:	gowtham.kumar.ks_intel.com
Sponsored by:   Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D52549

(cherry picked from commit 46a8a1f08f)
(cherry picked from commit f3c442950d)
2025-11-03 12:29:19 -08:00
Krzysztof Galazka 1d4a3083cf igb(4): Fix out-of-bounds register access on VFs
Virtual Functions have access to a limited number of registers,
and their bus space size is lower. Use KASSERT to detect out-of-bounds
access and eliminate them to avoid kernel panics in production
environment.

Signed-off-by: Krzysztof Galazka <[email protected]>

Approved by:	re (cperciva)
Reviewed by:	jmg
Tested by:	mateusz.moga_intel.com
Approved by:	kbowling (mentor), erj (mentor)
Sponsored by:   Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D52976

(cherry picked from commit 2c02e6ca71)
(cherry picked from commit 9d84e9cba1)
2025-11-03 12:29:15 -08:00
Ed Maste 6bbf1d23e2 bsd.prog.mk: Skip warnings if compiler.mk was not included
We emit a warning if src.conf options WITH_RETPOLINE or INIT_ALL are
in use, and the compiler or linker does not support the feature.

For targets like `cleandir` we skip including bsd.compiler.mk, which
leaves COMPILER_FEATURES unset and spurious warnings were emitted in
early buildworld stages, if these options are in use.

Commit 0837b2ebd5 ("pkg: Die if make -V BRANCH fails") added -W to
usr.sbin/pkg's make flags, causing it to exit on warnings.  As a result
buildworld failed when these src.conf options were in use.

Clean this up by omitting the warning if the magic
_NO_INCLUDE_COMPILERMK flag is set, which indicates that
COMPILER_FEATURES is not set.

Approved by:	re (cperciva)
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53501

(cherry picked from commit e4f2a35095)
(cherry picked from commit 1471af5110)
2025-11-03 12:29:11 -08:00
Ahmad Khalifa 258cc34745 bus_attach_children.9: fix typo
s/DEVICE_ATTACH/DEVICE_DETACH

Approved by:	re (cperciva)
Reviewed by:	ziaee
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D53449

(cherry picked from commit 9b9c726df1)
(cherry picked from commit c14f97c16b)
2025-11-03 12:29:07 -08:00
Alan Somers c3f3b96725 fusefs: fix page fault triggered by async notification when unmounted
A FUSE daemon can send asynchronous notification to the kernel in order
to, for example, invalidate an inode's cache.  Fix a page fault that can
happen if the file system isn't yet mounted, or is already unmounted,
when that notification arrives.

Approved by:	re (cperciva)
PR:		290519
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D53356

(cherry picked from commit 5d42c88139)
(cherry picked from commit 25e368c4da)
2025-11-03 12:29:04 -08:00
Martin Matuska 8a0b57ba54 libarchive: merge from vendor branch
libarchive 3.8.2

Important bugfixes:
 #2477 tar writer: fix replacing a regular file with a dir for
       ARCHIVE_EXTRACT_SAFE_WRITES
 #2659 lib: improve filter process handling
 #2664 zip writer: fix a memory leak if write callback error early
 #2665 lib: archive_read_data: handle sparse holes at end of file correctly
 #2668 7zip: Fix out of boundary access
 #2670 zip writer: fix writing with ZSTD compression
 #2672 lib: fix error checking in writing files
 #2678 zstd write filter: enable Zstandard's checksum feature
 #2679 lib: handle possible errors from system calls
 #2707 lib: avoid leaking file descriptors into subprocesses
 #2713 RAR5 reader: fix multiple issues in extra field parsing function
 #2716 RAR5 reader: early fail when file declares data for a dir entry
 #2717 bsdtar: Allow filename to have CRLF endings
 #2719 tar reader: fix checking the result of the strftime (CVE-2025-25724)
 #2737 tar reader: fix an infinite loop when parsing V headers
 #2742 lib: parse_date: handle dates in 2038 and beyond if time_t is big
       enough

Approved by:	re (cperciva)
Obtained from:	libarchive
Vendor commit:	7f53fce04e4e672230f4eb80b219af17975e4f83
Security:	CVE-2025-25724
PR:		290303 (exp-run)
MFC after:	1 week

(cherry picked from commit 401026e482)
(cherry picked from commit f55001cc9f)
2025-11-03 12:29:00 -08:00
Rick Macklem e5fc5bc53f nfs_commonsubs.c: Add a sanity check for nid_ngroup
The nfsuserd(8) daemon passes user credentials
(uid + gids) into the kernel for users and groups
identified by name (received from a NFSv4 server).

This patch add a sanity check for the number of
groups (nid_ngroup) passed in.

It's only purpose is to protect against a bogus
nfsuserd(8) running in a jail.

Approved by:	re (cperciva)

(cherry picked from commit 4672adcea4)
(cherry picked from commit 83a0732a4c)
2025-11-03 12:28:56 -08:00
Rick Macklem 5d37e6975e nfs_clrpcops.c: Check for too large a write reply
The "rlen" reply length for a Write operation/RPC
could cause trouble if a broken server replies with
too large a value.

Improve the sanity check for "rlen" to avoid this.

Approved by:	re (cperciva)

(cherry picked from commit 2c82cdd2e2)
(cherry picked from commit b5b6ddfc99)
2025-11-03 12:28:53 -08:00
Rick Macklem 82579ee1f0 nfs_clrpcops.c: Fix two possible large NFSM_DISSECT()s
There are two cases in nfs_clrpcops.c where it was possible
for the code to attempt to NFSM_DISSECT() a large size,
which is not allowed by nfsm_dissct().

This patch fixes them.

Reducing the maximum stripecnt should be no problem,
since there in no extant NFSv4.n server that does striped
File Layout pNFS and current development is centered
around the Flex File layout.

Approved by:	re (cperciva)

(cherry picked from commit b9e6206f59)
(cherry picked from commit 609c4eb70a)
2025-11-03 12:28:49 -08:00
Rick Macklem 9c47506fc7 nfs_clrpcops.c: Add sanity checks for the slot cnts
The reply to CreateSession includes the slot cnt for
both fore and back slots. It should never be larger
than the argument specified and the fore slot cnt
should always be at least 1.

Without this patch, the replied slot cnts were not
being sanity checked.

While here, replace 64 with NFSV4_SLOTS (which is 64).

Approved by:	re (cperciva)

(cherry picked from commit 3053b2a3dc)
(cherry picked from commit 14148591b9)
2025-11-03 12:28:45 -08:00
Rick Macklem f38a2cfd5f nfs_nfsdserv.c: Add a sanity check for layout commit cnt
If a client were to send a LayoutCommit (seldom
used and only for a pNFS server) with a bogus
cnt, there could be problems with a malloc() call
that uses it.

This patch adds a sanity check for the cnt. Note
that RFC8881 does not specify any upper bound
on the cnt.

Approved by:	re (cperciva)

(cherry picked from commit 1a679fb907)
(cherry picked from commit c69e0be70f)
2025-11-03 12:28:41 -08:00
Christos Margiolis 10858b0162 snd_dummy: Round channel pointer after each write
Otherwise we go out of bounds and keep incrementing endlessly.

Approved by:	re (cperciva)
Sponsored by:	The FreeBSD Foundation
MFC after:	4 days
Differential Revision:	https://reviews.freebsd.org/D53337

(cherry picked from commit 364864ea91)
(cherry picked from commit 4eac02b29f)
2025-11-03 12:28:38 -08:00
David E. O'Brien 4002a34e68 random: garbage collect the RANDOM_PURE_OCTEON entropy source
It was used for Octeon MIPS and all producers have been removed
from the source tree.

Approved by:	re (cperciva)
Reviewed by: emaste
Differential Revision:	https://reviews.freebsd.org/D53146
(cherry picked from commit 283699338c)
(cherry picked from commit b3bf22d70e)
2025-11-03 12:28:35 -08:00
David E. O'Brien 1b7bd82b6d random: add RDSEED as a provably unique entropy source
NIST SP800-90B allows for only a single entropy source to be claimed
in a FIPS-140-3 certificate.  In addition, only hardware sources that
have a NIST Entropy Source Validation (ESV) certificate, backed by
a SP800-90B Entropy Assessment Report, are usable.  Intel has obtained
ESV certificates for several of their processors, so RDSEED is a
FIPS-140-3 suitable entropy source.

However, even though RDRAND is seeded by RDSEED internally, RDRAND
would need a RBG certificate and CAVP testing run on the DRBG in order
to use it for FIPS-140-3 (SP800-90B) purposes.  So we need to know
down in the CSPRNG-subsystem which source the entropy came from.

In light of the potential issues surrounding AMD Zen 5 CPU's RDSEED
implementation[*], allow RDSEED to be disabled in loader.conf.
[*] https://www.phoronix.com/news/AMD-EPYC-Turin-RDSEED-Bug

Approved by:	re (cperciva)
Reviewed by:	cem
MFC after:	3 days
Sponsored by:	Juniper Networks
Differential Revision:	https://reviews.freebsd.org/D53150
Differential Revision:	https://reviews.freebsd.org/D53291
(cherry picked from commit 3a12982962)
(cherry picked from commit 38e9d282cd)
(cherry picked from commit 9ca8e09abb)
2025-11-03 12:28:29 -08:00
Colin Percival a7707f2a3b Revert "Merge commit e24f90190c77 from llvm git (by Brad Smith):"
The BETA4 builds failed on aarch64 with errors which look
suspiciously like this commit is involved.

This reverts commit 4ae6078a60.

Direct commit to releng/15.0.

Approved by:	re (cperciva)
2025-10-30 23:40:00 -07:00
Colin Percival f0b1ca546e 15.0: Update to BETA4
Approved by:	re (implicit)
Sponsored by:	https://www.patreon.com/cperciva
2025-10-30 17:00:17 -07:00
Dag-Erling Smørgrav 8c478bbfeb realpath: Belatedly document POSIX conformance
We've been mostly POSIX-conforming since r236400 and fully since r240410,
which fixed a corner case where a missing non-leaf directory would be
reported as ENOTDIR instead of ENOENT.

Approved by:	re (cperciva)
Sponsored by:	Klara, Inc.
Fixes:		7877ed7ce3 ("Avoid mapping ENOENT to ENOTDIR for non-existent path components.")
Reviewed by:	ziaee, markj
Differential Revision:	https://reviews.freebsd.org/D53027

(cherry picked from commit 7c66667d45)
(cherry picked from commit 50d6a56a19)
2025-10-30 16:49:52 -07:00
Dag-Erling Smørgrav 38c42ca57b realpath: Report correct path on failure
If lstat() fails with EACCES or ENOTDIR, the path we need to return in
the caller-provided buffer is that of the parent directory (which is
either unreadable or not a directory; the latter can only happen in the
case of a race) rather than that of the child we attempted to stat.

Approved by:	re (cperciva)
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D53025

(cherry picked from commit 1406de21e1)
(cherry picked from commit 6c9b25246d)
2025-10-30 16:49:49 -07:00
Dag-Erling Smørgrav 4dc6fd2b9b realpath: Additional test cases
* Passing NULL should result in EINVAL
* Passing an empty path should result in ENOENT
* Failure with a non-null buffer should leave a partial result.  As
  pointed out in a comment in the test case, this reveals a discrepancy
  between the documentation and reality.

Approved by:	re (cperciva)
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D53024

(cherry picked from commit f3386dfeb4)
(cherry picked from commit 5debbcb6b7)
2025-10-30 16:49:46 -07:00
Dag-Erling Smørgrav 201038a01b quot: Make nusers unsigned
Approved by:	re (cperciva)
Fixes:		195b00ec45 ("quot: Clean up")
Reviewed by:	rlibby
Differential Revision:	https://reviews.freebsd.org/D53224

(cherry picked from commit fa347930f8)
(cherry picked from commit 2427ae41b7)
2025-10-30 16:49:43 -07:00
Dag-Erling Smørgrav 1825be32d0 quot: Add tests
To facilitate the task, we change the comparison function so that users
with equal filesystem usage are sorted by UID, and add an undocumented
option that prevents quot from replacing numerical UIDs with names.  We
also switch from getfsfile(3) to getmntpoint(3) so the first line is
identical regardless of whether we pass quot a mountpoint or a device.

Approved by:	re (cperciva)
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D53133

(cherry picked from commit aa870a1935)
(cherry picked from commit b5f3f1a661)
2025-10-30 16:48:55 -07:00
Dag-Erling Smørgrav 08dda8c969 quot: Drop the -h option
There was probably a time, more than 30 years ago, when the actual
size of a file had to be calculated and this option saved time, but
all it does today is give incorrect results for no benefit.

Approved by:	re (cperciva)
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D53132

(cherry picked from commit 8209311c51)
(cherry picked from commit c0d4bbcb80)
2025-10-30 16:48:41 -07:00
Dag-Erling Smørgrav dedf7401bd quot: Drop the COMPAT version
We've had this code for 30 years, but there has never been a way to
build it.  We have no idea if it still works, or if it ever worked.

Approved by:	re (cperciva)
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D53131

(cherry picked from commit 0eaca4a24b)
(cherry picked from commit 9a7b48fef1)
2025-10-30 16:48:38 -07:00
Dag-Erling Smørgrav b0fdefbf31 quot: Clean up
* Fix numerous style violations.
* Modernize somewhat.
* Don't bother examining errno after calling get_inode(), as it always
  exits on error.
* Fix confusing wording in the manual page.

The code remains somewhat idiosyncratic, e.g. in its insistance on
counting down rather than up in simple for loops, but in the absence
of comprehensive automated tests, the risk of introducing bugs exceeds
the benefit of rewriting these into more idiomatic forms.

Approved by:	re (cperciva)
Reviewed by:	obiwac
Differential Revision:	https://reviews.freebsd.org/D53130

(cherry picked from commit 195b00ec45)
(cherry picked from commit 68911bf64e)
2025-10-30 16:48:34 -07:00
Dag-Erling Smørgrav 60384327a8 quot: Fix benign buffer overflow
If it encounters an inode whose owner does not have a pw entry, quot
allocates a 7-byte buffer (8 in practice, since that is the minimum
allocation size) and uses it to store the numeric uid preceded by a
hash character.  This will overflow the allocated buffer if the UID
exceeds 6 decimal digits.  Avoid this by using asprintf() instead.

While here, simplify the common case as well using strdup().

Approved by:	re (cperciva)
Reported by:	Igor Gabriel Sousa e Souza <[email protected]>
MFC after:	3 days
Reviewed by:	obiwac, emaste
Differential Revision:	https://reviews.freebsd.org/D53129

(cherry picked from commit 5854d1cbab)
(cherry picked from commit 3d680881f6)
2025-10-30 16:48:31 -07:00
Dag-Erling Smørgrav 8cf76cbac8 w: Trim whitespace and commas from time and uptime
When producing formatted output, trim leading whitespace and trailing
commas from the human-readable time and uptime before emitting them.
The text output remains unchanged.

Approved by:	re (cperciva)
PR:		290089
Fixes:          6e6febb54d ("w: Fix idle time in json output, add login/idle times to json output")
Reviewed by:	marius.h_lden.org
Differential Revision:	https://reviews.freebsd.org/D53167

(cherry picked from commit 4d5789532a)
(cherry picked from commit ca16a115a0)
2025-10-30 16:48:28 -07:00
Dag-Erling Smørgrav b763c111ad pwait: Add an option to print remaining processes
* On startup, insert all valid PIDs into a tree.
* In our main loop, whenever a process terminates, remove its PID
  from the tree.
* On exit, if the -p flag was specified, print the remaining PIDs.

Approved by:	re (cperciva)
MFC after:	3 days
Reviewed by:	bcr, markj
Differential Revision:	https://reviews.freebsd.org/D53293

(cherry picked from commit 3d73146bae)
(cherry picked from commit 955650f181)
2025-10-30 16:48:25 -07:00
Bryan Drewery 936ef70cea pwait: Avoid calling getpid(2) for each proc.
Approved by:	re (cperciva)

(cherry picked from commit ab4abce6c2)
(cherry picked from commit 54d1d527c8)
2025-10-30 16:48:22 -07:00
Dag-Erling Smørgrav ac84e695eb rc.subr: Fix slow shutdown issue
Instead of sleeping after pwait returns, use its new -p option to
obtain the list of processes that still have not terminated.

Approved by:	re (cperciva)
MFC after:	3 days
PR:		290357
Fixes:		5953e7c984 ("rc.subr: Move the sleep in wait_for_pids")
Reviewed by:	0mp, markj
Differential Revision:	https://reviews.freebsd.org/D53294

(cherry picked from commit 22cff1f3e9)
(cherry picked from commit 7b375832c2)
2025-10-30 16:48:19 -07:00
Dag-Erling Smørgrav 02de2f3b49 id: Add -d and -s options
These options may not be combined with any other options and print the
current or specified user's home directory and shell respectively.

Approved by:	re (cperciva)
Reviewed by:	imp, bcr
Differential Revision:	https://reviews.freebsd.org/D53301

(cherry picked from commit f41b1eb637)
(cherry picked from commit eff786f236)
2025-10-30 16:48:15 -07:00
Dag-Erling Smørgrav e392a6d78d id: Clean up
No functional change intended.

Approved by:	re (cperciva)
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D53300

(cherry picked from commit 70b72ede98)
(cherry picked from commit 758e4565a9)
2025-10-30 16:48:03 -07:00
Colin Percival 65a3f9cf30 pkg: Die if make -V BRANCH fails
If build logic breaks such that we can't figure out which branch we're
on, we should error out rather than shipping a default (and probably
wrong) /etc/pkg/FreeBSD.conf

Approved by:	re (cperciva)
Reviewed by:	ivy
MFC after:	5 minutes
Suggested by:	ivy
Differential Revision:	https://reviews.freebsd.org/D53487

(cherry picked from commit 0837b2ebd5)
(cherry picked from commit 1f528e32f5)
2025-10-30 13:53:30 -07:00
Colin Percival c824a13191 release: Only check no-root/no-qemu when building
Building VMs as non-root requires no-QEMU code paths (installing
packages from outside the VM image rather than inside it) and vice
versa; we have a check for broken combinations.

Unfortunately that check was breaking
make -C src/usr.sbin/pkg NO_ROOT=YES -V PKGCONFBRANCH
because that code reaches into src/release to determine the branch
name (which is then used to determine which /etc/pkg/FreeBSD.conf to
install).

Wrap the no-root/no-qemu check in an .if to only run when we've
asked for VM and/or CLOUD building to be enabled.

Approved by:	re (cperciva)
Reviewed by:	ivy
MFC after:	5 minutes
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D53486

(cherry picked from commit b485322d6b)
(cherry picked from commit 6b2f2e03f1)
2025-10-30 13:53:26 -07:00
Ed Maste 660255be1e ipfw: Retire obsolete compat code
The current IPFW version 3 dates to 2010 (commit cc4d3c30ea, "Bring in
the most recent version of ipfw and dummynet, developed").

The compat code for FreeBSD 8 and earlier has a number of issues and is
no longer needed, so remove it.

Approved by:	re (cperciva)
Reported by:	Ilja Van Sprundel <[email protected]>
Reviewed by:	ae, glebius
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53343

(cherry picked from commit c59aab9a5b)
(cherry picked from commit 9657c50cdd)
2025-10-30 13:53:23 -07:00
Ed Maste 443258a77a pmcstat: Remove no-op -k option
Commit 53d0b9e438 ("pmc: Provide full path to modules from kernel
linker") made pmcstat's -k option have no effect, but the option was
retained for backwards compatibility (while emitting a warning that
-k is not in FreeBSD 15).

Approved by:	re (cperciva)
Reviewed by:	jrtc27
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53397

(cherry picked from commit c6b156e360)
(cherry picked from commit 958659dc94)
2025-10-30 13:53:20 -07:00
Ed Maste fcf8720e9f bsdlabel: Bump removal to FreeBSD 16.0.
It is deprecated but was not removed prior to 15.0.

Approved by:	re (cperciva)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 9447a40781)
(cherry picked from commit be24d85ec7)
2025-10-30 13:53:13 -07:00
Lexi Winter a3cf750ba4 packages: Remove the /boot hack from mtree-to-plist.awk
Currently, files in /boot (other than /boot/kernel) are assigned to the
bootloader package using a filename match in mtree-to-plist.awk.  This
causes some problems, most notably that debug info for userboot ends up
in the utilities-dbg package instead of bootloader-dbg.

Remove the path handling from mtree-to-plist and instead set PACKAGE
in the appropriate Makefiles to put these in the correct package.

While here, move userboot*.so from bootloader-dev to bootloader.

Approved by:	re (cperciva)
MFC after:	3 days
Reviewed by:	cperciva
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53179

(cherry picked from commit 842942be28)
(cherry picked from commit a182020edf)
2025-10-30 09:15:15 -07:00
Lexi Winter ac849c0a1e flua: Move to a new flua package
flua is a standalone third-party component that deserves its own
package.  In particular, this means things can use flua without
having to depend on FreeBSD-utilities, which will be useful as
more base utilities use flua.

This saves ~500kB in FreeBSD-utilities for systems which don't
need flua.

Approved by:	re (cperciva)
MFC after:	3 days
Reviewed by:	kevans
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53161

(cherry picked from commit 957715f877)
(cherry picked from commit e4ef333917)
2025-10-30 09:15:09 -07:00
Lexi Winter bcb4095b36 packages: Put dhclient in the minimal-jail set
This is somewhat widely used in VNET jails, it's fairly small (150kB on
amd64) and it's enough of a core system component that it's reasonable
to include, even if many jails don't require it.

Approved by:	re (cperciva)
MFC after:	3 days
Reviewed by:	dch
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53154

(cherry picked from commit 8a9d29beda)
(cherry picked from commit c392cdae9b)
2025-10-30 09:15:06 -07:00
Lexi Winter a3fde3ac56 share/man/man5: Use MANGROUPS.yes
Simplify the Makefile logic by using MANGROUPS.yes for optional
packages.  Also, move bluetooth manpages to the correct package,
add the correct conditional for OpenSSH (MK_OPENSSH), and properly
alphabetise the file.

Approved by:	re (cperciva)
MFC after:	3 days
Reviewed by:	emaste
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53127

(cherry picked from commit 82f96b2bc9)
(cherry picked from commit 7a572fd52e)
2025-10-30 09:15:03 -07:00
Ed Maste 325663f0c0 man: Conditionally install ar.5 in toolchain package
Previously if WITHOUT_TOOLCHAIN was set we'd create a FreeBSD-clang
package that contained only ar.5.  As ar.5 describes the ar format
and doesn't come from Clang/LLVM move it to the FreeBSD-toolchain
package and make it conditional on MK_TOOLCHAIN.

Approved by:	re (cperciva)
Reviewed by:	ivy
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D52886

(cherry picked from commit a8d774d970)
(cherry picked from commit 4574a86c52)
2025-10-30 09:15:00 -07:00
Lexi Winter 2b0a1e6a93 packages: dhclient, local-unbound require resolvconf
Both of these packages use resolvconf for various things.  Add a
dependency to make this work.

Approved by:	re (cperciva)
MFC after:	3 days
Reviewed by:	des
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53115

(cherry picked from commit bf28c98f14)
(cherry picked from commit 01f1896527)
2025-10-30 09:14:57 -07:00
Lexi Winter 873f0864db mandoc: Also run makewhatis for /usr/share/openssl/man
We use a pkg(8) trigger to run makewhatis for /usr/share/man when
manpages are updated, but this doesn't cover /usr/share/openssl/man.

Rewrite the trigger to process a list of directories instead of a
single directory, and include /usr/share/openssl/man in the list.

Approved by:	re (cperciva)
MFC after:	3 days
Reviewed by:	emaste
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53064

(cherry picked from commit 450fb637f4)
(cherry picked from commit 37effd917e)
2025-10-30 09:14:53 -07:00
Lexi Winter 84e42ef510 packages: Install development manpages in the -dev package
Add a new per-group SUBPACKAGE option to bsd.man.mk.  When MANSPLITPKG
is enabled, this is forced to "-man", otherwise it defaults to empty
but can be overridden by the caller.

Use this in bsd.lib.mk to install library manpages in the -dev package
instead of the base package.  This is nearly always preferable, since
library manpages are usually in section 2 or 3 and are only relevant
to people with development packages installed.

For manpages which should be installed in the base package even for
libraries, add a new MANNODEV group in bsd.lib.mk.  Update existing
Makefiles to use this where appropriate.

Approved by:	re (cperciva)
MFC after:	3 days
Discussed with:	olce
Reviewed by:	olce
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D52832

(cherry picked from commit 031e711647)
(cherry picked from commit e1a6189f96)
2025-10-30 09:14:47 -07:00
Lexi Winter 32b6de9082 zlib: Move to a new zlib package
zlib is a standalone third-party component, and deserves its own
package rather than living in runtime.  For example, this will make
future security updates less invasive.  This also means there's no
dependency on runtime for ports that just require zlib, which is
useful for service jails.

Approved by:	re (cperciva)
MFC after:	3 days
Reviewed by:	bapt, emaste
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53058

(cherry picked from commit 924c0c60d4)
(cherry picked from commit a02e78a2c9)
2025-10-30 09:14:43 -07:00
Dimitry Andric 4ae6078a60 Merge commit e24f90190c77 from llvm git (by Brad Smith):
[Driver] Enable outline atomics for FreeBSD/aarch64 (#156089)

The compiler_rt helper functions have been built since 12.4, 13.1, 14
and anything newer.

Approved by:	re (cperciva)
MFC after:	3 days

(cherry picked from commit 51e8e8b0f3)
(cherry picked from commit 7778507bf9)
2025-10-30 09:14:38 -07:00
Jose Luis Duran bc59efc45c blocklist: blacklist: Chase recent upstream changes
Upstream introduced a fix that avoids blocklistd(8) from running into an
endless loop when it tries to delete an address from the database which
has been added multiple times.

Apply the same fix to blacklistd(8).

Approved by:	re (cperciva)
Upstream PR:	https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57193
MFC after:	2 days

(cherry picked from commit b502a451cb)
(cherry picked from commit 528e1d1403)
2025-10-29 21:36:41 -07:00
Jose Luis Duran 4afb96fdd2 MFV: Import blocklist 2025-10-26 (ff13526)
Merge commit 'df549a80425635d98419f7f742309d66d367e65f'

Changes:

https://github.com/zoulasc/blocklist/compare/156df4f...ff13526

Approved by:	re (cperciva)
MFC after:	2 days

(cherry picked from commit 34ffc7073f)
(cherry picked from commit dfc4a7c10c)
2025-10-29 21:36:37 -07:00
Jose Luis Duran c4f2ac409c blocklist: blacklist: Chase recent upstream changes
Upstream introduced an extra column in blocklistctl(8) to display the
name of the rule associated in the database entry.

It is intended to avoid confusion when seemingly duplicate locations
appear in the output of the blocklistctl dump command.  Especially when
users are transitioning from the old nomenclature to the new one.

The latest patches will not be fully backported to blacklistctl(8), to
avoid breaking current scripts that may be parsing its output.  Also we
are slowly preparing to feature-freeze everything related to blacklist.

Approved by:	re (cperciva)
MFC:	2 days

(cherry picked from commit eae98e28a0)
(cherry picked from commit cd284c1e17)
2025-10-29 21:36:32 -07:00
Jose Luis Duran 8ea3c27a03 MFV: Import blocklist 2025-10-25 (156df4f)
Merge commit '1ae0b2f3a242a48af2deef1e88649bf4a3a74e2f'

Changes:

https://github.com/zoulasc/blocklist/compare/8aa81bf...156df4f

Approved by:	re (cperciva)
MFC after:	2 days

(cherry picked from commit bcbe0a3c92)
(cherry picked from commit cbd8e3a004)
2025-10-29 21:36:28 -07:00
Jose Luis Duran b39a387442 libpfctl: Fix displaying deeply nested anchors
Set the number of rulesets (i.e., anchors) directly attached to the
anchor and its path in pfctl_get_ruleset().

While here, add a test to document this behavior.

Approved by:	re (cperciva)
PR:		290478
Reviewed by:	kp
Fixes:		041ce1d690 ("pfctl: recursively flush rules and tables")
MFC after:	2 days
Differential Revision:	https://reviews.freebsd.org/D53358

(cherry picked from commit a943a96a50)
(cherry picked from commit 1c8a554f75)
2025-10-29 21:36:20 -07:00
Jamie Gritton c37d95826a jail: fix a regression that creates zombies when removing dying jails
When adding jail descriptors, I split sys_jail remove in two, and
didn't properly track jail held between them when a jail was dying.
This fixes that as well as cleaning up the logic behind it.

Approved by:	re (cperciva)
PR:		290217
Reported by:	David 'equinox' Lamparter <equinox at diac24.net>
Reviewed by:	markj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D53200

(cherry picked from commit 78f70d4ff9)
(cherry picked from commit 2d3c6a06ed)
2025-10-29 21:23:18 -07:00
Jamie Gritton 9620ee8816 jail: fix an error condition that was returned without setting errno.
Approved by:	re (cperciva)
MFC after:	3 days

(cherry picked from commit 5f7d5709e0)
(cherry picked from commit c6bf733736)
2025-10-29 21:23:15 -07:00
Ed Maste 87b73c2684 ipfw: Remove more unused IP_FW_* cases
All of the do_cmd() calls are in dummynet.c and specify the socket
option at compile time; none of these removed cases are used in ipfw
after the v3 work.

Approved by:	re (cperciva)
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53378

(cherry picked from commit 0e2e0fb955)
(cherry picked from commit 6b1e5d4d20)
2025-10-29 21:23:12 -07:00
Ed Maste 37580e661b ipfw: Remove IP_DUMMYNET_GET case
IP_DUMMYNET_GET is no longer used in ipfw(1).

Approved by:	re (cperciva)
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53348

(cherry picked from commit 28e52dea96)
(cherry picked from commit 73c105268c)
2025-10-29 21:23:10 -07:00
Ed Maste a986bf1f4a ipfw: Correct error message
The failed allocation in the error pertains to IP_FW_XADD, not
IP_FW_ADD.

Approved by:	re (cperciva)
Reviewed by:	ae
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53359

(cherry picked from commit 498e561426)
(cherry picked from commit c22437c8b5)
2025-10-29 21:23:07 -07:00
Ed Maste 883230a190 ipfw: Update warning/error setsockopt references
Dummynet v3 switched to IP_DUMMYNET3 but did not update these
warnings/errors.

Approved by:	re (cperciva)
Fixes: cc4d3c30ea ("Bring in the most recent version of ipfw and dummynet, developed")
Sponsored by:	The FreeBSD Foundation
Differential Revision: sbin/ipfw/ipfw2.c

(cherry picked from commit 1f95a51788)
(cherry picked from commit a5dd21c7dd)
2025-10-29 21:23:04 -07:00
Ed Maste 6652930aaa closefrom.2: Add introduction of close_range to HISTORY
Approved by:	re (cperciva)
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53240

(cherry picked from commit 514fff24b1)
(cherry picked from commit 243a886019)
2025-10-29 21:23:02 -07:00
Ed Maste a085b67453 getrlimitusage.2: Update HISTORY section
Add 14.2, as this was cherry-picked prior to release.

Approved by:	re (cperciva)
Reported by:	Harald Eilertsen
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53320

(cherry picked from commit 2387a51af2)
(cherry picked from commit 87795ea454)
2025-10-29 21:22:59 -07:00
Ed Maste b17920af75 upgt.4: bump removal to 16.0
It was not actually removed prior to FreeBSD 15.0.

Approved by:	re (cperciva)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 0cd8754ad5)
(cherry picked from commit 453766184d)
2025-10-29 21:22:57 -07:00
Ed Maste 392061b369 agp.4: Bump deprecation to 16.0
It was not actually removed prior to FreeBSD 15.0.

Approved by:	re (cperciva)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit cadadd1a03)
(cherry picked from commit 92f169fe0f)
2025-10-29 21:22:53 -07:00
Ed Maste 901603ae6b cam: Bump deprecated sysctl removal to 16
The descriptions for these unmapped_io and rotating sysctls indicated
that they're deprecated and being removed for FreeBSD 15.0.  That did
not happen, so update to FreeBSD 16 instead.

Approved by:	re (cperciva)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit e93db9abc9)
(cherry picked from commit 469ab88d10)
2025-10-29 21:22:50 -07:00
Ed Maste c2c8f9d321 sys: Bump non-ISA PNP removal to 16.0
This may include atkbdc, which is not being removed in 15.0.

Approved by:	re (cperciva)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 46f982122c)
(cherry picked from commit db84583a93)
2025-10-29 21:22:47 -07:00
Ed Maste 1dc5e059da sys: Bump GIANT device removal to 16.0
It did not happen prior to FreeBSD 15.0.

Approved by:	re (cperciva)
Reported by:	zlei
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 24adb135c5)
(cherry picked from commit 8e276f22bd)
2025-10-29 21:22:44 -07:00
Ed Maste d67ed83c51 le(4): Update depreciation notice
This driver was in fact not removed prior to FreeBSD 15.0.

Approved by:	re (cperciva)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit e4d6433e9c)
(cherry picked from commit 59ba727849)
2025-10-29 21:22:34 -07:00
Ed Maste 61d4640720 fdisk: Bump removal to FreeBSD 16.0
Removal did not happen prior to 15.0.

Approved by:	re (cperciva)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit f817f6e7f4)
(cherry picked from commit 739750ae7c)
(cherry picked from commit 2be4c64a0d)
2025-10-29 21:22:31 -07:00
Mark Johnston 81a98c3a12 netmap: Fix error handling in nm_os_extmem_create()
We bump the object reference count prior to mapping it into the kernel
map, at which point the vm_map_entry owns the reference.  Then, if
vm_map_wire() fails, vm_map_remove() will release the reference, so we
should avoid decrementing it in the error path.

Approved by:	re (cperciva)
Reported by:	Ilja van Sprundel <[email protected]>
Reviewed by:	vmaffione
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D53066

(cherry picked from commit dfc1041c08)
(cherry picked from commit 6e1f47765d)
2025-10-29 21:22:28 -07:00
Mark Johnston c40e634e6a release: Use PKG_CMD when installing pkgbase packages in vmimage.subr
This defaults to plain "pkg", but being able to override it is useful
when testing pkg itself.

Approved by:	re (cperciva)
Reviewed by:	cperciva
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D53307

(cherry picked from commit bbe65c5e8c)
(cherry picked from commit 79fbc4ccb6)
2025-10-29 21:22:23 -07:00
Bojan Novković a91a62c42d pt: Switch to swi(9)
The pt hwt(4) backend uses NMIs to receive updates about the latest t
racing buffer offsets from the tracing hardware. However, it uses
taskqueue(9) to schedule the bottom-half handler. This can lead to
a panic since the taskqueue(9) code isn't aware it's being called
from an NMI context and uses the regular scheduling interfaces.

Fix this by scheduling the bottom-half handler using swi(9) and the
SWI_FROMNMI flag.

Approved by:	re (cperciva)
Fixes:	310162ea21
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D52491

(cherry picked from commit 96d82d2d13)
(cherry picked from commit 56b4719076)
2025-10-29 21:22:19 -07:00
Robert Clausecker 3c8ae8b1c9 sys/arm: add fp[gs]et* prototypes to <ieeefp.h>
We have provided implementations for hard float of these for
a while now.  Add them to the header to make things official.
This is required for a bunch of legacy programs in ports.

Approved by:	re (cperciva)
Approved by:	markj (mentor)
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D53156

(cherry picked from commit a8079d40ae)
(cherry picked from commit af39e511ee)
2025-10-29 21:22:16 -07:00
Robert Clausecker 245d95ce16 sys/arm64: fix COMPAT_FREEBSD32 __syscall()
It seems like _QUAD_LOWWORD was incorrectly expanded into 1,
which is correct for big endian but not little endian.  This
means we always grab the padding word for the syscall number,
which is usually 0, causing SIGSYS to be delivered to the caller.
Reintroduce _QUAD_LOWWORD to fix the syscall.

Approved by:	re (cperciva)
PR:		290411
MFC after:	1 week
Discussed with:	jrtc27
Reviewed by:	cognet, emaste
Approved by:	markj (mentor)
Fixes:		8c9c3144cc
Differential Revision:	https://reviews.freebsd.org/D53250

(cherry picked from commit 1ca09538d9)
(cherry picked from commit c824960b89)
2025-10-29 21:22:09 -07:00
Michael Tuexen 71f94c1e2c tcp: improve credential handling in syncache
When adding a syncache entry, take a reference count of the
credentials while the inp is still locked.
Thanks to markj@ for providing a hint regarding the root cause.

Approved by:	re (cperciva)
Reported by:		David Marker
Reviewed by:		glebius
Tested by:		David Marker
Fixes:			cbc9438f05 ("tcp: improve ref count handling when processing SYN")
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D53380

(cherry picked from commit 44cb1e857f)
(cherry picked from commit 9611bf2fed)
2025-10-29 21:22:06 -07:00
Michael Tuexen 54da44487a udp: honor IPV6_TCLASS cmsg for UDP/IPv4 packets
Honor the IPPROTO_IPV6-level cmsg of type IPV6_TCLASS when sending
an UDP/IPv4 packet on an AF_INET6 socket.

Approved by:	re (cperciva)
Reviewed by:		bz
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D53347

(cherry picked from commit d3a3854fdc)
(cherry picked from commit e31ff080e5)
2025-10-29 21:22:03 -07:00
Michael Tuexen bdbb23567f udp: honor IPV6_TCLASS socket option for UDP/IPv4 packets
Honor the IPPROTO_IPV6-level socket option IPV6_TCLASS when sending
an UDP/IPv4 packet on an AF_INET6 socket.

Approved by:	re (cperciva)
Reviewed by:		bz, glebius
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D53346

(cherry picked from commit 3535546a86)
(cherry picked from commit 8f5162f6fc)
2025-10-29 21:21:53 -07:00
Cy Schubert a988846174 unbound: Vendor import 1.24.1
Release notes at
	https://nlnetlabs.nl/news/2025/Oct/22/unbound-1.24.1-released/

Approved by:	re (cperciva)
Security:	CVE-2025-11411

Merge commit '73dd92916f532cb3fe353220103babe576d30a15'

(cherry picked from commit 8b29c373e6)
(cherry picked from commit fc3c317b05)
2025-10-28 14:23:22 -07:00
Dag-Erling Smørgrav fef4de6547 local-unbound-setup: Set so-sndbuf to 0
Without this setting, Unbound 1.24.0 and newer will attempt to set the
socket buffer size to 4 MB to mitigate issues that mostly affect servers
with large numbers of clients on local networks, which is not a scenario
local-unbound is intended for.  This is not only a waste of resources,
it can also fail, resulting in a warning message on daemon startup.

Approved by:	re (cperciva)
Fixes:		b2efd602ae ("unbound: Vendor import 1.24.0")
Reviewed by:	jlduran, cy
Differential Revision:	https://reviews.freebsd.org/D52977
(cherry picked from commit de3faa85d8)
(cherry picked from commit 65629acb4a)
2025-10-28 14:23:12 -07:00
Cy Schubert 4db0093fa0 unbound: Vendor import 1.24.0
Release notes at
	https://nlnetlabs.nl/news/2025/Sep/18/unbound-1.24.0-released/

Approved by:	re (cperciva)
MFC after:	1 week

Merge commit '0064eb9cf1c8d526e87d3149249445d4bc8d0248'

(cherry picked from commit b2efd602ae)
(cherry picked from commit 0143f06b45)
2025-10-28 14:23:08 -07:00
Jonathan T. Looney 8376d05279 x86: Reduce amount of time the MCA lock is held while emitting records
The MCA spin lock is acquired in the hardware interrupt context to
record MCA messages. It is also acquired by a task handler to emit
those messages.

Reduce the amount of time the task handler holds the lock to reduce
the maximum amount of time the hardware interrupt handler may need to
spin on the lock.

Approved by:	re (cperciva)
Reviewed by:	glebius, markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D52938

(cherry picked from commit e770e32aa3)
(cherry picked from commit d83dee356d)
2025-10-28 14:23:05 -07:00
Peter Lei df023b0275 tcp: save progress timeout cause in connection end status
TCP stats are currently incremented for the persist and progress
timeout conditions, but only the persist cause was saved in the
connection end info status, which in turn is logged in the
blackbox "connection end" event.

Approved by:	re (cperciva)
Reviewed by:	tuexen
Sponsored by:	Netflix, Inc.

(cherry picked from commit 1a61a673a3)
(cherry picked from commit 6b81787240)
2025-10-28 14:23:02 -07:00
Peter Lei f30ddc76d2 tcp rack: cleanup
The TCP_SAD_DETECTION code was removed. Remove the remaining
sysctl-variables and counters.

Approved by:	re (cperciva)
Reviewed by:	tuexen
Sponsored by:	Netflix, Inc.

(cherry picked from commit 04c2642406)
(cherry picked from commit 8856e55b47)
2025-10-28 14:22:59 -07:00
Martin Matuska ed0083d081 zfs: update zfs_config.h and zfs_gitrev.h after ce7e1f86a (zfs-2.4.0-rc3)
Approved by:	re (cperciva)

(cherry picked from commit 51d5e8c8ca)
2025-10-28 14:22:53 -07:00
Martin Matuska 6bf158defb zfs: merge openzfs/zfs@814f9afba (zfs-2.4-release) into stable/15
OpenZFS 2.4.0 rc3

Notable upstream pull request merges:
 #17750 964dfc317 FreeBSD: Correct _PC_MIN_HOLE_SIZE
 #17793 b9d1e28a7 ddt prune: Add SCL_ZIO deadlock workaround
 #17799 1585a10a8 Make mount/share errors non-fatal for zfs create/clone
 #17801 073b34b3e Fix display of default xattr to show 'sa'
 #17803 e09c86cb1 zvol: verify IO type is supported
 #17807 -multiple zpool iostat: fix regressions in "all pools" mode
                  after #17786
 #17826 b9356f06e Explicit set ashift for non-leaf vdevs
 #17830 f0bff230f Suppress some ashift warnings
 #17833 c1f55bff8 Fix the type of the raidz_outlier_check_interval_ms
                  parameter
 #17836 799bda73e Fix return value for setting zvol threading
 #17834 f0c76f8a7 libzpool/cmn_err: remove suppression, add stop option,
                  cleanup
 #17843 1956417b5 mmap_seek: print error code and text on failure
 #17847 7987d4deb Update device removal documentation
 #17851 6f6e1c90a FreeBSD: zfs_getpages: Don't zero freshly allocated pages

Approved by:	re (cperciva)
Obtained from:	OpenZFS
OpenZFS commit:	814f9afba7
OpenZFS tag:	zfs-2.4.0-rc3

(cherry picked from commit ce7e1f86a1)
2025-10-28 14:22:49 -07:00
Christos Margiolis 470fae965f sndctl(8): Modify vchans only on supported directions
Currently mod_play_vchans() and mod_rec_vchans() run unconditionally,
even if the direction (playback, recording) is not supported by the
device. This results in the "autoconv" (see mod_autoconv()) control
failing when run on simplex devices, because we'll be trying to modify
vchans on an unsupported direction.

Test whether the direction is supported and silently move on if it
isn't.

Approved by:	re (cperciva)
Sponsored by:	The FreeBSD Foundation
MFC after:	4 days
Differential Revision:	https://reviews.freebsd.org/D53233

(cherry picked from commit 70b34fbdbe)
(cherry picked from commit e015e079f9)
2025-10-28 14:22:43 -07:00
Poul-Henning Kamp 74a6de9f96 deadfs: Return ENXIO instead of EIO when the device is gone.
One some systems, under some conditions, pulling a USB stick would
read(2) returning EIO and not ENXIO, like it should and used to.

Recoverdisk(1), which does not give up on EIO, like most programs
would, spins furiously.

Arguably, deadfs was always wrong in returning EIO, because once you
get to deadfs no operation will ever work again, but we used to
take a different path through devfs_vnops.c which got us the ENXIO.

Something changed recently, and while testing this fix, I noticed
that drm-kmod-66/i915kms may be the condition which trigger
the different code-path.

Approved by:	re (cperciva)
MFC to: stable/15
Fixes: 289785
Thanks to: imp, kib

(cherry picked from commit 2612f1b864)
(cherry picked from commit 44e214f824)
2025-10-27 19:58:00 -07:00
Bjoern A. Zeeb 3dc891b8a5 LinuxKPI: 802.11: additions for Linux v6.17 based wireless drivers
This includes the conflicting changes from previous driver versions
(v6.11/v6.14), mostly being function pointer or function arguments.

Approved by:	re (cperciva)

(cherry picked from commit 76aed633b5)
(cherry picked from commit 22eb6e43d0)
2025-10-27 18:58:43 -07:00
Bjoern A. Zeeb dd5a80ba09 rtw89: update Realtek's rtw89 driver
This version is based on
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
e5f0a698b34ed76002dc5cff3804a61c80233a7a ( tag: v6.17 ).

Approved by:	re (cperciva)

(cherry picked from commit 354a030185)
(cherry picked from commit a13158f451)
2025-10-27 18:58:40 -07:00
Bjoern A. Zeeb 8bf92b4a45 rtw88: update Realtek's rtw88 driver
This version is based on
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
e5f0a698b34ed76002dc5cff3804a61c80233a7a ( tag: v6.17 ).

Approved by:	re (cperciva)

(cherry picked from commit eb15fdb1b7)
(cherry picked from commit 0272ecf586)
2025-10-27 18:58:33 -07:00
Bjoern A. Zeeb 30459f58e8 iwlwifi: update Intel's mvm/mld drivers
This version is based on
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
e5f0a698b34ed76002dc5cff3804a61c80233a7a ( tag: v6.17 ).

Some of the changes we reported upstream got incorporated in this
(or the v6.16) release.

This also includes a change from iwlwifi-next.git::next for missing symbols

iwl_mvm_v3_rate_from_fw() and iwl_mvm_v3_rate_to_fw() were originally
comitted to mvm/rs.[ch] which we do not have.  That left us with
unresolved symbols.  For the never comitted v6.16 driver update I had
started to piece these together but they have been migrated out to
utils.c so take them from there until the next release hopefully ships
this change.

Approved by:	re (cperciva)
Obtained from:	git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-next.git
	branch next, 1b49af228594452206d5c50a33b6a341428edb63

(cherry picked from commit 6b627f8858)
(cherry picked from commit e89beeee25)
2025-10-27 18:58:29 -07:00
Alan Somers 52245427a5 find: fix pathnames printed by the SIGINFO handler
Don't duplicate the last component.

Approved by:	re (cperciva)
PR:		290362
Reported by:	John F. Carr <[email protected]>
Fixes:		d06a00963b
Reviewed by:	jilles, Goran Mekić <[email protected]>
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1878

(cherry picked from commit f6d767fe86)
(cherry picked from commit be122b46be)
2025-10-27 18:58:26 -07:00
Michael Tuexen d9f8e8aa11 tcp over udp: don't copy more bytes than avaiable
When copying the data in the first mbuf to get rid of the UDP
header, use the correct length. It was copying too much (8 bytes,
the length of the UDP header).
This only applies to handling TCP over UDP packets. The support for
TCP over UDP is disabled by default.

Approved by:	re (cperciva)
Reported by:		jtl
Reviewed by:		Peter Lei
Sponsored by:		Netflix, Inc.

(cherry picked from commit bfda98a420)
(cherry picked from commit c566953da8)
2025-10-27 18:58:23 -07:00
Michael Tuexen 978615d7bf sockstat: add support for UDP-Lite endpoints
With this patch UDP-Lite endpoints are also show per default.

Approved by:	re (cperciva)
Reviewed by:		Peter Lei, Nick Banks
Relnotes:		yes
Differential Revision:	https://reviews.freebsd.org/D53230

(cherry picked from commit f48c6390dd)
(cherry picked from commit c10317b0c4)
2025-10-27 18:58:20 -07:00
Michael Tuexen 72016759da netstat: add support for UDP-Lite endpoints
With this patch UDP-Lite endpoints are also shown per default.

Approved by:	re (cperciva)
Reviewed by:		Nick Banks
Differential Revision:	https://reviews.freebsd.org/D53252

(cherry picked from commit c2b08c13c2)
(cherry picked from commit 372b604226)
2025-10-27 18:58:18 -07:00
Michael Tuexen 573270bf34 UDP-Lite: export pcblist via sysctl interface
Export the list of pcbs for UDP-Lite to be consumed by sockstat and
netstat.

Approved by:	re (cperciva)
Reviewed by:		Peter Lei, Nick Banks
Differential Revision:	https://reviews.freebsd.org/D53229

(cherry picked from commit be93b27483)
(cherry picked from commit da7a90f097)
2025-10-27 18:58:15 -07:00
Michael Tuexen 9c148488a0 UDP: let udp_pcblist() support UDP and UDP-Lite
Provide the IPPROTO_UDP in the arg2 parameter of udp_pcblist() and use
this to determine the inpcbinfo. This allows the same function to be
used in an upcoming commit to provide the list of pcbs for UDP-Lite
just by providing IPPROTO_UDPLITE in the arg2 parameter.

Approved by:	re (cperciva)
Reviewed by:		rrs
Differential Revision:	https://reviews.freebsd.org/D53218

(cherry picked from commit be3c59ff50)
(cherry picked from commit 365378184a)
2025-10-27 18:58:05 -07:00
John Baldwin 42cf7ea8dc inet_net_test: Use int to hold expected return values from inet_net_pton
GCC warns about the sign mismatch in comparisons:

lib/libc/tests/net/inet_net_test.cc: In member function 'virtual void {anonymous}::atfu_tc_inet_net_inet4::body() const':
lib/libc/tests/net/inet_net_test.cc:86:17: error: comparison of integer expressions of different signedness: 'int' and 'const unsigned int' [-Werror=sign-compare]
   86 |                 ATF_REQUIRE_EQ(bits, addr.bits);
      |                 ^~~~~~~~~~~~~~
lib/libc/tests/net/inet_net_test.cc: In member function 'virtual void {anonymous}::atfu_tc_inet_net_inet6::body() const':
lib/libc/tests/net/inet_net_test.cc:205:17: error: comparison of integer expressions of different signedness: 'int' and 'const unsigned int' [-Werror=sign-compare]
  205 |                 ATF_REQUIRE_EQ(bits, addr.bits);
      |                 ^~~~~~~~~~~~~~

Approved by:	re (cperciva)
Fixes:		8f4a0d2f7b ("libc: Import OpenBSD's inet_net_{ntop,pton}")
(cherry picked from commit e1aeb58cbb)
(cherry picked from commit 7ffd190ae9)
2025-10-25 21:13:26 -07:00
John Baldwin 595ddf009a inet_net_test: Compare pointers against nullptr
GCC does not like passing NULL (__null) to std::ostringstream::operator<<
inside of ATF_REQUIRE_EQ:

lib/libc/tests/net/inet_net_test.cc: In member function 'virtual void {anonymous}::atfu_tc_inet_net_ntop_invalid::body() const':
lib/libc/tests/net/inet_net_test.cc:306:9: error: passing NULL to non-pointer argument 1 of 'std::__1::basic_ostream<_CharT, _Traits>& std::__1::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::__1::char_traits<char>]' [-Werror=conversion-null]
  306 |         ATF_REQUIRE_EQ(ret, NULL);
      |         ^~~~~~~~~~~~~~
In file included from /usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/sstream:317,
                 from /usr/obj/.../amd64.amd64/tmp/usr/include/atf-c++/macros.hpp:29,
                 from /usr/obj/.../amd64.amd64/tmp/usr/include/atf-c++.hpp:29,
                 from lib/libc/tests/net/inet_net_test.cc:33:
/usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/__ostream/basic_ostream.h:338:81: note:   declared here
  338 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long __n) {
      |                                                                            ~~~~~^~~
...

Approved by:	re (cperciva)
Fixes:		8f4a0d2f7b ("libc: Import OpenBSD's inet_net_{ntop,pton}")
(cherry picked from commit aa358ce3ca)
(cherry picked from commit 848ca53d3a)
2025-10-25 21:13:20 -07:00
Konstantin Belousov 9c31c1a823 include/stdckdint.h: make the header compatible with C++
Approved by:	re (cperciva)
PR:	290299

(cherry picked from commit 3c052bec12)
(cherry picked from commit e54e24bcc7)
2025-10-25 15:10:19 -07:00
Colin Percival 0fc5b401bd 15.0: Update to BETA3
Approved by:	re (implicit)
Sponsored by:	https://www.patreon.com/cperciva
2025-10-23 16:59:30 -07:00
Mark Johnston a653824079 packages: Update the METALOG when (un)installing the caroot package
There may be other issues here but this change certainly seems to
be necessary.

Approved by:	re (cperciva)
PR:	290394
Reviewed by:	cperciva
Differential Revision:	https://reviews.freebsd.org/D53263

(cherry picked from commit fa240b7ff0)
(cherry picked from commit 8b45854447)
2025-10-23 16:36:32 -07:00
Mitchell Horne a4eedfccbe riscv: build starfive JH7110 DTBs
These are known to work if loaded manually by loader(8) (for VF2 at
least). If nothing else, it is useful to provide a DTB closely tied to
the kernel version.

Approved by:	re (cperciva)
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D53117

(cherry picked from commit 96b137c044)
(cherry picked from commit 2257adb848)
2025-10-23 16:32:44 -07:00
Mitchell Horne f2c15ac7c4 riscv: build allwinner DTBs
These are known to work if loaded manually by loader(8) (for the Nezha
board at least). If nothing else, it is useful to provide a DTB closely
tied to the kernel version.

Approved by:	re (cperciva)
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D53118

(cherry picked from commit 3ed48eb085)
(cherry picked from commit 9a44b56907)
2025-10-23 16:32:41 -07:00
Mitchell Horne 24718d1db0 dtb: sort by vendor on riscv
Just like arm64, our DTS comes from Linux and is correctly sorted into
subdirectories by vendor. Enable the logic to preserve these directories
in the installation, for example:

  /boot/dtb/sifive/hifive-unmatched-a00.dtb

Approved by:	re (cperciva)
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D53116

(cherry picked from commit cf202819af)
(cherry picked from commit 0cc2448fc2)
2025-10-23 16:32:37 -07:00
Michael Tuexen 369ef36d08 sockstat: fix column length for PROTO
The computation of the length was not taking into account that IPv6
endpoints, which are not IPv6 only, have a suffix of 46.
For UDP and TCP this bug was not relevant, since tcp46 and udp46
has the same length as PROTO, but sctp46 is longer. Upcoming
udplite support will also be affected.

Approved by:	re (cperciva)
Reviewed by:		asomers
Differential Revision:	https://reviews.freebsd.org/D53212

(cherry picked from commit 4ee0ddae1d)
(cherry picked from commit 8c197879bf)
2025-10-23 16:32:34 -07:00
Bjoern A. Zeeb 2c40d6e95f UPDATING: bump __FreeBSD_version for LinuxKPI changes
The size of an embedded struct has changed and might possibly be a
problem.  Allow this change to be detected by bumping __FreeBSD_version.

Approved by:	re (cperciva)

(cherry picked from commit 37ad1beaf5)
(cherry picked from commit a4ee95e54a)
2025-10-23 16:32:31 -07:00
Bjoern A. Zeeb 34353881ef LinuxKPI: 802.11: additions for Linux v6.17 based wireless drivers
This includes some type cleanups as well as some shuffling of structs
and functions to sort dependencies out.  Few new functions and defines
as well as new struct members.  Minor fixes to style and debug logging.

This is the majority of changes.  None of these should conflict with
current in-tree drivers.  The final bit of changes will come along with
the driver updates adding an extra argument to function pointers.

Approved by:	re (cperciva)

(cherry picked from commit 0567484734)
(cherry picked from commit f2b2d6c18a)
2025-10-23 16:32:27 -07:00
Bjoern A. Zeeb 70d9247e3a LinuxKPI: netdevice add attach/detach skeleton functions
For the moment add skeleton functions for netif_device_attach/detach()
needed by rtw8[89] v6.17.

Approved by:	re (cperciva)

(cherry picked from commit 5ea941a4fb)
(cherry picked from commit 4bdd0e51d7)
2025-10-23 16:32:24 -07:00
Bjoern A. Zeeb f6fe2cf64f LinuxKPI: skbuff: add a misplaced socket operation to skbuff.h for now
This likely belongs in socket code which we do not have in LinuxKPI.
Needed by a wirless driver at v6.17.

Approved by:	re (cperciva)

(cherry picked from commit 88dbf83345)
(cherry picked from commit 3ad05fa24a)
2025-10-23 16:32:21 -07:00
Bjoern A. Zeeb 645785359b LinuxKPI: soc/mediatek add pr_debug calls
We do not support Wireless Ethernet Dispatch (wed) on the mt76 (yet).
Add pr_debug calls with TODO in case we run into the calls anyway so
we could deal with them.

Approved by:	re (cperciva)

(cherry picked from commit 224ac9d2a0)
(cherry picked from commit b9b571e614)
2025-10-23 16:32:19 -07:00
Bjoern A. Zeeb 4a2f77958f LinuxKPI: page_pool headers moved; add netmem.h
page_pool headers were not used yet;  they were created for mt76 but
are without functionality.  Upstream has migrated them for v6.17 and
split them up into multiple files.  Also add netmem.h which the little
needed is directly related to page pools.

Approved by:	re (cperciva)

(cherry picked from commit 7c31cdfa40)
(cherry picked from commit d388ff8016)
2025-10-23 16:32:15 -07:00
Bjoern A. Zeeb 18bb10c59f LinuxKPI: add skeleton pci_enable_wake()
Given we do not yet support "wake" bits in device there is little need
doing it in PCI if we cannot check if we are supposed to do the
operation in first place.  Once we would implement this, we would need
to also do the appropriate PCI (pme) checks before enabling (disabling)
it.

Approved by:	re (cperciva)
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D53208

(cherry picked from commit 885e8f272f)
(cherry picked from commit be52a81be0)
2025-10-23 16:32:12 -07:00
Bjoern A. Zeeb 5440f67a31 LinuxKPI: add fips.h
We do not currently aim to support crypto FIPS compliance in LinuxKPI
so keep this turned off.

Approved by:	re (cperciva)
Reviewed by:	emaste, dumbbell
Differential Revision: https://reviews.freebsd.org/D53207

(cherry picked from commit 98609f4fec)
(cherry picked from commit 3aaaba2078)
2025-10-23 16:32:10 -07:00
Bjoern A. Zeeb 1a71288abc LinuxKPI: device_driver add (*coredump)()
Needed by multiple wireless driver for the v6.17 update (likely earlier
versions already).

Approved by:	re (cperciva)
Reviewed by:	dumbbell
Differential Revision: https://reviews.freebsd.org/D53206

(cherry picked from commit 8ea366f400)
(cherry picked from commit 0741aa3c72)
2025-10-23 16:32:07 -07:00
Bjoern A. Zeeb b691171a06 LinuxKPI: platform_device return type change
The return type now is void;  I believe no one ever used this
so we can just chnage it.  The only active platform_driver_register()
calls seems to be in ath1[01]k and mt76 and there in unsupported code.

Approved by:	re (cperciva)
Reviewed by:	dumbbell, emaste
Differential Revision: https://reviews.freebsd.org/D53205

(cherry picked from commit 0ae4998423)
(cherry picked from commit 5434a1635e)
2025-10-23 16:32:03 -07:00
Bjoern A. Zeeb 8c34b2e7fa LinuxKPI: add three skeleton functions to etherdevice.h
We will see how much we will need them and how to fill them at that
point.  They are left with a pr_debug("TODO") for now.

Approved by:	re (cperciva)
Differential Revision: https://reviews.freebsd.org/D53204

(cherry picked from commit cc792250ac)
(cherry picked from commit 805038b70a)
2025-10-23 16:32:00 -07:00
Bjoern A. Zeeb 257376b32b LinuxKPI: add __counted_by_le() and __counted_by_be()
The former is needed by a wireless driver at v6.17.

Approved by:	re (cperciva)
Reviewed by:	dumbbell, emaste
Differential Revision: https://reviews.freebsd.org/D53203

(cherry picked from commit 0a4b11ddb2)
(cherry picked from commit 0e30cab0f3)
2025-10-23 16:31:50 -07:00
Lexi Winter 7bdd04a687 libc: Import OpenBSD's inet_net_{ntop,pton}
Our versions of these functions (originally taken from BIND) simply
don't work correctly for AF_INET6.  These were removed from BIND itself
quite a while ago, but OpenBSD has made several fixes in the mean time,
so import their code.

Add tests for both functions.

Approved by:	re (cperciva)
PR:		289198
Reported by:	Nico Sonack <[email protected]>
MFC after:	1 week
Reviewed by:	des
Obtained from:	OpenBSD (lib/libc/net)
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D52629

(cherry picked from commit 8f4a0d2f7b)
(cherry picked from commit ff7a10d0e1)
2025-10-22 21:26:07 -07:00
Lexi Winter 1998d706df Makefile: Don't allow install{world,kernel} with pkgbase
Using these targets on a pkgbase system will cause the installed system
to become out of sync with the package database, which is almost certain
to cause issues the next time pkg(8) is used.

To prevent users doing this accidentally, disallow install* if we detect
that FreeBSD-runtime is installed in the target.  The check can be
overridden with DESTDIR=/ for users who are sure they want to do this.

Approved by:	re (cperciva)
MFC after:	3 days
Reviewed by:	emaste
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D52879

(cherry picked from commit 74a6bb524e)
(cherry picked from commit ef82bdc864)
2025-10-22 21:26:03 -07:00
Lexi Winter 72fbd38716 ncurses: Move utilities to the ncurses package
Approved by:	re (cperciva)
MFC after:	3 days
Reviewed by:	manu, kevans
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53163

(cherry picked from commit 09a49cd49b)
(cherry picked from commit 68897925ca)
2025-10-22 21:26:00 -07:00
Lexi Winter ecaa234c68 tar: Move to the utilities package
tar(1) is not a core runtime utility; in particular, nothing in
/etc/rc.d/* requires it.  Move it to utilities, which is also
where cpio(1) lives.

This removes the dependency from runtime to libarchive.

Approved by:	re (cperciva)
MFC after:	3 days
Reviewed by:	manu, emaste
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53059

(cherry picked from commit c0f17d637a)
(cherry picked from commit c6a19aed69)
2025-10-22 21:25:57 -07:00
Lexi Winter e01c7d02ba bsd.man.mk: Support MANGROUPS.yes
Similar to SUBDIR and CONFGROUPS, this allows the use of
MANGROUPS.${MK_FOO}, simplifying Makefile logic for optional
manpages.

Approved by:	re (cperciva)
MFC after:	3 seconds
Reviewed by:	emaste
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53126

(cherry picked from commit e757a92282)
(cherry picked from commit da0e0f755e)
2025-10-22 21:25:49 -07:00
Kristof Provost f138688ea4 pf: fix 'no rdr'
Ensure we always have a non-NULL rule pointer (ctx.rm).
It might have gotten set to NULL by pf_get_translation().

While here also restore the previous rdr behaviour be re-adding the incorrectly
removed 'break' in pf_match_translation_rule.

Approved by:	re (cperciva)
PR:		290177
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D53191

(cherry picked from commit cb36bfee25)
(cherry picked from commit 536b07512c)
2025-10-22 13:12:34 -07:00
Gordon Tetlow 0948c4d4a3 libc: Add "Z" as TZ designator for strptime.
ISO 8601 allows use of "Z" as the time zone designator. Update the
strptime parser to allow this usage.

While we are at it, update the manpage to reflect that both UTC and Z
are now valid options.

Approved by:	re (cperciva)
Reviewed by:	des
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D53083

(cherry picked from commit 79e57ea662)
(cherry picked from commit 3d368c699b)
2025-10-22 13:12:30 -07:00
Mark Johnston b1faa50c18 imgact_elf: Check note body sizes
In parse_notes we validate that the note name fits within the note
buffer, but we do not do the same for the note data, so there is some
potential for an OOB read in the note handler.  Add a bounds check.

Approved by:	re (cperciva)
Reported by:	Ilja Van Sprundel <[email protected]>
Reviewed by:	kib, emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D53063

(cherry picked from commit c86af2cc4c)
(cherry picked from commit 09ae918e1f)
2025-10-22 13:12:27 -07:00
Mark Johnston 95f60a34dd libnv: Fix a length check in nvpair_unpack_string_array()
A string array is represented by a set of nul-terminated strings
concatenated together.  For each string, we check to see if there's a
nul terminator at the end, taking care to avoid going past the end of
the buffer.  However, the code fails to handle the possibility that
size == 0 at the end of an iteration, leading to underflow.

Fix the length check.

Approved by:	re (cperciva)
Reported by:	Ilja van Sprundel <[email protected]>
Reviewed by:	emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D53069

(cherry picked from commit 937693fc9e)
(cherry picked from commit c47f9af477)
2025-10-22 13:12:23 -07:00
Mark Johnston eaafcf841c ipfw: Check for errors from sooptcopyin() and sooptcopyout()
Note, it looks like this code may be unused since commit 4a77657cbc
("ipfw: migrate ipfw to 32-bit size rule numbers").  In particular, it
looks like the ipfw_nat_*_ptr pointers are unused now.

Approved by:	re (cperciva)
Reviewed by:	ae
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D53068

(cherry picked from commit 2df39ce5d4)
(cherry picked from commit 302c4c540e)
2025-10-22 13:12:21 -07:00
Mark Johnston 945500c6dd exec: Check for errors when mapping the shared object
In the non-ASLR case, there is no check for an error from
vm_map_fixed().  Restore it, it was dropped in commit 939f0b6323.
This bug could result in a refcount leak of the object used to map the
VDSO page.

Approved by:	re (cperciva)
Reviewed by:	kib
Reported by:	Ilja Van Sprundel <[email protected]>
MFC after:	1 week
Fixes:	939f0b6323 ("Implement shared page address randomization")
Differential Revision:	https://reviews.freebsd.org/D53065

(cherry picked from commit 7117c86fcb)
(cherry picked from commit 6a5f0dc705)
2025-10-22 13:12:18 -07:00
Ed Maste 90cbdfa9dd bsdinstall: Use pkgbase release URL for BETA/RC
Approved by:	re (cperciva)
PR:		290238
Reviewed by:	ivy
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53214

(cherry picked from commit 604b6458f3)
2025-10-22 13:12:15 -07:00
Colin Percival 74cd979bcb release: Add pkg .conf to METALOG on dvd
We're correctly recording all of the packages in the dvd METALOG file,
but if we don't record ./packages/repos/FreeBSD_install_cdrom.conf then
users won't be able to install them very easily.

Approved by:	re (cperciva)
Reviewed by:	markj
Reported by:	Lars Tunkrans
MFC after:	3 days
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D53199

(cherry picked from commit 2b5c62494d)
(cherry picked from commit 52ea1ca18a)
2025-10-22 11:32:29 -07:00
Colin Percival 6f1622df13 Revert "release: Switch back to latest packages for now"
We now have 15.x quarterly package sets for both amd64 and arm64.

This reverts commit dc5aae134a.

Approved by:	re (cperciva)
2025-10-22 11:32:26 -07:00
Colin Percival 06e48a8d7a vmimage.subr: Fix when/where we fix up METALOG
We only need to check for unMETALOGed directories and sort the METALOG
file if we're using it, i.e. if we're doing a NO_ROOT build.  This
non-NO_ROOT builds by no longer bogusly writing to /METALOG*.

We only need to add databases (spwd.db etc) to METALOG if we're doing
a pkgbase-enabled NO_ROOT build; but we should always do this before
creating the filesystem, not only if we installed extra packages (in
vm_extra_install_packages, where that code was erroneously placed).
This fixes non-cloud VM images, which in 15.0-BETA2 shipped without
password databases.

Approved by:	re (cperciva)
Reviewed by:	ivy
MFC after:	3 days
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D53194

(cherry picked from commit 012014403b)
(cherry picked from commit 962194df83)
2025-10-22 11:32:18 -07:00
Mark Johnston c43777cd71 Add UPDATING entries and bump version
Approved by:	so
Approved by:	re (cperciva)
2025-10-22 15:50:12 +00:00
Mark Johnston aaf04147bd so_reuseport_lb_test: Add a test case for connected UDP sockets
Approved by:	so
Approved by:	re (cperciva)

(cherry picked from commit 1dd66c6ac2)
(cherry picked from commit 25e0657743)
2025-10-22 15:50:01 +00:00
Mark Johnston 98c5396678 inpcb: Ignore SO_REUSEPORT_LB on connected sockets
While TCP disallows connect()ing a socket with SO_REUSEPORT_LB, UDP does
not.  As a result, a connected UDP socket can be placed in the lbgroup
hash and thus receive datagrams from sources other than the connected
host.

Reported by:	Amit Klein <[email protected]>
Reported by:	Omer Ben Simhon <[email protected]>
Reviewed by:	glebius
Approved by:	so
Approved by:	re (cperciva)
Security:	FreeBSD-SA-25:09.netinet
Security:	CVE-2025-24934

(cherry picked from commit 320ad3dec5)
(cherry picked from commit ef159100ec)
2025-10-22 15:49:44 +00:00
Dave Cottlehuber e27e5b6b01 release: split up Oracle Cloudware tools
Sometimes one or the other but not both tools are present; this ensures
that all cases are correctly handled.

Reported by:	cperciva
Approved by:	cperciva (re)
Sponsored by:	SkunkWerks, GmbH

Reviewed by:	cperciva
Differential Revision:	https://reviews.freebsd.org/D53186

MFC after:	2 days

(cherry picked from commit 81d807a906)
2025-10-22 08:17:01 +00:00
Bjoern A. Zeeb cafb77e9e0 pci: add quirk to disable Function-Level Reset (FLR)
MediaTek mt76 WiFi cards are advertising FLR support but after issuing
a FLR the chipset is gone.  Add a quirk so we can disable FLR.  The
current reset code will automatically fall back to a power reset.

This makes the card show up under bhyve where before it would just not
be discovered at all. That should make wifibox work for it and will help
development for a LinuxKPI based mt76 driver as found in framework laptops
as no dedicated machine and constant reboots are needed anymore.
We will likely need to add more PCI vendor/device IDs once we can test
the other device IDs.

Approved by:	re (cperciva)
After a lot of help from: jhb
Really implemented by:	jhb (I just typed and tested)
GH issue:		github.com/pgj/freebsd-wifibox/issues/73
Reviewed by:		imp, emaste
Differential Revision: https://reviews.freebsd.org/D52728

(cherry picked from commit 4c0e53aced)
(cherry picked from commit 3bd015a1a9)
2025-10-20 22:45:11 -07:00
Chris Johns 71f065aab5 dc(4): fix argument to if_foreach_llmaddr() for 21143.
As found on RTEMS the argument to if_foreach_llmaddr() was wrong
causing crashes.

Approved by:	re (cperciva)
Fixes:		51e8082055
PR:		290314

(cherry picked from commit 33afdf0e35)
(cherry picked from commit 10c71151ad)
2025-10-20 22:45:08 -07:00
Bjoern A. Zeeb 07d7f0e07b fwget: pci: mediatek: correct package name
The port is called wifi-firmware-mt76-kmod not "mediatek" in the
moddle.

Approved by:	re (cperciva)
Reported by:	Lars Tunkrans (drsnx60 gmail.com)
Reviewed by:	emaste, jrm, imp
Differential Revision: https://reviews.freebsd.org/D53067

(cherry picked from commit 10d88a7aa6)
(cherry picked from commit e048748627)
2025-10-20 22:45:01 -07:00
Olivier Certner b15ff72140 vm_domainset: Ensure round-robin works properly
All iterators that rely on an object's 'struct domainset_ref' (field
'domain' on 'struct vm_object'), which is the case for page allocations
with objects, are used with the corresponding object locked for writing,
so cannot lose concurrent iterator index's increases even if those are
made without atomic operations.  The only offender was thread stack
allocation, which has just been fixed in commit 3b9b644576 ("vm: Fix
iterator usage in vm_thread_stack_create()").

However, the interleaved policy would still reset the iterator index
when restarting, losing track of the next domain to allocate from when
applying round-robin, which all allocation policies do if allocation
from the first domain fails.

Fix this last round-robin problem by not resetting the shared index at
iterator's phase init on DOMAINSET_POLICY_INTERLEAVE.

Add an assertion to check that, when passed, an object is write-locked
in order to prevent the problem mentioned in the first paragraph from
reappearing.

Approved by:	re (cperciva)
Reviewed by:    markj
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D52733

(cherry picked from commit 7b0fe2d405)
(cherry picked from commit d7226d1858)
2025-10-20 11:02:37 -07:00
Mark Johnston 9554bb1249 vm: Fix iterator usage in vm_thread_stack_create()
After commit 7a79d06697 we no longer hold the VM object lock when
initializing or advancing the domainset iterator in
vm_thread_stack_create().

We could lift the lock out of vm_thread_stack_back() but that poses
complications since we cannot allocate KVA with a VM object lock held.

Instead of overridding the object's iterator, just borrow that of the
current thread.  Kernel stacks are basically always allocated with a
DOMAINSET_POLICY_PREFER policy, so it's not very important to maintain a
global iterator for round-robin allocation.

As a part of this, fix up flag handling: make sure we handle
M_NOWAIT/M_WAITOK from the caller.  Delete a comment in vm_thread_new()
which refers to a non-existent consideration (stack swapping has been
removed).  I suspect vm_thread_new() can use M_WAITOK but opted not to
make that change here.

Approved by:	re (cperciva)
Reported by:	olce
Reviewed by:	olce, alc, kib
Fixes:		7a79d06697 ("vm: improve kstack_object pindex calculation to avoid pindex holes")
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D52982

(cherry picked from commit 3b9b644576)
(cherry picked from commit 511311e4f7)
2025-10-20 11:02:26 -07:00
Mark Johnston 30b015e2cf linprocfs: Add nodes for inotify
These map directly onto sysctls under vfs.inotify of the same name.

Approved by:	re (cperciva)
Reviewed by:	olce, des
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D53142

(cherry picked from commit 28c0ef7684)
2025-10-20 10:48:16 -07:00
Michael Osipov 5773d056fb manpages: Use canonical names for Linux filesystems
The manpages of linprocfs(5) and linsysfs(5) document incomplete names without
"fs" suffix. Make them identical to other filesystems.

Approved by:	re (cperciva)
PR:		283079
MFC after:	3 days
Reviewed by:	ziaee, markj
Differential Revision:	https://reviews.freebsd.org/D53155

(cherry picked from commit 88b9ca860e)
(cherry picked from commit 6ec0fbd8ff)
2025-10-20 10:48:13 -07:00
Paul Armstrong e3bd658fad login.conf: Remove never used ignoretime/ignoretime@
Approved by:	re (cperciva)
PR:		240378
Reviewed by:	otis (mentor), glebius (src committer)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D52991

(cherry picked from commit 4835fc45ef)
(cherry picked from commit 34710b2c08)
2025-10-20 10:48:09 -07:00
Mark Johnston 7cd9d3fe83 vmrun.sh: Don't require firmware on amd64 unless -E was specified
Approved by:	re (cperciva)
PR:		290232
Reported by:	David Marker <[email protected]>
Fixes:		aa34b1d20e ("vmrun.sh: Add arm64 support")
MFC after:	3 days

(cherry picked from commit f19f17b3af)
(cherry picked from commit 6c5540eebc)
2025-10-19 16:50:44 -07:00
Michael Tuexen aa2f726e9f socket: bump socket buffer limit to 8MB
Bump the socket buffer limit from 2 MB to 8MB.
In particular, this allows to use larger values for TCP sockets,
which may result in higher throughput values with default settings.
In the review I was proposing using 16 MB, but in the transport
call today we settled on a more conservative value of 8.
Bumping it further will be done in combination with mitigations
for mbuf exhaustion attacks.

Approved by:	re (cperciva)
Reviewed by:		rscheff, Peter Lei, jtl, thj
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D52873

(cherry picked from commit 1fe6497b48)
(cherry picked from commit 167b9fac60)
2025-10-19 16:50:41 -07:00
Michael Tuexen a95febd393 tcp: bump max rcv buffer size for autoscaling
This allows in higher throughput values with default settings.
In the review I was proposing using 16 MB, but in the transport
call today we settled on a more conservative value of 8.
Bumping it further will be done in combination with mitigations
for mbuf exhaustion attacks.

Approved by:	re (cperciva)
Reviewed by:		rscheff, Peter Lei, jtl, thj
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D52871

(cherry picked from commit baeff75122)
(cherry picked from commit c3cc8223dd)
2025-10-19 16:50:38 -07:00
Michael Tuexen a4198ef496 tcp: bump max snd buffer size for autoscaling
This allows in higher throughput values with default settings.
In the review I was proposing using 16 MB, but in the transport
call today we settled on a more conservative value of 8.
Bumping it further will be done in combination with mitigations
for mbuf exhaustion attacks.

Approved by:	re (cperciva)
Reviewed by:		rscheff, cc, glebius, Nick Banks, Peter Lei, jtl, thj, rrs
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D52872

(cherry picked from commit 9dd4742ee5)
(cherry picked from commit 7d29554b36)
2025-10-19 16:50:30 -07:00
Alexander Ziaee 0798de75ab nvd.4: Add a HARDWARE section for HW Relnotes
Approved by:	re (cperciva)
MFC after:	3 days
Reviewed by:	dab
Differential Revision:	https://reviews.freebsd.org/D52867

(cherry picked from commit 7f5267a998)
(cherry picked from commit 795f4eef2c)
2025-10-18 17:40:28 -07:00
Alexander Ziaee a441f8ef16 release.7: Update RPI example + CHROOTDIR + SPDX
+ arm/RPI-B.conf no longer exists, adjust for arm64/RPI.conf
+ document default CHROOTDIR, also add to FILES list
+ tag SPDX

Approved by:	re (cperciva)
MFC after:	3 days
Reviewed by:	cperciva
Differential Revision:	https://reviews.freebsd.org/D53078

(cherry picked from commit 8a9f1a2286)
(cherry picked from commit be9b7d8dd0)
2025-10-18 17:40:22 -07:00
Colin Percival 3edefa72bc 15.0: Update to BETA2
Approved by:	re (implicit)
Sponsored by:	https://www.patreon.com/cperciva
2025-10-17 11:16:15 -07:00
Mark Johnston 1ae34f2dd8 linker: Make it easier to find the VNET section layout
When trying to find the address of a VNET variable from a debugger, it
helps to have the original address of the VNET section.  In particular,
given the address of a vnet_entry_foo symbol, one wants to easily find
the linker file that the symbol belongs to.

In link_elf_obj.c, the section address for VNET and DPCPU sections is
overwritten in link_elf_link_preload() and link_elf_load_file().  Add an
"origaddr" field to store the original absolute address of the section
base.

In link_elf.c the elf_file_t already has the fields we want, but they
were not getting filled out for the kernel itself.  Fix that too, since
that simplifies things for debuggers and improves consistency.

Approved by:	re (cperciva)
Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D52730

(cherry picked from commit 07747afd51)
(cherry picked from commit 5a926b3cd5)
2025-10-17 10:59:15 -07:00
Mark Johnston bdb41ce607 certctl.8: Update documentation of BUNDLE
- Fix a typo.
- Provide the default path.

Approved by:	re (cperciva)
Reviewed by:	des
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D53001

(cherry picked from commit ec8e07e8fa)
(cherry picked from commit 1de06221cc)
2025-10-17 10:59:12 -07:00
Mark Johnston ecce77b7c9 vmstat: Print the number of wired pages in each object
Approved by:	re (cperciva)
Reviewed by:	alc, kib
MFC after:	1 week
Sponsored by:	Modirum MDPay
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D53008

(cherry picked from commit f66bb825f5)
(cherry picked from commit 5bc5ce6e61)
2025-10-17 10:59:08 -07:00
Mark Johnston cb752719c7 vm_object: Export the number of wired pages in vm_object_list_handler()
Approved by:	re (cperciva)
Reviewed by:	alc, kib
MFC after:	1 week
Sponsored by:	Modirum MDPay
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D53008

(cherry picked from commit ffca0c44ff)
(cherry picked from commit 2eaee0dbc2)
2025-10-17 10:59:04 -07:00
Mark Johnston 7060c79d24 vm_object: Reset kvo_path on each iteration in vm_object_list_handler()
Otherwise we print a bogus path for anonymous objects.

Approved by:	re (cperciva)
Reviewed by:	kib
MFC after:	1 week
Sponsored by:	Modirum MDPay
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D52997

(cherry picked from commit 13d866b314)
(cherry picked from commit 55ad7c573e)
2025-10-17 10:59:00 -07:00
Michael Tuexen 25d7786e32 sockstat: improve handling of path state
Only suppress the path state column when producing traditional text
output. When generating html output, always include the column.
Please note that when generating json or xml output, optional fields
like the path state are only generated if they is applicable. This
has not been changed.
The changes in this patch were suggested by asomers.

Approved by:	re (cperciva)
Reviewed by:		asomers
Fixes:			746eadecaa ("sockstat: show path state column only when useful")
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D53005

(cherry picked from commit 97e858f5b3)
(cherry picked from commit f6923c0a68)
2025-10-17 10:58:57 -07:00
Michael Tuexen 46d39e9f09 sockstat: show path state column only when useful
Showing the path state column is only useful, if there is at least one
SCTP endpoint shown, which is not in the state CLOSED or LISTEN.
Don't show it when it is not useful.

Approved by:	re (cperciva)
Reviewed by:		rrs
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D52986

(cherry picked from commit 746eadecaa)
(cherry picked from commit 9a0a114b7f)
2025-10-17 10:58:52 -07:00
Gleb Smirnoff 4940dc8c35 socket(2): refactor the manual page
Create a chapter on every important socket type: stream, datagram,
seqpacket.  Always list what protocol families do support what kinds of
sockets.  Improve some statements possessing language from the
specification [1].  Reduce some statements that are mostly specific to
TCP.  Provide more external links and references to various important
syscalls that can be used on sockets.

Add a paragrph on non-blocking mode.

The big factual change is documentation of SOCK_SEQPACKET.  In FreeBSD 15
this socket now fully follows the specification and is a stream socket
with record boundaries.

[1] https://pubs.opengroup.org/onlinepubs/9799919799/functions/V2_chap02.html#tag_16_10_06

Approved by:	re (cperciva)
Differential Revision:	https://reviews.freebsd.org/D52771

(cherry picked from commit 86d1723923)
(cherry picked from commit ad13fd5a8f)
(cherry picked from commit a091d6919c)
2025-10-17 10:58:47 -07:00
Gleb Smirnoff b05f153cd2 unix/stream: repair SO_SNDTIMEO
The send operations are waiting on the peer's socket buffer, but we shall
use our timeout value.  Provide a test for that.

Approved by:	re (cperciva)
Reported by:		phk
Reviewed by:		asomers
Differential Revision:	https://reviews.freebsd.org/D53081
Fixes:			d157927807

(cherry picked from commit ead7219352)
(cherry picked from commit bbfaff26bf)
2025-10-17 10:58:38 -07:00
Colin Percival 8d2dcf925d vmimage.subr: Add missing directories to METALOG
Theoretically METALOG should include everything which needs to go
into disk images; unfortunately there are still a few bugs which
are resulting in directories not being listed -- and if METALOG
has files in unrecorded directories, the directories end up being
created with 000 permissions.

Oddly enough, systems where / has 000 permissions are not very
usable.

As a temporary hack, compare the staging tree against METALOG and
add entries for any unrecorded directories.  This will hopefully
be reverted before 15.0-RELEASE.

Approved by:	re (cperciva)
Reviewed by:	bapt, emaste, ivy
Sponsored by:	https://www.patreon.com/cperciva
MFC after:	5 minutes
Differential Revision:	https://reviews.freebsd.org/D53153

(cherry picked from commit 71b2f98535)
(cherry picked from commit 7ce5d908fd)
2025-10-17 09:53:40 -07:00
Ed Maste b5d5181d74 pkg-stage: Correct /packages permissions
Include /packages in the METALOG used to create dvd1.iso.  Previously
we used an expression ^./packages/ (with a trailing /) which did not
match /packages itself, and then with no METALOG entry /packages on
dvd1.iso ended up with mode d---------.

Approved by:	re (cperciva)
PR:		290222
Reviewed by:	cperciva
MFC after:	1 minute
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2db11dda84)
(cherry picked from commit ecd943a5af)
2025-10-16 18:33:12 -07:00
Colin Percival dc5aae134a release: Switch back to latest packages for now
Normally in BETAs the DVD images get packages from the latest
quarterly package build; but aarch64 does not yet have a quarterly
package set built for 15.x, and this made the BETA1 aarch64 builds
fail.  Switch back to using packages from the "latest" package set.

Direct commit to releng/15.0; will be reverted before the release.

Approved by:	re (cperciva)
Sponsored by:	https://www.patreon.com/cperciva
2025-10-16 18:15:15 -07:00
Colin Percival 6fc227a68b Ping: Make build reproducible
As recently fixed in sockstat (9934558460), having tests/Makefile
include files from the parent directory with SRCS= ../foo.c results
in a race condition as the parent build and the tests build try to
produce the same object file but contain different paths.

Use .PATH to tell make to find sockstat.c in the parent directory
but place the object file in the current object directory.

Approved by:	re (cperciva)
Reviewed by:	emaste, jrtc27, kevans
MFC after:	3 days
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D53075

(cherry picked from commit 3c9a2f383f)
(cherry picked from commit a7c1d6b72a)
2025-10-16 13:08:09 -07:00
Colin Percival 8f5eb720e2 packages: Compress in parallel
The FreeBSD-base pkg repository is currrently dominated by a handful of
large packages: Out of a compressed repository size of ~960 MB, about
160 MB is taken up by the FreeBSD-src package, 128 MB (on amd64) is
used by the FreeBSD-kernel-generic-dbg package, and 91 MB is used by
the FreeBSD-src-sys package.  Consequently, running 'make packages -jN'
provides less benefit than one might hope, as most of the packages
finish building quickly, ultimately leaving the FreeBSD-src package
building by itself for a couple minutes while all the other CPUs are
idle.

Pass -T${PKG_CTHREADS} to the 'pkg create' commands (with a default
of -T0) in order to instruct pkg's zstd compression to use multiple
threads.

Testing on an EC2 r7i.48xlarge instance with -j192, this reduces the
time taken by 'make packages' from 6m17s to 1m39s; package creation
time itself (excluding the initial process of installing into world
and kernel staging directories) dropped from 5m37s to 59s.

Approved by:	re (cperciva)
Reviewed by:	ivy
MFC after:	3 days
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D53053

(cherry picked from commit 16155cccc4)
(cherry picked from commit 3d8ec3273d)
2025-10-16 13:08:05 -07:00
Olivier Certner 77a00e86d6 sys/rpc: UNIX auth: Do not log on bogus AUTH_SYS messages
Remove the printf() stances added in commit d4cc791f3b ("sys/rpc: UNIX
auth: Fix OOB reads on too short message").

Even if it can be helpful to know why an authentication message is
rejected, printing explanatory messages on each request attempt is
a remote log filler that could be triggered by accident, and the generic
RPC code generally does not do that.  These printf() calls should be
restored only after some limiting or configuration mechanism is devised.

Approved by:	re (cperciva)
MFC with:       d4cc791f3b ("sys/rpc: UNIX auth: Fix OOB reads on too short message")
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit 2110ae0ef9)
(cherry picked from commit fb8a978ebf)
2025-10-16 11:48:24 -07:00
Olivier Certner 2dda215652 sys/rpc: UNIX auth: Style: Remove unnecessary headers, minor changes
Approved by:	re (cperciva)
MFC after:      2 days
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit a4105a5d4e)
(cherry picked from commit d06658b806)
2025-10-16 11:48:21 -07:00
Olivier Certner 082e48e81b sys/rpc: UNIX auth: Support XDR_FREE
xdr_authunix_parms() does not allocate any auxiliary memory, so we can
simply support XDR_FREE by just returning TRUE.

Although there are currently no callers passing XDR_FREE, this makes us
immune to such a change in a way that doesn't cost more but is more
constructive than a mere KASSERT().

Approved by:	re (cperciva)
Suggested by:   rmacklem
MFC after:      2 days
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit 4ae70c3ea4)
(cherry picked from commit b27688a8b5)
2025-10-16 11:48:17 -07:00
Olivier Certner f96df7ef17 sys/rpc: UNIX auth: Fix OOB reads on too short message
In the inline version (_svcauth_unix()), fix multiple possible OOB reads
when the credentials part of a request is too short to contain mandatory
fields or with respect to the hostname length or number of groups it
advertises.  The previously existing check was arriving too late and
relied on possibly wrong data coming from earlier OOB reads.

While here, use 'uint32_t' as the length/size type, as it is more than
enough and removes the need for conversions, explicit or implicit.
While here, factor out setting 'stat' to AUTH_BADCRED and then jumping
to 'done' on error, through the new 'badcred' label.  While here,
through comments, refer to what the non-inline version is doing
(xdr_authunix_parms() in 'authunix_prot.c') and the reasons.

Approved by:	re (cperciva)
Reviewed by:    rmacklem
Fixes:          dfdcada31e ("Add the new kernel-mode NFS Lock Manager.")
MFC after:      2 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D52964

(cherry picked from commit d4cc791f3b)
(cherry picked from commit 45e671c9cd)
2025-10-16 11:48:14 -07:00
Olivier Certner d14f6f1704 sys/rpc: UNIX auth: Use AUTH_SYS_MAX_{GROUPS,HOSTNAME} as limits (2/2)
Remove local defines from 'svc_auth_unix.c' and use the new limit
macros instead.

Approved by:	re (cperciva)
Reviewed by:    rmacklem
MFC after:      2 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D52963

(cherry picked from commit e665c0f6f7)
(cherry picked from commit 9763e76ccc)
2025-10-16 11:48:11 -07:00
Olivier Certner fc3b621afd sys/rpc: UNIX auth: Use AUTH_SYS_MAX_{GROUPS,HOSTNAME} as limits (1/2)
Consistently with the XDR_INLINE() variant of xdr_authunix_parms()
(_svcauth_unix() in 'svc_auth_unix.c'), reject messages with credentials
having a machine name length in excess of AUTH_SYS_MAX_HOSTNAME or more
than AUTH_SYS_MAX_GROUPS supplementary groups, which do not conform to
RFC 5531.  This is done mainly because we cannot store excess groups
anyway, even if at odds with the robustness principle ("be liberal in
what you accept").

While here, make sure the current code is immune to AUTH_SYS_MAX_GROUPS
changing value (in future RFCs?) even if that seems improbable.

Approved by:	re (cperciva)
Reviewed by:    rmacklem
Fixes:          dfdcada31e ("Add the new kernel-mode NFS Lock Manager.")
MFC after:      2 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D52962

(cherry picked from commit b119ef0f6a)
(cherry picked from commit 34fc20503f)
2025-10-16 11:48:07 -07:00
Olivier Certner ed62b31e30 sys/rpc: Define AUTH_SYS_MAX_{GROUPS,HOSTNAME}
As, respectively, the maximum number of "supplementary" groups and the
maximum hostname size allowed in the credentials structure for AUTH_SYS
(aka, AUTH_UNIX).

Will be used in subsequent commits.

Approved by:	re (cperciva)
Reviewed by:    rmacklem
MFC after:      2 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D52961

(cherry picked from commit f7c4f800cc)
(cherry picked from commit 37aeac4464)
2025-10-16 11:48:04 -07:00
Olivier Certner f647564f3f sys/rpc: UNIX auth: Fix OOB accesses, notably writes on decode
When the received authentication message had more than XU_NGROUPS, we
would write group IDs beyond the end of cr_groups[] in the 'struct
xucred' being filled (as 'ngroups_max' is always greater than
XU_NGROUPS).

For robustness, prevent various OOB accesses that would result from
a change of value of XU_NGROUPS or a 'struct xucred' with an invalid
'cr_ngroups' field, even if these cases are unlikely.

Approved by:	re (cperciva)
Reviewed by:    rmacklem
Fixes:          dfdcada31e ("Add the new kernel-mode NFS Lock Manager.")
MFC after:      2 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D52960

(cherry picked from commit 47e9c81d4f)
(cherry picked from commit 9492a1e27f)
2025-10-16 11:48:00 -07:00
Olivier Certner 330b918549 sys/rpc: UNIX auth: Rename 'ngroups' => 'supp_ngroups' for clarity
Approved by:	re (cperciva)
MFC after:      2 days
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit bda3b61512)
(cherry picked from commit 5e482104ec)
2025-10-16 11:47:57 -07:00
Ed Maste 53eda63d6d zfs: Emit warning upon use of legacy sysctls
The introduction of OpenZFS moved some sysctls, and legacy compat shims
were added.  For example:

Old (legacy) name: vfs.zfs.min_auto_ashift
New name:          vfs.zfs.vdev.min_auto_ashift

Upstream OpenZFS removed these, but we've temporarily restored them in
FreeBSD.

Note that l2arc sysctls use generic sysctl functions (e.g. SYSCTL_UQUAD)
and thus cannot trivially have warnings added, so they are not handled.

Approved by:	re (cperciva)
PR:		266374
Reviewed by:	jlduran
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53033

(cherry picked from commit 654a3aa9a1)
(cherry picked from commit f0033878b9)
2025-10-16 11:15:49 -07:00
Ahmad Khalifa 4c87cff1c8 libm: remainder: make sure x is zero
Make sure the entirety of x is zero before flipping the sign bit.
Otherwise the sign would be wrong for small values of x when x is
negative and |n*y| > |x|

Approved by:	re (cperciva)
Reported by:	alfredo
PR:		251091
Reviewed by:	kargl
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D53023

(cherry picked from commit 25cca51ed2)
(cherry picked from commit 583e976d6d)
2025-10-16 10:37:22 -07:00
Jose Luis Duran 2b4d38a475 openssh: blocklist: Remove non async-signal safe probe
BLOCKLIST_NOTIFY() is called within a signal handler for the alarm after
the grace period has expired that may only take async-signal safe
actions.

Approved by:	re (cperciva)
Reviewed by:	emaste
Fixes:		e02003bce7 ("openssh: blocklist: Use NetBSD probes")
MFC after:	1 day
Differential Revision:	https://reviews.freebsd.org/D53109

(cherry picked from commit 9c82c17c2a)
(cherry picked from commit 7161c525ab)
2025-10-15 20:47:33 -07:00
Mark Johnston 24546cb506 rc: Update dependencies for zpool scripts
After commit 900bc02063, zpool depends on mountcritlocal.  zpoolreguid
and zpoolupgrade depend on zpool and want to run before mountcritcycle,
so we have a pair of cycles.

Update zpoolreguid and zpoolupgrade to avoid this.

Approved by:	re (cperciva)
Reviewed by:	des
MFC after:	3 days
Fixes:	900bc02063 ("rc.d/zpool: change mountcritlocal dep from BEFORE to REQUIRE")
Differential Revision:	https://reviews.freebsd.org/D52953

(cherry picked from commit ae6db60ff5)
(cherry picked from commit 8e957b78e6)
2025-10-15 12:23:44 -07:00
Hareshx Sankar Raj 138e36514f qat: enable qat driver for 402xx device
Enabled qat driver support for 402xx device with
ID 0x4944/0x4945. This is an additional device supported
under the existing qat_4xxx driver. Firmwares specific to
the 402xx device are added.

Signed-off-by: Hareshx Sankar Raj <[email protected]>

Approved by:	re (cperciva)
Relnotes:	yes
Sponsored by:	Intel Corporation
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D52488

(cherry picked from commit 7fbd362c09)
(cherry picked from commit 88c0ce38bc)
2025-10-15 12:23:40 -07:00
Lexi Winter d8897097ed packages: Rename unbound to local-unbound
This more accurately reflects its purpose, and its contents, since
everything in the package is prefixed with "local-".

While here, add a message on upgrade about regenerating the config.

Approved by:	re (cperciva)
MFC after:	3 seconds
Requested by:	des
Reviewed by:	des
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53056

(cherry picked from commit bf84861460)
(cherry picked from commit f1b0e00d56)
2025-10-15 12:23:36 -07:00
Lexi Winter 14d97bd64a ncurses: Add an ncurses-lib package
Set LIB_PACKAGE= in lib/ncurses/Makefile.inc so the ncurses libraries
go into the ncurses-lib subpackage rather than the base package. This
means applications that depend on ncurses can be installed without
needing to install the various utilities and manpages.

This removes a dependency from runtime to ncurses (it now depends on
ncurses-lib instead).

Approved by:	re (cperciva)
MFC after:	3 seconds
Reviewed by:	kevans
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53060

(cherry picked from commit bde703e8b6)
(cherry picked from commit 9dab0e61a9)
2025-10-15 12:23:32 -07:00
Ed Maste 7ae8ea82d7 Cirrus-CI: Bump to FreeBSD 14.3 image
Approved by:	re (cperciva)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit cca9295dd6)
(cherry picked from commit 608043e6d0)
2025-10-15 12:23:29 -07:00
Ed Maste c307343246 bsdinstall: Tweak pkgbase/dist set labels
Have the button labels refer to the artifact type directly (distribution
sets / packages), and use "Tech Preview" as packaged base is no longer
experimental.

Approved by:	re (cperciva)
Reviewed by:	ivy, cperciva
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D52999

(cherry picked from commit abd9424590)
(cherry picked from commit dbd1e32296)
2025-10-15 12:23:19 -07:00
Colin Percival f6751f1fc5 vmimage.subr: Sort METALOG before running makefs
When creating VM images from pkgbase, the METALOG may not be in order;
in particular, files may be listed before the directories which contain
them.  This causes makefs to create directories with 000 permissions.

Interestingly, such VM images boot just fine, since root ignores those
permissions; the first sign of trouble was sshd refusing logins with an
error message which said absolutely nothing about /etc/ having
incorrect permissions or being unable to read files inside it.

Immediately prior to running makefs, sort the METALOG file.  While
we're here, uniquify as well; this does not guarantee that we do not
have duplicate paths, but if there are duplicate paths with different
settings something else has gone wrong and we don't really have any
good way of solving the problem anyway.

Approved by:	re (cperciva)
Reviewed by:	ivy
Hint from:	imp
MFC after:	3 days
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D53046

(cherry picked from commit 0cc81b375e)
(cherry picked from commit ad2ca1c5c1)
2025-10-14 23:08:12 -07:00
Michael Tuexen a9ffe497c8 sockstat: improve output formatting
Fix the format when the output for a socket spans multiple lines.

Approved by:	re (cperciva)
Reviewed by:		rrs
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D52984

(cherry picked from commit 98b2a2265f)
(cherry picked from commit 7e567f51ff)
2025-10-14 23:08:09 -07:00
Michael Tuexen 72e948cff1 sockstat: improve indentation
No functional changes intended.

Approved by:	re (cperciva)
Sponsored by:	Netflix, Inc.

(cherry picked from commit ab837a2eed)
(cherry picked from commit 3dac4b92ec)
2025-10-14 23:08:05 -07:00
Mateusz Guzik 9bea2657c4 vfs offset: fix assertion failure in face of racing ffofset and setfl locking
Both use the same 16 bit var to store their locked and waiters bits,
then this in file_v_unlock:

        state = atomic_load_16(flagsp);
        if ((state & lock_wait_bit) == 0 &&
            atomic_cmpset_rel_16(flagsp, state, state & ~lock_bit))
                return;

can fail if for example foffset is being unlocked while setfl is getting
locked.

Afterwards the code assumes there are blocked waiters on foffset.

Approved by:	re (cperciva)
Reviewed by: kib, markj
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D52915

(cherry picked from commit f43e19db6c)
2025-10-14 23:08:01 -07:00
Jose Luis Duran bf591ddc87 blocklist: Add an UPDATING entry
Add an UPDATING entry about the renaming of blocklist.

Approved by:	re (cperciva)
Approved by:	emaste (mentor)
Fixes:	7238317403 ("blocklist: Rename blacklist to blocklist")
MFC after:	1 day

(cherry picked from commit ffa8165009)
(cherry picked from commit f22ca25404)
2025-10-13 21:36:45 -07:00
Jose Luis Duran 621d4b1d01 blacklist: Avoid duplicate manual pages in METALOG
Previously, blacklist man pages were just a symlink to their blocklist
counterpart, this in turn installed blocklist man pages twice, and
resulted in a duplicate error when running metalog_reader.lua -c.

Take advantage of the duplication to document nuances in blacklist, such
as the fact that it uses the new database and socket name (blocklist).
Also, note that it has been renamed to blocklist.  In the future, it
will help to document its deprecation.

Approved by:	re (cperciva)
Approved by:	emaste (mentor)
Fixes:	7238317403 ("blocklist: Rename blacklist to blocklist")
MFC after:	2 days

(cherry picked from commit c624004553)
(cherry picked from commit f935c0f66f)
2025-10-13 21:36:42 -07:00
Jose Luis Duran f315a3512c blocklist-helper: Silence a bogus pf warning
Silence a bogus warning about (an ethernet) anchor not being found.

It has been reported as PR 280516.  In the meantime, just sweep under
the carpet.

Approved by:	re (cperciva)
Approved by:	emaste (mentor)
MFC after:	2 days

(cherry picked from commit 2347ca21d6)
(cherry picked from commit ba5768504b)
2025-10-13 21:36:39 -07:00
Jose Luis Duran 2b6eb65612 blocklist: Rename blacklist to blocklist
Follow up upstream rename from blacklist to blocklist.

- Old names and rc scripts are still valid, but emitting an ugly warning
- Old firewall rules and anchor names should work, but emitting an ugly
  warning
- Old MK_BLACKLIST* knobs are wired to the new ones

Although care has been taken not to break current configurations, this
is a large patch containing mostly duplicated code.  If issues arise, it
will be swiftly reverted.

Approved by:	re (cperciva)
Reviewed by:	ivy (pkgbase)
Approved by:	emaste (mentor)
MFC after:	2 days
Relnotes:	yes

(cherry picked from commit 7238317403)
(cherry picked from commit 7f6f2139ee)
2025-10-13 21:36:35 -07:00
Jose Luis Duran 803c373304 blocklist: Revert upstream commit ddf6d71
Upstream commit ddf6d71 ("implement BLOCKLIST_BAD_USER as a "one-count"
failure") introduced BLOCKLIST_BAD_USER with a one-count failure
mechanism.  BLOCKLIST_AUTH_FAIL was implemented with a two-count failure
mechanism.  Since we have been utilizing BLOCKLIST_AUTH_FAIL, the number
of failed attempts now doubles towards the maximum limit (nfails),
giving system administrators the impression that the number of failed
authentication attempts is inaccurate.

Revert this commit until a consensus has been reached.  We do not want
to introduce yet another breaking change with the renaming of the
library.

Approved by:	re (cperciva)
Approved by:	emaste (mentor)
MFC after:	2 days

(cherry picked from commit 4d56eb007b)
(cherry picked from commit a719ef67e8)
2025-10-13 21:36:31 -07:00
Jose Luis Duran e2dcc9fc4d MFV: Import blocklist 2025-04-28 (8aa81bf)
Merge commit '70f30afd4e9af5a51ee324d97e4d8c5f2124ec15'

Breaking changes:

- Upstream commit 24932b6 ("blocklistd: log the conf file line number
  with bad protocol errors") breaks backward database compatibility.
  An error will be displayed:
      Key size mismatch 296 != 288
  A new and compatible database, with the new name, will be created when the
  service starts (committed separately).

- Upstream commit ddf6d71 ("implement BLOCKLIST_BAD_USER as a
  "one-count" failure") introduced BLOCKLIST_BAD_USER with a one-count
  failure mechanism.  BLOCKLIST_AUTH_FAIL was implemented with a
  two-count failure mechanism.  Since we utilize BLOCKLIST_AUTH_FAIL, the
  number of failed attempts now doubles towards the maximum limit
  (nfails).  This commit will be reverted separately.

Changes:

https://github.com/zoulasc/blocklist/compare/7093cd9...8aa81bf

Approved by:	re (cperciva)
Approved by:    emaste (mentor)
MFC after:      2 days
Differential Revision:  https://reviews.freebsd.org/D52869

(cherry picked from commit 48e64ca13d)
(cherry picked from commit 1a08326c6f)
2025-10-13 21:36:12 -07:00
Colin Percival 6908a35807 EC2: Fix additional files on small+builder AMIs
The file /usr/local/etc/ssl/cert.pem is not present on "small" and
"builder" AMIs, so we don't need to add it to METALOG.

Approved by:	re (cperciva)
Fixes:	2b0ffc0ee4 ("EC2: metalog_add missing files from packages")
MFC after:	3 days
Sponsored by:	https://www.patreon.com/cperciva

(cherry picked from commit 8a7ac88aa3)
(cherry picked from commit e9010214e9)
2025-10-13 19:54:24 -07:00
Lexi Winter f01adba1e2 Makefile.inc1: Build source packages before sets
To build set-src, we first need to build the source packages.  Add a
.ORDER to ensure this happens.  Otherwise, in a parallel build, sets
might be built before the src-* packages have finished building, and
set-src will be mysteriously missing.

Approved by:	re (cperciva)
MFC after:	3 seconds
Reported by:	cperciva
Actually diagnosed by:	jrtc27
One-line fix by:	ivy
Reviewed by:	cperciva
Differential Revision:	https://reviews.freebsd.org/D53076

(cherry picked from commit ea5685ba79)
(cherry picked from commit 3b5ec539be)
2025-10-13 19:47:36 -07:00
Igor Ostapenko e01a58798f mit-krb5.pc: Add missing -lkrb5profile
Fixes the ports that prefer static linking:
https://reviews.freebsd.org/D49277

Approved by:	re (cperciva)
Reviewed by:	ivy, dch, cy
Sponsored by:	SkunkWerks, GmbH
Differential Revision:	https://reviews.freebsd.org/D52910

(cherry picked from commit 2d9fd2c573)
(cherry picked from commit 771ee17c88)
2025-10-13 19:47:32 -07:00
Xin LI 573cb59c35 MFC: libbz2: add pkg-config file (bzip2.pc)
Add generation of a bzip2.pc file for use with pkg-config and create
a basic template as bzip2.pc.in.

This allows other software to easily locate and link against libbz2
using standard pkg-config mechanisms instead of manual compiler and
linker flags.

The version number is extracted automatically from bzlib.h to keep
it consistent with the library sources.

Approved by:	re (cperciva)
Tested:	pkg-config --exists --print-errors "bzip2 >= 1.0.9" (fail, expected)
	pkg-config --exists --print-errors "bzip2 >= 1.0" (succeeded)
	pkg-config --libs bzip2 (-lbz2)
	pkg-config --cflags bzip2 ()

(cherry picked from commit 5863197933)
(cherry picked from commit f139a644d3)
2025-10-13 08:28:24 -07:00
Lexi Winter ab0d79d537 libbluetooth: Move to the bluetooth-lib package
Move the library, but not any of the runtime.  This allows executables
to link against libbluetooth without having to pull in the entire BT
stack.

Approved by:	re (cperciva)
MFC after:	3 days
Reviewed by:	dch, emaste
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53016

(cherry picked from commit 426891e0f8)
(cherry picked from commit dced18c770)
2025-10-13 00:06:47 -07:00
Lexi Winter e74f3a9494 virtual_oss: Move plugins to the sound package
This is the correct place for them, and also issues an incorrect
dependency from utilities to sound.

Approved by:	re (cperciva)
Fixes:	1b806e607f ("packages: Add a sound package")
MFC after:	3 days
Reviewed by:	christos, dch
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53015

(cherry picked from commit 419dcdc2c9)
(cherry picked from commit 861225fbe3)
2025-10-13 00:06:44 -07:00
Lexi Winter fde09c8300 release/packages/ucl: Fix typos
Approved by:	re (cperciva)
MFC after:	3 days
Sponsored by:	https://www.patreon.com/bsdivy

(cherry picked from commit 039eba16f9)
(cherry picked from commit 663a53d8e7)
2025-10-13 00:06:29 -07:00
Lexi Winter 0fa9385d10 bridge.4: Fix the synopsis for -ifuntagged
This command doesn't accept a vlan-id.

Approved by:	re (cperciva)
PR:	290141
MFC after:	3 days
Reported by:	Paul Procacci <[email protected]>
Reviewed by:	ziaee (manpages)
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D53049

(cherry picked from commit dc978c5cb5)
(cherry picked from commit 53fcc7f9b0)
2025-10-13 00:06:21 -07:00
Rick Macklem c904188d35 rpc.tlsservd.c: Pin max threads at 1 for now
PR#289734 reports a crash in tcp_use_close() when the rpc.tlsservd
daemon is being used.  Although I have no, as yet, had time to track
down/fix the race, it turns out setting rpctls_maxthreads to 1
avoids the problem.

This patch pins rpctls_maxthreads to 1 to avoid the problem,
until there is a proper fix.

Approved by:	re (cperciva)
PR:	289734

(cherry picked from commit 7a289fe3cd)
(cherry picked from commit a7fc4e326c)
2025-10-12 18:25:42 -07:00
Colin Percival 36a923a476 release: Remove errant .endfor
This didn't show up in testing on main or stable/15 because it only
applies for "release" (BETA and onwards) builds.

Approved by:	re (cperciva)
Fixes:	afdc022deb ("release: Publish pkgbase-repo.tar")
MFC after:	30 seconds
Sponsored by:	https://www.patreon.com/cperciva

(cherry picked from commit 474ae083b1)
(cherry picked from commit 5de7bdab32)
2025-10-10 21:17:48 -07:00
Colin Percival 7849d8d239 EC2: metalog_add missing files from packages
The files
	/usr/local/etc/dhclient.conf
	/usr/local/etc/ssl/cert.pem
are created in EC2 images by installed packages, but are not being
registered in METALOG.  The reason for this is not immediately clear,
but may be related to the handling of "sample" files.

Approved by:	re (cperciva)
Reviewed by:	dch
MFC after:	5 minutes
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D53035

(cherry picked from commit 2b0ffc0ee4)
(cherry picked from commit 63da8d2639)
2025-10-10 17:05:24 -07:00
Colin Percival b1303ed636 vmimage.subr: metalog_add generated databases
The files /etc/login.conf.db, /etc/passwd, /etc/pwd.db, /etc/spwd.db,
and /var/db/services.db are generated at install time.  When VM images
are built using installworld, there is Makefile code which emits the
necessary METALOG lines; but the pkgbase triggers do not do this.  This
resulted in VM images which lacked these essential database files.

VM images are currently the only place where this matters, since this
issue is specific to non-root image builds uusing pkgbase.  (In some
point in the future we will start building release ISO iamges from
pkgbase, at which point it will be a problem there as well.)

The long-term solution for this is probably to teach the relevant
database-creating tools to emit METALOG lines; but for now, just log
the necessary files from vmimage.subr.

Approved by:	re (cperciva)
Reviewed by:	dch
MFC after:	5 minutes
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D53034

(cherry picked from commit 6081365c27)
(cherry picked from commit b3c5c7d6f1)
2025-10-10 17:05:16 -07:00
Colin Percival a2829ff9d1 15.0: create releng/15.0 branch
Update from ALPHA5 to BETA1
Switch pkg(8) configuration to use the quarterly repository
Bump __FreeBSD_version

Approved by:	re (implicit)
Sponsored by:	https://www.patreon.com/cperciva
2025-10-09 23:59:00 +00:00
2464 changed files with 132457 additions and 89226 deletions

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@ compute_engine_instance:
# gcloud compute images list --project freebsd-org-cloud-dev --no-standard-images
platform: freebsd
image_project: freebsd-org-cloud-dev
image: freebsd-14-2-release-amd64-ufs
image: freebsd-14-3-release-amd64-ufs
cpu: 8
memory: 8G
disk: 40
+41 -16
View File
@@ -466,7 +466,7 @@ SUBDIR+= ${_DIR}
# by calling 'makedb' in share/man. This is only relevant for
# install/distribute so they build the whatis file after every manpage is
# installed.
.if make(installworld) || make(install)
.if make(installworld) || make(install) || make(distributeworld) || make(distribute)
SUBDIR+=.WAIT
.endif
SUBDIR+=etc
@@ -600,7 +600,16 @@ PKG_VERSION:= ${_PKG_REVISION}${EXTRA_REVISION:C/[[:space:]]//g}
.endif
.endif # !defined(_MKSHOWCONFIG)
PKG_NAME_PREFIX?= FreeBSD
PKG_MAINTAINER?= [email protected]
PKG_WWW?= https://www.FreeBSD.org
PKG_WORKERS_COUNT?= 1
.if make(*package*)
.export PKG_NAME_PREFIX
.export PKG_MAINTAINER
.export PKG_WWW
.if !defined(PKG_TIMESTAMP)
.if !empty(GIT_CMD) && exists(${GIT_CMD}) && exists(${SRCDIR}/.git)
SOURCE_DATE_EPOCH!= ${GIT_CMD} -C ${SRCDIR} show -s --format=%ct HEAD
@@ -611,14 +620,6 @@ SOURCE_DATE_EPOCH= ${TIMEEPOCHNOW:gmtime}
.else
SOURCE_DATE_EPOCH= ${PKG_TIMESTAMP}
.endif
PKG_WORKERS_COUNT?= 1
PKG_NAME_PREFIX?= FreeBSD
PKG_MAINTAINER?= [email protected]
PKG_WWW?= https://www.FreeBSD.org
.export PKG_NAME_PREFIX
.export PKG_MAINTAINER
.export PKG_WWW
.endif
.if !defined(_MKSHOWCONFIG)
@@ -1366,6 +1367,28 @@ __installcheck_DESTDIR: .PHONY
.endif
.endif
#
# Don't allow installworld or installkernel on a pkgbase system. This avoids
# accidentally updating a pkgbase system with install{world,kernel}, causing
# the installed system to become out of date with the package database.
#
# Skip the check if DESTDIR is defined on the assumption the user knows what
# they're doing. This means the check can be disabled for the running system
# using DESTDIR=/.
#
.if !make(distributeworld) && !defined(DESTDIR)
_installcheck_world: __installcheck_PKG
_installcheck_kernel: __installcheck_PKG
__installcheck_PKG: .PHONY
.if exists(${LOCALBASE}/sbin/pkg-static)
@if ${LOCALBASE}/sbin/pkg-static info -e ${PKG_NAME_PREFIX}-runtime; then \
echo >&2 "ERROR: This target should not be used on a system installed from packages." ; \
echo >&2 " To override this check, set DESTDIR=/."; \
false; \
fi
.endif
.endif
.if !defined(DB_FROM_SRC)
#
# Check for missing UIDs/GIDs.
@@ -1977,6 +2000,7 @@ REPODIR?= ${OBJROOT}repo
PKG_FORMAT?= tzst
PKG_LEVEL?= -1
PKG_CLEVEL?= ${"${PKG_FORMAT:Mtar}" != "":?:-l ${PKG_LEVEL}}
PKG_CTHREADS?= 0
PKG_REPO_SIGNING_KEY?= # empty
PKG_OUTPUT_DIR?= ${PKG_VERSION}
PKG_ABI_FILE?= ${WSTAGEDIR}/usr/bin/uname
@@ -2107,6 +2131,7 @@ create-packages-world: _pkgbootstrap _repodir .PHONY
.ORDER: create-packages-world create-packages-sets
.ORDER: create-packages-kernel create-packages-sets
.ORDER: create-packages-source create-packages-sets
create-packages-sets: _pkgbootstrap _repodir .PHONY
${_+_}@cd ${.CURDIR}; \
${MAKE} -f Makefile.inc1 \
@@ -2156,7 +2181,7 @@ create-source-src-package: _pkgbootstrap .PHONY
${SSTAGEDIR}/src.ucl
${PKG_CMD} -o ABI=${PKG_ABI} \
-o OSVERSION="${SRCRELDATE}" \
create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
create -f ${PKG_FORMAT} ${PKG_CLEVEL} -T${PKG_CTHREADS} \
-M ${SSTAGEDIR}/src.ucl \
-p ${SSTAGEDIR}/src.plist \
-r ${SRCDIR} \
@@ -2182,7 +2207,7 @@ create-source-src-sys-package: _pkgbootstrap .PHONY
${SSTAGEDIR}/src-sys.ucl
${PKG_CMD} -o ABI=${PKG_ABI} \
-o OSVERSION="${SRCRELDATE}" \
create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
create -f ${PKG_FORMAT} ${PKG_CLEVEL} -T${PKG_CTHREADS} \
-M ${SSTAGEDIR}/src-sys.ucl \
-p ${SSTAGEDIR}/src-sys.plist \
-r ${SRCDIR} \
@@ -2225,7 +2250,7 @@ create-world-package-${pkgname}: .PHONY
fi
${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \
-o OSVERSION="${SRCRELDATE}" \
create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
create -f ${PKG_FORMAT} ${PKG_CLEVEL} -T${PKG_CTHREADS} \
-M ${WSTAGEDIR}/${pkgname}.ucl \
-p ${WSTAGEDIR}/${pkgname}.plist \
-r ${WSTAGEDIR} \
@@ -2244,7 +2269,7 @@ create-sets-packages: .PHONY
@for manifest in ${WSTAGEDIR}/set-*.ucl; do \
echo "--> Processing manifest: $$manifest"; \
${PKG_CMD} -o ABI=${PKG_ABI} -o OSVERSION="${SRCRELDATE}" \
create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
create -f ${PKG_FORMAT} ${PKG_CLEVEL} -T${PKG_CTHREADS} \
-M $$manifest \
-o "${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR}" \
|| exit 1; \
@@ -2274,7 +2299,7 @@ create-dtb-package: .PHONY
${KSTAGEDIR}/${DISTDIR}/dtb.ucl ; \
${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \
-o OSVERSION="${SRCRELDATE}" \
create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
create -f ${PKG_FORMAT} ${PKG_CLEVEL} -T${PKG_CTHREADS} \
-M ${KSTAGEDIR}/${DISTDIR}/dtb.ucl \
-p ${KSTAGEDIR}/${DISTDIR}/dtb.plist \
-r ${KSTAGEDIR}/${DISTDIR} \
@@ -2311,7 +2336,7 @@ create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap
${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl ; \
${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \
-o OSVERSION="${SRCRELDATE}" \
create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
create -f ${PKG_FORMAT} ${PKG_CLEVEL} -T${PKG_CTHREADS} \
-M ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.ucl \
-p ${KSTAGEDIR}/${DISTDIR}/kernel.${INSTALLKERNEL}${flavor}.plist \
-r ${KSTAGEDIR}/${DISTDIR} \
@@ -2351,7 +2376,7 @@ create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kerne
${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl ; \
${PKG_CMD} -o ABI=${PKG_ABI} -o ALLOW_BASE_SHLIBS=yes \
-o OSVERSION="${SRCRELDATE}" \
create -f ${PKG_FORMAT} ${PKG_CLEVEL} \
create -f ${PKG_FORMAT} ${PKG_CLEVEL} -T${PKG_CTHREADS} \
-M ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.ucl \
-p ${KSTAGEDIR}/kernel.${_kernel}/kernel.${_kernel}${flavor}.plist \
-r ${KSTAGEDIR}/kernel.${_kernel} \
+7
View File
@@ -51,6 +51,13 @@
# xargs -n1 | sort | uniq -d;
# done
# 20251121: Remove duplicate pam_krb5 manual page
OLD_FILES+=usr/share/man/man8/pam-krb5.8.gz
# 20251112: Remove pccard(4) and related
OLD_FILES+=share/man/man4/pccard.4.gz
OLD_FILES+=share/man/man4/pcic.4.gz
# 20251006: Remove libnss_tacplus.a (it never should have been installed)
OLD_FILES+=usr/lib/libnss_tacplus.a
+73
View File
@@ -12,11 +12,84 @@ Items affecting the ports and packages system can be found in
/usr/ports/UPDATING. Please read that file before updating system packages
and/or ports.
20260127:
15.0-RELEASE-p2 SA-26:01.openssl
EN-26:01.devinfo
EN-26:02.arm64
EN-26:03.vm
Fix multiple vulnerabilities in OpenSSL. [SA-26:01.openssl]
devinfo output formatting regression. [EN-26:01.devinfo]
arm64 SVE signal context misalignment. [EN-26:02.arm64]
The page fault handler fails to zero memory. [EN-26:03.vm]
20251216:
15.0-RELEASE-p1 SA-25:12.rtsold
EN-25:19.zfs
EN-25:20.vmm
Remote code execution via ND6 Router Advertisements. [SA-25:12.rtsold]
Unprivileged kernel NULL pointer dereference. [EN-25:19.zfs]
bhyve(8) PCI passthru regression. [EN-25:20.vmm]
20251202:
15.0-RELEASE.
20251126:
15.0-RC4-p1 SA-25:10.unbound
Fix DNS cache poison through YXDOMAIN and nodata non-referral
answers. [SA-25:10.unbound]
20251115:
The FreeBSD-base repository is now defined in /etc/pkg/FreeBSD.conf,
disabled by default. In -CURRENT and -STABLE this points at nightly
builds on pkg.freebsd.org; for BETA/RC/RELEASE builds it points at
release engineering builds on pkgbase.freebsd.org.
Users of pkgbase will need to replace any existing definition of the
FreeBSD-base repository in /usr/local/etc/pkg/repos/ with a single
line "FreeBSD-base: { enabled: yes }".
20251030:
flua(1) has moved to the new FreeBSD-flua package. If you use flua,
you may want to install this package if it's not otherwise installed
as a dependency of something else. This change only affects pkgbase
users.
20251023:
Bump __FreeBSD_version to 1500068 for LinuxKPI. An embedded struct
has changed size and might possibly be an issue otherwise.
20251022:
15.0-BETA2-p1 SA-25:09.netinet
SO_REUSEPORT_LB breaks connect(2) for UDP sockets. [SA-25:09.netinet]
20251015:
The "FreeBSD-unbound" package is renamed to "FreeBSD-local-unbound".
If you have set-optional or set-base installed, the new package will
be installed automatically, otherwise you should manually install the
new package and remove the old one.
This change only affects pkgbase users.
20251001:
The deprecated ftpd(8) has been removed. Users who still need ftpd
can install the ftp/freebsd-ftpd port. pkgbase users should remove
the orphaned FreeBSD-ftpd package.
20251012:
Blacklist has been renamed upstream to Blocklist. If you have it
configured, rename all configuration files, firewall anchors or
sentinel files to reflect the new nomenclature. Old setups will
continue to work emitting a warning.
20251002:
Audio-related utilities including mixer(8) and virtual_oss(8) have
moved to the new FreeBSD-sound package. If you have set-optional or
+6 -1
View File
@@ -433,6 +433,8 @@ copy(char *argv[], enum op type, int fts_options, struct stat *root_stat)
sep = strchr(to.base, '\0');
sep[0] = '/';
sep[1] = '\0';
} else if (strcmp(curr->fts_name, "/") == 0) {
/* special case when source is the root directory */
} else {
/* entering a directory; append its name to to.path */
len = snprintf(to.end, END(to.path) - to.end, "%s%s",
@@ -520,6 +522,8 @@ copy(char *argv[], enum op type, int fts_options, struct stat *root_stat)
if (type == DIR_TO_DNE &&
curr->fts_level == FTS_ROOTLEVEL) {
/* this is actually our created root */
} else if (strcmp(curr->fts_name, "/") == 0) {
/* special case when source is the root directory */
} else {
while (to.end > to.path && *to.end != '/')
to.end--;
@@ -551,7 +555,8 @@ copy(char *argv[], enum op type, int fts_options, struct stat *root_stat)
/* Not an error but need to remember it happened. */
if (to.path[0] == '\0') {
/*
* This can happen in two cases:
* This can happen in three cases:
* - The source path is the root directory.
* - DIR_TO_DNE; we created the directory and
* populated root_stat earlier.
* - FILE_TO_DIR if a source has a trailing slash;
+15
View File
@@ -747,9 +747,23 @@ dstmode_body()
atf_check cmp dir/file dst/file
}
atf_test_case root
root_head()
{
atf_set "descr" "Test copying the root directory"
}
root_body()
{
atf_check mkdir dst
atf_check -s exit:1 \
-e inline:"cp: / is a directory (not copied).\n" \
cp / dst
}
atf_test_case to_root cleanup
to_root_head()
{
atf_set "descr" "Test copying to the root directory"
atf_set "require.user" "unprivileged"
}
to_root_body()
@@ -893,6 +907,7 @@ atf_init_test_cases()
atf_add_test_case to_deaddirlink
atf_add_test_case to_link_outside
atf_add_test_case dstmode
atf_add_test_case root
atf_add_test_case to_root
atf_add_test_case dirloop
atf_add_test_case unrdir
+4 -2
View File
@@ -30,7 +30,7 @@
.\" USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
.\" OF SUCH DAMAGE.
.\"
.Dd January 21, 2021
.Dd October 22, 2025
.Dt PWAIT 1
.Os
.Sh NAME
@@ -39,7 +39,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl t Ar duration
.Op Fl ov
.Op Fl opv
.Ar pid
\&...
.Sh DESCRIPTION
@@ -51,6 +51,8 @@ The following option is available:
.Bl -tag -width indent
.It Fl o
Exit when any of the given processes has terminated.
.It Fl p
On exit, print a list of processes that have not terminated.
.It Fl t Ar duration
If any process is still running after
.Ar duration ,
+68 -34
View File
@@ -33,7 +33,9 @@
#include <sys/types.h>
#include <sys/event.h>
#include <sys/sysctl.h>
#include <sys/time.h>
#include <sys/tree.h>
#include <sys/wait.h>
#include <err.h>
@@ -46,10 +48,25 @@
#include <sysexits.h>
#include <unistd.h>
struct pid {
RB_ENTRY(pid) entry;
pid_t pid;
};
static int
pidcmp(const struct pid *a, const struct pid *b)
{
return (a->pid > b->pid ? 1 : a->pid < b->pid ? -1 : 0);
}
RB_HEAD(pidtree, pid);
static struct pidtree pids = RB_INITIALIZER(&pids);
RB_GENERATE_STATIC(pidtree, pid, entry, pidcmp);
static void
usage(void)
{
fprintf(stderr, "usage: pwait [-t timeout] [-ov] pid ...\n");
fprintf(stderr, "usage: pwait [-t timeout] [-opv] pid ...\n");
exit(EX_USAGE);
}
@@ -61,21 +78,28 @@ main(int argc, char *argv[])
{
struct itimerval itv;
struct kevent *e;
struct pid k, *p;
char *end, *s;
double timeout;
size_t sz;
long pid;
int i, kq, n, nleft, opt, status;
bool oflag, tflag, verbose;
pid_t mypid;
int i, kq, n, ndone, nleft, opt, pid_max, ret, status;
bool oflag, pflag, tflag, verbose;
oflag = false;
pflag = false;
tflag = false;
verbose = false;
memset(&itv, 0, sizeof(itv));
while ((opt = getopt(argc, argv, "ot:v")) != -1) {
while ((opt = getopt(argc, argv, "opt:v")) != -1) {
switch (opt) {
case 'o':
oflag = 1;
oflag = true;
break;
case 'p':
pflag = true;
break;
case 't':
tflag = true;
@@ -127,16 +151,18 @@ main(int argc, char *argv[])
usage();
}
kq = kqueue();
if (kq == -1) {
if ((kq = kqueue()) < 0)
err(EX_OSERR, "kqueue");
}
e = malloc((argc + tflag) * sizeof(struct kevent));
if (e == NULL) {
sz = sizeof(pid_max);
if (sysctlbyname("kern.pid_max", &pid_max, &sz, NULL, 0) != 0) {
pid_max = 99999;
}
if ((e = malloc((argc + tflag) * sizeof(*e))) == NULL) {
err(EX_OSERR, "malloc");
}
nleft = 0;
ndone = nleft = 0;
mypid = getpid();
for (n = 0; n < argc; n++) {
s = argv[n];
/* Undocumented Solaris compat */
@@ -145,35 +171,37 @@ main(int argc, char *argv[])
}
errno = 0;
pid = strtol(s, &end, 10);
if (pid < 0 || *end != '\0' || errno != 0) {
if (pid < 0 || pid > pid_max || *end != '\0' || errno != 0) {
warnx("%s: bad process id", s);
continue;
}
if (pid == getpid()) {
if (pid == mypid) {
warnx("%s: skipping my own pid", s);
continue;
}
for (i = 0; i < nleft; i++) {
if (e[i].ident == (uintptr_t)pid) {
break;
}
if ((p = malloc(sizeof(*p))) == NULL) {
err(EX_OSERR, NULL);
}
if (i < nleft) {
p->pid = pid;
if (RB_INSERT(pidtree, &pids, p) != NULL) {
/* Duplicate. */
free(p);
continue;
}
EV_SET(e + nleft, pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, NULL);
if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) {
if (errno != ESRCH)
err(EX_OSERR, "kevent()");
warn("%ld", pid);
if (oflag) {
exit(EX_OK);
}
RB_REMOVE(pidtree, &pids, p);
free(p);
ndone++;
} else {
nleft++;
}
}
if (nleft > 0 && tflag) {
if ((ndone == 0 || !oflag) && nleft > 0 && tflag) {
/*
* Explicitly detect SIGALRM so that an exit status of 124
* can be returned rather than 142.
@@ -188,7 +216,8 @@ main(int argc, char *argv[])
err(EX_OSERR, "setitimer");
}
}
while (nleft > 0) {
ret = EX_OK;
while ((ndone == 0 || !oflag) && ret == EX_OK && nleft > 0) {
n = kevent(kq, NULL, 0, e, nleft + tflag, NULL);
if (n == -1) {
err(EX_OSERR, "kevent");
@@ -198,29 +227,34 @@ main(int argc, char *argv[])
if (verbose) {
printf("timeout\n");
}
exit(124);
ret = 124;
}
pid = e[i].ident;
if (verbose) {
status = e[i].data;
if (WIFEXITED(status)) {
printf("%ld: exited with status %d.\n",
(long)e[i].ident,
WEXITSTATUS(status));
pid, WEXITSTATUS(status));
} else if (WIFSIGNALED(status)) {
printf("%ld: killed by signal %d.\n",
(long)e[i].ident,
WTERMSIG(status));
pid, WTERMSIG(status));
} else {
printf("%ld: terminated.\n",
(long)e[i].ident);
printf("%ld: terminated.\n", pid);
}
}
if (oflag) {
exit(EX_OK);
k.pid = pid;
if ((p = RB_FIND(pidtree, &pids, &k)) != NULL) {
RB_REMOVE(pidtree, &pids, p);
free(p);
ndone++;
}
--nleft;
}
}
exit(EX_OK);
if (pflag) {
RB_FOREACH(p, pidtree, &pids) {
printf("%d\n", p->pid);
}
}
exit(ret);
}
+38
View File
@@ -310,6 +310,43 @@ or_flag_cleanup()
wait $p2 $p4 $p6 >/dev/null 2>&1
}
atf_test_case print
print_head()
{
atf_set "descr" "Test the -p flag"
}
print_body()
{
sleep 1 &
p1=$!
sleep 5 &
p5=$!
sleep 10 &
p10=$!
atf_check \
-o inline:"$p5\n$p10\n" \
-s exit:124 \
pwait -t 2 -p $p10 $p5 $p1 $p5 $p10
atf_check \
-e inline:"kill: $p1: No such process\n" \
-s exit:1 \
kill -0 $p1
atf_check kill -0 $p5
atf_check kill -0 $p10
}
print_cleanup()
{
kill $p1 $p5 $p10 >/dev/null 2>&1
wait $p1 $p5 $p10 >/dev/null 2>&1
}
atf_init_test_cases()
{
atf_add_test_case basic
@@ -318,4 +355,5 @@ atf_init_test_cases()
atf_add_test_case timeout_no_timeout
atf_add_test_case timeout_many
atf_add_test_case or_flag
atf_add_test_case print
}
+1 -1
View File
@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.2 2015/01/22 17:49:41 christos Exp $
# $NetBSD: Makefile,v 1.1.1.1 2020/06/15 01:52:52 christos Exp $
SUBDIR = lib .WAIT include bin etc libexec
+4 -3
View File
@@ -1,10 +1,11 @@
# $NetBSD: Makefile.inc,v 1.3 2015/01/23 03:57:22 christos Exp $
# $NetBSD: Makefile.inc,v 1.3 2025/02/11 17:48:30 christos Exp $
WARNS=6
.if !defined(LIB)
LDADD+= -lblacklist
DPADD+= ${LIBBLACKLIST}
LDADD+= -lblocklist
DPADD+= ${LIBBLOCKLIST}
.endif
CPPFLAGS+= -I${.CURDIR}/../include
CPPFLAGS+=-DHAVE_STRUCT_SOCKADDR_SA_LEN -DHAVE_UTIL_H -DHAVE_DB_H
CPPFLAGS+=-DHAVE_SYS_CDEFS_H
+26 -26
View File
@@ -1,21 +1,21 @@
# $NetBSD: README,v 1.8 2017/04/13 17:59:34 christos Exp $
# $NetBSD: README,v 1.3 2024/02/09 00:53:30 wiz Exp $
This package contains library that can be used by network daemons to
communicate with a packet filter via a daemon to enforce opening and
closing ports dynamically based on policy.
The interface to the packet filter is in libexec/blacklistd-helper
The interface to the packet filter is in libexec/blocklistd-helper
(this is currently designed for npf) and the configuration file
(inspired from inetd.conf) is in etc/blacklistd.conf.
(inspired from inetd.conf) is in etc/blocklistd.conf.
On NetBSD you can find an example npf.conf and blacklistd.conf in
/usr/share/examples/blacklistd; you need to adjust the interface
On NetBSD you can find an example npf.conf and blocklistd.conf in
/usr/share/examples/blocklistd; you need to adjust the interface
in npf.conf and copy both files to /etc; then you just enable
blacklistd=YES in /etc/rc.conf, start it up, and you are all set.
blocklistd=YES in /etc/rc.conf, start it up, and you are all set.
There is also a startup file in etc/rc.d/blacklistd
There is also a startup file in etc/rc.d/blocklistd
Patches to various daemons to add blacklisting capabilitiers are in the
Patches to various daemons to add blocklisting capabilities are in the
"diff" directory:
- OpenSSH: diff/ssh.diff [tcp socket example]
- Bind: diff/named.diff [both tcp and udp]
@@ -23,21 +23,21 @@ Patches to various daemons to add blacklisting capabilitiers are in the
These patches have been applied to NetBSD-current.
The network daemon (for example sshd) communicates to blacklistd, via
a unix socket like syslog. The library calls are simple and everything
The network daemon (for example sshd) communicates to blocklistd, via
a Unix socket like syslog. The library calls are simple and everything
is handled by the library. In the simplest form the only thing the
daemon needs to do is to call:
blacklist(action, acceptedfd, message);
blocklist(action, acceptedfd, message);
Where:
action = 0 -> successful login clear blacklist state
action = 0 -> successful login clear blocklist state
1 -> failed login, add to the failed count
acceptedfd -> the file descriptor where the server is
connected to the remote client. It is used
to determine the listening socket, and the
remote address. This allows any program to
contact the blacklist daemon, since the verification
contact the blocklist daemon, since the verification
if the program has access to the listening
socket is done by virtue that the port
number is retrieved from the kernel.
@@ -46,13 +46,13 @@ Where:
Unfortunately there is no way to get information about the "peer"
from a udp socket, because there is no connection and that information
is kept with the server. In that case the daemon can provide the
peer information to blacklistd via:
peer information to blocklistd via:
blacklist_sa(action, acceptedfd, sockaddr, sockaddr_len, message);
blocklist_sa(action, acceptedfd, sockaddr, sockaddr_len, message);
The configuration file contains entries of the form:
# Blacklist rule
# Blocklist rule
# host/Port type protocol owner name nfail disable
192.168.1.1:ssh stream tcp * -int 10 1m
8.8.8.8:ssh stream tcp * -ext 6 60m
@@ -60,18 +60,18 @@ ssh stream tcp6 * * 6 60m
http stream tcp * * 6 60m
Here note that owner is * because the connection is done from the
child ssh socket which runs with user privs. We treat ipv4 connections
child ssh socket which runs with user privs. We treat IPv4 connections
differently by maintaining two different rules one for the external
interface and one from the internal We also register for both tcp
and tcp6 since those are different listening sockets and addresses;
we don't bother with ipv6 and separate rules. We use nfail = 6,
we don't bother with IPv6 and separate rules. We use nfail = 6,
because ssh allows 3 password attempts per connection, and this
will let us have 2 connections before blocking. Finally we block
for an hour; we could block forever too by specifying * in the
duration column.
blacklistd and the library use syslog(3) to report errors. The
blacklist filter state is persisted automatically in /var/db/blacklistd.db
blocklistd and the library use syslog(3) to report errors. The
blocklist filter state is persisted automatically in /var/db/blocklistd.db
so that if the daemon is restarted, it remembers what connections
is currently handling. To start from a fresh state (if you restart
npf too for example), you can use -f. To watch the daemon at work,
@@ -80,27 +80,27 @@ you can use -d.
The current control file is designed for npf, and it uses the
dynamic rule feature. You need to create a dynamic rule in your
/etc/npf.conf on the group referring to the interface you want to block
called blacklistd as follows:
called blocklistd as follows:
ext_if=bge0
int_if=sk0
group "external" on $ext_if {
...
ruleset "blacklistd-ext"
ruleset "blacklistd"
ruleset "blocklistd-ext"
ruleset "blocklistd"
...
}
group "internal" on $int_if {
...
ruleset "blacklistd-int"
ruleset "blocklistd-int"
...
}
You can use 'blacklistctl dump -a' to list all the current entries
You can use 'blocklistctl dump -a' to list all the current entries
in the database; the ones that have nfail <c>/<t> where <c>urrent
>= <t>otal, should have an id assosiated with them; this means that
>= <t>otal, should have an id associated with them; this means that
there is a packet filter rule added for that entry. For npf, you
can examine the packet filter dynamic rule entries using 'npfctl
rule <rulename> list'. The number of current entries can exceed
+46 -3
View File
@@ -1,4 +1,4 @@
# $NetBSD: TODO,v 1.7 2015/01/23 21:34:01 christos Exp $
# $NetBSD: TODO,v 1.3 2025/02/05 20:22:26 christos Exp $
- don't poll periodically, find the next timeout
- use the socket also for commands? Or separate socket?
@@ -17,5 +17,48 @@
-n
block
unblock
- do we need an api in blacklistctl to perform maintenance
- fix the blacklistctl output to be more user friendly
- do we need an api in blocklistctl to perform maintenance
- fix the blocklistctl output to be more user friendly
- figure out some way to do distributed operation securely (perhaps with
a helper daemon that authenticates local sockets and then communicates
local DB changes to the central server over a secure channel --
perhaps blocklistd-helper can have a back-end that can send updates to
a central server)
- add "blocklistd -l" to enable filter logging on all rules by default
- add some new options in the config file
"/all" - block both TCP and UDP (on the proto field?)
"/log" - enable filter logging (if not the default) (on the name field?)
"/nolog"- disable filter logging (if not the default) (on the name field?)
The latter two probably require a new parameter for blocklistd-helper.
- "blocklistd -f" should (also?) be a blocklistctl function!?!?!
- if blocklistd was started with '-r' then a SIGHUP should also do a
"control flush $rulename" and then re-add all the filter rules?
- should/could /etc/rc.conf.d/ipfilter be created with the following?
reload_postcmd=blocklistd_reload
start_postcmd=blocklistd_start
stop_precmd=blocklistd_stop
blocklistd_reload ()
{
/etc/rc.d/blocklistd reload # IFF SIGHUP does flush/re-add
# /etc/rc.d/blocklistd restart
}
blocklistd_stop ()
{
/etc/rc.d/blocklistd stop
}
blocklistd_start ()
{
/etc/rc.d/blocklistd start
}
or is there a better way?
+6 -6
View File
@@ -1,12 +1,12 @@
# $NetBSD: Makefile,v 1.11 2015/01/27 19:40:36 christos Exp $
# $NetBSD: Makefile,v 1.1.1.1 2020/06/15 01:52:52 christos Exp $
BINDIR=/sbin
PROGS=blacklistd blacklistctl
MAN.blacklistd=blacklistd.8 blacklistd.conf.5
MAN.blacklistctl=blacklistctl.8
SRCS.blacklistd = blacklistd.c conf.c run.c state.c support.c internal.c
SRCS.blacklistctl = blacklistctl.c conf.c state.c support.c internal.c
PROGS=blocklistd blocklistctl
MAN.blocklistd=blocklistd.8 blocklistd.conf.5
MAN.blocklistctl=blocklistctl.8
SRCS.blocklistd = blocklistd.c conf.c run.c state.c support.c internal.c
SRCS.blocklistctl = blocklistctl.c conf.c state.c support.c internal.c
DBG=-g
LDADD+=-lutil
+56 -7
View File
@@ -1,4 +1,4 @@
.\" $NetBSD: blacklistctl.8,v 1.9 2016/06/08 12:48:37 wiz Exp $
.\" $NetBSD: blocklistctl.8,v 1.4 2025/02/07 01:35:38 kre Exp $
.\"
.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,27 +27,42 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd June 7, 2016
.Dd January 27, 2025
.Dt BLACKLISTCTL 8
.Os
.Sh NAME
.Nm blacklistctl
.Nd display and change the state of blacklistd
.Nd display and change the state of the blacklistd database
.Sh SYNOPSIS
.Nm
.Cm dump
.Op Fl abdnrw
.Op Fl D Ar dbname
.Sh DESCRIPTION
.Nm
is a program used to display the state of
is a program used to display and change the state of the
.Xr blacklistd 8
.Pp
The following options are available:
database.
The following sub-commands are supported:
.Ss dump
The following options are available for the
.Cm dump
sub-command:
.Bl -tag -width indent
.It Fl a
Show all database entries, by default it shows only the embryonic ones.
Show all database entries, by default it shows only the active ones.
Inactive entries will be shown with a last-access (or, with
.Fl r ,
the remaining) time of
.Ql never .
.It Fl b
Show only the blocked entries.
.It Fl D Ar dbname
Specify the location of the
.Ic blacklistd
database file to use.
The default is
.Pa /var/db/blocklistd.db .
.It Fl d
Increase debugging level.
.It Fl n
@@ -59,9 +74,43 @@ Normally the width of addresses is good for IPv4, the
.Fl w
flag, makes the display wide enough for IPv6 addresses.
.El
.Pp
The output of the
.Cm dump
sub-command consists of a header (unless
.Fl n
was given) and one line for each record in the database, where each line
has the following columns:
.Bl -tag -width indent
.It Ql address/ma:port
The remote address, mask, and local port number of the client connection
associated with the database entry.
.It Ql id
column will show the identifier for the packet filter rule associated
with the database entry, though this may only be the word
.Ql OK
for packet filters which do not create a unique identifier for each rule.
.It Ql nfail
The number of
.Em failures
reported for the client on the noted port, as well as the number of
failures allowed before blocking (or, with
.Fl a ,
an asterisk
.Aq * )
.It So last access Sc | So remaining time Sc
The last time a the client was reported as attempting access, or, with
.Fl r ,
the time remaining before the rule blocking the client will be removed.
.El
.Sh SEE ALSO
.Xr blacklistd 8
.Sh NOTES
The
.Nm
program has been renamed to
.Xr blocklistctl 8 .
.Pp
Sometimes the reported number of failed attempts can exceed the number
of attempts that
.Xr blacklistd 8
+7 -4
View File
@@ -1,4 +1,4 @@
/* $NetBSD: blacklistctl.c,v 1.23 2018/05/24 19:21:01 christos Exp $ */
/* $NetBSD: blocklistctl.c,v 1.4 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
__RCSID("$NetBSD: blacklistctl.c,v 1.23 2018/05/24 19:21:01 christos Exp $");
#endif
__RCSID("$NetBSD: blocklistctl.c,v 1.4 2025/02/11 17:48:30 christos Exp $");
#include <stdio.h>
#include <time.h>
@@ -53,7 +55,7 @@ __RCSID("$NetBSD: blacklistctl.c,v 1.23 2018/05/24 19:21:01 christos Exp $");
#include "conf.h"
#include "state.h"
#include "internal.h"
#include "old_internal.h"
#include "support.h"
static __dead void
@@ -63,7 +65,8 @@ usage(int c)
warnx("Missing/unknown command");
else if (c != '?')
warnx("Unknown option `%c'", (char)c);
fprintf(stderr, "Usage: %s dump [-abdnrw]\n", getprogname());
fprintf(stderr,
"Usage: %s dump [-abdnrw] [-D dbname]\n", getprogname());
exit(EXIT_FAILURE);
}
+39 -15
View File
@@ -1,4 +1,4 @@
.\" $NetBSD: blacklistd.8,v 1.23 2020/04/21 13:57:12 christos Exp $
.\" $NetBSD: blocklistd.8,v 1.8 2025/02/25 22:13:34 christos Exp $
.\"
.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd April 21, 2020
.Dd February 25, 2025
.Dt BLACKLISTD 8
.Os
.Sh NAME
@@ -53,18 +53,31 @@ for notifications from other daemons about successful or failed connection
attempts.
If no such file is specified, then it only listens to the socket path
specified by
.Ar sockspath
.Ar sockpath
or if that is not specified to
.Pa /var/run/blacklistd.sock .
.Pa /var/run/blocklistd.sock .
Each notification contains an (action, port, protocol, address, owner) tuple
that identifies the remote connection and the action.
This tuple is consulted against entries in
.Ar configfile
with syntax specified in
This tuple is consulted against entries from the
.Ar configfile ,
with the syntax specified in
.Xr blacklistd.conf 5 .
If an entry is matched, a state entry is created for that tuple.
Each entry contains a number of tries limit and a duration.
.Pp
If
.Ar configfile
is a directory, or a directory exists with the same name as
.Ar configfile
with
.Qq .d
appended to it, each file in the directory will be read as configuration file.
If
.Ar configfile
exists as a file it will be processed before the contents of the
.Ar configfile Ns .d
directory if that also exists.
.Pp
The way
.Nm
does configuration entry matching is by having the client side pass the
@@ -152,7 +165,7 @@ The following options are available:
.It Fl C Ar controlprog
Use
.Ar controlprog
to communicate with the packet filter, usually
to communicate with the packet filter, instead of the default, which is
.Pa /usr/libexec/blacklistd-helper .
The following arguments are passed to the control program:
.Bl -tag -width protocol
@@ -161,7 +174,7 @@ The action to perform:
.Dv add ,
.Dv rem ,
or
.Dv flush
.Dv flush ;
to add, remove or flush a firewall rule.
.It name
The rule name.
@@ -183,13 +196,17 @@ identifier of the rule to be removed.
The add command is expected to return the rule identifier string to stdout.
.El
.It Fl c Ar configuration
The name of the configuration file to read, usually
The name of the configuration file to read.
The default when
.Fl c
is not given is
.Pa /etc/blacklistd.conf .
.It Fl D Ar dbfile
The Berkeley DB file where
.Nm
stores its state, usually
.Pa /var/db/blacklistd.db .
stores its state.
It defaults to
.Pa /var/db/blocklistd.db .
.It Fl d
Normally,
.Nm
@@ -203,7 +220,7 @@ are deleted by invoking the control script as:
.Bd -literal -offset indent
control flush <rulename>
.Ed
.It Fl P Ar sockspathsfile
.It Fl P Ar sockpathsfile
A file containing a list of pathnames, one per line that
.Nm
will create sockets to listen to.
@@ -261,16 +278,23 @@ to decrease the internal debugging level by 1.
Shell script invoked to interface with the packet filter.
.It Pa /etc/blacklistd.conf
Configuration file.
.It Pa /var/db/blacklistd.db
.It Pa /var/db/blocklistd.db
Database of current connection entries.
.It Pa /var/run/blacklistd.sock
.It Pa /var/run/blocklistd.sock
Socket to receive connection notifications.
.El
.Sh SEE ALSO
.Xr blacklistd.conf 5 ,
.Xr blacklistctl 8 ,
.Xr ipf 8 ,
.Xr ipfw 8 ,
.Xr pfctl 8 ,
.Xr syslogd 8
.Sh NOTES
The
.Nm
daemon has been renamed to
.Xr blocklistd 8 .
.Sh HISTORY
.Nm
first appeared in
+32 -18
View File
@@ -1,4 +1,4 @@
/* $NetBSD: blacklistd.c,v 1.38 2019/02/27 02:20:18 christos Exp $ */
/* $NetBSD: blocklistd.c,v 1.12 2025/10/25 18:43:51 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -31,8 +31,11 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
__RCSID("$NetBSD: blacklistd.c,v 1.38 2019/02/27 02:20:18 christos Exp $");
#endif
__RCSID("$NetBSD: blocklistd.c,v 1.12 2025/10/25 18:43:51 christos Exp $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -64,8 +67,8 @@ __RCSID("$NetBSD: blacklistd.c,v 1.38 2019/02/27 02:20:18 christos Exp $");
#include <ifaddrs.h>
#include <netinet/in.h>
#include "bl.h"
#include "internal.h"
#include "old_bl.h"
#include "old_internal.h"
#include "conf.h"
#include "run.h"
#include "state.h"
@@ -175,6 +178,8 @@ process(bl_t bl)
struct dbinfo dbi;
struct timespec ts;
memset(&dbi, 0, sizeof(dbi));
memset(&c, 0, sizeof(c));
if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
(*lfun)(LOG_ERR, "clock_gettime failed (%m)");
return;
@@ -186,24 +191,25 @@ process(bl_t bl)
}
if (getremoteaddress(bi, &rss, &rsl) == -1)
goto out;
return;
if (debug) {
if (debug || bi->bi_msg[0]) {
sockaddr_snprintf(rbuf, sizeof(rbuf), "%a:%p", (void *)&rss);
(*lfun)(LOG_DEBUG, "processing type=%d fd=%d remote=%s msg=%s"
" uid=%lu gid=%lu", bi->bi_type, bi->bi_fd, rbuf,
(*lfun)(bi->bi_msg[0] ? LOG_INFO : LOG_DEBUG,
"processing type=%d fd=%d remote=%s msg=\"%s\" uid=%lu gid=%lu",
bi->bi_type, bi->bi_fd, rbuf,
bi->bi_msg, (unsigned long)bi->bi_uid,
(unsigned long)bi->bi_gid);
}
if (conf_find(bi->bi_fd, bi->bi_uid, &rss, &c) == NULL) {
(*lfun)(LOG_DEBUG, "no rule matched");
goto out;
return;
}
if (state_get(state, &c, &dbi) == -1)
goto out;
return;
if (debug) {
char b1[128], b2[128];
@@ -220,7 +226,7 @@ process(bl_t bl)
* set the number of fails to be one less than the
* configured limit. Fallthrough to the normal BL_ADD
* processing, which will increment the failure count
* to the threshhold, and block the abusive address.
* to the threshold, and block the abusive address.
*/
if (c.c_nfail != -1)
dbi.count = c.c_nfail - 1;
@@ -263,8 +269,6 @@ process(bl_t bl)
state_put(state, &c, &dbi);
out:
close(bi->bi_fd);
if (debug) {
char b1[128], b2[128];
(*lfun)(LOG_DEBUG, "%s: final db state for %s: count=%d/%d "
@@ -325,8 +329,8 @@ again:
(*lfun)(LOG_INFO, "released %s/%d:%d after %d seconds",
buf, c.c_lmask, c.c_port, c.c_duration);
}
state_del(state, &c);
goto again;
if (state_del(state, &c) == 0)
goto again;
}
}
@@ -334,7 +338,7 @@ static void
addfd(struct pollfd **pfdp, bl_t **blp, size_t *nfd, size_t *maxfd,
const char *path)
{
bl_t bl = bl_create(true, path, vflag ? vdlog : vsyslog);
bl_t bl = bl_create(true, path, vflag ? vdlog : vsyslog_r);
if (bl == NULL || !bl_isconnected(bl))
exit(EXIT_FAILURE);
if (*nfd >= *maxfd) {
@@ -395,15 +399,25 @@ rules_flush(void)
static void
rules_restore(void)
{
DB *db;
struct conf c;
struct dbinfo dbi;
unsigned int f;
for (f = 1; state_iterate(state, &c, &dbi, f) == 1; f = 0) {
db = state_open(dbfile, O_RDONLY, 0);
if (db == NULL) {
(*lfun)(LOG_ERR, "Can't open `%s' to restore state (%m)",
dbfile);
return;
}
for (f = 1; state_iterate(db, &c, &dbi, f) == 1; f = 0) {
if (dbi.id[0] == '\0')
continue;
(void)run_change("add", &c, dbi.id, sizeof(dbi.id));
state_put(state, &c, &dbi);
}
state_close(db);
state_sync(state);
}
int
@@ -549,7 +563,7 @@ main(int argc, char *argv[])
conf_parse(configfile);
}
ret = poll(pfd, (nfds_t)nfd, tout);
if (debug)
if (debug && ret != 0)
(*lfun)(LOG_DEBUG, "received %d from poll()", ret);
switch (ret) {
case -1:
+42 -29
View File
@@ -1,6 +1,6 @@
.\" $NetBSD: blacklistd.conf.5,v 1.9 2019/11/06 20:33:30 para Exp $
.\" $NetBSD: blocklistd.conf.5,v 1.7 2025/02/11 17:47:05 christos Exp $
.\"
.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
.\" Copyright (c) 2015, 2025 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd May 18, 2020
.Dd February 5, 2025
.Dt BLACKLISTD.CONF 5
.Os
.Sh NAME
@@ -48,34 +48,34 @@ Comments are denoted by a
at the beginning of a line.
.Pp
There are two kinds of configuration lines,
.Va local
.Va [local]
and
.Va remote .
.Va [remote] .
By default, configuration lines are
.Va local ,
.Va [local] ,
i.e. the address specified refers to the addresses on the local machine.
To switch to between
.Va local
.Va [local]
and
.Va remote
.Va [remote]
configuration lines you can specify the stanzas:
.Dq [local]
and
.Dq [remote] .
.Pp
On
.Va local
.Va [local]
and
.Va remote
.Va [remote]
lines
.Dq *
means use the default, or wildcard match.
In addition, for
.Va remote
.Va [remote]
lines
.Dq =
means use the values from the matched
.Va local
.Va [local]
configuration line.
.Pp
The first four fields,
@@ -85,9 +85,9 @@ The first four fields,
and
.Va owner
are used to match the
.Va local
.Va [local]
or
.Va remote
.Va [remote]
addresses, whereas the last 3 fields
.Va name ,
.Va nfail ,
@@ -110,8 +110,8 @@ The
can be an IPv4 address in numeric format, an IPv6 address
in numeric format and enclosed by square brackets, or an interface name.
Mask modifiers are not allowed on interfaces because interfaces
can have multiple addresses in different protocols where the mask has a different
size.
can have multiple addresses in different protocols where the mask has a
different size.
.Pp
The
.Dv mask
@@ -143,8 +143,8 @@ The
field, is the name of the packet filter rule to be used.
If the
.Va name
starts with a
.Dq - ,
starts with a hyphen
.Pq Dq - ,
then the default rulename is prepended to the given name.
If the
.Dv name
@@ -160,13 +160,13 @@ field contains the number of failed attempts before access is blocked,
defaulting to
.Dq *
meaning never, and the last field
.Va disable
.Va duration
specifies the amount of time since the last access that the blocking
rule should be active, defaulting to
.Dq *
meaning forever.
The default unit for
.Va disable
.Va duration
is seconds, but one can specify suffixes for different units, such as
.Dq m
for minutes
@@ -176,25 +176,31 @@ for hours and
for days.
.Pp
Matching is done first by checking the
.Va local
.Va [local]
rules individually, in the order of the most specific to the least specific.
If a match is found, then the
.Va remote
If a match is found, then the matching
.Va [remote]
rules are applied.
The
.Va name ,
.Va nfail ,
and
.Va disable
.Va duration
fields can be altered by the
.Va remote
.Va [remote]
rule that matched.
.Pp
The
.Va remote
.Va [remote]
rules can be used for allowing specific addresses, changing the mask
size, the rule that the packet filter uses, the number of failed attempts,
or the block duration.
size (via
.Va name ) ,
the rule that the packet filter uses (also via
.Va name ) ,
the number of failed attempts (via
.Va nfail ) ,
or the duration to block (via
.Va duration ) .
.Sh FILES
.Bl -tag -width /etc/blacklistd.conf -compact
.It Pa /etc/blacklistd.conf
@@ -209,13 +215,20 @@ bnx0:ssh * * * * 3 6h
[remote]
# Never block 1.2.3.4
1.2.3.4:ssh * * * * * *
# For addresses coming from 8.8.0.0/16 block whole /24 networks instead of
# Never block the example IPv6 subnet either
[2001:db8::]/32:ssh * * * * * *
# For addresses coming from 8.8.0.0/16 block whole /24 networks instead
# individual hosts, but keep the rest of the blocking parameters the same.
8.8.0.0/16:ssh * * * /24 = =
.Ed
.Sh SEE ALSO
.Xr blacklistctl 8 ,
.Xr blacklistd 8
.Sh NOTES
The
.Nm
file has been renamed to
.Xr blocklistd.conf 8 .
.Sh HISTORY
.Nm
first appeared in
+134
View File
@@ -0,0 +1,134 @@
.\" $NetBSD: blocklistctl.8,v 1.6 2025/10/26 13:49:22 christos Exp $
.\"
.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Christos Zoulas.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd October 25, 2025
.Dt BLOCKLISTCTL 8
.Os
.Sh NAME
.Nm blocklistctl
.Nd display and change the state of the blocklistd database
.Sh SYNOPSIS
.Nm
.Cm dump
.Op Fl abdnrw
.Op Fl D Ar dbname
.Sh DESCRIPTION
.Nm
is a program used to display and change the state of the
.Xr blocklistd 8
database.
The following sub-commands are supported:
.Ss dump
The following options are available for the
.Cm dump
sub-command:
.Bl -tag -width indent
.It Fl a
Show all database entries, by default it shows only the active ones.
Inactive entries will be shown with a last-access (or, with
.Fl r ,
the remaining) time of
.Ql never .
.It Fl b
Show only the blocked entries.
.It Fl D Ar dbname
Specify the location of the
.Ic blocklistd
database file to use.
The default is
.Pa /var/db/blocklistd.db .
.It Fl d
Increase debugging level.
.It Fl n
Don't display a header.
.It Fl r
Show the remaining blocked time instead of the last activity time.
.It Fl w
Normally the width of addresses is good for IPv4, the
.Fl w
flag, makes the display wide enough for IPv6 addresses.
.El
.Pp
The output of the
.Cm dump
sub-command consists of a header (unless
.Fl n
was given) and one line for each record in the database, where each line
has the following columns:
.Bl -tag -width indent
.It Ql rulename
The packet filter rule name associated with the database entry,
usually
.Dv blocklistd .
.It Ql address/ma:port
The remote address, mask, and local port number of the client connection
associated with the database entry.
.It Ql id
column will show the identifier for the packet filter rule associated
with the database entry, though this may only be the word
.Ql OK
for packet filters which do not create a unique identifier for each rule.
.It Ql nfail
The number of
.Em failures
reported for the client on the noted port, as well as the number of
failures allowed before blocking (or, with
.Fl a ,
an asterisk
.Aq * )
.It So last access Sc | So remaining time Sc
The last time a the client was reported as attempting access, or, with
.Fl r ,
the time remaining before the rule blocking the client will be removed.
.El
.Sh SEE ALSO
.Xr blocklistd 8
.Sh NOTES
Sometimes the reported number of failed attempts can exceed the number
of attempts that
.Xr blocklistd 8
is configured to block.
This can happen either because the rule has been removed manually, or
because there were more attempts in flight while the rule block was being
added.
This condition is normal; in that case
.Xr blocklistd 8
will first attempt to remove the existing rule, and then it will re-add
it to make sure that there is only one rule active.
.Sh HISTORY
.Nm
first appeared in
.Nx 7 .
.Fx
support for
.Nm
was implemented in
.Fx 11 .
.Sh AUTHORS
.An Christos Zoulas
+170
View File
@@ -0,0 +1,170 @@
/* $NetBSD: blocklistctl.c,v 1.5 2025/10/25 16:56:10 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
__RCSID("$NetBSD: blocklistctl.c,v 1.5 2025/10/25 16:56:10 christos Exp $");
#include <stdio.h>
#include <time.h>
#ifdef HAVE_LIBUTIL_H
#include <libutil.h>
#endif
#ifdef HAVE_UTIL_H
#include <util.h>
#endif
#include <fcntl.h>
#include <string.h>
#include <syslog.h>
#include <err.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include "conf.h"
#include "state.h"
#include "internal.h"
#include "support.h"
static __dead void
usage(int c)
{
if (c == 0)
warnx("Missing/unknown command");
else if (c != '?')
warnx("Unknown option `%c'", (char)c);
fprintf(stderr,
"Usage: %s dump [-abdnrw] [-D dbname]\n", getprogname());
exit(EXIT_FAILURE);
}
static const char *
star(char *buf, size_t len, int val)
{
if (val == -1)
return "*";
snprintf(buf, len, "%d", val);
return buf;
}
int
main(int argc, char *argv[])
{
const char *dbname = _PATH_BLSTATE;
DB *db;
struct conf c;
struct dbinfo dbi;
unsigned int i;
struct timespec ts;
int all, blocked, remain, wide, noheader;
int o;
noheader = wide = blocked = all = remain = 0;
lfun = dlog;
if (argc == 1 || strcmp(argv[1], "dump") != 0)
usage(0);
argc--;
argv++;
while ((o = getopt(argc, argv, "abD:dnrw")) != -1)
switch (o) {
case 'a':
all = 1;
blocked = 0;
break;
case 'b':
blocked = 1;
break;
case 'D':
dbname = optarg;
break;
case 'd':
debug++;
break;
case 'n':
noheader = 1;
break;
case 'r':
remain = 1;
break;
case 'w':
wide = 1;
break;
default:
usage(o);
}
db = state_open(dbname, O_RDONLY, 0);
if (db == NULL)
err(EXIT_FAILURE, "Can't open `%s'", dbname);
clock_gettime(CLOCK_REALTIME, &ts);
wide = wide ? 8 * 4 + 7 : 4 * 3 + 3;
if (!noheader)
printf("rulename\t%*.*s/ma:port\tid\tnfail\t%s\n", wide, wide,
"address", remain ? "remaining time" : "last access");
for (i = 1; state_iterate(db, &c, &dbi, i) != 0; i = 0) {
char buf[BUFSIZ];
char mbuf[64], pbuf[64];
if (!all) {
if (blocked) {
if (c.c_nfail == -1 || dbi.count < c.c_nfail)
continue;
} else {
if (dbi.count >= c.c_nfail)
continue;
}
}
sockaddr_snprintf(buf, sizeof(buf), "%a", (void *)&c.c_ss);
printf("%s\t%*.*s/%s:%s\t", c.c_name, wide, wide, buf,
star(mbuf, sizeof(mbuf), c.c_lmask),
star(pbuf, sizeof(pbuf), c.c_port));
if (c.c_duration == -1) {
strlcpy(buf, "never", sizeof(buf));
} else {
if (remain)
fmtydhms(buf, sizeof(buf),
c.c_duration - (ts.tv_sec - dbi.last));
else
fmttime(buf, sizeof(buf), dbi.last);
}
printf("%s\t%d/%s\t%-s\n", dbi.id, dbi.count,
star(mbuf, sizeof(mbuf), c.c_nfail), buf);
}
state_close(db);
return EXIT_SUCCESS;
}
+303
View File
@@ -0,0 +1,303 @@
.\" $NetBSD: blocklistd.8,v 1.8 2025/02/25 22:13:34 christos Exp $
.\"
.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Christos Zoulas.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd February 25, 2025
.Dt BLOCKLISTD 8
.Os
.Sh NAME
.Nm blocklistd
.Nd block and release ports on demand to avoid DoS abuse
.Sh SYNOPSIS
.Nm
.Op Fl dfrv
.Op Fl C Ar controlprog
.Op Fl c Ar configfile
.Op Fl D Ar dbfile
.Op Fl P Ar sockpathsfile
.Op Fl R Ar rulename
.Op Fl s Ar sockpath
.Op Fl t Ar timeout
.Sh DESCRIPTION
.Nm
is a daemon similar to
.Xr syslogd 8
that listens to sockets at paths specified in the
.Ar sockpathsfile
for notifications from other daemons about successful or failed connection
attempts.
If no such file is specified, then it only listens to the socket path
specified by
.Ar sockpath
or if that is not specified to
.Pa /var/run/blocklistd.sock .
Each notification contains an (action, port, protocol, address, owner) tuple
that identifies the remote connection and the action.
This tuple is consulted against entries from the
.Ar configfile ,
with the syntax specified in
.Xr blocklistd.conf 5 .
If an entry is matched, a state entry is created for that tuple.
Each entry contains a number of tries limit and a duration.
.Pp
If
.Ar configfile
is a directory, or a directory exists with the same name as
.Ar configfile
with
.Qq .d
appended to it, each file in the directory will be read as configuration file.
If
.Ar configfile
exists as a file it will be processed before the contents of the
.Ar configfile Ns .d
directory if that also exists.
.Pp
The way
.Nm
does configuration entry matching is by having the client side pass the
file descriptor associated with the connection the client wants to blocklist
as well as passing socket credentials.
.Pp
The file descriptor is used to retrieve information (address and port)
about the remote side with
.Xr getpeername 2
and the local side with
.Xr getsockname 2 .
.Pp
By examining the port of the local side,
.Nm
can determine if the client program
.Dq owns
the port.
By examining the optional address portion on the local side, it can match
interfaces.
By examining the remote address, it can match specific allow or deny rules.
.Pp
Finally
.Nm
can examine the socket credentials to match the user in the configuration file.
.Pp
While this works well for TCP sockets, it cannot be relied on for unbound
UDP sockets.
It is also less meaningful when it comes to connections using non-privileged
ports.
On the other hand, if we receive a request that has a local endpoint indicating
a UDP privileged port, we can presume that the client was privileged to be
able to acquire that port.
.Pp
Once an entry is matched
.Nm
can perform various actions.
If the action is
.Dq add
and the number of tries limit is reached, then a
control script
.Ar controlprog
is invoked with arguments:
.Bd -literal -offset indent
control add <rulename> <proto> <address> <mask> <port>
.Ed
.Pp
and should invoke a packet filter command to block the connection
specified by the arguments.
The
.Ar rulename
argument can be set from the command line (default
.Dv blocklistd ) .
The script could print a numerical id to stdout as a handle for
the rule that can be used later to remove that connection, but
that is not required as all information to remove the rule is
kept.
.Pp
If the action is
.Dq rem
Then the same control script is invoked as:
.Bd -literal -offset indent
control rem <rulename> <proto> <address> <mask> <port> <id>
.Ed
.Pp
where
.Ar id
is the number returned from the
.Dq add
action.
.Pp
.Nm
maintains a database of known connections in
.Ar dbfile .
On startup it reads entries from that file, and updates its internal state.
.Pp
.Nm
checks the list of active entries every
.Ar timeout
seconds (default
.Dv 15 )
and removes entries and block rules using the control program as necessary.
.Pp
The following options are available:
.Bl -tag -width indent
.It Fl C Ar controlprog
Use
.Ar controlprog
to communicate with the packet filter, instead of the default, which is
.Pa /usr/libexec/blocklistd-helper .
The following arguments are passed to the control program:
.Bl -tag -width protocol
.It action
The action to perform:
.Dv add ,
.Dv rem ,
or
.Dv flush ;
to add, remove or flush a firewall rule.
.It name
The rule name.
.It protocol
The optional protocol name (can be empty):
.Dv tcp ,
.Dv tcp6 ,
.Dv udp ,
.Dv udp6 .
.It address
The IPv4 or IPv6 numeric address to be blocked or released.
.It mask
The numeric mask to be applied to the blocked or released address
.It port
The optional numeric port to be blocked (can be empty).
.It id
For packet filters that support removal of rules by rule identifier, the
identifier of the rule to be removed.
The add command is expected to return the rule identifier string to stdout.
.El
.It Fl c Ar configuration
The name of the configuration file to read.
The default when
.Fl c
is not given is
.Pa /etc/blocklistd.conf .
.It Fl D Ar dbfile
The Berkeley DB file where
.Nm
stores its state.
It defaults to
.Pa /var/db/blocklistd.db .
.It Fl d
Normally,
.Nm
disassociates itself from the terminal unless the
.Fl d
flag is specified, in which case it stays in the foreground.
.It Fl f
Truncate the state database and flush all the rules named
.Ar rulename
are deleted by invoking the control script as:
.Bd -literal -offset indent
control flush <rulename>
.Ed
.It Fl P Ar sockpathsfile
A file containing a list of pathnames, one per line that
.Nm
will create sockets to listen to.
This is useful for chrooted environments.
.It Fl R Ar rulename
Specify the default rule name for the packet filter rules, usually
.Dv blocklistd .
.It Fl r
Re-read the firewall rules from the internal database, then
remove and re-add them.
This helps for packet filters that do not retain state across reboots.
.It Fl s Ar sockpath
Add
.Ar sockpath
to the list of Unix sockets
.Nm
listens to.
.It Fl t Ar timeout
The interval in seconds
.Nm
polls the state file to update the rules.
.It Fl v
Cause
.Nm
to print
diagnostic messages to
.Dv stdout
instead of
.Xr syslogd 8 .
.El
.Sh SIGNAL HANDLING
.Nm
deals with the following signals:
.Bl -tag -width "USR2"
.It Dv HUP
Receipt of this signal causes
.Nm
to re-read the configuration file.
.It Dv INT , Dv TERM & Dv QUIT
These signals tell
.Nm
to exit in an orderly fashion.
.It Dv USR1
This signal tells
.Nm
to increase the internal debugging level by 1.
.It Dv USR2
This signal tells
.Nm
to decrease the internal debugging level by 1.
.El
.Sh FILES
.Bl -tag -width /usr/libexec/blocklistd-helper -compact
.It Pa /usr/libexec/blocklistd-helper
Shell script invoked to interface with the packet filter.
.It Pa /etc/blocklistd.conf
Configuration file.
.It Pa /var/db/blocklistd.db
Database of current connection entries.
.It Pa /var/run/blocklistd.sock
Socket to receive connection notifications.
.El
.Sh SEE ALSO
.Xr blocklistd.conf 5 ,
.Xr blocklistctl 8 ,
.Xr ipf 8 ,
.Xr ipfw 8 ,
.Xr pfctl 8 ,
.Xr syslogd 8
.Sh HISTORY
.Nm
first appeared in
.Nx 7 .
.Fx
support for
.Nm
was implemented in
.Fx 11 .
.Sh AUTHORS
.An Christos Zoulas
+590
View File
@@ -0,0 +1,590 @@
/* $NetBSD: blocklistd.c,v 1.12 2025/10/25 18:43:51 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
__RCSID("$NetBSD: blocklistd.c,v 1.12 2025/10/25 18:43:51 christos Exp $");
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/queue.h>
#ifdef HAVE_LIBUTIL_H
#include <libutil.h>
#endif
#ifdef HAVE_UTIL_H
#include <util.h>
#endif
#include <string.h>
#include <signal.h>
#include <netdb.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <inttypes.h>
#include <syslog.h>
#include <ctype.h>
#include <limits.h>
#include <errno.h>
#include <poll.h>
#include <fcntl.h>
#include <err.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <ifaddrs.h>
#include <netinet/in.h>
#include "bl.h"
#include "internal.h"
#include "conf.h"
#include "run.h"
#include "state.h"
#include "support.h"
static const char *configfile = _PATH_BLCONF;
static DB *state;
static const char *dbfile = _PATH_BLSTATE;
static sig_atomic_t readconf;
static sig_atomic_t done;
static int vflag;
static void
sigusr1(int n __unused)
{
debug++;
}
static void
sigusr2(int n __unused)
{
debug--;
}
static void
sighup(int n __unused)
{
readconf++;
}
static void
sigdone(int n __unused)
{
done++;
}
static __dead void
usage(int c)
{
if (c != '?')
warnx("Unknown option `%c'", (char)c);
fprintf(stderr, "Usage: %s [-vdfr] [-c <config>] [-R <rulename>] "
"[-P <sockpathsfile>] [-C <controlprog>] [-D <dbfile>] "
"[-s <sockpath>] [-t <timeout>]\n", getprogname());
exit(EXIT_FAILURE);
}
static int
getremoteaddress(bl_info_t *bi, struct sockaddr_storage *rss, socklen_t *rsl)
{
*rsl = sizeof(*rss);
memset(rss, 0, *rsl);
if (getpeername(bi->bi_fd, (void *)rss, rsl) != -1)
return 0;
if (errno != ENOTCONN) {
(*lfun)(LOG_ERR, "getpeername failed (%m)");
return -1;
}
if (bi->bi_slen == 0) {
(*lfun)(LOG_ERR, "unconnected socket with no peer in message");
return -1;
}
switch (bi->bi_ss.ss_family) {
case AF_INET:
*rsl = sizeof(struct sockaddr_in);
break;
case AF_INET6:
*rsl = sizeof(struct sockaddr_in6);
break;
default:
(*lfun)(LOG_ERR, "bad client passed socket family %u",
(unsigned)bi->bi_ss.ss_family);
return -1;
}
if (*rsl != bi->bi_slen) {
(*lfun)(LOG_ERR, "bad client passed socket length %u != %u",
(unsigned)*rsl, (unsigned)bi->bi_slen);
return -1;
}
memcpy(rss, &bi->bi_ss, *rsl);
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
if (*rsl != rss->ss_len) {
(*lfun)(LOG_ERR,
"bad client passed socket internal length %u != %u",
(unsigned)*rsl, (unsigned)rss->ss_len);
return -1;
}
#endif
return 0;
}
static void
process(bl_t bl)
{
struct sockaddr_storage rss;
socklen_t rsl;
char rbuf[BUFSIZ];
bl_info_t *bi;
struct conf c;
struct dbinfo dbi;
struct timespec ts;
memset(&dbi, 0, sizeof(dbi));
memset(&c, 0, sizeof(c));
if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
(*lfun)(LOG_ERR, "clock_gettime failed (%m)");
return;
}
if ((bi = bl_recv(bl)) == NULL) {
(*lfun)(LOG_ERR, "no message (%m)");
return;
}
if (getremoteaddress(bi, &rss, &rsl) == -1)
return;
if (debug || bi->bi_msg[0]) {
sockaddr_snprintf(rbuf, sizeof(rbuf), "%a:%p", (void *)&rss);
(*lfun)(bi->bi_msg[0] ? LOG_INFO : LOG_DEBUG,
"processing type=%d fd=%d remote=%s msg=\"%s\" uid=%lu gid=%lu",
bi->bi_type, bi->bi_fd, rbuf,
bi->bi_msg, (unsigned long)bi->bi_uid,
(unsigned long)bi->bi_gid);
}
if (conf_find(bi->bi_fd, bi->bi_uid, &rss, &c) == NULL) {
(*lfun)(LOG_DEBUG, "no rule matched");
return;
}
if (state_get(state, &c, &dbi) == -1)
return;
if (debug) {
char b1[128], b2[128];
(*lfun)(LOG_DEBUG, "%s: initial db state for %s: count=%d/%d "
"last=%s now=%s", __func__, rbuf, dbi.count, c.c_nfail,
fmttime(b1, sizeof(b1), dbi.last),
fmttime(b2, sizeof(b2), ts.tv_sec));
}
switch (bi->bi_type) {
case BL_ABUSE:
/*
* If the application has signaled abusive behavior,
* set the number of fails to be one less than the
* configured limit. Fallthrough to the normal BL_ADD
* processing, which will increment the failure count
* to the threshold, and block the abusive address.
*/
if (c.c_nfail != -1)
dbi.count = c.c_nfail - 1;
/*FALLTHROUGH*/
case BL_ADD:
dbi.count++;
dbi.last = ts.tv_sec;
if (c.c_nfail != -1 && dbi.count >= c.c_nfail) {
/*
* No point in re-adding the rule.
* It might exist already due to latency in processing
* and removing the rule is the wrong thing to do as
* it allows a window to attack again.
*/
if (dbi.id[0] == '\0') {
int res = run_change("add", &c,
dbi.id, sizeof(dbi.id));
if (res == -1)
goto out;
}
sockaddr_snprintf(rbuf, sizeof(rbuf), "%a",
(void *)&rss);
(*lfun)(LOG_INFO,
"blocked %s/%d:%d for %d seconds",
rbuf, c.c_lmask, c.c_port, c.c_duration);
}
break;
case BL_DELETE:
if (dbi.last == 0)
goto out;
dbi.count = 0;
dbi.last = 0;
break;
case BL_BADUSER:
/* ignore for now */
break;
default:
(*lfun)(LOG_ERR, "unknown message %d", bi->bi_type);
}
state_put(state, &c, &dbi);
out:
if (debug) {
char b1[128], b2[128];
(*lfun)(LOG_DEBUG, "%s: final db state for %s: count=%d/%d "
"last=%s now=%s", __func__, rbuf, dbi.count, c.c_nfail,
fmttime(b1, sizeof(b1), dbi.last),
fmttime(b2, sizeof(b2), ts.tv_sec));
}
}
static void
update_interfaces(void)
{
struct ifaddrs *oifas, *nifas;
if (getifaddrs(&nifas) == -1)
return;
oifas = ifas;
ifas = nifas;
if (oifas)
freeifaddrs(oifas);
}
static void
update(void)
{
struct timespec ts;
struct conf c;
struct dbinfo dbi;
unsigned int f, n;
char buf[128];
void *ss = &c.c_ss;
if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
(*lfun)(LOG_ERR, "clock_gettime failed (%m)");
return;
}
again:
for (n = 0, f = 1; state_iterate(state, &c, &dbi, f) == 1;
f = 0, n++)
{
time_t when = c.c_duration + dbi.last;
if (debug > 1) {
char b1[64], b2[64];
sockaddr_snprintf(buf, sizeof(buf), "%a:%p", ss);
(*lfun)(LOG_DEBUG, "%s:[%u] %s count=%d duration=%d "
"last=%s " "now=%s", __func__, n, buf, dbi.count,
c.c_duration, fmttime(b1, sizeof(b1), dbi.last),
fmttime(b2, sizeof(b2), ts.tv_sec));
}
if (c.c_duration == -1 || when >= ts.tv_sec)
continue;
if (dbi.id[0]) {
run_change("rem", &c, dbi.id, 0);
sockaddr_snprintf(buf, sizeof(buf), "%a", ss);
(*lfun)(LOG_INFO, "released %s/%d:%d after %d seconds",
buf, c.c_lmask, c.c_port, c.c_duration);
}
if (state_del(state, &c) == 0)
goto again;
}
}
static void
addfd(struct pollfd **pfdp, bl_t **blp, size_t *nfd, size_t *maxfd,
const char *path)
{
bl_t bl = bl_create(true, path, vflag ? vdlog : vsyslog_r);
if (bl == NULL || !bl_isconnected(bl))
exit(EXIT_FAILURE);
if (*nfd >= *maxfd) {
*maxfd += 10;
*blp = realloc(*blp, sizeof(**blp) * *maxfd);
if (*blp == NULL)
err(EXIT_FAILURE, "malloc");
*pfdp = realloc(*pfdp, sizeof(**pfdp) * *maxfd);
if (*pfdp == NULL)
err(EXIT_FAILURE, "malloc");
}
(*pfdp)[*nfd].fd = bl_getfd(bl);
(*pfdp)[*nfd].events = POLLIN;
(*blp)[*nfd] = bl;
*nfd += 1;
}
static void
uniqueadd(struct conf ***listp, size_t *nlist, size_t *mlist, struct conf *c)
{
struct conf **list = *listp;
if (c->c_name[0] == '\0')
return;
for (size_t i = 0; i < *nlist; i++) {
if (strcmp(list[i]->c_name, c->c_name) == 0)
return;
}
if (*nlist == *mlist) {
*mlist += 10;
void *p = realloc(*listp, *mlist * sizeof(*list));
if (p == NULL)
err(EXIT_FAILURE, "Can't allocate for rule list");
list = *listp = p;
}
list[(*nlist)++] = c;
}
static void
rules_flush(void)
{
struct conf **list;
size_t nlist, mlist;
list = NULL;
mlist = nlist = 0;
for (size_t i = 0; i < rconf.cs_n; i++)
uniqueadd(&list, &nlist, &mlist, &rconf.cs_c[i]);
for (size_t i = 0; i < lconf.cs_n; i++)
uniqueadd(&list, &nlist, &mlist, &lconf.cs_c[i]);
for (size_t i = 0; i < nlist; i++)
run_flush(list[i]);
free(list);
}
static void
rules_restore(void)
{
DB *db;
struct conf c;
struct dbinfo dbi;
unsigned int f;
db = state_open(dbfile, O_RDONLY, 0);
if (db == NULL) {
(*lfun)(LOG_ERR, "Can't open `%s' to restore state (%m)",
dbfile);
return;
}
for (f = 1; state_iterate(db, &c, &dbi, f) == 1; f = 0) {
if (dbi.id[0] == '\0')
continue;
(void)run_change("add", &c, dbi.id, sizeof(dbi.id));
state_put(state, &c, &dbi);
}
state_close(db);
state_sync(state);
}
int
main(int argc, char *argv[])
{
int c, tout, flags, flush, restore, ret;
const char *spath, **blsock;
size_t nblsock, maxblsock;
setprogname(argv[0]);
spath = NULL;
blsock = NULL;
maxblsock = nblsock = 0;
flush = 0;
restore = 0;
tout = 0;
flags = O_RDWR|O_EXCL|O_CLOEXEC;
while ((c = getopt(argc, argv, "C:c:D:dfP:rR:s:t:v")) != -1) {
switch (c) {
case 'C':
controlprog = optarg;
break;
case 'c':
configfile = optarg;
break;
case 'D':
dbfile = optarg;
break;
case 'd':
debug++;
break;
case 'f':
flush++;
break;
case 'P':
spath = optarg;
break;
case 'R':
rulename = optarg;
break;
case 'r':
restore++;
break;
case 's':
if (nblsock >= maxblsock) {
maxblsock += 10;
void *p = realloc(blsock,
sizeof(*blsock) * maxblsock);
if (p == NULL)
err(EXIT_FAILURE,
"Can't allocate memory for %zu sockets",
maxblsock);
blsock = p;
}
blsock[nblsock++] = optarg;
break;
case 't':
tout = atoi(optarg) * 1000;
break;
case 'v':
vflag++;
break;
default:
usage(c);
}
}
argc -= optind;
if (argc)
usage('?');
signal(SIGHUP, sighup);
signal(SIGINT, sigdone);
signal(SIGQUIT, sigdone);
signal(SIGTERM, sigdone);
signal(SIGUSR1, sigusr1);
signal(SIGUSR2, sigusr2);
openlog(getprogname(), LOG_PID, LOG_DAEMON);
if (debug) {
lfun = dlog;
if (tout == 0)
tout = 5000;
} else {
if (tout == 0)
tout = 15000;
}
update_interfaces();
conf_parse(configfile);
if (flush) {
rules_flush();
if (!restore)
flags |= O_TRUNC;
}
struct pollfd *pfd = NULL;
bl_t *bl = NULL;
size_t nfd = 0;
size_t maxfd = 0;
for (size_t i = 0; i < nblsock; i++)
addfd(&pfd, &bl, &nfd, &maxfd, blsock[i]);
free(blsock);
if (spath) {
FILE *fp = fopen(spath, "r");
char *line;
if (fp == NULL)
err(EXIT_FAILURE, "Can't open `%s'", spath);
for (; (line = fparseln(fp, NULL, NULL, NULL, 0)) != NULL;
free(line))
addfd(&pfd, &bl, &nfd, &maxfd, line);
fclose(fp);
}
if (nfd == 0)
addfd(&pfd, &bl, &nfd, &maxfd, _PATH_BLSOCK);
state = state_open(dbfile, flags, 0600);
if (state == NULL)
state = state_open(dbfile, flags | O_CREAT, 0600);
if (state == NULL)
return EXIT_FAILURE;
if (restore) {
if (!flush)
rules_flush();
rules_restore();
}
if (!debug) {
if (daemon(0, 0) == -1)
err(EXIT_FAILURE, "daemon failed");
if (pidfile(NULL) == -1)
err(EXIT_FAILURE, "Can't create pidfile");
}
for (size_t t = 0; !done; t++) {
if (readconf) {
readconf = 0;
conf_parse(configfile);
}
ret = poll(pfd, (nfds_t)nfd, tout);
if (debug && ret != 0)
(*lfun)(LOG_DEBUG, "received %d from poll()", ret);
switch (ret) {
case -1:
if (errno == EINTR)
continue;
(*lfun)(LOG_ERR, "poll (%m)");
return EXIT_FAILURE;
case 0:
state_sync(state);
break;
default:
for (size_t i = 0; i < nfd; i++)
if (pfd[i].revents & POLLIN)
process(bl[i]);
}
if (t % 100 == 0)
state_sync(state);
if (t % 10000 == 0)
update_interfaces();
update();
}
state_close(state);
return 0;
}
+237
View File
@@ -0,0 +1,237 @@
.\" $NetBSD: blocklistd.conf.5,v 1.7 2025/02/11 17:47:05 christos Exp $
.\"
.\" Copyright (c) 2015, 2025 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Christos Zoulas.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd February 5, 2025
.Dt BLOCKLISTD.CONF 5
.Os
.Sh NAME
.Nm blocklistd.conf
.Nd configuration file format for blocklistd
.Sh DESCRIPTION
The
.Nm
file contains configuration entries for
.Xr blocklistd 8
in a fashion similar to
.Xr inetd.conf 5 .
Only one entry per line is permitted.
Every entry must have all fields populated.
Each field can be separated by a tab or a space.
Comments are denoted by a
.Dq #
at the beginning of a line.
.Pp
There are two kinds of configuration lines,
.Va [local]
and
.Va [remote] .
By default, configuration lines are
.Va [local] ,
i.e. the address specified refers to the addresses on the local machine.
To switch to between
.Va [local]
and
.Va [remote]
configuration lines you can specify the stanzas:
.Dq [local]
and
.Dq [remote] .
.Pp
On
.Va [local]
and
.Va [remote]
lines
.Dq *
means use the default, or wildcard match.
In addition, for
.Va [remote]
lines
.Dq =
means use the values from the matched
.Va [local]
configuration line.
.Pp
The first four fields,
.Va location ,
.Va type ,
.Va proto ,
and
.Va owner
are used to match the
.Va [local]
or
.Va [remote]
addresses, whereas the last 3 fields
.Va name ,
.Va nfail ,
and
.Va disable
are used to modify the filtering action.
.Pp
The first field denotes the
.Va location
as an address, mask, and port.
The syntax for the
.Va location
is:
.Bd -literal -offset indent
[<address>|<interface>][/<mask>][:<port>]
.Ed
.Pp
The
.Dv address
can be an IPv4 address in numeric format, an IPv6 address
in numeric format and enclosed by square brackets, or an interface name.
Mask modifiers are not allowed on interfaces because interfaces
can have multiple addresses in different protocols where the mask has a
different size.
.Pp
The
.Dv mask
is always numeric, but the
.Dv port
can be either numeric or symbolic.
.Pp
The second field is the socket
.Va type :
.Dv stream ,
.Dv dgram ,
or numeric.
The third field is the
.Va protocol :
.Dv tcp ,
.Dv udp ,
.Dv tcp6 ,
.Dv udp6 ,
or numeric.
The fourth field is the effective user
.Va ( owner )
of the daemon process reporting the event,
either as a username or a userid.
.Pp
The rest of the fields control the behavior of the filter.
.Pp
The
.Va name
field, is the name of the packet filter rule to be used.
If the
.Va name
starts with a hyphen
.Pq Dq - ,
then the default rulename is prepended to the given name.
If the
.Dv name
contains a
.Dq / ,
the remaining portion of the name is interpreted as the mask to be
applied to the address specified in the rule, causing a single rule violation to
block the entire subnet for the configured prefix.
.Pp
The
.Va nfail
field contains the number of failed attempts before access is blocked,
defaulting to
.Dq *
meaning never, and the last field
.Va duration
specifies the amount of time since the last access that the blocking
rule should be active, defaulting to
.Dq *
meaning forever.
The default unit for
.Va duration
is seconds, but one can specify suffixes for different units, such as
.Dq m
for minutes
.Dq h
for hours and
.Dq d
for days.
.Pp
Matching is done first by checking the
.Va [local]
rules individually, in the order of the most specific to the least specific.
If a match is found, then the matching
.Va [remote]
rules are applied.
The
.Va name ,
.Va nfail ,
and
.Va duration
fields can be altered by the
.Va [remote]
rule that matched.
.Pp
The
.Va [remote]
rules can be used for allowing specific addresses, changing the mask
size (via
.Va name ) ,
the rule that the packet filter uses (also via
.Va name ) ,
the number of failed attempts (via
.Va nfail ) ,
or the duration to block (via
.Va duration ) .
.Sh FILES
.Bl -tag -width /etc/blocklistd.conf -compact
.It Pa /etc/blocklistd.conf
Configuration file.
.El
.Sh EXAMPLES
.Bd -literal -offset 8n
# Block ssh, after 3 attempts for 6 hours on the bnx0 interface
[local]
# location type proto owner name nfail duration
bnx0:ssh * * * * 3 6h
[remote]
# Never block 1.2.3.4
1.2.3.4:ssh * * * * * *
# Never block the example IPv6 subnet either
[2001:db8::]/32:ssh * * * * * *
# For addresses coming from 8.8.0.0/16 block whole /24 networks instead
# individual hosts, but keep the rest of the blocking parameters the same.
8.8.0.0/16:ssh * * * /24 = =
.Ed
.Sh SEE ALSO
.Xr blocklistctl 8 ,
.Xr blocklistd 8
.Sh HISTORY
.Nm
first appeared in
.Nx 7 .
.Fx
support for
.Nm
was implemented in
.Fx 11 .
.Sh AUTHORS
.An Christos Zoulas
+169 -31
View File
@@ -1,4 +1,4 @@
/* $NetBSD: conf.c,v 1.24 2016/04/04 15:52:56 christos Exp $ */
/* $NetBSD: conf.c,v 1.10 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
__RCSID("$NetBSD: conf.c,v 1.24 2016/04/04 15:52:56 christos Exp $");
#endif
__RCSID("$NetBSD: conf.c,v 1.10 2025/02/11 17:48:30 christos Exp $");
#include <stdio.h>
#ifdef HAVE_LIBUTIL_H
@@ -58,6 +60,7 @@ __RCSID("$NetBSD: conf.c,v 1.24 2016/04/04 15:52:56 christos Exp $");
#include <net/if.h>
#include <net/route.h>
#include <sys/socket.h>
#include <dirent.h>
#include "bl.h"
#include "internal.h"
@@ -261,7 +264,7 @@ conf_gethostport(const char *f, size_t l, bool local, struct conf *c,
if (debug)
(*lfun)(LOG_DEBUG, "%s: host6 %s", __func__, p);
if (strcmp(p, "*") != 0) {
if (inet_pton(AF_INET6, p, &sin6->sin6_addr) == -1)
if (inet_pton(AF_INET6, p, &sin6->sin6_addr) != 1)
goto out;
sin6->sin6_family = AF_INET6;
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
@@ -269,6 +272,8 @@ conf_gethostport(const char *f, size_t l, bool local, struct conf *c,
#endif
port = &sin6->sin6_port;
}
if (!*pstr)
pstr = "*";
} else if (pstr != p || strchr(p, '.') || conf_is_interface(p)) {
if (pstr == p)
pstr = "*";
@@ -311,7 +316,7 @@ conf_gethostport(const char *f, size_t l, bool local, struct conf *c,
*port = htons((in_port_t)c->c_port);
return 0;
out:
(*lfun)(LOG_ERR, "%s: %s, %zu: Bad address [%s]", __func__, f, l, pstr);
(*lfun)(LOG_ERR, "%s: %s, %zu: Bad address [%s]", __func__, f, l, p);
return -1;
out1:
(*lfun)(LOG_ERR, "%s: %s, %zu: Can't specify mask %d with "
@@ -407,6 +412,8 @@ conf_parseline(const char *f, size_t l, char *p, struct conf *c, bool local)
{
int e;
c->c_lineno = l;
while (*p && isspace((unsigned char)*p))
p++;
@@ -471,7 +478,6 @@ conf_amask_eq(const void *v1, const void *v2, size_t len, int mask)
uint32_t m;
int omask = mask;
len >>= 2;
switch (mask) {
case FSTAR:
if (memcmp(v1, v2, len) == 0)
@@ -485,7 +491,7 @@ conf_amask_eq(const void *v1, const void *v2, size_t len, int mask)
break;
}
for (size_t i = 0; i < len; i++) {
for (size_t i = 0; i < (len >> 2); i++) {
if (mask > 32) {
m = htonl((uint32_t)~0);
mask -= 32;
@@ -501,7 +507,6 @@ conf_amask_eq(const void *v1, const void *v2, size_t len, int mask)
out:
if (debug > 1) {
char b1[256], b2[256];
len <<= 2;
blhexdump(b1, sizeof(b1), "a1", v1, len);
blhexdump(b2, sizeof(b2), "a2", v2, len);
(*lfun)(LOG_DEBUG, "%s: %s != %s [0x%x]", __func__,
@@ -690,6 +695,25 @@ conf_addr_eq(const struct sockaddr_storage *s1,
static int
conf_eq(const struct conf *c1, const struct conf *c2)
{
if (!conf_addr_eq(&c1->c_ss, &c2->c_ss, FSTAR))
return 0;
#define CMP(a, b, f) \
if ((a)->f != (b)->f) \
return 0;
CMP(c1, c2, c_port);
CMP(c1, c2, c_proto);
CMP(c1, c2, c_family);
CMP(c1, c2, c_uid);
#undef CMP
return 1;
}
static int
conf_match(const struct conf *c1, const struct conf *c2)
{
if (!conf_addr_eq(&c1->c_ss, &c2->c_ss, c2->c_lmask))
@@ -953,13 +977,54 @@ confset_free(struct confset *cs)
}
static void
confset_replace(struct confset *dc, struct confset *sc)
confset_merge(struct confset *dc, struct confset *sc)
{
struct confset tc;
tc = *dc;
*dc = *sc;
confset_init(sc);
confset_free(&tc);
size_t i, j;
char buf[BUFSIZ];
/* Check each rule of the src confset (sc) */
for (i = 0; i < sc->cs_n; i++) {
/* Compare to each rule in the dest confset (dc) */
for (j = 0; j < dc->cs_n; j++) {
if (conf_eq(&dc->cs_c[j], &sc->cs_c[i])) {
break;
}
}
if (j == dc->cs_n) {
/* This is a new rule to add to the dest confset. */
if (confset_full(dc) && confset_grow(dc) == -1)
return;
*confset_get(dc) = sc->cs_c[i];
confset_add(dc);
continue;
}
/* We had a match above. */
/*
* Check whether the rule from the src confset is more
* restrictive than the existing one. Adjust the
* existing rule if necessary.
*/
if (sc->cs_c[i].c_nfail == dc->cs_c[j].c_nfail &&
sc->cs_c[i].c_duration && dc->cs_c[j].c_duration) {
(*lfun)(LOG_DEBUG, "skipping existing rule: %s",
conf_print(buf, sizeof (buf), "", "\t", &sc->cs_c[i]));
continue;
}
if (sc->cs_c[i].c_nfail < dc->cs_c[j].c_nfail)
dc->cs_c[j].c_nfail = sc->cs_c[i].c_nfail;
if (sc->cs_c[i].c_duration > dc->cs_c[j].c_duration)
dc->cs_c[j].c_duration = sc->cs_c[i].c_duration;
(*lfun)(LOG_DEBUG, "adjusted existing rule: %s",
conf_print(buf, sizeof (buf), "", "\t", &dc->cs_c[j]));
}
confset_free(sc);
}
static void
@@ -990,7 +1055,7 @@ confset_match(const struct confset *cs, struct conf *c,
if (debug)
(*lfun)(LOG_DEBUG, "%s", conf_print(buf, sizeof(buf),
"check:\t", "", &cs->cs_c[i]));
if (conf_eq(c, &cs->cs_c[i])) {
if (conf_match(c, &cs->cs_c[i])) {
if (debug)
(*lfun)(LOG_DEBUG, "%s",
conf_print(buf, sizeof(buf),
@@ -1160,21 +1225,14 @@ conf_find(int fd, uid_t uid, const struct sockaddr_storage *rss,
return cr;
}
void
conf_parse(const char *f)
static void
conf_parsefile(FILE *fp, const char *config_file)
{
FILE *fp;
char *line;
size_t lineno, len;
struct confset lc, rc, *cs;
if ((fp = fopen(f, "r")) == NULL) {
(*lfun)(LOG_ERR, "%s: Cannot open `%s' (%m)", __func__, f);
return;
}
lineno = 1;
lineno = 0;
confset_init(&rc);
confset_init(&lc);
@@ -1197,23 +1255,103 @@ conf_parse(const char *f)
if (confset_grow(cs) == -1) {
confset_free(&lc);
confset_free(&rc);
fclose(fp);
free(line);
return;
}
}
if (conf_parseline(f, lineno, line, confset_get(cs),
if (conf_parseline(config_file, lineno, line, confset_get(cs),
cs == &lc) == -1)
continue;
confset_add(cs);
}
fclose(fp);
confset_sort(&lc);
confset_sort(&rc);
confset_merge(&rconf, &rc);
confset_merge(&lconf, &lc);
}
confset_replace(&rconf, &rc);
confset_replace(&lconf, &lc);
static void
conf_parsedir(DIR *dir, const char *config_path)
{
long path_max;
struct dirent *dent;
char *path;
FILE *fp;
if ((path_max = pathconf(config_path, _PC_PATH_MAX)) == -1)
path_max = 2048;
if ((path = malloc((size_t)path_max)) == NULL) {
(*lfun)(LOG_ERR, "%s: Failed to allocate memory for path (%m)",
__func__);
return;
}
while ((dent = readdir(dir)) != NULL) {
if (strcmp(dent->d_name, ".") == 0 ||
strcmp(dent->d_name, "..") == 0)
continue;
(void) snprintf(path, (size_t)path_max, "%s/%s", config_path,
dent->d_name);
if ((fp = fopen(path, "r")) == NULL) {
(*lfun)(LOG_ERR, "%s: Cannot open `%s' (%m)", __func__,
path);
continue;
}
conf_parsefile(fp, path);
fclose(fp);
}
free(path);
}
void
conf_parse(const char *config_path)
{
char *path;
DIR *dir;
FILE *fp;
if ((dir = opendir(config_path)) != NULL) {
/*
* If config_path is a directory, parse the configuration files
* in the directory. Then we're done here.
*/
conf_parsedir(dir, config_path);
closedir(dir);
goto out;
} else if ((fp = fopen(config_path, "r")) != NULL) {
/* If config_path is a file, parse it. */
conf_parsefile(fp, config_path);
fclose(fp);
}
/*
* Append ".d" to config_path, and if that is a directory, parse the
* configuration files in the directory.
*/
if (asprintf(&path, "%s.d", config_path) < 0) {
(*lfun)(LOG_ERR, "%s: Failed to allocate memory for path (%m)",
__func__);
goto out;
}
if ((dir = opendir(path)) != NULL) {
conf_parsedir(dir, path);
closedir(dir);
}
free(path);
out:
if (dir == NULL && fp == NULL) {
(*lfun)(LOG_ERR, "%s: Cannot open `%s' (%m)", __func__,
config_path);
return;
}
confset_sort(&lconf);
confset_sort(&rconf);
if (debug) {
confset_list(&lconf, "local", "target");
+2 -1
View File
@@ -1,4 +1,4 @@
/* $NetBSD: conf.h,v 1.6 2015/01/27 19:40:36 christos Exp $ */
/* $NetBSD: conf.h,v 1.2 2025/02/05 20:09:33 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -34,6 +34,7 @@
#include <sys/socket.h>
struct conf {
size_t c_lineno;
struct sockaddr_storage c_ss;
int c_lmask;
int c_port;
+5 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: internal.c,v 1.5 2015/01/27 19:40:37 christos Exp $ */
/* $NetBSD: internal.c,v 1.2 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
__RCSID("$NetBSD: internal.c,v 1.5 2015/01/27 19:40:37 christos Exp $");
#endif
__RCSID("$NetBSD: internal.c,v 1.2 2025/02/11 17:48:30 christos Exp $");
#include <stdio.h>
#include <syslog.h>
@@ -41,7 +43,7 @@ __RCSID("$NetBSD: internal.c,v 1.5 2015/01/27 19:40:37 christos Exp $");
#include "internal.h"
int debug;
const char *rulename = "blacklistd";
const char *rulename = "blocklistd";
const char *controlprog = _PATH_BLCONTROL;
struct confset lconf, rconf;
struct ifaddrs *ifas;
+4 -4
View File
@@ -1,4 +1,4 @@
/* $NetBSD: internal.h,v 1.14 2016/04/04 15:52:56 christos Exp $ */
/* $NetBSD: internal.h,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,13 +32,13 @@
#define _INTERNAL_H
#ifndef _PATH_BLCONF
#define _PATH_BLCONF "/etc/blacklistd.conf"
#define _PATH_BLCONF "/etc/blocklistd.conf"
#endif
#ifndef _PATH_BLCONTROL
#define _PATH_BLCONTROL "/libexec/blacklistd-helper"
#define _PATH_BLCONTROL "/usr/libexec/blocklistd-helper"
#endif
#ifndef _PATH_BLSTATE
#define _PATH_BLSTATE "/var/db/blacklistd.db"
#define _PATH_BLSTATE "/var/db/blocklistd.db"
#endif
extern struct confset rconf, lconf;
+50
View File
@@ -0,0 +1,50 @@
/* $NetBSD: internal.c,v 1.2 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
__RCSID("$NetBSD: internal.c,v 1.2 2025/02/11 17:48:30 christos Exp $");
#include <stdio.h>
#include <syslog.h>
#include "conf.h"
#include "old_internal.h"
int debug;
const char *rulename = "blacklistd";
const char *controlprog = _PATH_BLCONTROL;
struct confset lconf, rconf;
struct ifaddrs *ifas;
void (*lfun)(int, const char *, ...) = syslog;
+58
View File
@@ -0,0 +1,58 @@
/* $NetBSD: internal.h,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _OLD_INTERNAL_H
#define _OLD_INTERNAL_H
#ifndef _PATH_BLCONF
#define _PATH_BLCONF "/etc/blacklistd.conf"
#endif
#ifndef _PATH_BLCONTROL
#define _PATH_BLCONTROL "/usr/libexec/blacklistd-helper"
#endif
#ifndef _PATH_BLSTATE
/* We want the new name, the old one would be incompatible after 24932b6 */
#define _PATH_BLSTATE "/var/db/blocklistd.db"
#endif
extern struct confset rconf, lconf;
extern int debug;
extern const char *rulename;
extern const char *controlprog;
extern struct ifaddrs *ifas;
#if !defined(__syslog_attribute__) && !defined(__syslog__)
#define __syslog__ __printf__
#endif
extern void (*lfun)(int, const char *, ...)
__attribute__((__format__(__syslog__, 2, 3)));
#endif /* _OLD_INTERNAL_H */
+6 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: run.c,v 1.14 2016/04/04 15:52:56 christos Exp $ */
/* $NetBSD: run.c,v 1.3 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
__RCSID("$NetBSD: run.c,v 1.14 2016/04/04 15:52:56 christos Exp $");
#endif
__RCSID("$NetBSD: run.c,v 1.3 2025/02/11 17:48:30 christos Exp $");
#include <stdio.h>
#ifdef HAVE_LIBUTIL_H
@@ -131,7 +133,8 @@ run_change(const char *how, const struct conf *c, char *id, size_t len)
prname = "udp";
break;
default:
(*lfun)(LOG_ERR, "%s: bad protocol %d", __func__, c->c_proto);
(*lfun)(LOG_ERR, "%s: bad protocol %d (line %zu)", __func__,
c->c_proto, c->c_lineno);
return -1;
}
+1 -1
View File
@@ -1,4 +1,4 @@
/* $NetBSD: run.h,v 1.5 2015/01/27 19:40:37 christos Exp $ */
/* $NetBSD: run.h,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
+5 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: state.c,v 1.19 2016/09/26 19:43:43 christos Exp $ */
/* $NetBSD: state.c,v 1.3 2025/10/25 18:43:51 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
__RCSID("$NetBSD: state.c,v 1.19 2016/09/26 19:43:43 christos Exp $");
#endif
__RCSID("$NetBSD: state.c,v 1.3 2025/10/25 18:43:51 christos Exp $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -129,7 +131,7 @@ state_del(DB *db, const struct conf *c)
(*lfun)(LOG_DEBUG, "%s: returns %d", __func__, rv);
(*db->sync)(db, 0);
}
return 0;
return rv;
default:
(*lfun)(LOG_ERR, "%s: failed (%m)", __func__);
return -1;
+1 -1
View File
@@ -1,4 +1,4 @@
/* $NetBSD: state.h,v 1.5 2015/01/27 19:40:37 christos Exp $ */
/* $NetBSD: state.h,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
+7 -4
View File
@@ -1,4 +1,4 @@
/* $NetBSD: support.c,v 1.9 2018/09/18 22:12:19 christos Exp $ */
/* $NetBSD: support.c,v 1.3 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
__RCSID("$NetBSD: support.c,v 1.9 2018/09/18 22:12:19 christos Exp $");
#endif
__RCSID("$NetBSD: support.c,v 1.3 2025/02/11 17:48:30 christos Exp $");
#include <time.h>
#include <string.h>
@@ -66,7 +68,8 @@ expandm(char *buf, size_t len, const char *fmt)
}
void
vdlog(int level __unused, const char *fmt, va_list ap)
vdlog(int level __unused, struct syslog_data *sd __unused,
const char *fmt, va_list ap)
{
char buf[BUFSIZ];
@@ -81,7 +84,7 @@ dlog(int level, const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
vdlog(level, fmt, ap);
vdlog(level, NULL, fmt, ap);
va_end(ap);
}
+4 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: support.h,v 1.7 2016/04/04 15:52:56 christos Exp $ */
/* $NetBSD: support.h,v 1.2 2024/08/02 17:11:55 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -34,8 +34,9 @@
__BEGIN_DECLS
const char *fmttime(char *, size_t, time_t);
const char *fmtydhms(char *, size_t, time_t);
void vdlog(int, const char *, va_list)
__attribute__((__format__(__printf__, 2, 0)));
struct syslog_data;
void vdlog(int, struct syslog_data *, const char *, va_list)
__attribute__((__format__(__printf__, 3, 0)));
void dlog(int, const char *, ...)
__attribute__((__format__(__printf__, 2, 3)));
ssize_t blhexdump(char *, size_t, const char *, const void *, size_t);
+6 -6
View File
@@ -2,17 +2,17 @@
+++ pfilter.c 2015-01-23 17:12:02.000000000 -0500
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <blacklist.h>
+#include <blocklist.h>
+
+#include "pfilter.h"
+
+static struct blacklist *blstate;
+static struct blocklist *blstate;
+
+void
+pfilter_open(void)
+{
+ if (blstate == NULL)
+ blstate = blacklist_open();
+ blstate = blocklist_open();
+}
+
+void
@@ -23,7 +23,7 @@
+ if (blstate == NULL)
+ return;
+
+ blacklist_r(blstate, what, 0, msg);
+ blocklist_r(blstate, what, 0, msg);
+}
--- /dev/null 2015-01-23 17:30:40.000000000 -0500
+++ pfilter.h 2015-01-23 17:07:25.000000000 -0500
@@ -42,8 +42,8 @@ diff -u -p -u -r1.63 Makefile
MLINKS= ftpusers.5 ftpchroot.5
+SRCS+= pfilter.c
+LDADD+= -lblacklist
+DPADD+= ${LIBBLACKLIST}
+LDADD+= -lblocklist
+DPADD+= ${LIBBLOCKLIST}
+
.if defined(NO_INTERNAL_LS)
CPPFLAGS+=-DNO_INTERNAL_LS
+6 -6
View File
@@ -8,17 +8,17 @@
+#include <named/types.h>
+#include <named/client.h>
+
+#include <blacklist.h>
+#include <blocklist.h>
+
+#include "pfilter.h"
+
+static struct blacklist *blstate;
+static struct blocklist *blstate;
+
+void
+pfilter_open(void)
+{
+ if (blstate == NULL)
+ blstate = blacklist_open();
+ blstate = blocklist_open();
+}
+
+#define TCP_CLIENT(c) (((c)->attributes & NS_CLIENTATTR_TCP) != 0)
@@ -39,7 +39,7 @@
+ }
+ if (socket == NULL)
+ return;
+ blacklist_sa_r(blstate,
+ blocklist_sa_r(blstate,
+ res != ISC_R_SUCCESS, isc_socket_getfd(socket),
+ &client->peeraddr.type.sa, client->peeraddr.length, msg);
+}
@@ -63,8 +63,8 @@ diff -u -u -r1.8 Makefile
+ pfilter.c tkeyconf.c tsigconf.c \
update.c xfrout.c zoneconf.c ${SRCS_UNIX}
+LDADD+=-lblacklist
+DPADD+=${LIBBLACKLIST}
+LDADD+=-lblocklist
+DPADD+=${LIBBLOCKLIST}
.include <bsd.prog.mk>
Index: dist/bin/named/client.c
===================================================================
+98
View File
@@ -0,0 +1,98 @@
Index: dist/src/smtpd/pfilter.c
===================================================================
RCS file: dist/src/smtpd/pfilter.c
diff -N dist/src/smtpd/pfilter.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ dist/src/smtpd/pfilter.c 1 Feb 2018 03:29:09 -0000
@@ -0,0 +1,19 @@
+#include "pfilter.h"
+#include <stdio.h> /* for NULL */
+#include <blocklist.h>
+
+static struct blocklist *blstate;
+
+void
+pfilter_notify(int a, int fd)
+{
+ if (blstate == NULL)
+ blstate = blocklist_open();
+ if (blstate == NULL)
+ return;
+ (void)blocklist_r(blstate, a, fd, "smtpd");
+ if (a == 0) {
+ blocklist_close(blstate);
+ blstate = NULL;
+ }
+}
Index: dist/src/smtpd/pfilter.h
===================================================================
RCS file: dist/src/smtpd/pfilter.h
diff -N dist/src/smtpd/pfilter.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ dist/src/smtpd/pfilter.h 1 Feb 2018 03:29:09 -0000
@@ -0,0 +1,2 @@
+
+void pfilter_notify(int, int);
Index: dist/src/smtpd/smtpd.c
===================================================================
RCS file: /cvsroot/src/external/ibm-public/postfix/dist/src/smtpd/smtpd.c,v
retrieving revision 1.14
diff -u -r1.14 smtpd.c
--- dist/src/smtpd/smtpd.c 14 Feb 2017 01:16:48 -0000 1.14
+++ dist/src/smtpd/smtpd.c 1 Feb 2018 03:29:09 -0000
@@ -1197,6 +1197,8 @@
#include <smtpd_milter.h>
#include <smtpd_expand.h>
+#include "pfilter.h"
+
/*
* Tunable parameters. Make sure that there is some bound on the length of
* an SMTP command, so that the mail system stays in control even when a
@@ -5048,6 +5050,7 @@
if (state->error_count >= var_smtpd_hard_erlim) {
state->reason = REASON_ERROR_LIMIT;
state->error_mask |= MAIL_ERROR_PROTOCOL;
+ pfilter_notify(1, vstream_fileno(state->client));
smtpd_chat_reply(state, "421 4.7.0 %s Error: too many errors",
var_myhostname);
break;
Index: libexec/smtpd/Makefile
===================================================================
RCS file: /cvsroot/src/external/ibm-public/postfix/libexec/smtpd/Makefile,v
retrieving revision 1.6
diff -u -r1.6 Makefile
--- libexec/smtpd/Makefile 21 May 2017 15:28:40 -0000 1.6
+++ libexec/smtpd/Makefile 1 Feb 2018 03:29:09 -0000
@@ -13,11 +13,14 @@
SRCS= smtpd.c smtpd_token.c smtpd_check.c smtpd_chat.c smtpd_state.c \
smtpd_peer.c smtpd_sasl_proto.c smtpd_sasl_glue.c smtpd_proxy.c \
smtpd_xforward.c smtpd_dsn_fix.c smtpd_milter.c smtpd_resolve.c \
- smtpd_expand.c smtpd_haproxy.c
+ smtpd_expand.c smtpd_haproxy.c pfilter.c
DPADD+= ${LIBPMASTER} ${LIBPMILTER} ${LIBPGLOBAL} ${LIBPDNS} ${LIBPXSASL}
LDADD+= ${LIBPMASTER} ${LIBPMILTER} ${LIBPGLOBAL} ${LIBPDNS} ${LIBPXSASL}
+DPADD+= ${LIBBLOCKLIST}
+LDADD+= -lblocklist
+
DPADD+= ${LIBPTLS} ${LIBSSL} ${LIBCRYPTO}
LDADD+= ${LIBPTLS} -lssl -lcrypto
Index: dist/src/smtpd/smtpd.c
===================================================================
RCS file: /cvsroot/src/external/ibm-public/postfix/dist/src/smtpd/smtpd.c,v
retrieving revision 1.17
diff -u -u -r1.17 smtpd.c
--- dist/src/smtpd/smtpd.c 18 Mar 2020 19:05:20 -0000 1.17
+++ dist/src/smtpd/smtpd.c 25 Sep 2020 12:51:52 -0000
@@ -5795,6 +5795,8 @@
|| strcmp(state->reason, REASON_LOST_CONNECTION)) {
msg_info("%s after %s from %s",
state->reason, state->where, state->namaddr);
+ if (strcmp(state->where, SMTPD_CMD_AUTH) == 0)
+ pfilter_notify(1, vstream_fileno(state->client));
}
}
+10 -10
View File
@@ -1,12 +1,12 @@
--- Make.rules.in.orig 2015-05-27 20:25:54.000000000 -0400
+++ Make.rules.in 2016-01-25 21:48:47.000000000 -0500
@@ -110,3 +110,8 @@
FTPWHO_OBJS=ftpwho.o scoreboard.o misc.o
BUILD_FTPWHO_OBJS=utils/ftpwho.o utils/scoreboard.o utils/misc.o
+
+CPPFLAGS+=-DHAVE_BLACKLIST
+LIBS+=-lblacklist
+CPPFLAGS+=-DHAVE_BLOCKLIST
+LIBS+=-lblocklist
+OBJS+= pfilter.o
+BUILD_OBJS+= src/pfilter.o
--- /dev/null 2016-01-22 17:30:55.000000000 -0500
@@ -84,25 +84,25 @@
+#include "pfilter.h"
+#include "conf.h"
+#include "privs.h"
+#ifdef HAVE_BLACKLIST
+#include <blacklist.h>
+#ifdef HAVE_BLOCKLIST
+#include <blocklist.h>
+#endif
+
+static struct blacklist *blstate;
+static struct blocklist *blstate;
+
+void
+pfilter_init(void)
+{
+#ifdef HAVE_BLACKLIST
+#ifdef HAVE_BLOCKLIST
+ if (blstate == NULL)
+ blstate = blacklist_open();
+ blstate = blocklist_open();
+#endif
+}
+
+void
+pfilter_notify(int a)
+{
+#ifdef HAVE_BLACKLIST
+#ifdef HAVE_BLOCKLIST
+ conn_t *c = session.c;
+ int fd;
+
@@ -119,6 +119,6 @@
+ pfilter_init();
+ if (blstate == NULL)
+ return;
+ (void)blacklist_r(blstate, a, fd, "proftpd");
+ (void)blocklist_r(blstate, a, fd, "proftpd");
+#endif
+}
+7 -7
View File
@@ -7,14 +7,14 @@
+#include "packet.h"
+#include "log.h"
+#include "pfilter.h"
+#include <blacklist.h>
+#include <blocklist.h>
+
+static struct blacklist *blstate;
+static struct blocklist *blstate;
+
+void
+pfilter_init(void)
+{
+ blstate = blacklist_open();
+ blstate = blocklist_open();
+}
+
+void
@@ -27,9 +27,9 @@
+ return;
+ // XXX: 3?
+ fd = packet_connection_is_on_socket() ? packet_get_connection_in() : 3;
+ (void)blacklist_r(blstate, a, fd, "ssh");
+ (void)blocklist_r(blstate, a, fd, "ssh");
+ if (a == 0) {
+ blacklist_close(blstate);
+ blocklist_close(blstate);
+ blstate = NULL;
+ }
+}
@@ -60,8 +60,8 @@ diff -u -u -r1.10 Makefile
LDADD+= -lwrap
DPADD+= ${LIBWRAP}
+
+LDADD+= -lblacklist
+DPADD+= ${LIBBLACKLIST}
+LDADD+= -lblocklist
+DPADD+= ${LIBBLOCKLIST}
diff -ru openssh-7.7p1/auth-pam.c dist/auth-pam.c
--- openssh-7.7p1/auth-pam.c 2018-04-02 01:38:28.000000000 -0400
+++ dist/auth-pam.c 2018-05-23 11:56:22.206661484 -0400
+5 -5
View File
@@ -1,10 +1,10 @@
# $NetBSD: Makefile,v 1.3 2015/01/26 00:18:40 christos Exp $
# $NetBSD: Makefile,v 1.2 2025/02/05 20:24:26 christos Exp $
SUBDIR=rc.d
SUBDIR= rc.d
FILESDIR= /usr/share/examples/blacklist
FILESMODE= 644
FILES= blacklistd.conf npf.conf
FILESDIR= /usr/share/examples/blocklist
FILESMODE= 644
FILES= blocklistd.conf ipf.conf npf.conf
.include <bsd.files.mk>
.include <bsd.subdir.mk>
@@ -1,5 +1,5 @@
# Blacklist rule
# adr/mask:port type proto owner name nfail disable
# Blocklist rule
# adr/mask:port type proto owner name nfail duration
[local]
ssh stream * * * 3 6h
ftp stream * * * 3 6h
@@ -7,8 +7,9 @@ domain * * named * 3 12h
#6161 stream tcp6 christos * 2 10m
* * * * * 3 60
# adr/mask:port type proto owner name nfail disable
# adr/mask:port type proto owner name nfail duration
[remote]
#129.168.0.0/16 * * * = * *
#[2001:db8::]/32:ssh * * * = * *
#6161 = = = =/24 = =
#* stream tcp * = = =
+45
View File
@@ -0,0 +1,45 @@
#========================================
#
# subsection for abuse blocking
#
#========================================
#
# This section should be included early in the main /etc/ipf.conf file, right
# after any basic generic accounting ("count") rules, and any cleanup rules to
# block invalid fragments, invalid options (e.g. "ssrr"), etc.
#
# Note these will not actually block anything since they don't include the
# "quick" flag, and are thus part of a last-match group. They simply set up a
# group such that any connection logging rule further below won't also match if
# one of the rules in the group matches, no matter when or where the subsequent
# matching rule is added. I.e. all rules in the group are checked for a match
# (and a possible "first match" with "quick") before any subsequent rules
# further below are used. Note group rules can be added at any time, including
# at runtime after all other rules have been added -- they will still belong to
# the group and once added will be checked as part of the group.
#
# head of "blocklistd" group:
#
# The "blocklistd" group will be used by blocklistd(8).
#
block in proto tcp/udp from any to any head blocklistd
#
# head of "attackers" group to block all attackers:
#
# The "attackers" group is intended to be used for manually maintained rules
# e.g. as could be added like this:
#
# echo 'block return-rst in log quick proto tcp from 118.136.0.0/15 to any flags S/SAFR group attackers' >> /etc/ipf.conf
# /etc/rc.d/ipfliter reload
#
# Note the choice in this example is to return RST packets for blocked SYN
# packets to help the other end close. This is not necessary, but it better
# mimics what the kernel does by default, thus perhaps hiding the fact a
# firewall is present.
#
# XXX This example still allows UDP services, but we would need to duplicate
# each rule with "proto udp" (and without "flags blah") due to IPF parsing
# limitations....
#
block in proto tcp/udp from any to any head attackers
#
+2 -2
View File
@@ -1,4 +1,4 @@
# Transparent firewall example for blacklistd
# Transparent firewall example for blocklistd
$ext_if = "bnx0"
@@ -6,7 +6,7 @@ set bpf.jit on;
alg "icmp"
group "external" on $ext_if {
ruleset "blacklistd"
ruleset "blocklistd"
pass final all
}
+2 -2
View File
@@ -1,6 +1,6 @@
# $NetBSD: Makefile,v 1.1 2015/01/22 17:49:41 christos Exp $
# $NetBSD: Makefile,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $
SCRIPTS=blacklistd
SCRIPTS=blocklistd
SCRIPTSDIR=/etc/rc.d
.include <bsd.prog.mk>
@@ -1,15 +1,15 @@
#!/bin/sh
#
# $NetBSD: blacklistd,v 1.2 2016/10/17 22:47:16 christos Exp $
# $NetBSD: blocklistd,v 1.2 2021/03/07 00:46:39 christos Exp $
#
# PROVIDE: blacklistd
# REQUIRE: npf
# PROVIDE: blocklistd
# REQUIRE: npf pf ipfilter
# BEFORE: SERVERS
$_rc_subr_loaded . /etc/rc.subr
name="blacklistd"
name="blocklistd"
rcvar=$name
command="/sbin/${name}"
pidfile="/var/run/${name}.pid"
@@ -18,17 +18,17 @@ start_precmd="${name}_precmd"
extra_commands="reload"
_sockfile="/var/run/${name}.sockets"
_sockname="blacklistd.sock"
_sockname="blocklistd.sock"
blacklistd_precmd()
blocklistd_precmd()
{
# Create default list of blacklistd sockets to watch
# Create default list of blocklistd sockets to watch
#
( umask 022 ; > $_sockfile )
# Find /etc/rc.d scripts with "chrootdir" rcorder(8) keyword,
# and if $${app}_chrootdir is a directory, add appropriate
# blacklistd socket to list of sockets to watch.
# blocklistd socket to list of sockets to watch.
#
for _lr in $(rcorder -k chrootdir /etc/rc.d/*); do
(
@@ -42,8 +42,8 @@ blacklistd_precmd()
done
# If other sockets have been provided, change run_rc_command()'s
# internal copy of $blacklistd_flags to force use of specific
# blacklistd sockets.
# internal copy of $blocklistd_flags to force use of specific
# blocklistd sockets.
#
if [ -s $_sockfile ]; then
echo "/var/run/${_sockname}" >> $_sockfile
+2 -2
View File
@@ -1,10 +1,10 @@
# $NetBSD: Makefile,v 1.1 2015/01/21 16:16:00 christos Exp $
# $NetBSD: Makefile,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $
# Doing a make includes builds /usr/include
NOOBJ= # defined
INCS= blacklist.h
INCS= blocklist.h
INCSDIR= /usr/include
.include <bsd.prog.mk>
+6 -5
View File
@@ -1,4 +1,4 @@
/* $NetBSD: bl.h,v 1.13 2016/03/11 17:16:40 christos Exp $ */
/* $NetBSD: bl.h,v 1.2 2024/08/02 17:11:55 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <stdarg.h>
#include <sys/param.h>
#include <sys/socket.h>
#include "blacklist.h"
#include "blocklist.h"
typedef enum {
BL_INVALID,
@@ -58,14 +58,15 @@ typedef struct {
#define bi_cred bi_u._bi_cred
#ifndef _PATH_BLSOCK
#define _PATH_BLSOCK "/var/run/blacklistd.sock"
#define _PATH_BLSOCK "/var/run/blocklistd.sock"
#endif
__BEGIN_DECLS
typedef struct blacklist *bl_t;
typedef struct blocklist *bl_t;
bl_t bl_create(bool, const char *, void (*)(int, const char *, va_list));
bl_t bl_create(bool, const char *,
void (*)(int, struct syslog_data *, const char *, va_list));
void bl_destroy(bl_t);
int bl_send(bl_t, bl_type_t, int, const struct sockaddr *, socklen_t,
const char *);
+13 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: blacklist.h,v 1.3 2015/01/23 18:48:56 christos Exp $ */
/* $NetBSD: blocklist.h,v 1.4 2025/02/11 17:42:17 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,16 +32,26 @@
#define _BLACKLIST_H
#include <sys/socket.h>
#include <syslog.h>
__BEGIN_DECLS
#if defined(__cplusplus)
extern "C" {
#endif
struct syslog_data;
struct blacklist *blacklist_open(void);
struct blacklist *blacklist_open2(
void (*)(int, struct syslog_data *, const char *, va_list));
void blacklist_close(struct blacklist *);
int blacklist(int, int, const char *);
int blacklist_r(struct blacklist *, int, int, const char *);
int blacklist_sa(int, int, const struct sockaddr *, socklen_t, const char *);
int blacklist_sa_r(struct blacklist *, int, int,
const struct sockaddr *, socklen_t, const char *);
__END_DECLS
#if defined(__cplusplus)
}
#endif
/* action values for user applications */
#define BLACKLIST_API_ENUM 1
+65
View File
@@ -0,0 +1,65 @@
/* $NetBSD: blocklist.h,v 1.4 2025/02/11 17:42:17 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _BLOCKLIST_H
#define _BLOCKLIST_H
#include <sys/socket.h>
#include <syslog.h>
#if defined(__cplusplus)
extern "C" {
#endif
struct syslog_data;
struct blocklist *blocklist_open(void);
struct blocklist *blocklist_open2(
void (*)(int, struct syslog_data *, const char *, va_list));
void blocklist_close(struct blocklist *);
int blocklist(int, int, const char *);
int blocklist_r(struct blocklist *, int, int, const char *);
int blocklist_sa(int, int, const struct sockaddr *, socklen_t, const char *);
int blocklist_sa_r(struct blocklist *, int, int,
const struct sockaddr *, socklen_t, const char *);
#if defined(__cplusplus)
}
#endif
/* action values for user applications */
#define BLOCKLIST_API_ENUM 1
enum {
BLOCKLIST_AUTH_OK = 0,
BLOCKLIST_AUTH_FAIL,
BLOCKLIST_ABUSIVE_BEHAVIOR,
BLOCKLIST_BAD_USER
};
#endif /* _BLOCKLIST_H */
+80
View File
@@ -0,0 +1,80 @@
/* $NetBSD: bl.h,v 1.2 2024/08/02 17:11:55 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _OLD_BL_H
#define _OLD_BL_H
#include <stdbool.h>
#include <stdarg.h>
#include <sys/param.h>
#include <sys/socket.h>
#include "blacklist.h"
typedef enum {
BL_INVALID,
BL_ADD,
BL_DELETE,
BL_ABUSE,
BL_BADUSER
} bl_type_t;
typedef struct {
bl_type_t bi_type;
int bi_fd;
uid_t bi_uid;
gid_t bi_gid;
socklen_t bi_slen;
struct sockaddr_storage bi_ss;
char bi_msg[1024];
} bl_info_t;
#define bi_cred bi_u._bi_cred
/* We want the new name */
#ifndef _PATH_BLSOCK
#define _PATH_BLSOCK "/var/run/blocklistd.sock"
#endif
__BEGIN_DECLS
typedef struct blacklist *bl_t;
bl_t bl_create(bool, const char *,
void (*)(int, struct syslog_data *, const char *, va_list));
void bl_destroy(bl_t);
int bl_send(bl_t, bl_type_t, int, const struct sockaddr *, socklen_t,
const char *);
int bl_getfd(bl_t);
bl_info_t *bl_recv(bl_t);
bool bl_isconnected(bl_t);
__END_DECLS
#endif /* _OLD_BL_H */
+10 -10
View File
@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.7 2019/03/08 20:40:05 christos Exp $
# $NetBSD: Makefile,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $
.include <bsd.own.mk>
@@ -6,14 +6,14 @@ USE_SHLIBDIR= yes
CPPFLAGS+=-D_REENTRANT
#LIBDPLIBS+=pthread ${NETBSDSRCDIR}/lib/libpthread
LIB=blacklist
SRCS=bl.c blacklist.c
MAN=libblacklist.3
MLINKS+=libblacklist.3 blacklist_open.3
MLINKS+=libblacklist.3 blacklist_close.3
MLINKS+=libblacklist.3 blacklist.3
MLINKS+=libblacklist.3 blacklist_r.3
MLINKS+=libblacklist.3 blacklist_sa.3
MLINKS+=libblacklist.3 blacklist_sa_r.3
LIB=blocklist
SRCS=bl.c blocklist.c
MAN=libblocklist.3
MLINKS+=libblocklist.3 blocklist_open.3
MLINKS+=libblocklist.3 blocklist_close.3
MLINKS+=libblocklist.3 blocklist.3
MLINKS+=libblocklist.3 blocklist_r.3
MLINKS+=libblocklist.3 blocklist_sa.3
MLINKS+=libblocklist.3 blocklist_sa_r.3
.include <bsd.lib.mk>
+67 -45
View File
@@ -1,4 +1,4 @@
/* $NetBSD: bl.c,v 1.28 2016/07/29 17:13:09 christos Exp $ */
/* $NetBSD: bl.c,v 1.9 2025/03/30 01:53:59 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
__RCSID("$NetBSD: bl.c,v 1.28 2016/07/29 17:13:09 christos Exp $");
#endif
__RCSID("$NetBSD: bl.c,v 1.9 2025/03/30 01:53:59 christos Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -57,6 +59,10 @@ __RCSID("$NetBSD: bl.c,v 1.28 2016/07/29 17:13:09 christos Exp $");
#include <pthread.h>
#endif
#if defined(SO_RECVUCRED)
#include <ucred.h>
#endif
#include "bl.h"
typedef struct {
@@ -68,7 +74,7 @@ typedef struct {
char bl_data[];
} bl_message_t;
struct blacklist {
struct blocklist {
#ifdef _REENTRANT
pthread_mutex_t b_mutex;
# define BL_INIT(b) pthread_mutex_init(&b->b_mutex, NULL)
@@ -82,7 +88,8 @@ struct blacklist {
int b_fd;
int b_connected;
struct sockaddr_un b_sun;
void (*b_fun)(int, const char *, va_list);
struct syslog_data b_syslog_data;
void (*b_fun)(int, struct syslog_data *, const char *, va_list);
bl_info_t b_info;
};
@@ -115,14 +122,16 @@ bl_reset(bl_t b, bool locked)
}
static void
bl_log(void (*fun)(int, const char *, va_list), int level,
const char *fmt, ...)
bl_log(bl_t b, int level, const char *fmt, ...)
{
va_list ap;
int serrno = errno;
if (b->b_fun == NULL)
return;
va_start(ap, fmt);
(*fun)(level, fmt, ap);
(*b->b_fun)(level, &b->b_syslog_data, fmt, ap);
va_end(ap);
errno = serrno;
}
@@ -152,7 +161,7 @@ bl_init(bl_t b, bool srv)
b->b_fd = socket(PF_LOCAL,
SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK|SOCK_NOSIGPIPE, 0);
if (b->b_fd == -1) {
bl_log(b->b_fun, LOG_ERR, "%s: socket failed (%s)",
bl_log(b, LOG_ERR, "%s: socket failed (%s)",
__func__, strerror(errno));
BL_UNLOCK(b);
return -1;
@@ -186,7 +195,7 @@ bl_init(bl_t b, bool srv)
rv = connect(b->b_fd, (const void *)sun, (socklen_t)sizeof(*sun));
if (rv == 0) {
if (srv) {
bl_log(b->b_fun, LOG_ERR,
bl_log(b, LOG_ERR,
"%s: another daemon is handling `%s'",
__func__, sun->sun_path);
goto out;
@@ -199,7 +208,7 @@ bl_init(bl_t b, bool srv)
* and only log once.
*/
if (b->b_connected != 1) {
bl_log(b->b_fun, LOG_DEBUG,
bl_log(b, LOG_DEBUG,
"%s: connect failed for `%s' (%s)",
__func__, sun->sun_path, strerror(errno));
b->b_connected = 1;
@@ -207,8 +216,7 @@ bl_init(bl_t b, bool srv)
BL_UNLOCK(b);
return -1;
}
bl_log(b->b_fun, LOG_DEBUG, "Connected to blacklist server",
__func__);
bl_log(b, LOG_DEBUG, "Connected to blocklist server", __func__);
}
if (srv) {
@@ -219,8 +227,7 @@ bl_init(bl_t b, bool srv)
(void)umask(om);
errno = serrno;
if (rv == -1) {
bl_log(b->b_fun, LOG_ERR,
"%s: bind failed for `%s' (%s)",
bl_log(b, LOG_ERR, "%s: bind failed for `%s' (%s)",
__func__, sun->sun_path, strerror(errno));
goto out;
}
@@ -231,8 +238,8 @@ bl_init(bl_t b, bool srv)
#if defined(LOCAL_CREDS)
#define CRED_LEVEL 0
#define CRED_NAME LOCAL_CREDS
#define CRED_SC_UID sc_euid
#define CRED_SC_GID sc_egid
#define CRED_SC_UID(x) (x)->sc_euid
#define CRED_SC_GID(x) (x)->sc_egid
#define CRED_MESSAGE SCM_CREDS
#define CRED_SIZE SOCKCREDSIZE(NGROUPS_MAX)
#define CRED_TYPE struct sockcred
@@ -240,12 +247,21 @@ bl_init(bl_t b, bool srv)
#elif defined(SO_PASSCRED)
#define CRED_LEVEL SOL_SOCKET
#define CRED_NAME SO_PASSCRED
#define CRED_SC_UID uid
#define CRED_SC_GID gid
#define CRED_SC_UID(x) (x)->uid
#define CRED_SC_GID(x) (x)->gid
#define CRED_MESSAGE SCM_CREDENTIALS
#define CRED_SIZE sizeof(struct ucred)
#define CRED_TYPE struct ucred
#define GOT_CRED 2
#elif defined(SO_RECVUCRED)
#define CRED_LEVEL SOL_SOCKET
#define CRED_NAME SO_RECVUCRED
#define CRED_SC_UID(x) ucred_geteuid(x)
#define CRED_SC_GID(x) ucred_getegid(x)
#define CRED_MESSAGE SCM_UCRED
#define CRED_SIZE ucred_size()
#define CRED_TYPE ucred_t
#define GOT_CRED 2
#else
#define GOT_CRED 0
/*
@@ -259,7 +275,7 @@ bl_init(bl_t b, bool srv)
#ifdef CRED_LEVEL
if (setsockopt(b->b_fd, CRED_LEVEL, CRED_NAME,
&one, (socklen_t)sizeof(one)) == -1) {
bl_log(b->b_fun, LOG_ERR, "%s: setsockopt %s "
bl_log(b, LOG_ERR, "%s: setsockopt %s "
"failed (%s)", __func__, __STRING(CRED_NAME),
strerror(errno));
goto out;
@@ -275,12 +291,15 @@ out:
}
bl_t
bl_create(bool srv, const char *path, void (*fun)(int, const char *, va_list))
bl_create(bool srv, const char *path,
void (*fun)(int, struct syslog_data *, const char *, va_list))
{
static struct syslog_data sd = SYSLOG_DATA_INIT;
bl_t b = calloc(1, sizeof(*b));
if (b == NULL)
goto out;
b->b_fun = fun == NULL ? vsyslog : fun;
return NULL;
b->b_fun = fun;
b->b_syslog_data = sd;
b->b_fd = -1;
b->b_connected = -1;
BL_INIT(b);
@@ -295,11 +314,6 @@ bl_create(bool srv, const char *path, void (*fun)(int, const char *, va_list))
bl_init(b, srv);
return b;
out:
free(b);
bl_log(fun, LOG_ERR, "%s: malloc failed (%s)", __func__,
strerror(errno));
return NULL;
}
void
@@ -327,7 +341,7 @@ bl_getsock(bl_t b, struct sockaddr_storage *ss, const struct sockaddr *sa,
family = AF_INET6;
break;
default:
bl_log(b->b_fun, LOG_ERR, "%s: invalid socket len %u (%s)",
bl_log(b, LOG_ERR, "%s: invalid socket len %u (%s)",
__func__, (unsigned)slen, ctx);
errno = EINVAL;
return -1;
@@ -336,7 +350,7 @@ bl_getsock(bl_t b, struct sockaddr_storage *ss, const struct sockaddr *sa,
memcpy(ss, sa, slen);
if (ss->ss_family != family) {
bl_log(b->b_fun, LOG_INFO,
bl_log(b, LOG_INFO,
"%s: correcting socket family %d to %d (%s)",
__func__, ss->ss_family, family, ctx);
ss->ss_family = family;
@@ -344,7 +358,7 @@ bl_getsock(bl_t b, struct sockaddr_storage *ss, const struct sockaddr *sa,
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
if (ss->ss_len != slen) {
bl_log(b->b_fun, LOG_INFO,
bl_log(b, LOG_INFO,
"%s: correcting socket len %u to %u (%s)",
__func__, ss->ss_len, (unsigned)slen, ctx);
ss->ss_len = (uint8_t)slen;
@@ -424,10 +438,11 @@ bl_recv(bl_t b)
union {
char ctrl[CMSG_SPACE(sizeof(int)) + CMSG_SPACE(CRED_SIZE)];
uint32_t fd;
CRED_TYPE sc;
} ua;
struct cmsghdr *cmsg;
#if GOT_CRED != 0
CRED_TYPE *sc;
#endif
union {
bl_message_t bl;
char buf[512];
@@ -450,18 +465,18 @@ bl_recv(bl_t b)
msg.msg_flags = 0;
msg.msg_control = ua.ctrl;
msg.msg_controllen = sizeof(ua.ctrl) + 100;
msg.msg_controllen = sizeof(ua.ctrl);
rlen = recvmsg(b->b_fd, &msg, 0);
if (rlen == -1) {
bl_log(b->b_fun, LOG_ERR, "%s: recvmsg failed (%s)", __func__,
bl_log(b, LOG_ERR, "%s: recvmsg failed (%s)", __func__,
strerror(errno));
return NULL;
}
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
if (cmsg->cmsg_level != SOL_SOCKET) {
bl_log(b->b_fun, LOG_ERR,
bl_log(b, LOG_ERR,
"%s: unexpected cmsg_level %d",
__func__, cmsg->cmsg_level);
continue;
@@ -469,10 +484,15 @@ bl_recv(bl_t b)
switch (cmsg->cmsg_type) {
case SCM_RIGHTS:
if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) {
bl_log(b->b_fun, LOG_ERR,
int *fd = (void *)CMSG_DATA(cmsg);
size_t len = cmsg->cmsg_len / sizeof(int);
bl_log(b, LOG_ERR,
"%s: unexpected cmsg_len %d != %zu",
__func__, cmsg->cmsg_len,
CMSG_LEN(2 * sizeof(int)));
CMSG_LEN(sizeof(int)));
for (size_t i = 0; i < len; i++)
(void)close(fd[i]);
continue;
}
memcpy(&bi->bi_fd, CMSG_DATA(cmsg), sizeof(bi->bi_fd));
@@ -481,13 +501,13 @@ bl_recv(bl_t b)
#ifdef CRED_MESSAGE
case CRED_MESSAGE:
sc = (void *)CMSG_DATA(cmsg);
bi->bi_uid = sc->CRED_SC_UID;
bi->bi_gid = sc->CRED_SC_GID;
bi->bi_uid = CRED_SC_UID(sc);
bi->bi_gid = CRED_SC_GID(sc);
got |= GOT_CRED;
break;
#endif
default:
bl_log(b->b_fun, LOG_ERR,
bl_log(b, LOG_ERR,
"%s: unexpected cmsg_type %d",
__func__, cmsg->cmsg_type);
continue;
@@ -496,7 +516,7 @@ bl_recv(bl_t b)
}
if (got != (GOT_CRED|GOT_FD)) {
bl_log(b->b_fun, LOG_ERR, "message missing %s %s",
bl_log(b, LOG_ERR, "message missing %s %s",
#if GOT_CRED != 0
(got & GOT_CRED) == 0 ? "cred" :
#endif
@@ -506,13 +526,13 @@ bl_recv(bl_t b)
rem = (size_t)rlen;
if (rem < sizeof(ub.bl)) {
bl_log(b->b_fun, LOG_ERR, "message too short %zd", rlen);
bl_log(b, LOG_ERR, "message too short %zd", rlen);
return NULL;
}
rem -= sizeof(ub.bl);
if (ub.bl.bl_version != BL_VERSION) {
bl_log(b->b_fun, LOG_ERR, "bad version %d", ub.bl.bl_version);
bl_log(b, LOG_ERR, "bad version %d", ub.bl.bl_version);
return NULL;
}
@@ -523,10 +543,12 @@ bl_recv(bl_t b)
bi->bi_uid = -1;
bi->bi_gid = -1;
#endif
rem = MIN(sizeof(bi->bi_msg), rem);
if (rem == 0)
bi->bi_msg[0] = '\0';
else
strlcpy(bi->bi_msg, ub.bl.bl_data, rem);
else {
rem = MIN(sizeof(bi->bi_msg) - 1, rem);
memcpy(bi->bi_msg, ub.bl.bl_data, rem);
bi->bi_msg[rem] = '\0';
}
return bi;
}
+13 -4
View File
@@ -1,4 +1,4 @@
/* $NetBSD: blacklist.c,v 1.5 2015/01/22 16:19:53 christos Exp $ */
/* $NetBSD: blocklist.c,v 1.4 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,11 +32,13 @@
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
__RCSID("$NetBSD: blacklist.c,v 1.5 2015/01/22 16:19:53 christos Exp $");
#endif
__RCSID("$NetBSD: blocklist.c,v 1.4 2025/02/11 17:48:30 christos Exp $");
#include <stdio.h>
#include <bl.h>
#include <old_bl.h>
#include <stdarg.h>
#include <errno.h>
@@ -98,7 +100,14 @@ blacklist_r(struct blacklist *bl, int action, int rfd, const char *msg)
struct blacklist *
blacklist_open(void) {
return bl_create(false, NULL, vsyslog);
return bl_create(false, NULL, vsyslog_r);
}
struct blacklist *
blacklist_open2(
void (*logger)(int, struct syslog_data *, const char *, va_list))
{
return bl_create(false, NULL, logger);
}
void
+117
View File
@@ -0,0 +1,117 @@
/* $NetBSD: blocklist.c,v 1.4 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
__RCSID("$NetBSD: blocklist.c,v 1.4 2025/02/11 17:48:30 christos Exp $");
#include <stdio.h>
#include <bl.h>
#include <stdarg.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <syslog.h>
int
blocklist_sa(int action, int rfd, const struct sockaddr *sa, socklen_t salen,
const char *msg)
{
struct blocklist *bl;
int rv;
if ((bl = blocklist_open()) == NULL)
return -1;
rv = blocklist_sa_r(bl, action, rfd, sa, salen, msg);
blocklist_close(bl);
return rv;
}
int
blocklist_sa_r(struct blocklist *bl, int action, int rfd,
const struct sockaddr *sa, socklen_t slen, const char *msg)
{
bl_type_t internal_action;
/* internal values are not the same as user application values */
switch (action) {
case BLOCKLIST_AUTH_FAIL:
internal_action = BL_ADD;
break;
case BLOCKLIST_AUTH_OK:
internal_action = BL_DELETE;
break;
case BLOCKLIST_ABUSIVE_BEHAVIOR:
internal_action = BL_ABUSE;
break;
case BLOCKLIST_BAD_USER:
internal_action = BL_BADUSER;
break;
default:
internal_action = BL_INVALID;
break;
}
return bl_send(bl, internal_action, rfd, sa, slen, msg);
}
int
blocklist(int action, int rfd, const char *msg)
{
return blocklist_sa(action, rfd, NULL, 0, msg);
}
int
blocklist_r(struct blocklist *bl, int action, int rfd, const char *msg)
{
return blocklist_sa_r(bl, action, rfd, NULL, 0, msg);
}
struct blocklist *
blocklist_open(void) {
return bl_create(false, NULL, vsyslog_r);
}
struct blocklist *
blocklist_open2(
void (*logger)(int, struct syslog_data *, const char *, va_list))
{
return bl_create(false, NULL, logger);
}
void
blocklist_close(struct blocklist *bl)
{
bl_destroy(bl);
}
+29 -8
View File
@@ -1,4 +1,4 @@
.\" $NetBSD: libblacklist.3,v 1.10 2020/03/30 15:47:15 christos Exp $
.\" $NetBSD: libblocklist.3,v 1.7 2025/02/05 20:14:30 christos Exp $
.\"
.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,11 +27,12 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd March 30, 2020
.Dd February 5, 2025
.Dt LIBBLACKLIST 3
.Os
.Sh NAME
.Nm blacklist_open ,
.Nm blacklist_open2 ,
.Nm blacklist_close ,
.Nm blacklist_r ,
.Nm blacklist ,
@@ -44,6 +45,8 @@
.In blacklist.h
.Ft struct blacklist *
.Fn blacklist_open "void"
.Ft struct blacklist *
.Fn blacklist_open2 "void (*logger)(int, struct syslog_data *, va_list)"
.Ft void
.Fn blacklist_close "struct blacklist *cookie"
.Ft int
@@ -68,6 +71,19 @@ and returns a pointer to it, or
.Dv NULL
on failure.
.Pp
The function
.Fn blacklist_open2
is similar to
.Fn blacklist_open
but allows a
.Fa logger
to be specified.
If the
.Fa logger
is
.Dv NULL ,
then no logging is performed.
.Pp
The
.Fn blacklist_close
function frees all memory and resources used.
@@ -89,17 +105,17 @@ argument.
The
.Ar action
parameter can take these values:
.Bl -tag -width ".Va BLACKLIST_ABUSIVE_BEHAVIOR"
.It Va BLACKLIST_AUTH_FAIL
.Bl -tag -width ".Dv BLACKLIST_ABUSIVE_BEHAVIOR"
.It Dv BLACKLIST_AUTH_FAIL
There was an unsuccessful authentication attempt.
.It Va BLACKLIST_AUTH_OK
.It Dv BLACKLIST_AUTH_OK
A user successfully authenticated.
.It Va BLACKLIST_ABUSIVE_BEHAVIOR
.It Dv BLACKLIST_ABUSIVE_BEHAVIOR
The sending daemon has detected abusive behavior
from the remote system.
The remote address should
be blocked as soon as possible.
.It Va BLACKLIST_BAD_USER
.It Dv BLACKLIST_BAD_USER
The sending daemon has determined the username
presented for authentication is invalid.
The
@@ -108,7 +124,7 @@ daemon compares the username to a configured list of forbidden
usernames and
blocks the address immediately if a forbidden username matches.
(The
.Ar BLACKLIST_BAD_USER
.Dv BLACKLIST_BAD_USER
support is not currently available.)
.El
.Pp
@@ -160,6 +176,11 @@ on success and
on failure setting
.Dv errno
to an appropriate value.
.Sh NOTES
The
.Lb libblacklist
has been renamed to
.Xr libblocklist 3 .
.Sh SEE ALSO
.Xr blacklistd.conf 5 ,
.Xr blacklistd 8
+183
View File
@@ -0,0 +1,183 @@
.\" $NetBSD: libblocklist.3,v 1.7 2025/02/05 20:14:30 christos Exp $
.\"
.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Christos Zoulas.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd February 5, 2025
.Dt LIBBLOCKLIST 3
.Os
.Sh NAME
.Nm blocklist_open ,
.Nm blocklist_open2 ,
.Nm blocklist_close ,
.Nm blocklist_r ,
.Nm blocklist ,
.Nm blocklist_sa ,
.Nm blocklist_sa_r
.Nd Blocklistd notification library
.Sh LIBRARY
.Lb libblocklist
.Sh SYNOPSIS
.In blocklist.h
.Ft struct blocklist *
.Fn blocklist_open "void"
.Ft struct blocklist *
.Fn blocklist_open2 "void (*logger)(int, struct syslog_data *, va_list)"
.Ft void
.Fn blocklist_close "struct blocklist *cookie"
.Ft int
.Fn blocklist "int action" "int fd" "const char *msg"
.Ft int
.Fn blocklist_r "struct blocklist *cookie" "int action" "int fd" "const char *msg"
.Ft int
.Fn blocklist_sa "int action" "int fd" "const struct sockaddr *sa" "socklen_t salen" "const char *msg"
.Ft int
.Fn blocklist_sa_r "struct blocklist *cookie" "int action" "int fd" "const struct sockaddr *sa" "socklen_t salen" "const char *msg"
.Sh DESCRIPTION
These functions can be used by daemons to notify
.Xr blocklistd 8
about successful and failed remote connections so that blocklistd can
block or release port access to prevent Denial of Service attacks.
.Pp
The function
.Fn blocklist_open
creates the necessary state to communicate with
.Xr blocklistd 8
and returns a pointer to it, or
.Dv NULL
on failure.
.Pp
The function
.Fn blocklist_open2
is similar to
.Fn blocklist_open
but allows a
.Fa logger
to be specified.
If the
.Fa logger
is
.Dv NULL ,
then no logging is performed.
.Pp
The
.Fn blocklist_close
function frees all memory and resources used.
.Pp
The
.Fn blocklist
function sends a message to
.Xr blocklistd 8 ,
with an integer
.Ar action
argument specifying the type of notification,
a file descriptor
.Ar fd
specifying the accepted file descriptor connected to the client,
and an optional message in the
.Ar msg
argument.
.Pp
The
.Ar action
parameter can take these values:
.Bl -tag -width ".Dv BLOCKLIST_ABUSIVE_BEHAVIOR"
.It Dv BLOCKLIST_AUTH_FAIL
There was an unsuccessful authentication attempt.
.It Dv BLOCKLIST_AUTH_OK
A user successfully authenticated.
.It Dv BLOCKLIST_ABUSIVE_BEHAVIOR
The sending daemon has detected abusive behavior
from the remote system.
The remote address should
be blocked as soon as possible.
.It Dv BLOCKLIST_BAD_USER
The sending daemon has determined the username
presented for authentication is invalid.
The
.Xr blocklistd 8
daemon compares the username to a configured list of forbidden
usernames and
blocks the address immediately if a forbidden username matches.
(The
.Dv BLOCKLIST_BAD_USER
support is not currently available.)
.El
.Pp
The
.Fn blocklist_r
function is more efficient because it keeps the blocklist state around.
.Pp
The
.Fn blocklist_sa
and
.Fn blocklist_sa_r
functions can be used with unconnected sockets, where
.Xr getpeername 2
will not work, the server will pass the peer name in the message.
.Pp
In all cases the file descriptor passed in the
.Fa fd
argument must be pointing to a valid socket so that
.Xr blocklistd 8
can establish ownership of the local endpoint
using
.Xr getsockname 2 .
.Pp
By default,
.Xr syslogd 8
is used for message logging.
The internal
.Fn bl_create
function can be used to create the required internal
state and specify a custom logging function.
.Sh RETURN VALUES
The function
.Fn blocklist_open
returns a cookie on success and
.Dv NULL
on failure setting
.Dv errno
to an appropriate value.
.Pp
The functions
.Fn blocklist ,
.Fn blocklist_sa ,
and
.Fn blocklist_sa_r
return
.Dv 0
on success and
.Dv \-1
on failure setting
.Dv errno
to an appropriate value.
.Sh SEE ALSO
.Xr blocklistd.conf 5 ,
.Xr blocklistd 8
.Sh AUTHORS
.An Christos Zoulas
+554
View File
@@ -0,0 +1,554 @@
/* $NetBSD: bl.c,v 1.9 2025/03/30 01:53:59 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
__RCSID("$NetBSD: bl.c,v 1.9 2025/03/30 01:53:59 christos Exp $");
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/un.h>
#include <stdio.h>
#include <string.h>
#include <syslog.h>
#include <signal.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <stdbool.h>
#include <errno.h>
#include <stdarg.h>
#include <netinet/in.h>
#ifdef _REENTRANT
#include <pthread.h>
#endif
#if defined(SO_RECVUCRED)
#include <ucred.h>
#endif
#include "old_bl.h"
typedef struct {
uint32_t bl_len;
uint32_t bl_version;
uint32_t bl_type;
uint32_t bl_salen;
struct sockaddr_storage bl_ss;
char bl_data[];
} bl_message_t;
struct blacklist {
#ifdef _REENTRANT
pthread_mutex_t b_mutex;
# define BL_INIT(b) pthread_mutex_init(&b->b_mutex, NULL)
# define BL_LOCK(b) pthread_mutex_lock(&b->b_mutex)
# define BL_UNLOCK(b) pthread_mutex_unlock(&b->b_mutex)
#else
# define BL_INIT(b) do {} while(/*CONSTCOND*/0)
# define BL_LOCK(b) BL_INIT(b)
# define BL_UNLOCK(b) BL_INIT(b)
#endif
int b_fd;
int b_connected;
struct sockaddr_un b_sun;
struct syslog_data b_syslog_data;
void (*b_fun)(int, struct syslog_data *, const char *, va_list);
bl_info_t b_info;
};
#define BL_VERSION 1
bool
bl_isconnected(bl_t b)
{
return b->b_connected == 0;
}
int
bl_getfd(bl_t b)
{
return b->b_fd;
}
static void
bl_reset(bl_t b, bool locked)
{
int serrno = errno;
if (!locked)
BL_LOCK(b);
close(b->b_fd);
errno = serrno;
b->b_fd = -1;
b->b_connected = -1;
if (!locked)
BL_UNLOCK(b);
}
static void
bl_log(bl_t b, int level, const char *fmt, ...)
{
va_list ap;
int serrno = errno;
if (b->b_fun == NULL)
return;
va_start(ap, fmt);
(*b->b_fun)(level, &b->b_syslog_data, fmt, ap);
va_end(ap);
errno = serrno;
}
static int
bl_init(bl_t b, bool srv)
{
static int one = 1;
/* AF_UNIX address of local logger */
mode_t om;
int rv, serrno;
struct sockaddr_un *sun = &b->b_sun;
#ifndef SOCK_NONBLOCK
#define SOCK_NONBLOCK 0
#endif
#ifndef SOCK_CLOEXEC
#define SOCK_CLOEXEC 0
#endif
#ifndef SOCK_NOSIGPIPE
#define SOCK_NOSIGPIPE 0
#endif
BL_LOCK(b);
if (b->b_fd == -1) {
b->b_fd = socket(PF_LOCAL,
SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK|SOCK_NOSIGPIPE, 0);
if (b->b_fd == -1) {
bl_log(b, LOG_ERR, "%s: socket failed (%s)",
__func__, strerror(errno));
BL_UNLOCK(b);
return -1;
}
#if SOCK_CLOEXEC == 0
fcntl(b->b_fd, F_SETFD, FD_CLOEXEC);
#endif
#if SOCK_NONBLOCK == 0
fcntl(b->b_fd, F_SETFL, fcntl(b->b_fd, F_GETFL) | O_NONBLOCK);
#endif
#if SOCK_NOSIGPIPE == 0
#ifdef SO_NOSIGPIPE
int o = 1;
setsockopt(b->b_fd, SOL_SOCKET, SO_NOSIGPIPE, &o, sizeof(o));
#else
signal(SIGPIPE, SIG_IGN);
#endif
#endif
}
if (bl_isconnected(b)) {
BL_UNLOCK(b);
return 0;
}
/*
* We try to connect anyway even when we are a server to verify
* that no other server is listening to the socket. If we succeed
* to connect and we are a server, someone else owns it.
*/
rv = connect(b->b_fd, (const void *)sun, (socklen_t)sizeof(*sun));
if (rv == 0) {
if (srv) {
bl_log(b, LOG_ERR,
"%s: another daemon is handling `%s'",
__func__, sun->sun_path);
goto out;
}
} else {
if (!srv) {
/*
* If the daemon is not running, we just try a
* connect, so leave the socket alone until it does
* and only log once.
*/
if (b->b_connected != 1) {
bl_log(b, LOG_DEBUG,
"%s: connect failed for `%s' (%s)",
__func__, sun->sun_path, strerror(errno));
b->b_connected = 1;
}
BL_UNLOCK(b);
return -1;
}
bl_log(b, LOG_DEBUG, "Connected to blacklist server", __func__);
}
if (srv) {
(void)unlink(sun->sun_path);
om = umask(0);
rv = bind(b->b_fd, (const void *)sun, (socklen_t)sizeof(*sun));
serrno = errno;
(void)umask(om);
errno = serrno;
if (rv == -1) {
bl_log(b, LOG_ERR, "%s: bind failed for `%s' (%s)",
__func__, sun->sun_path, strerror(errno));
goto out;
}
}
b->b_connected = 0;
#define GOT_FD 1
#if defined(LOCAL_CREDS)
#define CRED_LEVEL 0
#define CRED_NAME LOCAL_CREDS
#define CRED_SC_UID(x) (x)->sc_euid
#define CRED_SC_GID(x) (x)->sc_egid
#define CRED_MESSAGE SCM_CREDS
#define CRED_SIZE SOCKCREDSIZE(NGROUPS_MAX)
#define CRED_TYPE struct sockcred
#define GOT_CRED 2
#elif defined(SO_PASSCRED)
#define CRED_LEVEL SOL_SOCKET
#define CRED_NAME SO_PASSCRED
#define CRED_SC_UID(x) (x)->uid
#define CRED_SC_GID(x) (x)->gid
#define CRED_MESSAGE SCM_CREDENTIALS
#define CRED_SIZE sizeof(struct ucred)
#define CRED_TYPE struct ucred
#define GOT_CRED 2
#elif defined(SO_RECVUCRED)
#define CRED_LEVEL SOL_SOCKET
#define CRED_NAME SO_RECVUCRED
#define CRED_SC_UID(x) ucred_geteuid(x)
#define CRED_SC_GID(x) ucred_getegid(x)
#define CRED_MESSAGE SCM_UCRED
#define CRED_SIZE ucred_size()
#define CRED_TYPE ucred_t
#define GOT_CRED 2
#else
#define GOT_CRED 0
/*
* getpeereid() and LOCAL_PEERCRED don't help here
* because we are not a stream socket!
*/
#define CRED_SIZE 0
#define CRED_TYPE void * __unused
#endif
#ifdef CRED_LEVEL
if (setsockopt(b->b_fd, CRED_LEVEL, CRED_NAME,
&one, (socklen_t)sizeof(one)) == -1) {
bl_log(b, LOG_ERR, "%s: setsockopt %s "
"failed (%s)", __func__, __STRING(CRED_NAME),
strerror(errno));
goto out;
}
#endif
BL_UNLOCK(b);
return 0;
out:
bl_reset(b, true);
BL_UNLOCK(b);
return -1;
}
bl_t
bl_create(bool srv, const char *path,
void (*fun)(int, struct syslog_data *, const char *, va_list))
{
static struct syslog_data sd = SYSLOG_DATA_INIT;
bl_t b = calloc(1, sizeof(*b));
if (b == NULL)
return NULL;
b->b_fun = fun;
b->b_syslog_data = sd;
b->b_fd = -1;
b->b_connected = -1;
BL_INIT(b);
memset(&b->b_sun, 0, sizeof(b->b_sun));
b->b_sun.sun_family = AF_LOCAL;
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
b->b_sun.sun_len = sizeof(b->b_sun);
#endif
strlcpy(b->b_sun.sun_path,
path ? path : _PATH_BLSOCK, sizeof(b->b_sun.sun_path));
bl_init(b, srv);
return b;
}
void
bl_destroy(bl_t b)
{
bl_reset(b, false);
free(b);
}
static int
bl_getsock(bl_t b, struct sockaddr_storage *ss, const struct sockaddr *sa,
socklen_t slen, const char *ctx)
{
uint8_t family;
memset(ss, 0, sizeof(*ss));
switch (slen) {
case 0:
return 0;
case sizeof(struct sockaddr_in):
family = AF_INET;
break;
case sizeof(struct sockaddr_in6):
family = AF_INET6;
break;
default:
bl_log(b, LOG_ERR, "%s: invalid socket len %u (%s)",
__func__, (unsigned)slen, ctx);
errno = EINVAL;
return -1;
}
memcpy(ss, sa, slen);
if (ss->ss_family != family) {
bl_log(b, LOG_INFO,
"%s: correcting socket family %d to %d (%s)",
__func__, ss->ss_family, family, ctx);
ss->ss_family = family;
}
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
if (ss->ss_len != slen) {
bl_log(b, LOG_INFO,
"%s: correcting socket len %u to %u (%s)",
__func__, ss->ss_len, (unsigned)slen, ctx);
ss->ss_len = (uint8_t)slen;
}
#endif
return 0;
}
int
bl_send(bl_t b, bl_type_t e, int pfd, const struct sockaddr *sa,
socklen_t slen, const char *ctx)
{
struct msghdr msg;
struct iovec iov;
union {
char ctrl[CMSG_SPACE(sizeof(int))];
uint32_t fd;
} ua;
struct cmsghdr *cmsg;
union {
bl_message_t bl;
char buf[512];
} ub;
size_t ctxlen, tried;
#define NTRIES 5
ctxlen = strlen(ctx);
if (ctxlen > 128)
ctxlen = 128;
iov.iov_base = ub.buf;
iov.iov_len = sizeof(bl_message_t) + ctxlen;
ub.bl.bl_len = (uint32_t)iov.iov_len;
ub.bl.bl_version = BL_VERSION;
ub.bl.bl_type = (uint32_t)e;
if (bl_getsock(b, &ub.bl.bl_ss, sa, slen, ctx) == -1)
return -1;
ub.bl.bl_salen = slen;
memcpy(ub.bl.bl_data, ctx, ctxlen);
msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_flags = 0;
msg.msg_control = ua.ctrl;
msg.msg_controllen = sizeof(ua.ctrl);
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
memcpy(CMSG_DATA(cmsg), &pfd, sizeof(pfd));
tried = 0;
again:
if (bl_init(b, false) == -1)
return -1;
if ((sendmsg(b->b_fd, &msg, 0) == -1) && tried++ < NTRIES) {
bl_reset(b, false);
goto again;
}
return tried >= NTRIES ? -1 : 0;
}
bl_info_t *
bl_recv(bl_t b)
{
struct msghdr msg;
struct iovec iov;
union {
char ctrl[CMSG_SPACE(sizeof(int)) + CMSG_SPACE(CRED_SIZE)];
uint32_t fd;
} ua;
struct cmsghdr *cmsg;
#if GOT_CRED != 0
CRED_TYPE *sc;
#endif
union {
bl_message_t bl;
char buf[512];
} ub;
int got;
ssize_t rlen;
size_t rem;
bl_info_t *bi = &b->b_info;
got = 0;
memset(bi, 0, sizeof(*bi));
iov.iov_base = ub.buf;
iov.iov_len = sizeof(ub);
msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_flags = 0;
msg.msg_control = ua.ctrl;
msg.msg_controllen = sizeof(ua.ctrl);
rlen = recvmsg(b->b_fd, &msg, 0);
if (rlen == -1) {
bl_log(b, LOG_ERR, "%s: recvmsg failed (%s)", __func__,
strerror(errno));
return NULL;
}
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
if (cmsg->cmsg_level != SOL_SOCKET) {
bl_log(b, LOG_ERR,
"%s: unexpected cmsg_level %d",
__func__, cmsg->cmsg_level);
continue;
}
switch (cmsg->cmsg_type) {
case SCM_RIGHTS:
if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) {
int *fd = (void *)CMSG_DATA(cmsg);
size_t len = cmsg->cmsg_len / sizeof(int);
bl_log(b, LOG_ERR,
"%s: unexpected cmsg_len %d != %zu",
__func__, cmsg->cmsg_len,
CMSG_LEN(sizeof(int)));
for (size_t i = 0; i < len; i++)
(void)close(fd[i]);
continue;
}
memcpy(&bi->bi_fd, CMSG_DATA(cmsg), sizeof(bi->bi_fd));
got |= GOT_FD;
break;
#ifdef CRED_MESSAGE
case CRED_MESSAGE:
sc = (void *)CMSG_DATA(cmsg);
bi->bi_uid = CRED_SC_UID(sc);
bi->bi_gid = CRED_SC_GID(sc);
got |= GOT_CRED;
break;
#endif
default:
bl_log(b, LOG_ERR,
"%s: unexpected cmsg_type %d",
__func__, cmsg->cmsg_type);
continue;
}
}
if (got != (GOT_CRED|GOT_FD)) {
bl_log(b, LOG_ERR, "message missing %s %s",
#if GOT_CRED != 0
(got & GOT_CRED) == 0 ? "cred" :
#endif
"", (got & GOT_FD) == 0 ? "fd" : "");
return NULL;
}
rem = (size_t)rlen;
if (rem < sizeof(ub.bl)) {
bl_log(b, LOG_ERR, "message too short %zd", rlen);
return NULL;
}
rem -= sizeof(ub.bl);
if (ub.bl.bl_version != BL_VERSION) {
bl_log(b, LOG_ERR, "bad version %d", ub.bl.bl_version);
return NULL;
}
bi->bi_type = ub.bl.bl_type;
bi->bi_slen = ub.bl.bl_salen;
bi->bi_ss = ub.bl.bl_ss;
#ifndef CRED_MESSAGE
bi->bi_uid = -1;
bi->bi_gid = -1;
#endif
if (rem == 0)
bi->bi_msg[0] = '\0';
else {
rem = MIN(sizeof(bi->bi_msg) - 1, rem);
memcpy(bi->bi_msg, ub.bl.bl_data, rem);
bi->bi_msg[rem] = '\0';
}
return bi;
}
+1 -1
View File
@@ -1,2 +1,2 @@
major=0
minor=0
minor=1
+2 -2
View File
@@ -1,6 +1,6 @@
# $NetBSD: Makefile,v 1.1 2015/01/22 17:49:41 christos Exp $
# $NetBSD: Makefile,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $
SCRIPTS= blacklistd-helper
SCRIPTS= blocklistd-helper
SCRIPTSDIR= /libexec
.include <bsd.prog.mk>
-134
View File
@@ -1,134 +0,0 @@
#!/bin/sh
#echo "run $@" 1>&2
#set -x
# $1 command
# $2 rulename
# $3 protocol
# $4 address
# $5 mask
# $6 port
# $7 id
pf=
if [ -f "/etc/ipfw-blacklist.rc" ]; then
pf="ipfw"
. /etc/ipfw-blacklist.rc
ipfw_offset=${ipfw_offset:-2000}
fi
if [ -z "$pf" ]; then
for f in npf pf ipf; do
if [ -f "/etc/$f.conf" ]; then
pf="$f"
break
fi
done
fi
if [ -z "$pf" ]; then
echo "$0: Unsupported packet filter" 1>&2
exit 1
fi
if [ -n "$3" ]; then
proto="proto $3"
fi
if [ -n "$6" ]; then
port="port $6"
fi
addr="$4"
mask="$5"
case "$4" in
::ffff:*.*.*.*)
if [ "$5" = 128 ]; then
mask=32
addr=${4#::ffff:}
fi;;
esac
case "$1" in
add)
case "$pf" in
ipf)
/sbin/ipfstat -io | /sbin/ipf -I -f - >/dev/null 2>&1
echo block in quick $proto from $addr/$mask to \
any port=$6 head port$6 | \
/sbin/ipf -I -f - -s >/dev/null 2>&1 && echo OK
;;
ipfw)
# use $ipfw_offset+$port for rule number
rule=$(($ipfw_offset + $6))
tname="port$6"
/sbin/ipfw table $tname create type addr 2>/dev/null
/sbin/ipfw -q table $tname add "$addr/$mask"
# if rule number $rule does not already exist, create it
/sbin/ipfw show $rule >/dev/null 2>&1 || \
/sbin/ipfw add $rule drop $3 from \
table"("$tname")" to any dst-port $6 >/dev/null && \
echo OK
;;
npf)
/sbin/npfctl rule "$2" add block in final $proto from \
"$addr/$mask" to any $port
;;
pf)
# if the filtering rule does not exist, create it
/sbin/pfctl -a "$2/$6" -sr 2>/dev/null | \
grep -q "<port$6>" || \
echo "block in quick $proto from <port$6> to any $port" | \
/sbin/pfctl -a "$2/$6" -f -
# insert $ip/$mask into per-protocol/port anchored table
/sbin/pfctl -qa "$2/$6" -t "port$6" -T add "$addr/$mask" && \
/sbin/pfctl -qk "$addr" && echo OK
;;
esac
;;
rem)
case "$pf" in
ipf)
/sbin/ipfstat -io | /sbin/ipf -I -f - >/dev/null 2>&1
echo block in quick $proto from $addr/$mask to \
any port=$6 head port$6 | \
/sbin/ipf -I -r -f - -s >/dev/null 2>&1 && echo OK
;;
ipfw)
/sbin/ipfw table "port$6" delete "$addr/$mask" 2>/dev/null && \
echo OK
;;
npf)
/sbin/npfctl rule "$2" rem-id "$7"
;;
pf)
/sbin/pfctl -qa "$2/$6" -t "port$6" -T delete "$addr/$mask" && \
echo OK
;;
esac
;;
flush)
case "$pf" in
ipf)
/sbin/ipf -Z -I -Fi -s > /dev/null && echo OK
;;
ipfw)
/sbin/ipfw table "port$6" flush 2>/dev/null && echo OK
;;
npf)
/sbin/npfctl rule "$2" flush
;;
pf)
# dynamically determine which anchors exist
for anchor in $(/sbin/pfctl -a "$2" -s Anchors); do
/sbin/pfctl -a $anchor -t "port${anchor##*/}" -T flush
/sbin/pfctl -a $anchor -F rules
done
echo OK
;;
esac
;;
*)
echo "$0: Unknown command '$1'" 1>&2
exit 1
;;
esac
+272
View File
@@ -0,0 +1,272 @@
#!/bin/sh
#echo "run $@" 1>&2
#set -x
# $1 command
# $2 rulename
# $3 protocol
# $4 address
# $5 mask
# $6 port
# $7 id
pf=
if [ -f "/etc/ipfw-blocklist.rc" ]; then
pf="ipfw"
. /etc/ipfw-blocklist.rc
ipfw_offset=${ipfw_offset:-2000}
fi
if [ -z "$pf" ]; then
for f in npf pf ipfilter ipfw; do
if [ -x /etc/rc.d/$f ]; then
if /etc/rc.d/$f status >/dev/null 2>&1; then
pf="$f"
break
fi
elif [ -f "/etc/$f.conf" ]; then
# xxx assume a config file means it can be enabled --
# and the first one wins!
pf="$f"
break
fi
done
fi
if [ -z "$pf" -a -x "/sbin/iptables" ]; then
pf="iptables"
fi
if [ -z "$pf" ]; then
echo "$0: Unsupported packet filter" 1>&2
exit 1
fi
flags=
if [ -n "$3" ]; then
raw_proto="$3"
proto="proto $3"
if [ $3 = "tcp" ]; then
flags="flags S/SAFR"
fi
fi
if [ -n "$6" ]; then
raw_port="$6"
port="port $6"
fi
addr="$4"
mask="$5"
case "$4" in
::ffff:*.*.*.*)
if [ "$5" = 128 ]; then
mask=32
addr=${4#::ffff:}
fi;;
esac
case "$1" in
add)
case "$pf" in
ipfilter)
# N.B.: If you reload /etc/ipf.conf then you need to stop and
# restart blocklistd (and make sure blocklistd_flags="-r").
# This should normally already be implemented in
# /etc/rc.d/ipfilter, but if then not add the following lines to
# the end of the ipfilter_reload() function:
#
# if checkyesnox blocklistd; then
# /etc/rc.d/blocklistd restart
# fi
#
# XXX we assume the following rule is present in /etc/ipf.conf:
# (should we check? -- it probably cannot be added dynamically)
#
# block in proto tcp/udp from any to any head blocklistd
#
# where "blocklistd" is the default rulename (i.e. "$2")
#
# This rule can come before any rule that logs connections,
# etc., and should be followed by final rules such as:
#
# # log all as-yet unblocked incoming TCP connection
# # attempts
# log in proto tcp from any to any flags S/SAFR
# # last "pass" match wins for all non-blocked packets
# pass in all
# pass out all
#
# I.e. a "pass" rule which will be the final match and override
# the "block". This way the rules added by blocklistd will
# actually block packets, and prevent logging of them as
# connections, because they include the "quick" flag.
#
# N.b.: $port is not included/used in rules -- abusers are cut
# off completely from all services!
#
# Note RST packets are not returned for blocked SYN packets of
# active attacks, so the port will not appear to be closed.
# This will probably give away the fact that a firewall has been
# triggered to block connections, but it prevents generating
# extra outbound traffic, and it may also slow down the attacker
# somewhat.
#
# Note also that we don't block all packets, just new attempts
# to open connections (see $flags above). This allows us to do
# counterespionage against the attacker (or continue to make use
# of any other services that might be on the same subnet as the
# supposed attacker). However it does not kill any active
# connections -- we rely on the reporting daemon to do its own
# protection and cleanup.
#
# N.B.: The rule generated here must exactly match the
# corresponding rule generated for the "rem" command below!
#
echo block in log quick $proto \
from $addr/$mask to any $flags group $2 | \
/sbin/ipf -A -f - >/dev/null 2>&1 && echo OK
;;
ipfw)
# use $ipfw_offset+$port for rule number
rule=$(($ipfw_offset + $6))
tname="port$6"
/sbin/ipfw table $tname create type addr 2>/dev/null
/sbin/ipfw -q table $tname add "$addr/$mask"
# if rule number $rule does not already exist, create it
/sbin/ipfw show $rule >/dev/null 2>&1 || \
/sbin/ipfw add $rule drop $3 from \
table"("$tname")" to any dst-port $6 >/dev/null && \
echo OK
;;
iptables)
if ! /sbin/iptables --list "$2" >/dev/null 2>&1; then
/sbin/iptables --new-chain "$2"
fi
/sbin/iptables --append INPUT --proto "$raw_proto" \
--dport "$raw_port" --jump "$2"
/sbin/iptables --append "$2" --proto "$raw_proto" \
--source "$addr/$mask" --dport "$raw_port" --jump DROP
echo OK
;;
npf)
/sbin/npfctl rule "$2" add block in final $proto from \
"$addr/$mask" to any $port
;;
pf)
# if the filtering rule does not exist, create it
/sbin/pfctl -a "$2/$6" -sr 2>/dev/null | \
grep -q "<port$6>" || \
echo "block in quick $proto from <port$6> to any $port" | \
/sbin/pfctl -a "$2/$6" -f -
# insert $ip/$mask into per-protocol/port anchored table
/sbin/pfctl -qa "$2/$6" -t "port$6" -T add "$addr/$mask" && \
/sbin/pfctl -qk "$addr" && echo OK
;;
esac
;;
rem)
case "$pf" in
ipfilter)
# N.B.: The rule generated here must exactly match the
# corresponding rule generated for the "add" command above!
#
echo block in log quick $proto \
from $addr/$mask to any $flags group $2 | \
/sbin/ipf -A -r -f - >/dev/null 2>&1 && echo OK
;;
ipfw)
/sbin/ipfw table "port$6" delete "$addr/$mask" 2>/dev/null && \
echo OK
;;
iptables)
if /sbin/iptables --list "$2" >/dev/null 2>&1; then
/sbin/iptables --delete "$2" --proto "$raw_proto" \
--source "$addr/$mask" --dport "$raw_port" \
--jump DROP
fi
echo OK
;;
npf)
/sbin/npfctl rule "$2" rem-id "$7"
;;
pf)
/sbin/pfctl -qa "$2/$6" -t "port$6" -T delete "$addr/$mask" && \
echo OK
;;
esac
;;
flush)
case "$pf" in
ipfilter)
#
# N.B. WARNING: This is obviously not reentrant!
#
# First we flush all the rules from the inactive set, then we
# reload the ones that do not belong to the group "$2", and
# finally we swap the active and inactive rule sets.
#
/sbin/ipf -I -F a
#
# "ipf -I -F a" also flushes active accounting rules!
#
# Note that accounting rule groups are unique to accounting
# rules and have nothing to do with filter rules, though of
# course theoretically one could use the same group name for
# them too.
#
# In theory anyone using any such accounting rules should have a
# wrapper /etc/rc.conf.d/blocklistd script (and corresponding
# /etc/rc.conf.d/ipfilter script) that will record and
# consolidate the values accumulated by such accounting rules
# before they are flushed, since otherwise their counts will be
# lost forever.
#
/usr/sbin/ipfstat -io | fgrep -v "group $2" | \
/sbin/ipf -I -f - >/dev/null 2>&1
#
# This MUST be done last and separately as "-s" is executed
# _while_ the command arguments are being processed!
#
/sbin/ipf -s && echo OK
;;
ipfw)
/sbin/ipfw table "port$6" flush 2>/dev/null && echo OK
;;
iptables)
if /sbin/iptables --list "$2" >/dev/null 2>&1; then
/sbin/iptables --flush "$2"
fi
echo OK
;;
npf)
/sbin/npfctl rule "$2" flush
;;
pf)
# dynamically determine which anchors exist
for anchor in $(/sbin/pfctl -a "$2" -s Anchors 2> /dev/null); do
/sbin/pfctl -a "$anchor" -t "port${anchor##*/}" -T flush 2> /dev/null
/sbin/pfctl -a "$anchor" -F rules
done
echo OK
;;
esac
;;
*)
echo "$0: Unknown command '$1'" 1>&2
exit 1
;;
esac
+28 -14
View File
@@ -1,25 +1,39 @@
#
ACLOCAL_AMFLAGS = -I m4
lib_LTLIBRARIES = libblacklist.la
include_HEADERS = ../include/blacklist.h
lib_LTLIBRARIES = libblocklist.la
include_HEADERS = $(srcdir)/../include/blocklist.h
bin_PROGRAMS = blacklistd blacklistctl srvtest cltest
exampledir = $(datarootdir)/examples
example_DATA = $(srcdir)/../etc/blocklistd.conf $(srcdir)/../etc/npf.conf $(srcdir)/../etc/ipf.conf
VPATH = ../bin:../lib:../test:../include
sbin_PROGRAMS = blocklistd blocklistctl
noinst_PROGRAMS = srvtest cltest
libexec_SCRIPTS = $(srcdir)/../libexec/blocklistd-helper
AM_CPPFLAGS = -I../include -DDOT="."
man5_MANS = $(srcdir)/../bin/blocklistd.conf.5
man8_MANS = $(srcdir)/../bin/blocklistd.8 $(srcdir)/../bin/blocklistctl.8
VPATH = $(srcdir)/../port:$(srcdir)/../bin:$(srcdir)/../lib:$(srcdir)/../test:$(srcdir)/../include
AM_CPPFLAGS = -I$(srcdir)/../include -DDOT="."
AM_CPPFLAGS += -D_PATH_BLCONF=\"$(sysconfdir)/blocklistd.conf\"
AM_CPPFLAGS += -D_PATH_BLCONTROL=\"$(libexecdir)/blocklistd-helper\"
AM_CPPFLAGS += -D_PATH_BLSOCK=\"$(runstatedir)/blocklistd.sock\"
AM_CPPFLAGS += -D_PATH_BLSTATE=\"$(localstatedir)/db/blocklistd.db\"
AM_CPPFLAGS += -std=c99 -D_POSIX_C_SOURCE=200809L -D__EXTENSIONS__
AM_CPPFLAGS += -D__BSD_VISIBLE=1
AM_CFLAGS = @WARNINGS@
libblacklist_la_SOURCES = bl.c blacklist.c
libblacklist_la_LDFLAGS = -no-undefined -version-info 0:0:0
libblacklist_la_LIBADD = $(LTLIBOBJS)
libblocklist_la_SOURCES = bl.c blocklist.c
libblocklist_la_LDFLAGS = -no-undefined -version-info 0:0:0
libblocklist_la_LIBADD = $(LTLIBOBJS)
SRCS = internal.c support.c run.c conf.c state.c
blacklistd_SOURCES = blacklistd.c ${SRCS}
blacklistd_LDADD = libblacklist.la
blacklistctl_SOURCES = blacklistctl.c ${SRCS}
blacklistctl_LDADD = libblacklist.la
blocklistd_SOURCES = blocklistd.c ${SRCS}
blocklistd_LDADD = libblocklist.la
blocklistctl_SOURCES = blocklistctl.c ${SRCS}
blocklistctl_LDADD = libblocklist.la
srvtest_SOURCES = srvtest.c ${SRCS}
srvtest_LDADD = libblacklist.la
srvtest_LDADD = libblocklist.la
cltest_SOURCES = cltest.c ${SRCS}
cltest_LDADD = libblacklist.la
cltest_LDADD = libblocklist.la
+1 -1
View File
@@ -1,4 +1,4 @@
/* $NetBSD: _strtoi.h,v 1.1 2015/01/22 02:15:59 christos Exp $ */
/* $NetBSD: _strtoi.h,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
+7 -5
View File
@@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT([blacklistd],[0.1],[[email protected]])
AC_INIT([blocklistd],[0.1],[[email protected]])
AM_INIT_AUTOMAKE([subdir-objects foreign])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
@@ -7,9 +7,10 @@ AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_SUBST(WARNINGS)
AC_SUBST(LINK_NTOA)
dnl Checks for programs.
AC_PROG_CC_STDC
AC_PROG_CC
AC_USE_SYSTEM_EXTENSIONS
AM_PROG_CC_C_O
AC_C_BIGENDIAN
@@ -18,18 +19,19 @@ AC_PROG_LN_S
LT_INIT([disable-static pic-only])
gl_VISIBILITY
dnl Checks for headers
AC_HEADER_STDC
AC_HEADER_MAJOR
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(stdint.h fcntl.h stdint.h inttypes.h unistd.h)
AC_CHECK_HEADERS(sys/un.h sys/socket.h limits.h)
AC_CHECK_HEADERS(arpa/inet.h getopt.h err.h)
AC_CHECK_HEADERS(sys/types.h util.h sys/time.h time.h)
AC_CHECK_HEADERS(netatalk/at.h net/if_dl.h db.h db_185.h)
AC_CHECK_HEADERS(netatalk/at.h db.h db_185.h)
AC_CHECK_HEADERS(sys/cdefs.h)
AC_CHECK_LIB(rt, clock_gettime)
AC_CHECK_LIB(db, __db185_open)
AC_CHECK_LIB(util, pidfile)
AC_CHECK_LIB(util, sockaddr_snprintf)
AC_SEARCH_LIBS(__xnet_connect, socket)
AH_BOTTOM([
#ifndef __NetBSD__
@@ -82,7 +84,7 @@ dnl Checks for functions
AC_CHECK_FUNCS(strerror)
dnl Provide implementation of some required functions if necessary
AC_REPLACE_FUNCS(strtoi sockaddr_snprintf popenve clock_gettime strlcpy strlcat getprogname fparseln fgetln pidfile)
AC_REPLACE_FUNCS(strtoi sockaddr_snprintf popenve clock_gettime strlcpy strlcat getprogname fparseln fgetln pidfile vsyslog_r)
dnl See if we are cross-compiling
AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
+1 -1
View File
@@ -1,4 +1,4 @@
/* $NetBSD: fgetln.c,v 1.1 2015/01/22 03:48:07 christos Exp $ */
/* $NetBSD: fgetln.c,v 1.1.1.1 2020/06/15 01:52:54 christos Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
+4 -2
View File
@@ -1,4 +1,4 @@
/* $NetBSD: fparseln.c,v 1.1 2015/01/22 03:48:07 christos Exp $ */
/* $NetBSD: fparseln.c,v 1.2 2025/02/11 17:48:30 christos Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@@ -27,9 +27,11 @@
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: fparseln.c,v 1.1 2015/01/22 03:48:07 christos Exp $");
__RCSID("$NetBSD: fparseln.c,v 1.2 2025/02/11 17:48:30 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
+4 -2
View File
@@ -1,4 +1,4 @@
/* $NetBSD: pidfile.c,v 1.2 2016/04/05 12:28:57 christos Exp $ */
/* $NetBSD: pidfile.c,v 1.2 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -32,9 +32,11 @@
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: pidfile.c,v 1.2 2016/04/05 12:28:57 christos Exp $");
__RCSID("$NetBSD: pidfile.c,v 1.2 2025/02/11 17:48:30 christos Exp $");
#endif
#include <sys/param.h>
+4 -2
View File
@@ -1,4 +1,4 @@
/* $NetBSD: popenve.c,v 1.2 2015/01/22 03:10:50 christos Exp $ */
/* $NetBSD: popenve.c,v 1.2 2025/02/11 17:48:30 christos Exp $ */
/*
* Copyright (c) 1988, 1993
@@ -36,12 +36,14 @@
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95";
#else
__RCSID("$NetBSD: popenve.c,v 1.2 2015/01/22 03:10:50 christos Exp $");
__RCSID("$NetBSD: popenve.c,v 1.2 2025/02/11 17:48:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
+27 -5
View File
@@ -1,6 +1,7 @@
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sys/param.h>
#include <stdio.h>
#include <inttypes.h>
#include <time.h>
@@ -15,6 +16,22 @@
#define __dead __attribute__((__noreturn__))
#endif
#ifndef __BEGIN_DECLS
#define __BEGIN_DECLS
#endif
#ifndef __END_DECLS
#define __END_DECLS
#endif
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif
#ifndef __RCSID
#define __RCSID(a)
#endif
@@ -27,6 +44,10 @@
#define __arraycount(a) (sizeof(a) / sizeof(a[0]))
#endif
#ifndef __STRING
#define __STRING(x) #x
#endif
#ifndef HAVE_STRLCPY
size_t strlcpy(char *, const char *, size_t);
#endif
@@ -78,9 +99,10 @@ int clock_gettime(int, struct timespec *);
#define CLOCK_REALTIME 0
#endif
#if !defined(__FreeBSD__)
#define _PATH_BLCONF "conf"
#define _PATH_BLCONTROL "control"
#define _PATH_BLSOCK "blacklistd.sock"
#define _PATH_BLSTATE "blacklistd.db"
#ifndef HAVE_VSYSLOG_R
#define SYSLOG_DATA_INIT { 0 }
struct syslog_data {
int dummy;
};
void vsyslog_r(int, struct syslog_data *, const char *, va_list);
#endif
+4 -2
View File
@@ -1,4 +1,4 @@
/* $NetBSD: sockaddr_snprintf.c,v 1.11 2016/06/01 22:57:51 christos Exp $ */
/* $NetBSD: sockaddr_snprintf.c,v 1.2 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -32,9 +32,11 @@
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: sockaddr_snprintf.c,v 1.11 2016/06/01 22:57:51 christos Exp $");
__RCSID("$NetBSD: sockaddr_snprintf.c,v 1.2 2025/02/11 17:48:30 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
+5 -2
View File
@@ -1,4 +1,4 @@
/* $NetBSD: strlcat.c,v 1.2 2015/01/22 03:48:07 christos Exp $ */
/* $NetBSD: strlcat.c,v 1.2 2025/02/11 17:48:30 christos Exp $ */
/* $OpenBSD: strlcat.c,v 1.10 2003/04/12 21:56:39 millert Exp $ */
/*
@@ -22,9 +22,12 @@
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: strlcat.c,v 1.2 2015/01/22 03:48:07 christos Exp $");
__RCSID("$NetBSD: strlcat.c,v 1.2 2025/02/11 17:48:30 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#ifdef _LIBC
+5 -2
View File
@@ -1,4 +1,4 @@
/* $NetBSD: strlcpy.c,v 1.2 2015/01/22 03:48:07 christos Exp $ */
/* $NetBSD: strlcpy.c,v 1.2 2025/02/11 17:48:30 christos Exp $ */
/* $OpenBSD: strlcpy.c,v 1.7 2003/04/12 21:56:39 millert Exp $ */
/*
@@ -22,9 +22,12 @@
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: strlcpy.c,v 1.2 2015/01/22 03:48:07 christos Exp $");
__RCSID("$NetBSD: strlcpy.c,v 1.2 2025/02/11 17:48:30 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#ifdef _LIBC
+4 -2
View File
@@ -1,4 +1,4 @@
/* $NetBSD: strtoi.c,v 1.3 2015/01/22 03:10:50 christos Exp $ */
/* $NetBSD: strtoi.c,v 1.2 2025/02/11 17:48:31 christos Exp $ */
/*-
* Copyright (c) 2005 The DragonFly Project. All rights reserved.
@@ -33,8 +33,10 @@
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
__RCSID("$NetBSD: strtoi.c,v 1.3 2015/01/22 03:10:50 christos Exp $");
#endif
__RCSID("$NetBSD: strtoi.c,v 1.2 2025/02/11 17:48:31 christos Exp $");
#if defined(_KERNEL)
#include <sys/param.h>
+13
View File
@@ -0,0 +1,13 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <syslog.h>
#include <stdarg.h>
void
vsyslog_r(int priority, struct syslog_data *sd __unused, const char *fmt, va_list ap)
{
vsyslog(priority, fmt, ap);
}
+1 -1
View File
@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.3 2015/05/30 22:40:38 christos Exp $
# $NetBSD: Makefile,v 1.1.1.1 2020/06/15 01:52:54 christos Exp $
MKMAN=no
+4 -2
View File
@@ -1,4 +1,4 @@
/* $NetBSD: cltest.c,v 1.6 2015/01/22 05:44:28 christos Exp $ */
/* $NetBSD: cltest.c,v 1.2 2025/02/11 17:48:31 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
__RCSID("$NetBSD: cltest.c,v 1.6 2015/01/22 05:44:28 christos Exp $");
#endif
__RCSID("$NetBSD: cltest.c,v 1.2 2025/02/11 17:48:31 christos Exp $");
#include <sys/types.h>
#include <sys/socket.h>
+30 -12
View File
@@ -1,4 +1,4 @@
/* $NetBSD: srvtest.c,v 1.10 2015/05/30 22:40:38 christos Exp $ */
/* $NetBSD: srvtest.c,v 1.2 2025/02/11 17:43:16 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
__RCSID("$NetBSD: srvtest.c,v 1.10 2015/05/30 22:40:38 christos Exp $");
#endif
__RCSID("$NetBSD: srvtest.c,v 1.2 2025/02/11 17:43:16 christos Exp $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -48,7 +50,7 @@ __RCSID("$NetBSD: srvtest.c,v 1.10 2015/05/30 22:40:38 christos Exp $");
#include <poll.h>
#include <err.h>
#include "blacklist.h"
#include "blocklist.h"
#ifdef BLDEBUG
#include "bl.h"
static void *b;
@@ -71,9 +73,9 @@ process_tcp(int afd)
buffer[sizeof(buffer) - 1] = '\0';
printf("%s: sending %d %s\n", getprogname(), afd, buffer);
#ifdef BLDEBUG
blacklist_r(b, 1, afd, buffer);
blocklist_r(b, 1, afd, buffer);
#else
blacklist(1, afd, buffer);
blocklist(1, afd, buffer);
#endif
exit(0);
}
@@ -95,7 +97,7 @@ process_udp(int afd)
err(1, "recvfrom");
buffer[sizeof(buffer) - 1] = '\0';
printf("%s: sending %d %s\n", getprogname(), afd, buffer);
blacklist_sa(1, afd, (void *)&ss, slen, buffer);
blocklist_sa(1, afd, (void *)&ss, slen, buffer);
exit(0);
}
static int
@@ -167,7 +169,11 @@ static __dead void
usage(int c)
{
warnx("Unknown option `%c'", (char)c);
fprintf(stderr, "Usage: %s [-u] [-p <num>]\n", getprogname());
fprintf(stderr, "Usage: %s [-u] [-p <num>]"
#ifdef BLDEBUG
" [-s <sockpath>]"
#endif
"\n", getprogname());
exit(EXIT_FAILURE);
}
@@ -182,14 +188,16 @@ main(int argc, char *argv[])
struct pollfd pfd[NUMFD];
int type = SOCK_STREAM, c;
in_port_t port = 6161;
#ifdef BLDEBUG
char *sockpath = "blsock";
const char *optstr = "up:s:";
#else
const char *optstr = "up:";
#endif
signal(SIGCHLD, SIG_IGN);
#ifdef BLDEBUG
b = bl_create(false, "blsock", vsyslog);
#endif
while ((c = getopt(argc, argv, "up:")) != -1)
while ((c = getopt(argc, argv, optstr)) != -1)
switch (c) {
case 'u':
type = SOCK_DGRAM;
@@ -197,10 +205,20 @@ main(int argc, char *argv[])
case 'p':
port = (in_port_t)atoi(optarg);
break;
#ifdef BLDEBUG
case 's':
sockpath = (char *)optarg;
break;
#endif
default:
usage(c);
}
#ifdef BLDEBUG
b = bl_create(false, sockpath, vsyslog_r);
#endif
pfd[0].fd = cr(AF_INET, type, port);
pfd[0].events = POLLIN;
#if NUMFD > 1
+1
View File
@@ -21,6 +21,7 @@ examples_library/msgbox
examples_library/pause
examples_library/radiolist
examples_library/rangebox
examples_library/textbox
examples_library/theme
examples_library/timebox
examples_library/yesno
+48 -2
View File
@@ -1,11 +1,57 @@
2024-07-01 1.0.4
2025-06-22 Version 1.0.5
Manual:
* fix: "User-friendly documentation for alternate screen"
https://bugs.freebsd.org/285459.
Improve bsddialog.1: --alternate-screen and --normal-screen.
NetBSD (tested on amd64) refactoring, no function changes:
* https://gitlab.com/alfix/bsddialog/-/merge_requests/4
lib: include <stdarg.h> in lib_util.c.
* https://gitlab.com/alfix/bsddialog/-/merge_requests/5
a call to curses' refresh() is performed, while a local
variable is also called refresh.
* Makefiles: add install and uninstall targets (both GND and BSD)
https://gitlab.com/alfix/bsddialog/-/merge_requests/3
MacOS (tested on amd64) refactoring, no function changes:
* https://gitlab.com/alfix/bsddialog/-/merge_requests/6
utility: replace u_int with unsigned int.
Library:
* fix: useless refreshes, https://gitlab.com/alfix/bsddialog/-/issues/8:
"It takes lot of time when running over a 115200 UART".
Not fixed for bsddialog_gauge() because it has to be rewritten.
* change: bsddialog_backtitle() does not update the screen so the
backtitle is not printed. To use if a dialog is built later.
Rationale: see "115200 UART" problem above.
* add: bsddialog_backtitle_rf() to print a top title refreshing the
screen like bsddialog_backtitle() was previously.
* change: forms, ENTER is also a navigation keys in forms fields.
Request: https://bugs.freebsd.org/287592
If conf.button.always_active is true the form is closes immediatly.
Library and implicitly utility:
* fix: textbox buttons returned values (was always OK).
Thanks to https://reviews.freebsd.org/D48668.
* change: TAB is a navigation keys in forms. Previously it directly
switched form-fields <-> buttons.
Request: https://bugs.freebsd.org/287592
Utility:
* change: forms, ENTER is a also navigation keys in forms fields.
Previously it directly closed the form except with --switch-buttons
Request: https://bugs.freebsd.org/287592
2024-07-01 Version 1.0.4
Utility internal refactoring (no functional change):
* change: rename an internal constant to avoid a future conflict
because FreeBSD is changing headers files for _FORTIFY_SOURCE.
Reported and fixed by Kyle Evans.
2024-05-27 1.0.3
2024-05-27 Version 1.0.3
Utility:
change: --form and --mixedform do not print field value to output fd if
+1 -1
View File
@@ -1,6 +1,6 @@
BSD 2-Clause License
Copyright (c) 2021-2024, Alfonso Sabato Siciliano
Copyright (c) 2021-2025, Alfonso Sabato Siciliano
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+11 -2
View File
@@ -4,7 +4,7 @@
# Written in 2023 by Alfonso Sabato Siciliano
OUTPUT = bsddialog
export VERSION=1.0.4
export VERSION=1.0.5
.CURDIR ?= ${CURDIR}
LIBPATH = ${.CURDIR}/lib
LIBBSDDIALOG = ${LIBPATH}/libbsddialog.so
@@ -22,7 +22,15 @@ DEBUG ?=
export ENABLEDEBUG=${DEBUG}
###################
all : ${OUTPUT}
all: ${OUTPUT}
install: all
${MAKE} -C ${LIBPATH} install
${MAKE} -C ${UTILITYPATH} install
uninstall:
${MAKE} -C ${UTILITYPATH} uninstall
${MAKE} -C ${LIBPATH} uninstall
${OUTPUT}: ${LIBBSDDIALOG}
${MAKE} -C ${UTILITYPATH} LIBPATH=${LIBPATH}
@@ -36,3 +44,4 @@ clean:
${MAKE} -C ${UTILITYPATH} clean
${RM} ${OUTPUT} *.core
.PHONY: all install uninstall clean
+2 -3
View File
@@ -1,4 +1,4 @@
# BSDDialog 1.0.4
# BSDDialog 1.0.5
This project provides **bsddialog** and **libbsddialog**, an utility
and a library to build scripts and tools with TUI dialogs and widgets.
@@ -129,7 +129,6 @@ in the _Public Domain_ to build new projects:
- implement global buttons handler.
- doc: external tutorial, theming guide.
- implement menutype.min\_on.
- improve refresh at startup, avoid dialog refresh before drawing text.
- add debug API: bsddialog\_debug(y,x,refresh,"fmt",...).
- add mouse support.
- use alarm(2) for bsddialog\_pause.
@@ -139,4 +138,4 @@ in the _Public Domain_ to build new projects:
- fix --mixedform "" 0 0 0 Label 1 0 Init 1 12 0 0 2 (with 0 editable field).
- add *text* customization to --hmsg *help-message*
- check --passwordform *fieldlen* like --form and --mixedform.
- add manuals to Makefiles installe and uninstall targets.
+5 -3
View File
@@ -8,14 +8,16 @@
# worldwide. This software is distributed without any warranty, see:
# <http://creativecommons.org/publicdomain/zero/1.0/>.
set -x
libpath=../lib
examples="menu checklist radiolist mixedlist theme infobox yesno msgbox \
datebox form timebox rangebox pause calendar gauge mixedgauge"
datebox form timebox rangebox pause calendar gauge mixedgauge textbox"
rm -f $examples
for e in $examples
do
cc -g -Wall -Wextra -I$libpath ${e}.c -o $e -L$libpath -lbsddialog \
-Wl,-rpath=$libpath
cc -g -Wall -Wextra -I$libpath ${e}.c -o $e \
-Wl,-rpath=$libpath -L$libpath -lbsddialog
done
@@ -0,0 +1,38 @@
/*-
* SPDX-License-Identifier: CC0-1.0
*
* Written in 2025 by Alfonso Sabato Siciliano.
* To the extent possible under law, the author has dedicated all copyright
* and related and neighboring rights to this software to the public domain
* worldwide. This software is distributed without any warranty, see:
* <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
#include <bsddialog.h>
#include <stdio.h>
int main()
{
int output;
struct bsddialog_conf conf;
if (bsddialog_init() == BSDDIALOG_ERROR) {
printf("Error: %s\n", bsddialog_geterror());
return (1);
}
bsddialog_initconf(&conf);
conf.title = "textbox";
output = bsddialog_textbox(&conf, "./textbox.c", 20, 80);
bsddialog_end();
switch (output) {
case BSDDIALOG_ERROR:
printf("Error %s\n", bsddialog_geterror());
return (1);
case BSDDIALOG_OK:
printf("[Exit]\n");
break;
}
return (0);
}
+18 -1
View File
@@ -9,6 +9,7 @@ HEADERS = bsddialog.h bsddialog_theme.h bsddialog_progressview.h
SOURCES = barbox.c datebox.c formbox.c libbsddialog.c lib_util.c \
menubox.c messagebox.c textbox.c theme.c timebox.c
OBJECTS = $(SOURCES:.c=.o)
PREFIX = /usr/local
ifneq ($(ENABLEDEBUG),)
CFLAGS += -g
@@ -21,7 +22,21 @@ LIBFLAG = -shared
RM = rm -f
LN = ln -s -f
all : $(LIBRARY)
all: $(LIBRARY)
install: all
${INSTALL} -m 0644 bsddialog.h ${DESTDIR}${PREFIX}/include/bsddialog.h
${INSTALL} -m 0644 bsddialog_progressview.h ${DESTDIR}${PREFIX}/include/bsddialog_progressview.h
${INSTALL} -m 0644 bsddialog_theme.h ${DESTDIR}${PREFIX}/include/bsddialog_theme.h
${INSTALL} -m 0755 ${LIBRARY_SO}.${VERSION} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}.${VERSION}
${LN} ${LIBRARY_SO}.${VERSION} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}
uninstall:
${RM} ${DESTDIR}${PREFIX}/include/bsddialog.h
${RM} ${DESTDIR}${PREFIX}/include/bsddialog_progressview.h
${RM} ${DESTDIR}${PREFIX}/include/bsddialog_theme.h
${RM} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}.${VERSION}
${RM} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}
$(LIBRARY): $(OBJECTS)
$(CC) $(LIBFLAG) $^ -o $(LIBRARY_SO).$(VERSION) $(LDFLAGS)
@@ -32,3 +47,5 @@ $(LIBRARY): $(OBJECTS)
clean:
$(RM) $(LIBRARY_SO)* *.o *~
.PHONY: all install uninstall ${LIBRARY} clean
+20 -1
View File
@@ -10,6 +10,7 @@ HEADERS = bsddialog.h bsddialog_theme.h bsddialog_progressview.h
SOURCES = barbox.c datebox.c formbox.c libbsddialog.c lib_util.c \
menubox.c messagebox.c textbox.c theme.c timebox.c
OBJECTS = ${SOURCES:.c=.o}
PREFIX = /usr/local
.if defined(DEBUG)
CFLAGS += -g
@@ -23,7 +24,23 @@ LDFLAGS += -fstack-protector-strong -shared -Wl,-x -Wl,--fatal-warnings \
LN = ln -s -f
RM = rm -f
all : ${LIBRARY}
all: ${LIBRARY}
install: all
${INSTALL} -m 0644 bsddialog.h ${DESTDIR}${PREFIX}/include/bsddialog.h
${INSTALL} -m 0644 bsddialog_progressview.h ${DESTDIR}${PREFIX}/include/bsddialog_progressview.h
${INSTALL} -m 0644 bsddialog_theme.h ${DESTDIR}${PREFIX}/include/bsddialog_theme.h
${INSTALL} -m 0644 ${LIBRARY_A} ${DESTDIR}${PREFIX}/lib/${LIBRARY_A}
${INSTALL} -m 0755 ${LIBRARY_SO}.${VERSION} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}.${VERSION}
${LN} ${LIBRARY_SO}.${VERSION} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}
uninstall:
${RM} ${DESTDIR}${PREFIX}/include/bsddialog.h
${RM} ${DESTDIR}${PREFIX}/include/bsddialog_progressview.h
${RM} ${DESTDIR}${PREFIX}/include/bsddialog_theme.h
${RM} ${DESTDIR}${PREFIX}/lib/${LIBRARY_A}
${RM} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}.${VERSION}
${RM} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}
${LIBRARY}: ${LIBRARY_SO} ${LIBRARY_A}
@@ -42,3 +59,5 @@ ${LIBRARY_A}: ${OBJECTS}
clean:
${RM} ${LIBRARY_SO}* *.o *~ *.gz ${LIBRARY_A}
.PHONY: all install uninstall ${LIBRARY} clean
+19 -18
View File
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2021-2024 Alfonso Sabato Siciliano
* Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -371,7 +371,7 @@ bsddialog_progressview (struct bsddialog_conf *conf, const char *text, int rows,
unsigned int i, mainperc, totaltodo;
float readforsec;
const char **minilabels;
time_t tstart, told, tnew, refresh;
time_t tstart, told, tnew, trefresh;
if ((minilabels = calloc(nminibar, sizeof(char*))) == NULL)
RETURN_ERROR("Cannot allocate memory for minilabels");
@@ -385,7 +385,7 @@ bsddialog_progressview (struct bsddialog_conf *conf, const char *text, int rows,
minipercs[i] = minibar[i].status;
}
refresh = pvconf->refresh == 0 ? 0 : pvconf->refresh - 1;
trefresh = pvconf->refresh == 0 ? 0 : pvconf->refresh - 1;
retval = BSDDIALOG_OK;
i = 0;
update = true;
@@ -398,7 +398,7 @@ bsddialog_progressview (struct bsddialog_conf *conf, const char *text, int rows,
mainperc = (bsddialog_total_progview * 100) / totaltodo;
time(&tnew);
if (update || tnew > told + refresh) {
if (update || tnew > told + trefresh) {
retval = do_mixedgauge(conf, text, rows, cols, mainperc,
nminibar, minilabels, minipercs, true);
if (retval == BSDDIALOG_ERROR)
@@ -440,17 +440,18 @@ bsddialog_progressview (struct bsddialog_conf *conf, const char *text, int rows,
return (retval);
}
static int rangebox_redraw(struct dialog *d, struct bar *b, int *bigchange)
static int
rangebox_redraw(struct dialog *d, bool redraw, struct bar *b, int *bigchange)
{
if (d->built) {
if (redraw) {
hide_dialog(d);
refresh(); /* Important for decreasing screen */
}
if (dialog_size_position(d, HBOX, MIN_WBOX, NULL) != 0)
return (BSDDIALOG_ERROR);
if (draw_dialog(d) != 0)
if (draw_dialog(d) != 0) /* doupdate() in main loop */
return (BSDDIALOG_ERROR);
if (d->built)
if (redraw)
refresh(); /* Important to fix grey lines expanding screen */
TEXTPAD(d, HBOX + HBUTTONS);
@@ -490,7 +491,7 @@ bsddialog_rangebox(struct bsddialog_conf *conf, const char *text, int rows,
RETURN_ERROR("Cannot build WINDOW bar");
b.y = b.x = 1;
b.fmt = "%d";
if (rangebox_redraw(&d, &b, &bigchange) != 0)
if (rangebox_redraw(&d, false, &b, &bigchange) != 0)
return (BSDDIALOG_ERROR);
loop = true;
@@ -568,12 +569,12 @@ bsddialog_rangebox(struct bsddialog_conf *conf, const char *text, int rows,
break;
if (f1help_dialog(conf) != 0)
return (BSDDIALOG_ERROR);
if (rangebox_redraw(&d, &b, &bigchange) != 0)
if (rangebox_redraw(&d, true, &b, &bigchange) != 0)
return (BSDDIALOG_ERROR);
break;
case KEY_CTRL('l'):
case KEY_RESIZE:
if (rangebox_redraw(&d, &b, &bigchange) != 0)
if (rangebox_redraw(&d, true, &b, &bigchange) != 0)
return (BSDDIALOG_ERROR);
break;
default:
@@ -594,17 +595,17 @@ bsddialog_rangebox(struct bsddialog_conf *conf, const char *text, int rows,
return (retval);
}
static int pause_redraw(struct dialog *d, struct bar *b)
static int pause_redraw(struct dialog *d, bool redraw, struct bar *b)
{
if (d->built) {
if (redraw) {
hide_dialog(d);
refresh(); /* Important for decreasing screen */
}
if (dialog_size_position(d, HBOX, MIN_WBOX, NULL) != 0)
return (BSDDIALOG_ERROR);
if (draw_dialog(d) != 0)
if (draw_dialog(d) != 0) /* doupdate() in main loop */
return (BSDDIALOG_ERROR);
if (d->built)
if (redraw)
refresh(); /* Important to fix grey lines expanding screen */
TEXTPAD(d, HBOX + HBUTTONS);
@@ -633,7 +634,7 @@ bsddialog_pause(struct bsddialog_conf *conf, const char *text, int rows,
RETURN_ERROR("Cannot build WINDOW bar");
b.y = b.x = 1;
b.fmt = "%d";
if (pause_redraw(&d, &b) != 0)
if (pause_redraw(&d, false, &b) != 0)
return (BSDDIALOG_ERROR);
tout = *seconds;
@@ -687,12 +688,12 @@ bsddialog_pause(struct bsddialog_conf *conf, const char *text, int rows,
break;
if (f1help_dialog(conf) != 0)
return (BSDDIALOG_ERROR);
if (pause_redraw(&d, &b) != 0)
if (pause_redraw(&d, true, &b) != 0)
return (BSDDIALOG_ERROR);
break;
case KEY_CTRL('l'):
case KEY_RESIZE:
if (pause_redraw(&d, &b) != 0)
if (pause_redraw(&d, true, &b) != 0)
return (BSDDIALOG_ERROR);
break;
default:
+12 -4
View File
@@ -1,5 +1,5 @@
.\"
.\" Copyright (c) 2021-2024 Alfonso Sabato Siciliano
.\" Copyright (c) 2021-2025 Alfonso Sabato Siciliano
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@@ -22,11 +22,12 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd March 16, 2024
.Dd June 22, 2025
.Dt BSDDIALOG 3
.Os
.Sh NAME
.Nm bsddialog_backtitle ,
.Nm bsddialog_backtitle_rf ,
.Nm bsddialog_calendar ,
.Nm bsddialog_clear ,
.Nm bsddialog_color ,
@@ -65,6 +66,8 @@
.Ft int
.Fn bsddialog_backtitle "struct bsddialog_conf *conf" "const char *backtitle"
.Ft int
.Fn bsddialog_backtitle_rf "struct bsddialog_conf *conf" "const char *backtitle"
.Ft int
.Fo bsddialog_calendar
.Fa "struct bsddialog_conf *conf"
.Fa "const char *text"
@@ -292,7 +295,7 @@ and before
.Dv false
otherwise.
.Pp
.Fn bsddialog_backtitle
.Fn bsddialog_backtitle_rf
prints
.Fa backtitle
on the top of the screen.
@@ -302,6 +305,11 @@ and
.Fa conf.no_lines
described later.
.Pp
.Fn bsddialog_backtitle
is like
.Fn bsddialog_backtitle_rf
but it does not update the screen, using if a dialog is built later.
.Pp
.Fn bsddialog_error
returns a string to describe the last error.
The function should be called after a
@@ -902,7 +910,7 @@ provides a dialog for a
the labels on buttons are
.Dq Yes
and
.Dq No .
.Dq &No .
.Ss Keys
.Bl -tag -width Ds
.It Ctrl-l
+3 -2
View File
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2021-2024 Alfonso Sabato Siciliano
* Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,7 +30,7 @@
#include <stdbool.h>
#define LIBBSDDIALOG_VERSION "1.0.4"
#define LIBBSDDIALOG_VERSION "1.0.5"
/* Return values */
#define BSDDIALOG_ERROR -1
@@ -179,6 +179,7 @@ int bsddialog_init_notheme(void);
bool bsddialog_inmode(void);
int bsddialog_end(void);
int bsddialog_backtitle(struct bsddialog_conf *conf, const char *backtitle);
int bsddialog_backtitle_rf(struct bsddialog_conf *conf, const char *backtitle);
int bsddialog_initconf(struct bsddialog_conf *conf);
void bsddialog_clear(unsigned int y);
void bsddialog_refresh(void);
+1 -1
View File
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2021-2023 Alfonso Sabato Siciliano
* Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
+14 -14
View File
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2022-2024 Alfonso Sabato Siciliano
* Copyright (c) 2022-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -296,20 +296,20 @@ print_calendar(struct bsddialog_conf *conf, WINDOW *win, int yy, int mm, int dd,
}
static int
calendar_redraw(struct dialog *d, WINDOW *yy_win, WINDOW *mm_win,
calendar_draw(struct dialog *d, bool redraw, WINDOW *yy_win, WINDOW *mm_win,
WINDOW *dd_win)
{
int ycal, xcal;
if (d->built) {
if (redraw) {
hide_dialog(d);
refresh(); /* Important for decreasing screen */
}
if (dialog_size_position(d, MINHCAL, MINWCAL, NULL) != 0)
return (BSDDIALOG_ERROR);
if (draw_dialog(d) != 0)
if (draw_dialog(d) != 0) /* doupdate in main loop */
return (BSDDIALOG_ERROR);
if (d->built)
if (redraw)
refresh(); /* Important to fix grey lines expanding screen */
TEXTPAD(d, MINHCAL + HBUTTONS);
@@ -354,7 +354,7 @@ bsddialog_calendar(struct bsddialog_conf *conf, const char *text, int rows,
if ((dd_win = newwin(1, 1, 1, 1)) == NULL)
RETURN_ERROR("Cannot build WINDOW for dd");
wbkgd(dd_win, t.dialog.color);
if (calendar_redraw(&d, yy_win, mm_win, dd_win) != 0)
if (calendar_draw(&d, false, yy_win, mm_win, dd_win) != 0)
return (BSDDIALOG_ERROR);
sel = -1;
@@ -503,12 +503,12 @@ bsddialog_calendar(struct bsddialog_conf *conf, const char *text, int rows,
break;
if (f1help_dialog(conf) != 0)
return (BSDDIALOG_ERROR);
if (calendar_redraw(&d, yy_win, mm_win, dd_win) != 0)
if (calendar_draw(&d, true, yy_win, mm_win, dd_win) != 0)
return (BSDDIALOG_ERROR);
break;
case KEY_CTRL('l'):
case KEY_RESIZE:
if (calendar_redraw(&d, yy_win, mm_win, dd_win) != 0)
if (calendar_draw(&d, true, yy_win, mm_win, dd_win) != 0)
return (BSDDIALOG_ERROR);
break;
default:
@@ -533,11 +533,11 @@ bsddialog_calendar(struct bsddialog_conf *conf, const char *text, int rows,
return (retval);
}
static int datebox_redraw(struct dialog *d, struct dateitem *di)
static int datebox_draw(struct dialog *d, bool redraw, struct dateitem *di)
{
int y, x;
if (d->built) {
if (redraw) {
hide_dialog(d);
refresh(); /* Important for decreasing screen */
}
@@ -545,7 +545,7 @@ static int datebox_redraw(struct dialog *d, struct dateitem *di)
return (BSDDIALOG_ERROR);
if (draw_dialog(d) != 0)
return (BSDDIALOG_ERROR);
if (d->built)
if (redraw)
refresh(); /* Important to fix grey lines expanding screen */
TEXTPAD(d, 3 /*windows*/ + HBUTTONS);
@@ -624,7 +624,7 @@ bsddialog_datebox(struct bsddialog_conf *conf, const char *text, int rows,
set_buttons(&d, true, OK_LABEL, CANCEL_LABEL);
if (build_dateitem(conf->date.format, &yy, &mm, &dd, di) != 0)
return (BSDDIALOG_ERROR);
if (datebox_redraw(&d, di) != 0)
if (datebox_draw(&d, false, di) != 0)
return (BSDDIALOG_ERROR);
sel = -1;
@@ -716,12 +716,12 @@ bsddialog_datebox(struct bsddialog_conf *conf, const char *text, int rows,
break;
if (f1help_dialog(conf) != 0)
return (BSDDIALOG_ERROR);
if (datebox_redraw(&d, di) != 0)
if (datebox_draw(&d, true, di) != 0)
return (BSDDIALOG_ERROR);
break;
case KEY_CTRL('l'):
case KEY_RESIZE:
if (datebox_redraw(&d, di) != 0)
if (datebox_draw(&d, true, di) != 0)
return (BSDDIALOG_ERROR);
break;
default:
+34 -14
View File
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2021-2024 Alfonso Sabato Siciliano
* Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -601,11 +601,11 @@ static int form_size_position(struct dialog *d, struct privateform *f)
}
static int
form_redraw(struct dialog *d, struct privateform *f, bool focusinform)
form_draw(struct dialog *d, bool redraw, struct privateform *f, bool focusinform)
{
unsigned int i;
if (d->built) {
if (redraw) {
hide_dialog(d);
refresh(); /* Important for decreasing screen */
}
@@ -613,9 +613,9 @@ form_redraw(struct dialog *d, struct privateform *f, bool focusinform)
f->w = f->wmin;
if (form_size_position(d, f) != 0)
return (BSDDIALOG_ERROR);
if (draw_dialog(d) != 0)
if (draw_dialog(d) != 0) /* doupdate() in main loop */
return (BSDDIALOG_ERROR);
if (d->built)
if (redraw)
refresh(); /* Important to fix grey lines expanding screen */
TEXTPAD(d, 2 /* box borders */ + f->viewrows + HBUTTONS);
@@ -707,7 +707,7 @@ bsddialog_form(struct bsddialog_conf *conf, const char *text, int rows,
}
form.formheight = formheight;
if (form_redraw(&d, &form, focusinform) != 0)
if (form_draw(&d, false, &form, focusinform) != 0)
return (BSDDIALOG_ERROR);
changeitem = switchfocus = false;
@@ -719,10 +719,16 @@ bsddialog_form(struct bsddialog_conf *conf, const char *text, int rows,
switch(input) {
case KEY_ENTER:
case 10: /* Enter */
if (focusinform && conf->button.always_active == false)
break;
retval = BUTTONVALUE(d.bs);
loop = false;
if (focusinform && conf->button.always_active == false) {
next = nextitem(form.nitems, form.pritems, form.sel);
if (next > form.sel)
changeitem = true; /* needs next */
else
switchfocus = true;
} else {
retval = BUTTONVALUE(d.bs);
loop = false;
}
break;
case 27: /* Esc */
if (conf->key.enable_esc) {
@@ -732,7 +738,12 @@ bsddialog_form(struct bsddialog_conf *conf, const char *text, int rows,
break;
case '\t': /* TAB */
if (focusinform) {
switchfocus = true;
next = nextitem(form.nitems, form.pritems,
form.sel);
if (next > form.sel)
changeitem = true; /* needs next */
else
switchfocus = true;
} else {
if (d.bs.curr + 1 < (int)d.bs.nbuttons) {
d.bs.curr++;
@@ -839,12 +850,12 @@ bsddialog_form(struct bsddialog_conf *conf, const char *text, int rows,
retval = BSDDIALOG_ERROR;
loop = false;
}
if (form_redraw(&d, &form, focusinform) != 0)
if (form_draw(&d, true, &form, focusinform) != 0)
return (BSDDIALOG_ERROR);
break;
case KEY_CTRL('l'):
case KEY_RESIZE:
if (form_redraw(&d, &form, focusinform) != 0)
if (form_draw(&d, true, &form, focusinform) != 0)
return (BSDDIALOG_ERROR);
break;
default:
@@ -884,11 +895,20 @@ bsddialog_form(struct bsddialog_conf *conf, const char *text, int rows,
conf->button.always_active || !focusinform,
!focusinform);
wnoutrefresh(d.widget);
DRAWITEM_TRICK(&form, form.sel, focusinform);
if (focusinform == false)
DRAWITEM_TRICK(&form, form.sel, false);
else {
next = firstitem(form.nitems, form.pritems);
if (next == form.sel)
DRAWITEM_TRICK(&form, form.sel, true);
else
changeitem = true;
}
switchfocus = false;
}
if (changeitem) {
/* useless after if(switchfocus) */
DRAWITEM_TRICK(&form, form.sel, false);
form.sel = next;
item = &form.pritems[form.sel];
+2 -1
View File
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2021-2023 Alfonso Sabato Siciliano
* Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,6 +25,7 @@
* SUCH DAMAGE.
*/
#include <stdarg.h>
#include <curses.h>
#include <stdlib.h>
#include <string.h>
+2 -2
View File
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2021-2024 Alfonso Sabato Siciliano
* Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -62,7 +62,7 @@ extern bool hastermcolors;
RETURN_ERROR("*" #p " is NULL"); \
} while (0)
#define CHECK_ARRAY(nitem, a) do { \
if (nitem > 0 && a == NULL) \
if (nitem > 0 && a == NULL) \
RETURN_FMTERROR(#nitem " is %d but *" #a " is NULL", nitem); \
} while (0)
/* widget utils */
+12 -2
View File
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2021-2023 Alfonso Sabato Siciliano
* Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -114,11 +114,21 @@ int bsddialog_backtitle(struct bsddialog_conf *conf, const char *backtitle)
mvhline_set(1, 1, WACS_HLINE, SCREENCOLS - 2);
}
refresh();
wnoutrefresh(stdscr);
return (BSDDIALOG_OK);
}
int bsddialog_backtitle_rf(struct bsddialog_conf *conf, const char *backtitle)
{
int rv;
rv = bsddialog_backtitle(conf, backtitle);
doupdate();
return (rv);
}
bool bsddialog_inmode(void)
{
return (in_bsddialog_mode);
+9 -9
View File
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2021-2024 Alfonso Sabato Siciliano
* Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -391,7 +391,7 @@ drawitem(struct bsddialog_conf *conf, struct privatemenu *m, int y, bool focus)
attron(t.menu.bottomdesccolor);
addstr(pritem->bottomdesc);
attroff(t.menu.bottomdesccolor);
refresh();
wnoutrefresh(stdscr);
}
}
}
@@ -454,18 +454,18 @@ static int menu_size_position(struct dialog *d, struct privatemenu *m)
return (0);
}
static int mixedlist_redraw(struct dialog *d, struct privatemenu *m)
static int mixedlist_draw(struct dialog *d, bool redraw, struct privatemenu *m)
{
if (d->built) {
if (redraw) {
hide_dialog(d);
refresh(); /* Important for decreasing screen */
}
m->menurows = m->apimenurows;
if (menu_size_position(d, m) != 0)
return (BSDDIALOG_ERROR);
if (draw_dialog(d) != 0)
if (draw_dialog(d) != 0) /* doupdate() in main loop */
return (BSDDIALOG_ERROR);
if (d->built)
if (redraw)
refresh(); /* Important to fix grey lines expanding screen */
TEXTPAD(d, 2/*bmenu*/ + m->menurows + HBUTTONS);
@@ -532,7 +532,7 @@ do_mixedlist(struct bsddialog_conf *conf, const char *text, int rows, int cols,
drawitem(d.conf, &m, m.sel, true);
m.ypad = 0;
m.apimenurows = menurows;
if (mixedlist_redraw(&d, &m) != 0)
if (mixedlist_draw(&d, false, &m) != 0)
return (BSDDIALOG_ERROR);
changeitem = false;
@@ -575,12 +575,12 @@ do_mixedlist(struct bsddialog_conf *conf, const char *text, int rows, int cols,
break;
if (f1help_dialog(conf) != 0)
return (BSDDIALOG_ERROR);
if (mixedlist_redraw(&d, &m) != 0)
if (mixedlist_draw(&d, true, &m) != 0)
return (BSDDIALOG_ERROR);
break;
case KEY_CTRL('l'):
case KEY_RESIZE:
if (mixedlist_redraw(&d, &m) != 0)
if (mixedlist_draw(&d, true, &m) != 0)
return (BSDDIALOG_ERROR);
break;
}
+8 -8
View File
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2021-2024 Alfonso Sabato Siciliano
* Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -69,19 +69,19 @@ static int message_size_position(struct dialog *d, int *htext)
return (0);
}
static int message_draw(struct dialog *d, struct scroll *s)
static int message_draw(struct dialog *d, bool redraw, struct scroll *s)
{
int unused;
if (d->built) {
if (redraw) { /* redraw: RESIZE or F1 */
hide_dialog(d);
refresh(); /* Important for decreasing screen */
}
if (message_size_position(d, &s->htext) != 0)
return (BSDDIALOG_ERROR);
if (draw_dialog(d) != 0)
if (draw_dialog(d) != 0) /* doupdate() in main loop */
return (BSDDIALOG_ERROR);
if (d->built)
if (redraw)
refresh(); /* Important to fix grey lines expanding screen */
s->printrows = d->h - BORDER - HBUTTONS - BORDER;
@@ -106,7 +106,7 @@ do_message(struct bsddialog_conf *conf, const char *text, int rows, int cols,
return (BSDDIALOG_ERROR);
set_buttons(&d, true, oklabel, cancellabel);
s.htext = -1;
if (message_draw(&d, &s) != 0)
if (message_draw(&d, false, &s) != 0)
return (BSDDIALOG_ERROR);
loop = true;
@@ -170,12 +170,12 @@ do_message(struct bsddialog_conf *conf, const char *text, int rows, int cols,
break;
if (f1help_dialog(d.conf) != 0)
return (BSDDIALOG_ERROR);
if (message_draw(&d, &s) != 0)
if (message_draw(&d, true, &s) != 0)
return (BSDDIALOG_ERROR);
break;
case KEY_CTRL('l'):
case KEY_RESIZE:
if (message_draw(&d, &s) != 0)
if (message_draw(&d, true, &s) != 0)
return (BSDDIALOG_ERROR);
break;
default:
+8 -8
View File
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2021-2024 Alfonso Sabato Siciliano
* Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -101,17 +101,17 @@ static int textbox_size_position(struct dialog *d, struct scrolltext *st)
return (0);
}
static int textbox_draw(struct dialog *d, struct scrolltext *st)
static int textbox_draw(struct dialog *d, bool redraw, struct scrolltext *st)
{
if (d->built) {
if (redraw) {
hide_dialog(d);
refresh(); /* Important for decreasing screen */
}
if (textbox_size_position(d, st) != 0)
return (BSDDIALOG_ERROR);
if (draw_dialog(d) != 0)
if (draw_dialog(d) != 0) /* wrefresh() and prefresh() in main loop */
return (BSDDIALOG_ERROR);
if (d->built)
if (redraw)
refresh(); /* Important to fix grey lines expanding screen */
st->ys = d->y + 1;
@@ -175,7 +175,7 @@ bsddialog_textbox(struct bsddialog_conf *conf, const char *file, int rows,
fclose(fp);
set_tabsize(defaulttablen); /* reset because it is curses global */
if (textbox_draw(&d, &st) != 0)
if (textbox_draw(&d, false, &st) != 0)
return (BSDDIALOG_ERROR);
loop = true;
@@ -254,12 +254,12 @@ bsddialog_textbox(struct bsddialog_conf *conf, const char *file, int rows,
break;
if (f1help_dialog(conf) != 0)
return (BSDDIALOG_ERROR);
if (textbox_draw(&d, &st) != 0)
if (textbox_draw(&d, true, &st) != 0)
return (BSDDIALOG_ERROR);
break;
case KEY_CTRL('l'):
case KEY_RESIZE:
if (textbox_draw(&d, &st) != 0)
if (textbox_draw(&d, true, &st) != 0)
return (BSDDIALOG_ERROR);
break;
}
Loaded 100 of 2464 files, more files were not shown because too many files have changed in this diff. Show more