git: 6a8ca2ff5338 - stable/14 - __cxa_thread_call_dtors(3): fix dtor pointer validity check

2024-05-10 Thread Konstantin Belousov
The branch stable/14 has been updated by kib:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=6a8ca2ff53389c36233e5e0b1576696d34b74407

commit 6a8ca2ff53389c36233e5e0b1576696d34b74407
Author: Konstantin Belousov 
AuthorDate: 2024-05-03 09:32:01 +
Commit: Konstantin Belousov 
CommitDate: 2024-05-10 07:49:10 +

__cxa_thread_call_dtors(3): fix dtor pointer validity check

PR: 278701

(cherry picked from commit b27eb9ce96b838622e125fd969e8dc4914aabe18)
---
 lib/libc/stdlib/cxa_thread_atexit_impl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/libc/stdlib/cxa_thread_atexit_impl.c 
b/lib/libc/stdlib/cxa_thread_atexit_impl.c
index f95384b30347..3123bd12dca8 100644
--- a/lib/libc/stdlib/cxa_thread_atexit_impl.c
+++ b/lib/libc/stdlib/cxa_thread_atexit_impl.c
@@ -102,7 +102,7 @@ walk_cb_call(struct cxa_thread_dtor *dtor)
 {
struct dl_phdr_info phdr_info;
 
-   if (_rtld_addr_phdr(dtor->dso, &phdr_info) &&
+   if (_rtld_addr_phdr(dtor->func, &phdr_info) &&
__elf_phdr_match_addr(&phdr_info, dtor->func))
dtor->func(dtor->obj);
else



git: 5cf78a550034 - stable/13 - __cxa_thread_call_dtors(3): fix dtor pointer validity check

2024-05-10 Thread Konstantin Belousov
The branch stable/13 has been updated by kib:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=5cf78a5500345340771f7eb840724c2422b2ff96

commit 5cf78a5500345340771f7eb840724c2422b2ff96
Author: Konstantin Belousov 
AuthorDate: 2024-05-03 09:32:01 +
Commit: Konstantin Belousov 
CommitDate: 2024-05-10 07:49:36 +

__cxa_thread_call_dtors(3): fix dtor pointer validity check

PR: 278701

(cherry picked from commit b27eb9ce96b838622e125fd969e8dc4914aabe18)
---
 lib/libc/stdlib/cxa_thread_atexit_impl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/libc/stdlib/cxa_thread_atexit_impl.c 
b/lib/libc/stdlib/cxa_thread_atexit_impl.c
index 2ebf20ef7fd9..ef9f3567d483 100644
--- a/lib/libc/stdlib/cxa_thread_atexit_impl.c
+++ b/lib/libc/stdlib/cxa_thread_atexit_impl.c
@@ -103,7 +103,7 @@ walk_cb_call(struct cxa_thread_dtor *dtor)
 {
struct dl_phdr_info phdr_info;
 
-   if (_rtld_addr_phdr(dtor->dso, &phdr_info) &&
+   if (_rtld_addr_phdr(dtor->func, &phdr_info) &&
__elf_phdr_match_addr(&phdr_info, dtor->func))
dtor->func(dtor->obj);
else



git: e1ae31fc1155 - stable/13 - calendar: cleanup obsolete directories

2024-05-10 Thread Dag-Erling Smørgrav
The branch stable/13 has been updated by des:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=e1ae31fc1155ac2d4a346a7f7f07365a37d3285f

commit e1ae31fc1155ac2d4a346a7f7f07365a37d3285f
Author: Yuri Pankov 
AuthorDate: 2023-05-08 22:43:12 +
Commit: Dag-Erling Smørgrav 
CommitDate: 2024-05-10 08:55:46 +

calendar: cleanup obsolete directories

Follow 5282ada06bb and don't reinstall obsolete directories.

(cherry picked from commit 7adea6dbed35061e6175b7da69a47073916b3c25)
---
 etc/mtree/BSD.usr.dist | 20 
 1 file changed, 20 deletions(-)

diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist
index 0630708b9024..6e6b733c141d 100644
--- a/etc/mtree/BSD.usr.dist
+++ b/etc/mtree/BSD.usr.dist
@@ -196,26 +196,6 @@
 ..
 ..
 calendar
-de_AT.ISO_8859-15
-..
-de_DE.ISO8859-1
-..
-fr_FR.ISO8859-1
-..
-hr_HR.ISO8859-2
-..
-hu_HU.ISO8859-2
-..
-pt_BR.ISO8859-1
-..
-pt_BR.UTF-8
-..
-ru_RU.KOI8-R
-..
-ru_RU.UTF-8
-..
-uk_UA.KOI8-U
-..
 ..
 certs
 blacklisted tags=package=caroot



git: 44e72c6e2e6b - main - Add man page for nfslockd.

2024-05-10 Thread Dag-Erling Smørgrav
The branch main has been updated by des:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=44e72c6e2e6bcfa2cba89afb92fa05f6ac4d5660

commit 44e72c6e2e6bcfa2cba89afb92fa05f6ac4d5660
Author: Dag-Erling Smørgrav 
AuthorDate: 2024-05-10 09:23:13 +
Commit: Dag-Erling Smørgrav 
CommitDate: 2024-05-10 09:23:13 +

Add man page for nfslockd.

PR: 130238
MFC after:  3 days
Differential Revision:  https://reviews.freebsd.org/D45139
---
 share/man/man4/Makefile|  1 +
 share/man/man4/nfslockd.4  | 45 ++
 usr.sbin/rpc.lockd/lockd.c |  3 ++-
 usr.sbin/rpc.lockd/rpc.lockd.8 |  5 +++--
 4 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile
index c5ba7e46deb8..5deb4ddea874 100644
--- a/share/man/man4/Makefile
+++ b/share/man/man4/Makefile
@@ -341,6 +341,7 @@ MAN=aac.4 \
netlink.4 \
netmap.4 \
${_nfe.4} \
+   nfslockd.4 \
${_nfsmb.4} \
ng_async.4 \
ng_bpf.4 \
diff --git a/share/man/man4/nfslockd.4 b/share/man/man4/nfslockd.4
new file mode 100644
index ..770d9b8736b0
--- /dev/null
+++ b/share/man/man4/nfslockd.4
@@ -0,0 +1,45 @@
+.\"-
+.\" Copyright (c) 2024 Dag-Erling Smørgrav
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.Dd May 8, 2024
+.Dt NFSLOCKD 4
+.Os
+.Sh NAME
+.Nm nfslockd
+.Nd NFS advisory locking
+.Sh SYNOPSIS
+To compile this driver into the kernel, place the following lines in
+your kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "options NFSLOCKD"
+.Ed
+.Pp
+Alternatively, to load the driver as a module at boot time, place the
+following line in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+nfslockd_load="YES"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+driver provides kernel support for NFSv3 advisory locking.
+It works in tandem with
+.Xr rpc.lockd 8 ,
+which will normally load it on startup if it is not already loaded or
+compiled-in.
+.Sh SEE ALSO
+.Xr rpc.lockd 8
+.Sh HISTORY
+The
+.Nm
+driver first appeared in
+.Fx 6.4 .
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+driver was written by
+.An Doug Rabson Aq Mt d...@freebsd.org .
diff --git a/usr.sbin/rpc.lockd/lockd.c b/usr.sbin/rpc.lockd/lockd.c
index 7e0652d26533..0ac7ddfeea5c 100644
--- a/usr.sbin/rpc.lockd/lockd.c
+++ b/usr.sbin/rpc.lockd/lockd.c
@@ -188,7 +188,8 @@ main(int argc, char **argv)
kernel_lockd_client = FALSE;
if (modfind("nfslockd") < 0) {
if (kldload("nfslockd") < 0) {
-   fprintf(stderr, "Can't find or load kernel support for 
rpc.lockd - using non-kernel implementation\n");
+   fprintf(stderr, "Unable to load nfslockd(4), "
+   "using userland implementation\n");
} else {
kernel_lockd = TRUE;
}
diff --git a/usr.sbin/rpc.lockd/rpc.lockd.8 b/usr.sbin/rpc.lockd/rpc.lockd.8
index 89f55087901d..89592a1cceaf 100644
--- a/usr.sbin/rpc.lockd/rpc.lockd.8
+++ b/usr.sbin/rpc.lockd/rpc.lockd.8
@@ -27,7 +27,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd November 21, 2019
+.Dd May 8, 2024
 .Dt RPC.LOCKD 8
 .Os
 .Sh NAME
@@ -44,7 +44,7 @@
 The
 .Nm
 utility provides monitored and unmonitored file and record locking services
-in an NFS environment.
+in an NFSv3 environment.
 To monitor the status of hosts requesting locks,
 the locking daemon typically operates in conjunction
 with
@@ -137,6 +137,7 @@ RPC protocol specification for the network lock manager 
protocol.
 .El
 .Sh SEE ALSO
 .Xr syslog 3 ,
+.Xr nfslockd 4 ,
 .Xr rc.conf 5 ,
 .Xr rpc.statd 8
 .Sh STANDARDS



git: e353ac0cfd5d - main - am64: Allow cpu.h to be included from assembly

2024-05-10 Thread Andrew Turner
The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=e353ac0cfd5d155c01253ee17c2bf23f888cb7de

commit e353ac0cfd5d155c01253ee17c2bf23f888cb7de
Author: Andrew Turner 
AuthorDate: 2024-05-03 16:07:29 +
Commit: Andrew Turner 
CommitDate: 2024-05-10 09:29:24 +

am64: Allow cpu.h to be included from assembly

Reviewed by:jhibbits, kevans
Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D45081
---
 sys/arm64/include/cpu.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/sys/arm64/include/cpu.h b/sys/arm64/include/cpu.h
index 8f5a9e3dbd3c..91ed3634c6d8 100644
--- a/sys/arm64/include/cpu.h
+++ b/sys/arm64/include/cpu.h
@@ -42,8 +42,10 @@
 #ifndef _MACHINE_CPU_H_
 #define_MACHINE_CPU_H_
 
+#if !defined(__ASSEMBLER__)
 #include 
 #include 
+#endif
 #include 
 
 #defineTRAPF_PC(tfp)   ((tfp)->tf_elr)
@@ -198,6 +200,7 @@
 #defineCPU_MATCH_ERRATA_CAVIUM_THUNDERX_1_10
 #endif
 
+#if !defined(__ASSEMBLER__)
 extern char btext[];
 extern char etext[];
 
@@ -268,6 +271,7 @@ ADDRESS_TRANSLATE_FUNC(s1e0w)
 ADDRESS_TRANSLATE_FUNC(s1e1r)
 ADDRESS_TRANSLATE_FUNC(s1e1w)
 
+#endif /* !__ASSEMBLER__ */
 #endif
 
 #endif /* !_MACHINE_CPU_H_ */



git: c78ebc69c2aa - main - arm64: Support a shared release for spin-table

2024-05-10 Thread Andrew Turner
The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c78ebc69c2aa5454b4dc8fd7451b3b0d031205b8

commit c78ebc69c2aa5454b4dc8fd7451b3b0d031205b8
Author: Andrew Turner 
AuthorDate: 2024-04-29 14:23:42 +
Commit: Andrew Turner 
CommitDate: 2024-05-10 09:29:24 +

arm64: Support a shared release for spin-table

When releasing multiple CPUs that share a release address we need them
to wait for their turn to boot. Add a mechanism to do this by booting
them until they enable the TLB before waiting their turn to enter
init_secondary.

Reviewed by:jhibbits, kevans
Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D45082
---
 sys/arm64/arm64/locore.S | 55 
 sys/arm64/arm64/mp_machdep.c | 21 +
 2 files changed, 67 insertions(+), 9 deletions(-)

diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S
index fd77938edae9..94a50b735bc6 100644
--- a/sys/arm64/arm64/locore.S
+++ b/sys/arm64/arm64/locore.S
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -192,12 +193,50 @@ END(_start)
 
 #ifdef SMP
 /*
- * mpentry(unsigned long)
+ * void
+ * mpentry_psci(unsigned long)
  *
- * Called by a core when it is being brought online.
+ * Called by a core when it is being brought online with psci.
  * The data in x0 is passed straight to init_secondary.
  */
-ENTRY(mpentry)
+ENTRY(mpentry_psci)
+   mov x26, xzr
+   b   mpentry_common
+END(mpentry_psci)
+
+/*
+ * void
+ * mpentry_spintable(void)
+ *
+ * Called by a core when it is being brought online with a spin-table.
+ * Reads the new CPU ID and passes this to init_secondary.
+ */
+ENTRY(mpentry_spintable)
+   ldr x26, =spintable_wait
+   b   mpentry_common
+END(mpentry_spintable)
+
+/* Wait for the current CPU to be released */
+LENTRY(spintable_wait)
+   /* Read the affinity bits from mpidr_el1 */
+   mrs x1, mpidr_el1
+   ldr x2, =CPU_AFF_MASK
+   and x1, x1, x2
+
+   adrpx2, ap_cpuid
+1:
+   ldr x0, [x2, :lo12:ap_cpuid]
+   cmp x0, x1
+   b.ne1b
+
+   str xzr, [x2, :lo12:ap_cpuid]
+   dsb sy
+   sev
+
+   ret
+LEND(mpentry_spintable)
+
+LENTRY(mpentry_common)
/* Disable interrupts */
msr daifset, #DAIF_INTR
 
@@ -228,6 +267,14 @@ ENTRY(mpentry)
 mp_virtdone:
BTI_J
 
+   /*
+* Allow this CPU to wait until the kernel is ready for it,
+* e.g. with spin-table but each CPU uses the same release address
+*/
+   cbz x26, 1f
+   blr x26
+1:
+
/* Start using the AP boot stack */
adrpx4, bootstack
ldr x4, [x4, :lo12:bootstack]
@@ -258,7 +305,7 @@ mp_virtdone:
msr tpidr_el1, x18
 
b   init_secondary
-END(mpentry)
+LEND(mpentry_common)
 #endif
 
 /*
diff --git a/sys/arm64/arm64/mp_machdep.c b/sys/arm64/arm64/mp_machdep.c
index 9c6175445572..bd13dde9cee0 100644
--- a/sys/arm64/arm64/mp_machdep.c
+++ b/sys/arm64/arm64/mp_machdep.c
@@ -106,7 +106,8 @@ static void ipi_stop(void *);
 static u_int fdt_cpuid;
 #endif
 
-void mpentry(unsigned long cpuid);
+void mpentry_psci(unsigned long cpuid);
+void mpentry_spintable(void);
 void init_secondary(uint64_t);
 
 /* Synchronize AP startup. */
@@ -114,6 +115,7 @@ static struct mtx ap_boot_mtx;
 
 /* Used to initialize the PCPU ahead of calling init_secondary(). */
 void *bootpcpu;
+uint64_t ap_cpuid;
 
 /* Stacks for AP initialization, discarded once idle threads are started. */
 void *bootstack;
@@ -420,7 +422,10 @@ enable_cpu_spin(uint64_t cpu, vm_paddr_t entry, vm_paddr_t 
release_paddr)
 {
vm_paddr_t *release_addr;
 
-   release_addr = pmap_mapdev(release_paddr, sizeof(*release_addr));
+   ap_cpuid = cpu & CPU_AFF_MASK;
+
+   release_addr = pmap_mapdev_attr(release_paddr, sizeof(*release_addr),
+   VM_MEMATTR_DEFAULT);
if (release_addr == NULL)
return (ENOMEM);
 
@@ -432,6 +437,10 @@ enable_cpu_spin(uint64_t cpu, vm_paddr_t entry, vm_paddr_t 
release_paddr)
"sev\n"
::: "memory");
 
+   /* Wait for the target CPU to start */
+   while (atomic_load_64(&ap_cpuid) != 0)
+   __asm __volatile("wfe");
+
return (0);
 }
 
@@ -475,7 +484,6 @@ start_cpu(u_int cpuid, uint64_t target_cpu, int domain, 
vm_paddr_t release_addr)
bootstack = (char *)bootstacks[cpuid] + MP_BOOTSTACK_SIZE;
 
printf("Starting CPU %u (%lx)\n", cpuid, target_cpu);
-   pa = pmap_extract(kernel_pmap, (vm_offset_t)mpentry);
 
/*
 * A limited set of hardware we support can only do spintables and
@@ -483,10 +491,13 @@ start_cpu(u_int cpuid, uint64_t target_cpu, int domain, 
vm_paddr_t release_addr)
 * PSCI branch here.
 */
MPASS(release_addr =

git: 797f1c7c3dea - main - arm64: Flush the spintable release address

2024-05-10 Thread Andrew Turner
The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=797f1c7c3dea51f88fa4c365e75c354a93827ca0

commit 797f1c7c3dea51f88fa4c365e75c354a93827ca0
Author: Andrew Turner 
AuthorDate: 2024-05-03 16:17:25 +
Commit: Andrew Turner 
CommitDate: 2024-05-10 09:29:24 +

arm64: Flush the spintable release address

Ensure the spintable release address is written back from the cache
to memory. The other CPUs reading this may not be reading it with the
cache enabled so ensure it is written to the point of coherency
before issuing the wakeup sev.

As cpu_dcache_wbinv_range includes the needed barrier remove it from
the inline asm before the sev instruction.

Reviewed by:jhibbits, kevans
Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D45083
---
 sys/arm64/arm64/mp_machdep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/arm64/arm64/mp_machdep.c b/sys/arm64/arm64/mp_machdep.c
index bd13dde9cee0..e9b015443477 100644
--- a/sys/arm64/arm64/mp_machdep.c
+++ b/sys/arm64/arm64/mp_machdep.c
@@ -430,10 +430,10 @@ enable_cpu_spin(uint64_t cpu, vm_paddr_t entry, 
vm_paddr_t release_paddr)
return (ENOMEM);
 
*release_addr = entry;
+   cpu_dcache_wbinv_range(release_addr, sizeof(*release_addr));
pmap_unmapdev(release_addr, sizeof(*release_addr));
 
__asm __volatile(
-   "dsb sy \n"
"sev\n"
::: "memory");
 



git: f91e9401c209 - main - dev/psci: Check all compat strings

2024-05-10 Thread Andrew Turner
The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f91e9401c2098ba56f43093ef9747d0b1f60f8eb

commit f91e9401c2098ba56f43093ef9747d0b1f60f8eb
Author: Andrew Turner 
AuthorDate: 2024-04-23 11:27:09 +
Commit: Andrew Turner 
CommitDate: 2024-05-10 09:29:24 +

dev/psci: Check all compat strings

When searching for the PSCI FDT node we only check a few compat strings.
Use the existing compat_data array to check all strings the driver may
attach to.

Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D44913
---
 sys/dev/psci/psci.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/sys/dev/psci/psci.c b/sys/dev/psci/psci.c
index e1e9c1880b54..3211c331ed6e 100644
--- a/sys/dev/psci/psci.c
+++ b/sys/dev/psci/psci.c
@@ -378,12 +378,18 @@ psci_fdt_callfn(psci_callfn_t *callfn)
 {
phandle_t node;
 
-   node = ofw_bus_find_compatible(OF_peer(0), "arm,psci-0.2");
-   if (node == 0) {
-   node = ofw_bus_find_compatible(OF_peer(0), "arm,psci-1.0");
-   if (node == 0)
-   return (PSCI_MISSING);
+   /* XXX: This is suboptimal, we should walk the tree & check each
+* node against compat_data, but we only have a few entries so
+* it's ok for now.
+*/
+   for (int i = 0; compat_data[i].ocd_str != NULL; i++) {
+   node = ofw_bus_find_compatible(OF_peer(0),
+   compat_data[i].ocd_str);
+   if (node != 0)
+   break;
}
+   if (node == 0)
+   return (PSCI_MISSING);
 
if (!ofw_bus_node_status_okay(node))
return (PSCI_MISSING);



git: 4ab0f5ab3fd6 - main - arm64/gicv3: Check if the hardware supports LPIs

2024-05-10 Thread Andrew Turner
The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=4ab0f5ab3fd6dcd7f76c1ed1c9dc0dcd152fb64f

commit 4ab0f5ab3fd6dcd7f76c1ed1c9dc0dcd152fb64f
Author: Andrew Turner 
AuthorDate: 2024-04-23 11:28:23 +
Commit: Andrew Turner 
CommitDate: 2024-05-10 09:29:24 +

arm64/gicv3: Check if the hardware supports LPIs

Some simulators have the ITS in the DTB passed to the kernel, however
it is a runtime configuration option to enable it.

Check the GICD_TYPER register to see if LPIs are enabled before
attaching the ITS driver.

Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D44914
---
 sys/arm64/arm64/gic_v3.c | 4 
 sys/arm64/arm64/gic_v3_var.h | 2 ++
 sys/arm64/arm64/gicv3_its.c  | 6 ++
 3 files changed, 12 insertions(+)

diff --git a/sys/arm64/arm64/gic_v3.c b/sys/arm64/arm64/gic_v3.c
index b57dd9be48aa..0b25650b3fbf 100644
--- a/sys/arm64/arm64/gic_v3.c
+++ b/sys/arm64/arm64/gic_v3.c
@@ -494,6 +494,10 @@ gic_v3_read_ivar(device_t dev, device_t child, int which, 
uintptr_t *result)
case GICV3_IVAR_REDIST:
*result = (uintptr_t)&sc->gic_redists.pcpu[PCPU_GET(cpuid)];
return (0);
+   case GICV3_IVAR_SUPPORT_LPIS:
+   *result =
+   (gic_d_read(sc, 4, GICD_TYPER) & GICD_TYPER_LPIS) != 0;
+   return (0);
case GIC_IVAR_HW_REV:
KASSERT(
GICR_PIDR2_ARCH(sc->gic_pidr2) == GICR_PIDR2_ARCH_GICv3 ||
diff --git a/sys/arm64/arm64/gic_v3_var.h b/sys/arm64/arm64/gic_v3_var.h
index 81526e7cc15e..1c5d354ee217 100644
--- a/sys/arm64/arm64/gic_v3_var.h
+++ b/sys/arm64/arm64/gic_v3_var.h
@@ -102,9 +102,11 @@ MALLOC_DECLARE(M_GIC_V3);
 #defineGICV3_IVAR_NIRQS1000
 /* 1001 was GICV3_IVAR_REDIST_VADDR */
 #defineGICV3_IVAR_REDIST   1002
+#defineGICV3_IVAR_SUPPORT_LPIS 1003
 
 __BUS_ACCESSOR(gicv3, nirqs, GICV3, NIRQS, u_int);
 __BUS_ACCESSOR(gicv3, redist, GICV3, REDIST, void *);
+__BUS_ACCESSOR(gicv3, support_lpis, GICV3, SUPPORT_LPIS, bool);
 
 /* Device methods */
 int gic_v3_attach(device_t dev);
diff --git a/sys/arm64/arm64/gicv3_its.c b/sys/arm64/arm64/gicv3_its.c
index 31a0ded6c95d..46695a415e86 100644
--- a/sys/arm64/arm64/gicv3_its.c
+++ b/sys/arm64/arm64/gicv3_its.c
@@ -2208,6 +2208,9 @@ gicv3_its_fdt_probe(device_t dev)
if (!ofw_bus_is_compatible(dev, "arm,gic-v3-its"))
return (ENXIO);
 
+   if (!gicv3_get_support_lpis(dev))
+   return (ENXIO);
+
device_set_desc(dev, "ARM GIC Interrupt Translation Service");
return (BUS_PROBE_DEFAULT);
 }
@@ -2277,6 +2280,9 @@ gicv3_its_acpi_probe(device_t dev)
if (gic_get_hw_rev(dev) < 3)
return (EINVAL);
 
+   if (!gicv3_get_support_lpis(dev))
+   return (ENXIO);
+
device_set_desc(dev, "ARM GIC Interrupt Translation Service");
return (BUS_PROBE_DEFAULT);
 }



git: 719908c81300 - main - arm64: Merge common page table creation code

2024-05-10 Thread Andrew Turner
The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=719908c8130012234898c3602eb0c0db9af0a620

commit 719908c8130012234898c3602eb0c0db9af0a620
Author: Andrew Turner 
AuthorDate: 2024-04-25 13:06:23 +
Commit: Andrew Turner 
CommitDate: 2024-05-10 09:29:24 +

arm64: Merge common page table creation code

Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D45061
---
 sys/arm64/arm64/locore.S | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S
index 94a50b735bc6..67bdece402c2 100644
--- a/sys/arm64/arm64/locore.S
+++ b/sys/arm64/arm64/locore.S
@@ -520,17 +520,27 @@ common:
 * when the page size is larger than 4k, L2 blocks are too large to
 * map the kernel with such an alignment.
 */
+#definePTE_SHIFT   L3_SHIFT
+#defineBUILD_PTE_FUNC  build_l3_page_pagetable
+#else
+#definePTE_SHIFT   L2_SHIFT
+#defineBUILD_PTE_FUNC  build_l2_block_pagetable
+#endif
 
-   /* Get the number of l3 pages to allocate, rounded down */
-   lsr x10, x8, #(L3_SHIFT)
+   /* Get the number of blocks/pages to allocate, rounded down */
+   lsr x10, x8, #(PTE_SHIFT)
 
-   /* Create the kernel space L2 table */
+   /* Create the kernel space PTE table */
mov x6, x26
mov x7, #(ATTR_S1_IDX(VM_MEMATTR_WRITE_BACK))
mov x8, #(KERNBASE)
mov x9, x28
-   bl  build_l3_page_pagetable
+   bl  BUILD_PTE_FUNC
+
+#undef PTE_SHIFT
+#undef BUILD_PTE_FUNC
 
+#if PAGE_SIZE != PAGE_SIZE_4K
/* Move to the l2 table */
ldr x9, =(PAGE_SIZE * L3_PAGE_COUNT)
add x26, x26, x9
@@ -539,16 +549,6 @@ common:
mov x9, x6
mov x6, x26
bl  link_l2_pagetable
-#else
-   /* Get the number of l2 pages to allocate, rounded down */
-   lsr x10, x8, #(L2_SHIFT)
-
-   /* Create the kernel space L2 table */
-   mov x6, x26
-   mov x7, #(ATTR_S1_IDX(VM_MEMATTR_WRITE_BACK))
-   mov x8, #(KERNBASE)
-   mov x9, x28
-   bl  build_l2_block_pagetable
 #endif
 
/* Move to the l1 table */



git: 634dd430b966 - main - arm64: Update the page table list in locore

2024-05-10 Thread Andrew Turner
The branch main has been updated by andrew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=634dd430b966405f7bd9c2d647b0d7c1281c3de9

commit 634dd430b966405f7bd9c2d647b0d7c1281c3de9
Author: Andrew Turner 
AuthorDate: 2024-04-24 10:23:42 +
Commit: Andrew Turner 
CommitDate: 2024-05-10 09:29:24 +

arm64: Update the page table list in locore

The comment describing the page tables was out of date. Update it with
the current list.

Sponsored by:   Arm Ltd
---
 sys/arm64/arm64/locore.S | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S
index 67bdece402c2..f53cd365de55 100644
--- a/sys/arm64/arm64/locore.S
+++ b/sys/arm64/arm64/locore.S
@@ -429,14 +429,16 @@ LEND(get_load_phys_addr)
  *  All the memory must not cross a 1GiB boundaty
  *  x28 contains the physical address we were loaded from
  *
- * TODO: This is out of date.
- *  There are at least 5 pages before that address for the page tables
+ *  There are 7 or 8 pages before that address for the page tables
  *   The pages used are:
+ *- The Kernel L3 tables (only for 16k kernel)
  *- The Kernel L2 table
  *- The Kernel L1 table
  *- The Kernel L0 table (TTBR1)
+ *- The identity (PA = VA) L2 table
  *- The identity (PA = VA) L1 table
- *- The identity (PA = VA) L0 table (TTBR0)
+ *- The identity (PA = VA) L0 table (Early TTBR0)
+ *- The Kernel empty L0 table   (Late TTBR0)
  */
 LENTRY(create_pagetables)
/* Save the Link register */



git: c6f9df706410 - main - cat: Check for lack of success rather than a specific failure.

2024-05-10 Thread Dag-Erling Smørgrav
The branch main has been updated by des:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c6f9df7064106a3b016c13ea3b9a930362b53089

commit c6f9df7064106a3b016c13ea3b9a930362b53089
Author: Dag-Erling Smørgrav 
AuthorDate: 2024-05-10 10:59:18 +
Commit: Dag-Erling Smørgrav 
CommitDate: 2024-05-10 10:59:30 +

cat: Check for lack of success rather than a specific failure.

MFC after:  3 days
Sponsored by:   Klara, Inc.
Reviewed by:oshogbo
Differential Revision:  https://reviews.freebsd.org/D45149
---
 bin/cat/cat.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/bin/cat/cat.c b/bin/cat/cat.c
index 5dceb1cad94b..5db2781e9912 100644
--- a/bin/cat/cat.c
+++ b/bin/cat/cat.c
@@ -198,7 +198,7 @@ main(int argc, char *argv[])
stdout_lock.l_start = 0;
stdout_lock.l_type = F_WRLCK;
stdout_lock.l_whence = SEEK_SET;
-   if (fcntl(STDOUT_FILENO, F_SETLKW, &stdout_lock) == -1)
+   if (fcntl(STDOUT_FILENO, F_SETLKW, &stdout_lock) != 0)
err(EXIT_FAILURE, "stdout");
}
 
@@ -266,7 +266,7 @@ scanfiles(char *argv[], int cooked __unused)
 #endif
} else {
 #ifndef BOOTSTRAP_CAT
-   if (in_kernel_copy(fd) == -1) {
+   if (in_kernel_copy(fd) != 0) {
if (errno == EINVAL || errno == EBADF ||
errno == EISDIR)
raw_cat(fd);
@@ -500,12 +500,12 @@ udom_open(const char *path, int flags)
switch (flags & O_ACCMODE) {
case O_RDONLY:
cap_rights_clear(&rights, CAP_WRITE);
-   if (shutdown(fd, SHUT_WR) == -1)
+   if (shutdown(fd, SHUT_WR) != 0)
warn(NULL);
break;
case O_WRONLY:
cap_rights_clear(&rights, CAP_READ);
-   if (shutdown(fd, SHUT_RD) == -1)
+   if (shutdown(fd, SHUT_RD) != 0)
warn(NULL);
break;
default:
@@ -513,7 +513,7 @@ udom_open(const char *path, int flags)
}
 
cap_rights_clear(&rights, CAP_CONNECT, CAP_SHUTDOWN);
-   if (caph_rights_limit(fd, &rights) < 0) {
+   if (caph_rights_limit(fd, &rights) != 0) {
serrno = errno;
close(fd);
errno = serrno;



git: ad4f3bdf733c - main - cat: Missed a couple.

2024-05-10 Thread Dag-Erling Smørgrav
The branch main has been updated by des:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=ad4f3bdf733c1a670021f4db378338f5aaedbfd8

commit ad4f3bdf733c1a670021f4db378338f5aaedbfd8
Author: Dag-Erling Smørgrav 
AuthorDate: 2024-05-10 11:04:56 +
Commit: Dag-Erling Smørgrav 
CommitDate: 2024-05-10 11:05:45 +

cat: Missed a couple.

MFC after:  3 days
Sponsored by:   Klara, Inc.
---
 bin/cat/cat.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bin/cat/cat.c b/bin/cat/cat.c
index 5db2781e9912..3e7974e5f334 100644
--- a/bin/cat/cat.c
+++ b/bin/cat/cat.c
@@ -125,7 +125,7 @@ init_casper_net(cap_channel_t *casper)
familylimit = AF_LOCAL;
cap_net_limit_name2addr_family(limit, &familylimit, 1);
 
-   if (cap_net_limit(limit) < 0)
+   if (cap_net_limit(limit) != 0)
err(EXIT_FAILURE, "unable to apply limits");
 }
 #endif
@@ -206,7 +206,7 @@ main(int argc, char *argv[])
 
caph_cache_catpages();
 
-   if (caph_enter_casper() < 0)
+   if (caph_enter_casper() != 0)
err(EXIT_FAILURE, "capsicum");
 
if (bflag || eflag || nflag || sflag || tflag || vflag)
@@ -471,7 +471,7 @@ udom_open(const char *path, int flags)
errno = serrno;
return (-1);
}
-   if (caph_rights_limit(fd, &rights) < 0) {
+   if (caph_rights_limit(fd, &rights) != 0) {
serrno = errno;
close(fd);
freeaddrinfo(res0);



git: 2e0c027e69de - main - ukswitch: fix non-debug build

2024-05-10 Thread Ed Maste
The branch main has been updated by emaste:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2e0c027e69de66afc1157c76bd42ecd3737d54e1

commit 2e0c027e69de66afc1157c76bd42ecd3737d54e1
Author: Ed Maste 
AuthorDate: 2024-05-10 12:52:06 +
Commit: Ed Maste 
CommitDate: 2024-05-10 12:53:15 +

ukswitch: fix non-debug build

PR: 278847
Sponsored by:   The FreeBSD Foundation
---
 sys/dev/etherswitch/ukswitch/ukswitch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/dev/etherswitch/ukswitch/ukswitch.c 
b/sys/dev/etherswitch/ukswitch/ukswitch.c
index 6eff37bb118e..88726422bd01 100644
--- a/sys/dev/etherswitch/ukswitch/ukswitch.c
+++ b/sys/dev/etherswitch/ukswitch/ukswitch.c
@@ -514,7 +514,7 @@ ukswitch_writephy(device_t dev, int phy, int reg, int data)
 static int
 ukswitch_readreg(device_t dev, int addr)
 {
-   struct ukswitch_softc *sc;
+   struct ukswitch_softc *sc __diagused;
 
sc = device_get_softc(dev);
UKSWITCH_LOCK_ASSERT(sc, MA_OWNED);
@@ -526,7 +526,7 @@ ukswitch_readreg(device_t dev, int addr)
 static int
 ukswitch_writereg(device_t dev, int addr, int value)
 {
-   struct ukswitch_softc *sc;
+   struct ukswitch_softc *sc __diagused;
 
sc = device_get_softc(dev);
UKSWITCH_LOCK_ASSERT(sc, MA_OWNED);



git: 0e0220d11add - stable/14 - clock_gettime.2: fix markup

2024-05-10 Thread Ed Maste
The branch stable/14 has been updated by emaste:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=0e0220d11addc60fe7ed6fca79aefac2a3a9af27

commit 0e0220d11addc60fe7ed6fca79aefac2a3a9af27
Author: Ed Maste 
AuthorDate: 2024-05-06 19:59:42 +
Commit: Ed Maste 
CommitDate: 2024-05-10 13:01:52 +

clock_gettime.2: fix markup

The CLOCK_* constants are "defined variable or preprocessor constants"
and so use .Dv.

Reviewed by:imp
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45106

(cherry picked from commit 2d29d2ecebf8ea19221995b3ea2e3a7ac700bf81)
---
 lib/libc/sys/clock_gettime.2 | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/lib/libc/sys/clock_gettime.2 b/lib/libc/sys/clock_gettime.2
index ed469153a40e..c8bef4c5424f 100644
--- a/lib/libc/sys/clock_gettime.2
+++ b/lib/libc/sys/clock_gettime.2
@@ -94,29 +94,29 @@ Returns the execution time of the calling thread.
 .El
 .Pp
 The clock IDs
-.Fa CLOCK_REALTIME ,
-.Fa CLOCK_MONOTONIC ,
+.Dv CLOCK_REALTIME ,
+.Dv CLOCK_MONOTONIC ,
 and
-.Fa CLOCK_UPTIME
+.Dv CLOCK_UPTIME
 perform a full time counter query.
 The clock IDs with the _FAST suffix, i.e.,
-.Fa CLOCK_REALTIME_FAST ,
-.Fa CLOCK_MONOTONIC_FAST ,
+.Dv CLOCK_REALTIME_FAST ,
+.Dv CLOCK_MONOTONIC_FAST ,
 and
-.Fa CLOCK_UPTIME_FAST ,
+.Dv CLOCK_UPTIME_FAST ,
 do not perform
 a full time counter query, so their accuracy is one timer tick.
 Similarly,
-.Fa CLOCK_REALTIME_PRECISE ,
-.Fa CLOCK_MONOTONIC_PRECISE ,
+.Dv CLOCK_REALTIME_PRECISE ,
+.Dv CLOCK_MONOTONIC_PRECISE ,
 and
-.Fa CLOCK_UPTIME_PRECISE
+.Dv CLOCK_UPTIME_PRECISE
 are used to get the most exact value as possible, at the expense of
 execution time.
 The clock IDs
-.Fa CLOCK_REALTIME_COARSE
+.Dv CLOCK_REALTIME_COARSE
 and
-.Fa CLOCK_MONOTONIC_COARSE
+.Dv CLOCK_MONOTONIC_COARSE
 are aliases of corresponding IDs with _FAST suffix for compatibility with other
 systems.
 Finally,
@@ -138,7 +138,7 @@ struct timespec {
 .Ed
 .Pp
 Only the super-user may set the time of day, using only
-.Fa CLOCK_REALTIME .
+.Dv CLOCK_REALTIME .
 If the system
 .Xr securelevel 7
 is greater than 1 (see
@@ -186,14 +186,14 @@ and
 system calls conform to
 .St -p1003.1b-93 .
 The clock IDs
-.Fa CLOCK_REALTIME_FAST ,
-.Fa CLOCK_REALTIME_PRECISE ,
-.Fa CLOCK_MONOTONIC_FAST ,
-.Fa CLOCK_MONOTONIC_PRECISE ,
-.Fa CLOCK_UPTIME ,
-.Fa CLOCK_UPTIME_FAST ,
-.Fa CLOCK_UPTIME_PRECISE ,
-.Fa CLOCK_SECOND
+.Dv CLOCK_REALTIME_FAST ,
+.Dv CLOCK_REALTIME_PRECISE ,
+.Dv CLOCK_MONOTONIC_FAST ,
+.Dv CLOCK_MONOTONIC_PRECISE ,
+.Dv CLOCK_UPTIME ,
+.Dv CLOCK_UPTIME_FAST ,
+.Dv CLOCK_UPTIME_PRECISE ,
+.Dv CLOCK_SECOND
 are
 .Fx
 extensions to the POSIX interface.



git: 5e7de5daa95d - stable/14 - smsc(4): update to mention Microchip

2024-05-10 Thread Ed Maste
The branch stable/14 has been updated by emaste:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=5e7de5daa95dd901fc4f051120461805aaff29e3

commit 5e7de5daa95dd901fc4f051120461805aaff29e3
Author: Ed Maste 
AuthorDate: 2024-05-07 15:33:45 +
Commit: Ed Maste 
CommitDate: 2024-05-10 13:01:52 +

smsc(4): update to mention Microchip

Microchip Technology acquired SMSC in 2012, and all current products
and datasheets refer to the devices supported by this driver as
Microchip parts.  Mention SMSC in a parenthetical comment to explain
the driver's name.

Reviewed by:imp
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45115

(cherry picked from commit 7ef6ce51742d44a7375ccbaeda4cc64e034c4816)
---
 share/man/man4/smsc.4 | 12 ++--
 sys/dev/usb/net/if_smsc.c |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/share/man/man4/smsc.4 b/share/man/man4/smsc.4
index 56c1556e5f83..61b12c7d230c 100644
--- a/share/man/man4/smsc.4
+++ b/share/man/man4/smsc.4
@@ -25,12 +25,12 @@
 .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd November 24, 2015
+.Dd May 7, 2024
 .Dt SMSC 4
 .Os
 .Sh NAME
 .Nm smsc
-.Nd "USB SMSC LAN9xxx Fast Ethernet driver"
+.Nd "USB Microchip LAN9xxx Fast Ethernet driver"
 .Sh SYNOPSIS
 To load the driver as a module at boot time, place the
 following line in
@@ -53,7 +53,7 @@ following lines in your kernel configuration file:
 The
 .Nm
 device driver provides support for USB Fast Ethernet adapters based
-on the SMSC LAN9xxx chipsets.
+on the Microchip (formerly SMSC) LAN9xxx chipsets.
 .Pp
 For more information on configuring this device, see
 .Xr ifconfig 8 .
@@ -64,11 +64,11 @@ driver:
 .Pp
 .Bl -bullet -compact
 .It
-SMSC LAN9500, LAN9500A, LAN9505 and LAN9505A based Ethernet adapters
+LAN9500, LAN9500A, LAN9505 and LAN9505A based Ethernet adapters
 .It
-SMSC LAN89530, LAN9530 and LAN9730 based Ethernet adapters
+LAN89530, LAN9530 and LAN9730 based Ethernet adapters
 .It
-SMSC LAN951x Ethernet adapters with integrated USB hub
+LAN951x Ethernet adapters with integrated USB hub
 .El
 .Sh SEE ALSO
 .Xr arp 4 ,
diff --git a/sys/dev/usb/net/if_smsc.c b/sys/dev/usb/net/if_smsc.c
index a59501b6bbff..58809de4ad3a 100644
--- a/sys/dev/usb/net/if_smsc.c
+++ b/sys/dev/usb/net/if_smsc.c
@@ -28,7 +28,7 @@
 
 #include 
 /*
- * SMSC LAN9xxx devices (http://www.smsc.com/)
+ * Microchip LAN9xxx devices (https://www.microchip.com/en-us/product/lan9500a)
  * 
  * The LAN9500 & LAN9500A devices are stand-alone USB to Ethernet chips that
  * support USB 2.0 and 10/100 Mbps Ethernet.
@@ -38,7 +38,7 @@
  * supports the hub part.
  *
  * This driver is closely modelled on the Linux driver written and copyrighted
- * by SMSC.
+ * by SMSC (later acquired by Microchip).
  *
  *
  *



git: d45f1f519342 - stable/14 - sys/net/if_bridge: support non-INET kernels

2024-05-10 Thread Zhenlei Huang
The branch stable/14 has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d45f1f5193420fac7f9a64c0455991a80e7cb89a

commit d45f1f5193420fac7f9a64c0455991a80e7cb89a
Author: Lexi Winter 
AuthorDate: 2024-04-23 21:12:57 +
Commit: Zhenlei Huang 
CommitDate: 2024-05-10 14:03:10 +

sys/net/if_bridge: support non-INET kernels

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1159

(cherry picked from commit 65767e6126a7e92bc76561b4ffd005cf85ba525e)

if_bridge: Minor style fixes

And more comments on the #ifdef INET blocks to improve readability.

While here, revert the order of two prototypes to produce minimal diff
compared to stable branches.

(cherry picked from commit 73585176ffd84c13d68cad67c2ca81643f09075c)
---
 sys/net/if_bridge.c | 48 +---
 1 file changed, 33 insertions(+), 15 deletions(-)

diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index 1b4ac92b62a3..1e6f9b578ee3 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -403,12 +403,14 @@ static intbridge_ioctl_sproto(struct bridge_softc 
*, void *);
 static int bridge_ioctl_stxhc(struct bridge_softc *, void *);
 static int bridge_pfil(struct mbuf **, struct ifnet *, struct ifnet *,
int);
+#ifdef INET
 static int bridge_ip_checkbasic(struct mbuf **mp);
+static int bridge_fragment(struct ifnet *, struct mbuf **mp,
+   struct ether_header *, int, struct llc *);
+#endif /* INET */
 #ifdef INET6
 static int bridge_ip6_checkbasic(struct mbuf **mp);
 #endif /* INET6 */
-static int bridge_fragment(struct ifnet *, struct mbuf **mp,
-   struct ether_header *, int, struct llc *);
 static voidbridge_linkstate(struct ifnet *ifp);
 static voidbridge_linkcheck(struct bridge_softc *sc);
 
@@ -3390,12 +3392,15 @@ bridge_state_change(struct ifnet *ifp, int state)
 static int
 bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct ifnet *ifp, int dir)
 {
-   int snap, error, i, hlen;
+   int snap, error, i;
struct ether_header *eh1, eh2;
-   struct ip *ip;
struct llc llc1;
u_int16_t ether_type;
pfil_return_t rv;
+#ifdef INET
+   struct ip *ip = NULL;
+   int hlen = 0;
+#endif
 
snap = 0;
error = -1; /* Default error if not error == 0 */
@@ -3436,31 +3441,36 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, 
struct ifnet *ifp, int dir)
}
 
/*
-* If we're trying to filter bridge traffic, don't look at anything
-* other than IP and ARP traffic.  If the filter doesn't understand
-* IPv6, don't allow IPv6 through the bridge either.  This is lame
-* since if we really wanted, say, an AppleTalk filter, we are hosed,
-* but of course we don't have an AppleTalk filter to begin with.
-* (Note that since pfil doesn't understand ARP it will pass *ALL*
-* ARP traffic.)
+* If we're trying to filter bridge traffic, only look at traffic for
+* protocols available in the kernel (IPv4 and/or IPv6) to avoid
+* passing traffic for an unsupported protocol to the filter.  This is
+* lame since if we really wanted, say, an AppleTalk filter, we are
+* hosed, but of course we don't have an AppleTalk filter to begin
+* with.  (Note that since pfil doesn't understand ARP it will pass
+* *ALL* ARP traffic.)
 */
switch (ether_type) {
+#ifdef INET
case ETHERTYPE_ARP:
case ETHERTYPE_REVARP:
if (V_pfil_ipfw_arp == 0)
return (0); /* Automatically pass */
-   break;
 
+   /* FALLTHROUGH */
case ETHERTYPE_IP:
+#endif
 #ifdef INET6
case ETHERTYPE_IPV6:
 #endif /* INET6 */
break;
+
default:
/*
-* Check to see if the user wants to pass non-ip
-* packets, these will not be checked by pfil(9) and
-* passed unconditionally so the default is to drop.
+* We get here if the packet isn't from a supported
+* protocol.  Check to see if the user wants to pass
+* non-IP packets, these will not be checked by pfil(9)
+* and passed unconditionally so the default is to
+* drop.
 */
if (V_pfil_onlyip)
goto bad;
@@ -3492,9 +3502,11 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct 
ifnet *ifp, int dir)
 */
if (dir == PFIL_IN) {
switch (ether_type) {
+#ifdef INET
case ETHERTYPE_IP:
   

git: 07e4121aa14b - stable/13 - if_bridge: clean up INET/INET6 handling

2024-05-10 Thread Zhenlei Huang
The branch stable/13 has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=07e4121aa14b4fb2f3def60272eee5d3c6d288a6

commit 07e4121aa14b4fb2f3def60272eee5d3c6d288a6
Author: Lexi Winter 
AuthorDate: 2024-04-21 18:56:23 +
Commit: Zhenlei Huang 
CommitDate: 2024-05-10 14:09:20 +

if_bridge: clean up INET/INET6 handling

The if_bridge contains several instances of:

if (AF_INET code ...
#ifdef INET6
AF_INET6 code ...
#endif
) {
...

Clean this up by adding a couple of macros at the top of the file that
are conditionally defined based on whether INET and/or INET6 are enabled,
which makes the code more readable and easier to maintain.

No functional change intended.

Reviewed by:zlei, markj
MFC after:  1 week
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1191

(cherry picked from commit ef84dd8f4926304306d5989ca9afdbf760c6d813)
(cherry picked from commit 2f95e4a01e194428d65572ff3a3c97563120b38a)
---
 sys/net/if_bridge.c | 65 +
 1 file changed, 31 insertions(+), 34 deletions(-)

diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index e0fe45e3d326..82526d848f5e 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -141,6 +141,31 @@
 extern voidnd6_setmtu(struct ifnet *);
 #endif
 
+/*
+ * At various points in the code we need to know if we're hooked into the INET
+ * and/or INET6 pfil.  Define some macros to do that based on which IP versions
+ * are enabled in the kernel.  This avoids littering the rest of the code with
+ * #ifnet INET6 to avoid referencing V_inet6_pfil_head.
+ */
+#ifdef INET6
+#definePFIL_HOOKED_IN_INET6
PFIL_HOOKED_IN(V_inet6_pfil_head)
+#definePFIL_HOOKED_OUT_INET6   
PFIL_HOOKED_OUT(V_inet6_pfil_head)
+#else
+#definePFIL_HOOKED_IN_INET6false
+#definePFIL_HOOKED_OUT_INET6   false
+#endif
+
+#ifdef INET
+#definePFIL_HOOKED_IN_INET PFIL_HOOKED_IN(V_inet_pfil_head)
+#definePFIL_HOOKED_OUT_INET
PFIL_HOOKED_OUT(V_inet_pfil_head)
+#else
+#definePFIL_HOOKED_IN_INET false
+#definePFIL_HOOKED_OUT_INETfalse
+#endif
+
+#definePFIL_HOOKED_IN_46   (PFIL_HOOKED_IN_INET6 || 
PFIL_HOOKED_IN_INET)
+#definePFIL_HOOKED_OUT_46  (PFIL_HOOKED_OUT_INET6 || 
PFIL_HOOKED_OUT_INET)
+
 /*
  * Size of the route hash table.  Must be a power of two.
  */
@@ -2097,11 +2122,7 @@ bridge_dummynet(struct mbuf *m, struct ifnet *ifp)
return;
}
 
-   if (PFIL_HOOKED_OUT(V_inet_pfil_head)
-#ifdef INET6
-   || PFIL_HOOKED_OUT(V_inet6_pfil_head)
-#endif
-   ) {
+   if (PFIL_HOOKED_OUT_46) {
if (bridge_pfil(&m, sc->sc_ifp, ifp, PFIL_OUT) != 0)
return;
if (m == NULL)
@@ -2385,11 +2406,7 @@ bridge_forward(struct bridge_softc *sc, struct 
bridge_iflist *sbif,
ETHER_BPF_MTAP(ifp, m);
 
/* run the packet filter */
-   if (PFIL_HOOKED_IN(V_inet_pfil_head)
-#ifdef INET6
-   || PFIL_HOOKED_IN(V_inet6_pfil_head)
-#endif
-   ) {
+   if (PFIL_HOOKED_IN_46) {
if (bridge_pfil(&m, ifp, src_if, PFIL_IN) != 0)
return;
if (m == NULL)
@@ -2421,11 +2438,7 @@ bridge_forward(struct bridge_softc *sc, struct 
bridge_iflist *sbif,
dbif->bif_stp.bp_state == BSTP_IFSTATE_DISCARDING)
goto drop;
 
-   if (PFIL_HOOKED_OUT(V_inet_pfil_head)
-#ifdef INET6
-   || PFIL_HOOKED_OUT(V_inet6_pfil_head)
-#endif
-   ) {
+   if (PFIL_HOOKED_OUT_46) {
if (bridge_pfil(&m, ifp, dst_if, PFIL_OUT) != 0)
return;
if (m == NULL)
@@ -2551,12 +2564,6 @@ bridge_input(struct ifnet *ifp, struct mbuf *m)
 #defineCARP_CHECK_WE_ARE_SRC(iface)false
 #endif
 
-#ifdef INET6
-#definePFIL_HOOKED_INET6   PFIL_HOOKED_IN(V_inet6_pfil_head)
-#else
-#definePFIL_HOOKED_INET6   false
-#endif
-
 #define GRAB_OUR_PACKETS(iface)
\
if ((iface)->if_type == IFT_GIF)\
continue;   \
@@ -2581,8 +2588,7 @@ bridge_input(struct ifnet *ifp, struct mbuf *m)
if_inc_counter(bifp, IFCOUNTER_IPACKETS, 1);\
if_inc_counter(bifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); \
/* Filter on the physical interface. */ \
-   if (V_pfil_local_phys && (PFIL_HOOKED_IN(V_inet_pfil_head) || \
-   PFIL_HOOKED_INET6)) {   \
+   if (V_pfil_local_phy

git: e57876309dbe - stable/13 - sys/net/if_bridge: support non-INET kernels

2024-05-10 Thread Zhenlei Huang
The branch stable/13 has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=e57876309dbe0e1ba9fdacc01b8be444bf997996

commit e57876309dbe0e1ba9fdacc01b8be444bf997996
Author: Lexi Winter 
AuthorDate: 2024-04-23 21:12:57 +
Commit: Zhenlei Huang 
CommitDate: 2024-05-10 14:10:29 +

sys/net/if_bridge: support non-INET kernels

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1159

(cherry picked from commit 65767e6126a7e92bc76561b4ffd005cf85ba525e)

if_bridge: Minor style fixes

And more comments on the #ifdef INET blocks to improve readability.

While here, revert the order of two prototypes to produce minimal diff
compared to stable branches.

(cherry picked from commit 73585176ffd84c13d68cad67c2ca81643f09075c)
(cherry picked from commit d45f1f5193420fac7f9a64c0455991a80e7cb89a)
---
 sys/net/if_bridge.c | 48 +---
 1 file changed, 33 insertions(+), 15 deletions(-)

diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index 82526d848f5e..6dea0f046bfb 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -407,12 +407,14 @@ static intbridge_ioctl_sproto(struct bridge_softc 
*, void *);
 static int bridge_ioctl_stxhc(struct bridge_softc *, void *);
 static int bridge_pfil(struct mbuf **, struct ifnet *, struct ifnet *,
int);
+#ifdef INET
 static int bridge_ip_checkbasic(struct mbuf **mp);
+static int bridge_fragment(struct ifnet *, struct mbuf **mp,
+   struct ether_header *, int, struct llc *);
+#endif /* INET */
 #ifdef INET6
 static int bridge_ip6_checkbasic(struct mbuf **mp);
 #endif /* INET6 */
-static int bridge_fragment(struct ifnet *, struct mbuf **mp,
-   struct ether_header *, int, struct llc *);
 static voidbridge_linkstate(struct ifnet *ifp);
 static voidbridge_linkcheck(struct bridge_softc *sc);
 
@@ -3282,12 +3284,15 @@ bridge_state_change(struct ifnet *ifp, int state)
 static int
 bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct ifnet *ifp, int dir)
 {
-   int snap, error, i, hlen;
+   int snap, error, i;
struct ether_header *eh1, eh2;
-   struct ip *ip;
struct llc llc1;
u_int16_t ether_type;
pfil_return_t rv;
+#ifdef INET
+   struct ip *ip = NULL;
+   int hlen = 0;
+#endif
 
snap = 0;
error = -1; /* Default error if not error == 0 */
@@ -3328,31 +,36 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, 
struct ifnet *ifp, int dir)
}
 
/*
-* If we're trying to filter bridge traffic, don't look at anything
-* other than IP and ARP traffic.  If the filter doesn't understand
-* IPv6, don't allow IPv6 through the bridge either.  This is lame
-* since if we really wanted, say, an AppleTalk filter, we are hosed,
-* but of course we don't have an AppleTalk filter to begin with.
-* (Note that since pfil doesn't understand ARP it will pass *ALL*
-* ARP traffic.)
+* If we're trying to filter bridge traffic, only look at traffic for
+* protocols available in the kernel (IPv4 and/or IPv6) to avoid
+* passing traffic for an unsupported protocol to the filter.  This is
+* lame since if we really wanted, say, an AppleTalk filter, we are
+* hosed, but of course we don't have an AppleTalk filter to begin
+* with.  (Note that since pfil doesn't understand ARP it will pass
+* *ALL* ARP traffic.)
 */
switch (ether_type) {
+#ifdef INET
case ETHERTYPE_ARP:
case ETHERTYPE_REVARP:
if (V_pfil_ipfw_arp == 0)
return (0); /* Automatically pass */
-   break;
 
+   /* FALLTHROUGH */
case ETHERTYPE_IP:
+#endif
 #ifdef INET6
case ETHERTYPE_IPV6:
 #endif /* INET6 */
break;
+
default:
/*
-* Check to see if the user wants to pass non-ip
-* packets, these will not be checked by pfil(9) and
-* passed unconditionally so the default is to drop.
+* We get here if the packet isn't from a supported
+* protocol.  Check to see if the user wants to pass
+* non-IP packets, these will not be checked by pfil(9)
+* and passed unconditionally so the default is to
+* drop.
 */
if (V_pfil_onlyip)
goto bad;
@@ -3384,9 +3394,11 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct 
ifnet *ifp, int dir)
 */
if (dir == PFIL_IN) {
switch (ethe

git: 10eea8dc8c4f - main - tpm20: Support partial reads

2024-05-10 Thread Justin Hibbits
The branch main has been updated by jhibbits:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=10eea8dc8c4f3d2a3495e7fb08837d91adf465e9

commit 10eea8dc8c4f3d2a3495e7fb08837d91adf465e9
Author: Justin Hibbits 
AuthorDate: 2024-05-09 19:27:35 +
Commit: Justin Hibbits 
CommitDate: 2024-05-10 18:35:28 +

tpm20: Support partial reads

Summary:
In some cases the TPM utilities may read only a partial block, instead
of a full block.  If a new command starts while in the middle of a read
it may cause the TPM to go catatonic and no longer respond to SPI.

Reviewed by:kd
Obtained from:  Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D45140
---
 sys/dev/tpm/tpm20.c| 10 +++---
 sys/dev/tpm/tpm20.h|  1 +
 sys/dev/tpm/tpm_crb.c  |  1 +
 sys/dev/tpm/tpm_tis_core.c |  1 +
 4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/sys/dev/tpm/tpm20.c b/sys/dev/tpm/tpm20.c
index 3399e17f53aa..80f7d9e105a6 100644
--- a/sys/dev/tpm/tpm20.c
+++ b/sys/dev/tpm/tpm20.c
@@ -68,6 +68,7 @@ tpm20_read(struct cdev *dev, struct uio *uio, int flags)
 {
struct tpm_sc *sc;
size_t bytes_to_transfer;
+   size_t offset;
int result = 0;
 
sc = (struct tpm_sc *)dev->si_drv1;
@@ -80,10 +81,10 @@ tpm20_read(struct cdev *dev, struct uio *uio, int flags)
}
 
bytes_to_transfer = MIN(sc->pending_data_length, uio->uio_resid);
+   offset = sc->total_length - sc->pending_data_length;
if (bytes_to_transfer > 0) {
-   result = uiomove((caddr_t) sc->buf, bytes_to_transfer, uio);
-   memset(sc->buf, 0, TPM_BUFSIZE);
-   sc->pending_data_length = 0;
+   result = uiomove((caddr_t) sc->buf + offset, bytes_to_transfer, 
uio);
+   sc->pending_data_length -= bytes_to_transfer;
cv_signal(&sc->buf_cv);
} else {
result = ETIMEDOUT;
@@ -152,6 +153,7 @@ tpm20_discard_buffer(void *arg)
 
memset(sc->buf, 0, TPM_BUFSIZE);
sc->pending_data_length = 0;
+   sc->total_length = 0;
 
cv_signal(&sc->buf_cv);
sx_xunlock(&sc->dev_lock);
@@ -191,6 +193,7 @@ tpm20_init(struct tpm_sc *sc)
cv_init(&sc->buf_cv, "TPM buffer cv");
callout_init(&sc->discard_buffer_callout, 1);
sc->pending_data_length = 0;
+   sc->total_length = 0;
 
make_dev_args_init(&args);
args.mda_devsw = &tpm20_cdevsw;
@@ -275,6 +278,7 @@ tpm20_harvest(void *arg, int unused)
 
/* Ignore response size */
sc->pending_data_length = 0;
+   sc->total_length = 0;
 
/* The number of random bytes we got is placed right after the header */
entropy_size = (uint16_t) sc->buf[TPM_HEADER_SIZE + 1];
diff --git a/sys/dev/tpm/tpm20.h b/sys/dev/tpm/tpm20.h
index 683cd7549bd4..7c2ccd30143a 100644
--- a/sys/dev/tpm/tpm20.h
+++ b/sys/dev/tpm/tpm20.h
@@ -124,6 +124,7 @@ struct tpm_sc {
 
uint8_t *buf;
size_t  pending_data_length;
+   size_t  total_length;
lwpid_t owner_tid;
 
struct callout  discard_buffer_callout;
diff --git a/sys/dev/tpm/tpm_crb.c b/sys/dev/tpm/tpm_crb.c
index b9ddcf0dd3e1..017ebd45c7ea 100644
--- a/sys/dev/tpm/tpm_crb.c
+++ b/sys/dev/tpm/tpm_crb.c
@@ -398,6 +398,7 @@ tpmcrb_transmit(device_t dev, size_t length)
 
tpmcrb_relinquish_locality(sc);
sc->pending_data_length = bytes_available;
+   sc->total_length = bytes_available;
 
return (0);
 }
diff --git a/sys/dev/tpm/tpm_tis_core.c b/sys/dev/tpm/tpm_tis_core.c
index 230eb12d2acd..d8421f8156c9 100644
--- a/sys/dev/tpm/tpm_tis_core.c
+++ b/sys/dev/tpm/tpm_tis_core.c
@@ -469,6 +469,7 @@ tpmtis_transmit(device_t dev, size_t length)
}
tpmtis_relinquish_locality(sc);
sc->pending_data_length = bytes_available;
+   sc->total_length = bytes_available;
 
return (0);
 }



git: de1ac9462f31 - main - conf: Generate fdt_static_dtb.h in OBJDIR

2024-05-10 Thread Justin Hibbits
The branch main has been updated by jhibbits:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=de1ac9462f31956a98e9953009f02a0e39eed283

commit de1ac9462f31956a98e9953009f02a0e39eed283
Author: Justin Hibbits 
AuthorDate: 2024-05-09 19:46:09 +
Commit: Justin Hibbits 
CommitDate: 2024-05-10 18:35:50 +

conf: Generate fdt_static_dtb.h in OBJDIR

Though the kernel build expects ${.OBJDIR} to be equal to ${.CURDIR}
that may not always be the case.  Correctly generate fdt_static_dtb.h in
${.OBJDIR}, which is conceptually more correct anyway.

Obtained from:  Juniper Networks, Inc.
---
 sys/conf/files | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/conf/files b/sys/conf/files
index 7fd79bb0345d..56c92f51947f 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -19,7 +19,7 @@ bhnd_nvram_map_data.h optional bhnd   
   \
no-obj no-implicit-rule before-depend  \
clean   "bhnd_nvram_map_data.h"
 fdt_static_dtb.h   optional fdt fdt_dtb_static \
-   compile-with "sh -c 'MACHINE=${MACHINE} $S/tools/fdt/make_dtbh.sh 
${FDT_DTS_FILE} ${.CURDIR}'" \
+   compile-with "sh -c 'MACHINE=${MACHINE} $S/tools/fdt/make_dtbh.sh 
${FDT_DTS_FILE} ${.OBJDIR}'" \
dependency  "${FDT_DTS_FILE:T:R}.dtb" \
no-obj no-implicit-rule before-depend \
clean   "fdt_static_dtb.h"



git: a5a2e963f9a0 - stable/14 - in6.h: expose s6_addr* definitions to user level

2024-05-10 Thread Mike Karels
The branch stable/14 has been updated by karels:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=a5a2e963f9a0a4bc65aa1c70a361243328e23961

commit a5a2e963f9a0a4bc65aa1c70a361243328e23961
Author: Mike Karels 
AuthorDate: 2024-05-02 15:24:37 +
Commit: Mike Karels 
CommitDate: 2024-05-10 14:37:43 +

in6.h: expose s6_addr* definitions to user level

The only element of of in6_addr that is specified in RFC 3493 or
in POSIX.1-2017 is s6_addr, implemented via a #define to a union
member.  However, FreeBSD and other BSD systems have additional
definitions for the other union members, s6_addr{8,16,32} which
are defined for the kernel and loader.  Some Linux applications
also use them, and they seem to be allowed by the RFC and POSIX.
Remove the current ifdefs, exposing the additional fields to user
level, and replace with #if __BSD_VISIBLE.  Add an explanatory
comment expanding on the previous "nonstandard" comment.

Reviewed by:bz
Differential Revision:  https://reviews.freebsd.org/D44979

(cherry picked from commit eb3dbf2dbe22ed6d4df54aebbf23f5b555a21cf1)
---
 sys/netinet6/in6.h | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sys/netinet6/in6.h b/sys/netinet6/in6.h
index 78c9cd56ed60..ce3bbea6b8e6 100644
--- a/sys/netinet6/in6.h
+++ b/sys/netinet6/in6.h
@@ -102,7 +102,13 @@ struct in6_addr {
 };
 
 #define s6_addr   __u6_addr.__u6_addr8
-#if defined(_KERNEL) || defined(_STANDALONE) /* XXX nonstandard */
+#if __BSD_VISIBLE
+/*
+ * s6_addr is the only in6_addr element specified in RFCs 2553 and 3493,
+ * also in POSIX 1003.1-2017.  The following three definitions were not
+ * exposed to user programs in FreeBSD before 14.1, or in other BSDs,
+ * and are thus less portable than s6_addr.
+ */
 #define s6_addr8  __u6_addr.__u6_addr8
 #define s6_addr16 __u6_addr.__u6_addr16
 #define s6_addr32 __u6_addr.__u6_addr32



git: 06af7bd12a4a - main - posix: POSIX-1.2008 moved SA_* from XSI to base standard

2024-05-10 Thread Warner Losh
The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=06af7bd12a4a654f5c5e8da41cf329eee3aa61f6

commit 06af7bd12a4a654f5c5e8da41cf329eee3aa61f6
Author: Warner Losh 
AuthorDate: 2024-05-10 15:18:43 +
Commit: Warner Losh 
CommitDate: 2024-05-10 15:20:21 +

posix: POSIX-1.2008 moved SA_* from XSI to base standard

Starting with POSIX-1.2008, "The SA_RESETHAND, SA_RESTART, SA_SIGINFO,
SA_NOCLDWAIT, and SA_NODEFER constants are moved from the XSI option to
the Base." Make them so visible.

PR: 275328
Sponsored by:   Netflix
---
 sys/sys/signal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/sys/signal.h b/sys/sys/signal.h
index 113b5aaa9fa1..c0b65c0c9ef0 100644
--- a/sys/sys/signal.h
+++ b/sys/sys/signal.h
@@ -372,7 +372,7 @@ struct sigaction {
 #defineSA_NOCLDSTOP0x0008  /* do not generate SIGCHLD on child 
stop */
 #endif /* __POSIX_VISIBLE || __XSI_VISIBLE */
 
-#if __XSI_VISIBLE
+#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200809
 #defineSA_ONSTACK  0x0001  /* take signal on signal stack */
 #defineSA_RESTART  0x0002  /* restart system call on signal return 
*/
 #defineSA_RESETHAND0x0004  /* reset to SIG_DFL when taking signal 
*/



git: 71ed1adda83d - main - grdc: add countdown timer mode

2024-05-10 Thread Warner Losh
The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=71ed1adda83dfaa5d1a2482341b47bd7919498e3

commit 71ed1adda83dfaa5d1a2482341b47bd7919498e3
Author: Gavin Atkinson 
AuthorDate: 2024-05-10 15:22:38 +
Commit: Warner Losh 
CommitDate: 2024-05-10 15:22:38 +

grdc: add countdown timer mode

PR: 35113
Differential Revision:  https://reviews.freebsd.org/D43463
---
 usr.bin/grdc/grdc.6 | 19 +++-
 usr.bin/grdc/grdc.c | 83 ++---
 2 files changed, 71 insertions(+), 31 deletions(-)

diff --git a/usr.bin/grdc/grdc.6 b/usr.bin/grdc/grdc.6
index 3c9660055e2b..7420c8ecbe8b 100644
--- a/usr.bin/grdc/grdc.6
+++ b/usr.bin/grdc/grdc.6
@@ -1,4 +1,4 @@
-.Dd September 25, 2001
+.Dd January 15, 2023
 .Dt GRDC 6
 .Os
 .Sh NAME
@@ -8,6 +8,9 @@
 .Nm
 .Op Fl st
 .Op Ar n
+.Nm
+.Fl c
+.Ar n
 .Sh DESCRIPTION
 .Nm
 runs a digital clock made of reverse-video blanks on a curses
@@ -17,6 +20,11 @@ With an optional numeric argument
 it stops after
 .Ar n
 seconds (default never).
+The clock can act as a countdown timer with the
+.Fl c
+flag,
+.Ar n
+specifies the number of seconds to time for.
 The optional
 .Fl s
 flag makes digits scroll as they change.
@@ -37,8 +45,17 @@ for more information.
 If this variable is not set, the time zone is determined based on
 .Pa /etc/localtime .
 .El
+.Sh NOTES
+In countdown timer mode, the specifying of
+.Fl n
+> 36 seconds (100 hours) will lead to the counter displaying
+incorrect remaining time, however it will time correctly, and
+display correctly when the remaining time becomes less than
+100 hours.
 .Sh AUTHORS
 .An -nosplit
 .An Amos Shapir ,
 modified for curses by
 .An John Lupien .
+Countdown timer mode by
+.An Gavin Atkinson .
diff --git a/usr.bin/grdc/grdc.c b/usr.bin/grdc/grdc.c
index e2a694ebc461..07d12f5a7fb0 100644
--- a/usr.bin/grdc/grdc.c
+++ b/usr.bin/grdc/grdc.c
@@ -1,12 +1,15 @@
 /*
  * Grand digital clock for curses compatible terminals
  * Usage: grdc [-st] [n]   -- run for n seconds (default infinity)
- * Flags: -s: scroll
+ *grdc -c n-- countdown n seconds
+ * Flags: -c: Countdown timer mode
+ *-s: scroll
  *-t: output time in 12-hour format
  *
  *
  * modified 10-18-89 for curses (jrl)
  * 10-18-89 added signal handling
+ * 02-18-02 added countdown timer mode
  *
  * modified 03-25-03 for 12 hour option
  * - Samy Al Bahra 
@@ -26,6 +29,7 @@
 
 static struct timespec now;
 static struct tm *tm;
+static struct timespec end;
 
 static short disp[11] = {
075557, 01, 071747, 071717, 055711,
@@ -59,18 +63,19 @@ main(int argc, char *argv[])
int i, j, s, k;
int n;
int ch;
-   int scrol;
-   int t12;
+   bool scrol = false, t12 = false, timer = false;
+   int hour, minute, second;
 
-   t12 = scrol = 0;
-
-   while ((ch = getopt(argc, argv, "ts")) != -1)
+   while ((ch = getopt(argc, argv, "cst")) != -1)
switch (ch) {
+   case 'c':
+   timer = true;
+   break;
case 's':
-   scrol = 1;
+   scrol = true;
break;
case 't':
-   t12 = 1;
+   t12 = true;
break;
case '?':
default:
@@ -80,7 +85,7 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
 
-   if (argc > 1) {
+   if ((argc > 1) || (argc == 0 && timer)) {
usage();
/* NOTREACHED */
}
@@ -95,6 +100,9 @@ main(int argc, char *argv[])
} else
n = 0;
 
+   if (timer && n == 0)
+   return(0);
+
initscr();
 
signal(SIGINT,sighndl);
@@ -107,7 +115,7 @@ main(int argc, char *argv[])
 
hascolor = has_colors();
 
-   if(hascolor) {
+   if (hascolor) {
start_color();
init_pair(1, COLOR_BLACK, COLOR_RED);
init_pair(2, COLOR_RED, COLOR_BLACK);
@@ -118,7 +126,7 @@ main(int argc, char *argv[])
clear();
refresh();
 
-   if(hascolor) {
+   if (hascolor) {
attrset(COLOR_PAIR(3));
 
mvaddch(YBASE - 2,  XBASE - 3, ACS_ULCORNER);
@@ -139,28 +147,42 @@ main(int argc, char *argv[])
}
clock_gettime(CLOCK_REALTIME_FAST, &now);
prev_sec = now.tv_sec;
+   if (timer) {
+   end = now;
+   end.tv_sec += n;
+   }
do {
mask = 0;
-   tm = localtime(&now.tv_sec);
-   set(tm->tm_sec%10, 0);
-   set(tm->tm_sec/10, 4);
-   set(tm->tm_min%10, 10);
-   set(tm->tm_min/10, 14);
-
-   if (t12) {
-   if (tm->tm_hour < 12) {
-   if (tm->tm_hour == 0)
-   tm->tm_hour = 12;
-   mvaddstr(YBASE + 5, XBASE + 5

git: 6ed7d0e3ac9c - main - grdc: Add copyright

2024-05-10 Thread Warner Losh
The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=6ed7d0e3ac9c34fa9deeb73f2322b9f25b708788

commit 6ed7d0e3ac9c34fa9deeb73f2322b9f25b708788
Author: Warner Losh 
AuthorDate: 2024-05-10 15:22:44 +
Commit: Warner Losh 
CommitDate: 2024-05-10 15:22:44 +

grdc: Add copyright

Add the stock BSD copyright and license from the 4.4-Lite distribution
(indirected by SPDX).

Sponsored by:   Netflix
---
 usr.bin/grdc/grdc.6 | 5 +
 usr.bin/grdc/grdc.c | 7 +++
 2 files changed, 12 insertions(+)

diff --git a/usr.bin/grdc/grdc.6 b/usr.bin/grdc/grdc.6
index 7420c8ecbe8b..4af2cab53517 100644
--- a/usr.bin/grdc/grdc.6
+++ b/usr.bin/grdc/grdc.6
@@ -1,3 +1,8 @@
+.\" SPDX-License-Identifier: BSD-3-Clause
+.\"
+.\" Copyright 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
+.\"The Regents of the University of California.  All rights reserved.
+.\"
 .Dd January 15, 2023
 .Dt GRDC 6
 .Os
diff --git a/usr.bin/grdc/grdc.c b/usr.bin/grdc/grdc.c
index 07d12f5a7fb0..f9e5a9e36bba 100644
--- a/usr.bin/grdc/grdc.c
+++ b/usr.bin/grdc/grdc.c
@@ -1,3 +1,10 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
+ * The Regents of the University of California.  All rights reserved.
+ */
+
 /*
  * Grand digital clock for curses compatible terminals
  * Usage: grdc [-st] [n]   -- run for n seconds (default infinity)



git: ff99bfe3ef73 - stable/13 - inet6: protect address manipulation with a lock

2024-05-10 Thread Zhenlei Huang
The branch stable/13 has been updated by zlei:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=ff99bfe3ef739a026e0cf554295774c8bf02d326

commit ff99bfe3ef739a026e0cf554295774c8bf02d326
Author: Mateusz Guzik 
AuthorDate: 2023-03-29 12:46:41 +
Commit: Zhenlei Huang 
CommitDate: 2024-05-10 16:27:07 +

inet6: protect address manipulation with a lock

This is a total hack/bare minimum which follows inet4.

Otherwise 2 threads removing the same address can easily crash.

Reviewed by:kp
Sponsored by:   Rubicon Communications, LLC ("Netgate")
Differential Revision:  https://reviews.freebsd.org/D39317

(cherry picked from commit f5a365e51feea75d1e5ebc86c53808d8cae7b6d7)
---
 sys/netinet6/in6.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index 946a49030920..acf04e1e56bb 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -163,6 +163,9 @@ static int in6_broadcast_ifa(struct ifnet *, struct 
in6_aliasreq *,
 #define ifa2ia6(ifa)   ((struct in6_ifaddr *)(ifa))
 #define ia62ifa(ia6)   (&((ia6)->ia_ifa))
 
+static struct sx in6_control_sx;
+SX_SYSINIT(in6_control_sx, &in6_control_sx, "in6_control");
+
 void
 in6_newaddrmsg(struct in6_ifaddr *ia, int cmd)
 {
@@ -251,6 +254,7 @@ in6_control(struct socket *so, u_long cmd, caddr_t data,
int carp_attached = 0;
int error;
u_long ocmd = cmd;
+   bool control_locked = false;
 
/*
 * Compat to make pre-10.x ifconfig(8) operable.
@@ -406,6 +410,8 @@ in6_control(struct socket *so, u_long cmd, caddr_t data,
if (td != NULL && (error = prison_check_ip6(td->td_ucred,
&sa6->sin6_addr)) != 0)
return (error);
+   sx_xlock(&in6_control_sx);
+   control_locked = true;
ia = in6ifa_ifpwithaddr(ifp, &sa6->sin6_addr);
} else
ia = NULL;
@@ -710,6 +716,9 @@ aifaddr_out:
 
error = 0;
 out:
+   if (control_locked)
+   sx_xunlock(&in6_control_sx);
+
if (ia != NULL)
ifa_free(&ia->ia_ifa);
return (error);



git: bf1820f187bd - main - nvmecontrol: Fix a sizeof mismatch

2024-05-10 Thread John Baldwin
The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=bf1820f187bd3f90935dc5514e61d1d3a394a21c

commit bf1820f187bd3f90935dc5514e61d1d3a394a21c
Author: John Baldwin 
AuthorDate: 2024-05-10 15:54:02 +
Commit: John Baldwin 
CommitDate: 2024-05-10 15:54:02 +

nvmecontrol: Fix a sizeof mismatch

In this case it is harmless since it is an array of pointers so the
resulting length is identical.

Reported by:Coverity Scan
CID:1545055
Sponsored by:   Chelsio Communications
---
 sbin/nvmecontrol/fabrics.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sbin/nvmecontrol/fabrics.c b/sbin/nvmecontrol/fabrics.c
index c9aca088c47e..d93e984ee7a3 100644
--- a/sbin/nvmecontrol/fabrics.c
+++ b/sbin/nvmecontrol/fabrics.c
@@ -488,7 +488,7 @@ connect_nvm_queues(const struct nvmf_association_params 
*aparams,
}
 
/* I/O queues. */
-   memset(io, 0, sizeof(io) * num_io_queues);
+   memset(io, 0, sizeof(*io) * num_io_queues);
for (u_int i = 0; i < num_io_queues; i++) {
memset(&qparams, 0, sizeof(qparams));
qparams.admin = false;



git: 1f029b86bbe1 - main - nvmf: Use strlcpy instead of strncpy to ensure termination

2024-05-10 Thread John Baldwin
The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=1f029b86bbe11ba6e4bae2392920346817933df0

commit 1f029b86bbe11ba6e4bae2392920346817933df0
Author: John Baldwin 
AuthorDate: 2024-05-10 15:56:51 +
Commit: John Baldwin 
CommitDate: 2024-05-10 15:56:51 +

nvmf: Use strlcpy instead of strncpy to ensure termination

Reported by:Coverity Scan
CID:1545054
Sponsored by:   Chelsio Communications
---
 sys/dev/nvmf/host/nvmf_sim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/nvmf/host/nvmf_sim.c b/sys/dev/nvmf/host/nvmf_sim.c
index b097b04d64c3..00dad07889d1 100644
--- a/sys/dev/nvmf/host/nvmf_sim.c
+++ b/sys/dev/nvmf/host/nvmf_sim.c
@@ -183,7 +183,7 @@ nvmf_sim_action(struct cam_sim *sim, union ccb *ccb)
cpi->xport_specific.nvmf.nsid =
xpt_path_lun_id(ccb->ccb_h.path);
cpi->xport_specific.nvmf.trtype = sc->trtype;
-   strncpy(cpi->xport_specific.nvmf.dev_name,
+   strlcpy(cpi->xport_specific.nvmf.dev_name,
device_get_nameunit(sc->dev),
sizeof(cpi->xport_specific.nvmf.dev_name));
cpi->maxio = sc->max_xfer_size;



git: 0ac468c7b641 - main - nvmecontrol: Free array of I/O queue pairs on failure to handoff

2024-05-10 Thread John Baldwin
The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=0ac468c7b641a1db4ad1435cb7072919ab569c50

commit 0ac468c7b641a1db4ad1435cb7072919ab569c50
Author: John Baldwin 
AuthorDate: 2024-05-10 16:04:51 +
Commit: John Baldwin 
CommitDate: 2024-05-10 16:13:21 +

nvmecontrol: Free array of I/O queue pairs on failure to handoff

This is harmless but cleaner.

Reported by:Coverity Scan
CID:1545041,1545049
Sponsored by:   Chelsio Communications
---
 sbin/nvmecontrol/connect.c   | 5 -
 sbin/nvmecontrol/reconnect.c | 5 -
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/sbin/nvmecontrol/connect.c b/sbin/nvmecontrol/connect.c
index afb78725a3c7..14bd0cce1f8f 100644
--- a/sbin/nvmecontrol/connect.c
+++ b/sbin/nvmecontrol/connect.c
@@ -84,12 +84,15 @@ connect_nvm_controller(enum nvmf_trtype trtype, int adrfam, 
const char *address,
error = connect_nvm_queues(&aparams, trtype, adrfam, address, port,
cntlid, subnqn, opt.hostnqn, opt.kato, &admin, io,
opt.num_io_queues, opt.queue_size, &cdata);
-   if (error != 0)
+   if (error != 0) {
+   free(io);
return (error);
+   }
 
error = nvmf_handoff_host(admin, opt.num_io_queues, io, &cdata);
if (error != 0) {
warnc(error, "Failed to handoff queues to kernel");
+   free(io);
return (EX_IOERR);
}
free(io);
diff --git a/sbin/nvmecontrol/reconnect.c b/sbin/nvmecontrol/reconnect.c
index c8a010c038d0..b606409eea90 100644
--- a/sbin/nvmecontrol/reconnect.c
+++ b/sbin/nvmecontrol/reconnect.c
@@ -85,12 +85,15 @@ reconnect_nvm_controller(int fd, enum nvmf_trtype trtype, 
int adrfam,
error = connect_nvm_queues(&aparams, trtype, adrfam, address, port,
rparams.cntlid, rparams.subnqn, opt.hostnqn, opt.kato, &admin, io,
opt.num_io_queues, opt.queue_size, &cdata);
-   if (error != 0)
+   if (error != 0) {
+   free(io);
return (error);
+   }
 
error = nvmf_reconnect_host(fd, admin, opt.num_io_queues, io, &cdata);
if (error != 0) {
warnc(error, "Failed to handoff queues to kernel");
+   free(io);
return (EX_IOERR);
}
free(io);



git: 1662e47d91d1 - main - nvmecontrol: Free the addrinfo list when failing to open a TCP socket

2024-05-10 Thread John Baldwin
The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=1662e47d91d137891b62fe64ba1370047e7b506f

commit 1662e47d91d137891b62fe64ba1370047e7b506f
Author: John Baldwin 
AuthorDate: 2024-05-10 16:06:54 +
Commit: John Baldwin 
CommitDate: 2024-05-10 16:13:40 +

nvmecontrol: Free the addrinfo list when failing to open a TCP socket

Reported by:Coverity Scan
CID:1545048
Sponsored by:   Chelsio Communications
---
 sbin/nvmecontrol/fabrics.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sbin/nvmecontrol/fabrics.c b/sbin/nvmecontrol/fabrics.c
index d93e984ee7a3..de069e3df62a 100644
--- a/sbin/nvmecontrol/fabrics.c
+++ b/sbin/nvmecontrol/fabrics.c
@@ -168,6 +168,7 @@ tcp_qpair_params(struct nvmf_qpair_params *params, int 
adrfam,
return (true);
}
warn("Failed to connect to controller at %s:%s", address, port);
+   freeaddrinfo(list);
return (false);
 }
 



git: 1f83483d7392 - main - ctl_backend_block: Correct value of NVME nsdata nuse field

2024-05-10 Thread John Baldwin
The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=1f83483d73924de5fa2d5915676f6b2cd350d986

commit 1f83483d73924de5fa2d5915676f6b2cd350d986
Author: John Baldwin 
AuthorDate: 2024-05-10 16:09:53 +
Commit: John Baldwin 
CommitDate: 2024-05-10 16:13:40 +

ctl_backend_block: Correct value of NVME nsdata nuse field

Reported by:Coverity Scan
CID:1545043
Sponsored by:   Chelsio Communications
---
 sys/cam/ctl/ctl_backend_block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c
index 714ed57b5652..55a5ce0d047a 100644
--- a/sys/cam/ctl/ctl_backend_block.c
+++ b/sys/cam/ctl/ctl_backend_block.c
@@ -1339,7 +1339,7 @@ ctl_be_block_namespace_data(struct ctl_be_block_lun 
*be_lun,
memset(nsdata, 0, sizeof(*nsdata));
nsdata->nsze = htole64(be_lun->size_blocks);
nsdata->ncap = nsdata->nsze;
-   nsdata->nuse = nsdata->nuse;
+   nsdata->nuse = nsdata->nsze;
nsdata->nlbaf = 1 - 1;
nsdata->dlfeat = NVMEM(NVME_NS_DATA_DLFEAT_DWZ) |
NVMEF(NVME_NS_DATA_DLFEAT_READ, NVME_NS_DATA_DLFEAT_READ_00);



git: 50884a0b09a8 - main - nvmf_transport: Remove invalid assertion

2024-05-10 Thread John Baldwin
The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=50884a0b09a8e02f08d1083efc9722e49b49c71b

commit 50884a0b09a8e02f08d1083efc9722e49b49c71b
Author: John Baldwin 
AuthorDate: 2024-05-10 16:12:03 +
Commit: John Baldwin 
CommitDate: 2024-05-10 16:13:40 +

nvmf_transport: Remove invalid assertion

This is leftover from an earlier iteration of the code where 'nt' was
not dynamically allocated but was the passed in 'ops' pointer so was
always alive.

Reported by:Coverity Scan
CID:1545042
Sponsored by:   Chelsio Communications
---
 sys/dev/nvmf/nvmf_transport.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/sys/dev/nvmf/nvmf_transport.c b/sys/dev/nvmf/nvmf_transport.c
index 14d526192270..ea4aee8cc7ae 100644
--- a/sys/dev/nvmf/nvmf_transport.c
+++ b/sys/dev/nvmf/nvmf_transport.c
@@ -292,8 +292,6 @@ nvmf_transport_module_handler(struct module *mod, int what, 
void *arg)
prev = nt;
}
if (nt == NULL) {
-   KASSERT(nt->nt_active_qpairs == 0,
-   ("unregistered transport has connections"));
sx_xunlock(&nvmf_transports_lock);
return (0);
}



git: dd4d206cad0c - main - kmod.mk use ${XARGS}

2024-05-10 Thread Simon J. Gerraty
The branch main has been updated by sjg:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=dd4d206cad0cc8ba02ba10a039d708209a83a487

commit dd4d206cad0cc8ba02ba10a039d708209a83a487
Author: Simon J. Gerraty 
AuthorDate: 2024-05-10 19:05:05 +
Commit: Simon J. Gerraty 
CommitDate: 2024-05-10 19:05:05 +

kmod.mk use ${XARGS}

Also ${XARGS_J} this allows use of non-BSD xargs when building
kernel modules.

Reviewed by:imp
Differential Revision:  https://reviews.freebsd.org/D45146
---
 sys/conf/kmod.mk | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk
index 5cc0ff70c3e2..ed186619434d 100644
--- a/sys/conf/kmod.mk
+++ b/sys/conf/kmod.mk
@@ -71,6 +71,8 @@ KMODLOAD?=/sbin/kldload
 KMODUNLOAD?=   /sbin/kldunload
 KMODISLOADED?= /sbin/kldstat -q -n
 OBJCOPY?=  objcopy
+XARGS?=xargs
+XARGS_J?=  -J
 
 .include "kmod.opts.mk"
 .include 
@@ -275,12 +277,12 @@ ${FULLPROG}: ${OBJS} ${BLOB_OBJS}
grep -v '^#' < ${EXPORT_SYMS} > export_syms
 .endif
${AWK} -f ${SYSDIR}/conf/kmod_syms.awk ${.TARGET} \
-   export_syms | xargs -J% ${OBJCOPY} % ${.TARGET}
+   export_syms | ${XARGS} ${XARGS_J} % ${OBJCOPY} % ${.TARGET}
 .endif
 .endif # defined(EXPORT_SYMS)
 .if defined(PREFIX_SYMS)
${AWK} -v prefix=${PREFIX_SYMS} -f ${SYSDIR}/conf/kmod_syms_prefix.awk \
-   ${.TARGET} /dev/null | xargs -J% ${OBJCOPY} % ${.TARGET}
+   ${.TARGET} /dev/null | ${XARGS} ${XARGS_J} % ${OBJCOPY} % ${.TARGET}
 .endif
 .if !defined(DEBUG_FLAGS) && ${__KLD_SHARED} == no
${OBJCOPY} --strip-debug ${.TARGET}



git: 0b272e0926b3 - main - madt: print CPU APIC ID as signed int

2024-05-10 Thread Ed Maste
The branch main has been updated by emaste:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=0b272e0926b3c4b1961131119e22ed5791be7230

commit 0b272e0926b3c4b1961131119e22ed5791be7230
Author: Ed Maste 
AuthorDate: 2024-05-10 18:57:22 +
Commit: Ed Maste 
CommitDate: 2024-05-10 19:20:40 +

madt: print CPU APIC ID as signed int

Instead of printing something like "MADT: Found CPU APIC ID 4294967295
ACPI ID 512: disabled" print the APIC ID as a singed int for a more
user-friendly -1.

Reviewed by:jhb
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45158
---
 sys/x86/acpica/madt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/x86/acpica/madt.c b/sys/x86/acpica/madt.c
index c6358ad7e847..a593028ffb5a 100644
--- a/sys/x86/acpica/madt.c
+++ b/sys/x86/acpica/madt.c
@@ -368,8 +368,8 @@ madt_add_cpu(u_int acpi_id, u_int apic_id, u_int flags)
 * MP code figure out which CPU is the BSP on its own.
 */
if (bootverbose)
-   printf("MADT: Found CPU APIC ID %u ACPI ID %u: %s\n",
-   apic_id, acpi_id, flags & ACPI_MADT_ENABLED ?
+   printf("MADT: Found CPU APIC ID %d ACPI ID %u: %s\n",
+   (int)apic_id, acpi_id, flags & ACPI_MADT_ENABLED ?
"enabled" : "disabled");
if (!(flags & ACPI_MADT_ENABLED))
return;



git: 9d8a3718e24c - main - sctp: store cookie secret change time as time_t Reported by: Coverity Scan CID: 1492349 CID: 1493281 MFC after: 3 days

2024-05-10 Thread Michael Tuexen
The branch main has been updated by tuexen:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=9d8a3718e24c9ec1ffca6efba64aba3e308aee96

commit 9d8a3718e24c9ec1ffca6efba64aba3e308aee96
Author: Michael Tuexen 
AuthorDate: 2024-05-10 18:09:06 +
Commit: Michael Tuexen 
CommitDate: 2024-05-10 18:14:16 +

sctp: store cookie secret change time as time_t
Reported by:Coverity Scan
CID:1492349
CID:1493281
MFC after:  3 days
---
 sys/netinet/sctp_input.c | 4 ++--
 sys/netinet/sctp_pcb.c   | 2 +-
 sys/netinet/sctp_pcb.h   | 4 ++--
 sys/netinet/sctputil.c   | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c
index 0a8372a07362..dc31ffbc2161 100644
--- a/sys/netinet/sctp_input.c
+++ b/sys/netinet/sctp_input.c
@@ -2329,7 +2329,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int 
offset,
}
ep = &(*inp_p)->sctp_ep;
/* which cookie is it? */
-   if ((cookie->time_entered.tv_sec < (long)ep->time_of_secret_change) &&
+   if ((cookie->time_entered.tv_sec < ep->time_of_secret_change) &&
(ep->current_secret_number != ep->last_secret_number)) {
/* it's the old cookie */
(void)sctp_hmac_m(SCTP_HMAC,
@@ -2352,7 +2352,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int 
offset,
/* compare the received digest with the computed digest */
if (timingsafe_bcmp(calc_sig, sig, SCTP_SIGNATURE_SIZE) != 0) {
/* try the old cookie? */
-   if ((cookie->time_entered.tv_sec == 
(long)ep->time_of_secret_change) &&
+   if ((cookie->time_entered.tv_sec == ep->time_of_secret_change) 
&&
(ep->current_secret_number != ep->last_secret_number)) {
/* compute digest with old */
(void)sctp_hmac_m(SCTP_HMAC,
diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c
index 1509ac13901e..65ac584827e0 100644
--- a/sys/netinet/sctp_pcb.c
+++ b/sys/netinet/sctp_pcb.c
@@ -2570,7 +2570,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id)
 
/* Setup the initial secret */
(void)SCTP_GETTIME_TIMEVAL(&time);
-   m->time_of_secret_change = (unsigned int)time.tv_sec;
+   m->time_of_secret_change = time.tv_sec;
 
for (i = 0; i < SCTP_NUMBER_OF_SECRETS; i++) {
m->secret_key[0][i] = sctp_select_initial_TSN(m);
diff --git a/sys/netinet/sctp_pcb.h b/sys/netinet/sctp_pcb.h
index e57e13654073..5c6ead92bf9b 100644
--- a/sys/netinet/sctp_pcb.h
+++ b/sys/netinet/sctp_pcb.h
@@ -263,8 +263,8 @@ struct sctp_base_info {
  * access /dev/random.
  */
 struct sctp_pcb {
-   unsigned int time_of_secret_change; /* number of seconds from
-* timeval.tv_sec */
+   time_t time_of_secret_change;   /* number of seconds from
+* timeval.tv_sec */
uint32_t secret_key[SCTP_HOW_MANY_SECRETS][SCTP_NUMBER_OF_SECRETS];
unsigned int size_of_a_cookie;
 
diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c
index b23efd9c8968..22d45d150544 100644
--- a/sys/netinet/sctputil.c
+++ b/sys/netinet/sctputil.c
@@ -1944,7 +1944,7 @@ sctp_timeout_handler(void *t)
type, inp, stcb, net));
SCTP_STAT_INCR(sctps_timosecret);
(void)SCTP_GETTIME_TIMEVAL(&tv);
-   inp->sctp_ep.time_of_secret_change = (unsigned int)tv.tv_sec;
+   inp->sctp_ep.time_of_secret_change = tv.tv_sec;
inp->sctp_ep.last_secret_number =
inp->sctp_ep.current_secret_number;
inp->sctp_ep.current_secret_number++;



git: 4e3286818327 - main - Increase IOAPIC_MAX_ID to 255 (from 254)

2024-05-10 Thread Ed Maste
The branch main has been updated by emaste:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=4e3286818327453efd8e4c133928ba26a169567a

commit 4e3286818327453efd8e4c133928ba26a169567a
Author: Ed Maste 
AuthorDate: 2024-05-10 17:40:59 +
Commit: Ed Maste 
CommitDate: 2024-05-10 19:40:18 +

Increase IOAPIC_MAX_ID to 255 (from 254)

A test system provided by AMD panicked with "madt_parse_apics:
I/O APIC ID 255 too high".  I/O APIC ID 255 is acceptable, so increase
the limit.

Reviewed by:jhb, kib
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45157
---
 sys/x86/include/apicvar.h | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sys/x86/include/apicvar.h b/sys/x86/include/apicvar.h
index 10016e291b9b..ac6a82659e34 100644
--- a/sys/x86/include/apicvar.h
+++ b/sys/x86/include/apicvar.h
@@ -78,7 +78,12 @@
 #defineMAX_APIC_ID 0x800
 #defineAPIC_ID_ALL 0x
 
-#defineIOAPIC_MAX_ID   xAPIC_MAX_APIC_ID
+/*
+ * The 0xff ID is used for broadcast IPIs for local APICs when not using
+ * x2APIC.  IPIs are not sent to I/O APICs so it's acceptable for an I/O APIC
+ * to use that ID.
+ */
+#defineIOAPIC_MAX_ID   0xff
 
 /* I/O Interrupts are used for external devices such as ISA, PCI, etc. */
 #defineAPIC_IO_INTS(IDT_IO_INTS + 16)



git: 42aeb8d490fb - main - sctp: store vtag expire time as time_t Reported by: Coverity Scan CID: 1492525 CID: 1493239 MFC after: 3 days

2024-05-10 Thread Michael Tuexen
The branch main has been updated by tuexen:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=42aeb8d490fb7e8f4c9d27b3797179b861bd85e3

commit 42aeb8d490fb7e8f4c9d27b3797179b861bd85e3
Author: Michael Tuexen 
AuthorDate: 2024-05-10 18:25:04 +
Commit: Michael Tuexen 
CommitDate: 2024-05-10 18:28:38 +

sctp: store vtag expire time as time_t
Reported by:Coverity Scan
CID:1492525
CID:1493239
MFC after:  3 days
---
 sys/netinet/sctp_pcb.c | 12 ++--
 sys/netinet/sctp_pcb.h |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c
index 65ac584827e0..340786e3484e 100644
--- a/sys/netinet/sctp_pcb.c
+++ b/sys/netinet/sctp_pcb.c
@@ -4541,7 +4541,7 @@ sctp_del_remote_addr(struct sctp_tcb *stcb, struct 
sockaddr *remaddr)
 }
 
 static bool
-sctp_is_in_timewait(uint32_t tag, uint16_t lport, uint16_t rport, uint32_t now)
+sctp_is_in_timewait(uint32_t tag, uint16_t lport, uint16_t rport, time_t now)
 {
struct sctpvtaghead *chain;
struct sctp_tagblock *twait_block;
@@ -4563,7 +4563,7 @@ sctp_is_in_timewait(uint32_t tag, uint16_t lport, 
uint16_t rport, uint32_t now)
 }
 
 static void
-sctp_set_vtag_block(struct sctp_timewait *vtag_block, uint32_t time,
+sctp_set_vtag_block(struct sctp_timewait *vtag_block, time_t time,
 uint32_t tag, uint16_t lport, uint16_t rport)
 {
vtag_block->tv_sec_at_expire = time;
@@ -4578,13 +4578,13 @@ sctp_add_vtag_to_timewait(uint32_t tag, uint16_t lport, 
uint16_t rport)
struct sctpvtaghead *chain;
struct sctp_tagblock *twait_block;
struct timeval now;
-   uint32_t time;
+   time_t time;
int i;
bool set;
 
SCTP_INP_INFO_WLOCK_ASSERT();
(void)SCTP_GETTIME_TIMEVAL(&now);
-   time = (uint32_t)now.tv_sec + SCTP_BASE_SYSCTL(sctp_vtag_time_wait);
+   time = now.tv_sec + SCTP_BASE_SYSCTL(sctp_vtag_time_wait);
chain = &SCTP_BASE_INFO(vtag_timewait)[(tag % 
SCTP_STACK_VTAG_HASH_SIZE)];
set = false;
LIST_FOREACH(twait_block, chain, sctp_nxt_tagblock) {
@@ -4596,7 +4596,7 @@ sctp_add_vtag_to_timewait(uint32_t tag, uint16_t lport, 
uint16_t rport)
continue;
}
if ((twait_block->vtag_block[i].v_tag != 0) &&
-   (twait_block->vtag_block[i].tv_sec_at_expire < 
(uint32_t)now.tv_sec)) {
+   (twait_block->vtag_block[i].tv_sec_at_expire < 
now.tv_sec)) {
if (set) {
/* Audit expires this guy */

sctp_set_vtag_block(twait_block->vtag_block + i, 0, 0, 0, 0);
@@ -6745,7 +6745,7 @@ sctp_is_vtag_good(uint32_t tag, uint16_t lport, uint16_t 
rport, struct timeval *
return (false);
}
}
-   return (!sctp_is_in_timewait(tag, lport, rport, (uint32_t)now->tv_sec));
+   return (!sctp_is_in_timewait(tag, lport, rport, now->tv_sec));
 }
 
 static void
diff --git a/sys/netinet/sctp_pcb.h b/sys/netinet/sctp_pcb.h
index 5c6ead92bf9b..ade29fb3544d 100644
--- a/sys/netinet/sctp_pcb.h
+++ b/sys/netinet/sctp_pcb.h
@@ -130,7 +130,7 @@ struct sctp_block_entry {
 };
 
 struct sctp_timewait {
-   uint32_t tv_sec_at_expire;  /* the seconds from boot to expire */
+   time_t tv_sec_at_expire;/* the seconds from boot to expire */
uint32_t v_tag; /* the vtag that can not be reused */
uint16_t lport; /* the local port used in vtag */
uint16_t rport; /* the remote port used in vtag */



git: b67716dd58b9 - main - sctp: store heartbeat creation time as time_t Reported by: Coverity Scan CID: 1493087 MFC after: 3 days

2024-05-10 Thread Michael Tuexen
The branch main has been updated by tuexen:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=b67716dd58b93f373523cf35373c56fcfad44b12

commit b67716dd58b93f373523cf35373c56fcfad44b12
Author: Michael Tuexen 
AuthorDate: 2024-05-10 18:40:15 +
Commit: Michael Tuexen 
CommitDate: 2024-05-10 18:40:15 +

sctp: store heartbeat creation time as time_t
Reported by:Coverity Scan
CID:1493087
MFC after:  3 days
---
 sys/netinet/sctp_header.h | 2 +-
 sys/netinet/sctp_output.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/netinet/sctp_header.h b/sys/netinet/sctp_header.h
index 9696c4e954ba..c9fd0341f83a 100644
--- a/sys/netinet/sctp_header.h
+++ b/sys/netinet/sctp_header.h
@@ -83,7 +83,7 @@ struct sctp_supported_addr_param {
 /* heartbeat info parameter */
 struct sctp_heartbeat_info_param {
struct sctp_paramhdr ph;
-   uint32_t time_value_1;
+   time_t time_value_1;
uint32_t time_value_2;
uint32_t random_value1;
uint32_t random_value2;
diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c
index c146bda95c7c..cc8d017aba16 100644
--- a/sys/netinet/sctp_output.c
+++ b/sys/netinet/sctp_output.c
@@ -11427,7 +11427,7 @@ sctp_send_hb(struct sctp_tcb *stcb, struct sctp_nets 
*net, int so_locked)
/* Fill out hb parameter */
hb->heartbeat.hb_info.ph.param_type = htons(SCTP_HEARTBEAT_INFO);
hb->heartbeat.hb_info.ph.param_length = htons(sizeof(struct 
sctp_heartbeat_info_param));
-   hb->heartbeat.hb_info.time_value_1 = (uint32_t)now.tv_sec;
+   hb->heartbeat.hb_info.time_value_1 = now.tv_sec;
hb->heartbeat.hb_info.time_value_2 = now.tv_usec;
/* Did our user request this one, put it in */
hb->heartbeat.hb_info.addr_family = 
(uint8_t)net->ro._l_addr.sa.sa_family;



git: 88cbbbb6070c - main - Revert "grdc: Add copyright"

2024-05-10 Thread Warner Losh
The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=88c6070ce3c5aea7b8d511039d44fc1f1c47

commit 88c6070ce3c5aea7b8d511039d44fc1f1c47
Author: Warner Losh 
AuthorDate: 2024-05-10 16:50:46 +
Commit: Warner Losh 
CommitDate: 2024-05-10 20:12:19 +

Revert "grdc: Add copyright"

It turns out this wasn't in 4.4BSD. I had a false positive for gdc.c
(which is in 4.4BSD, but part of gated, not this). gdc.c comes from the
ncurses tests, so it shouldn't have this copyright. This version is
mostly Amos Shapir and John Lupien's code. It comes from ncurses test
directory. ncurses has made dozens of improvements to this file since
we imported it in 1997 (which pre-dates their online history), so it's
not clear if their new copyright applies (which doesn't mention Amos
or John) or if some other copyright applies. In any case, it wasn't
4.4BSD, so revert this.

This reverts commit 6ed7d0e3ac9c34fa9deeb73f2322b9f25b708788.

Sponsored by:   Netflix
---
 usr.bin/grdc/grdc.6 | 5 -
 usr.bin/grdc/grdc.c | 7 ---
 2 files changed, 12 deletions(-)

diff --git a/usr.bin/grdc/grdc.6 b/usr.bin/grdc/grdc.6
index 4af2cab53517..7420c8ecbe8b 100644
--- a/usr.bin/grdc/grdc.6
+++ b/usr.bin/grdc/grdc.6
@@ -1,8 +1,3 @@
-.\" SPDX-License-Identifier: BSD-3-Clause
-.\"
-.\" Copyright 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
-.\"The Regents of the University of California.  All rights reserved.
-.\"
 .Dd January 15, 2023
 .Dt GRDC 6
 .Os
diff --git a/usr.bin/grdc/grdc.c b/usr.bin/grdc/grdc.c
index f9e5a9e36bba..07d12f5a7fb0 100644
--- a/usr.bin/grdc/grdc.c
+++ b/usr.bin/grdc/grdc.c
@@ -1,10 +1,3 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
- * The Regents of the University of California.  All rights reserved.
- */
-
 /*
  * Grand digital clock for curses compatible terminals
  * Usage: grdc [-st] [n]   -- run for n seconds (default infinity)



git: 5120ea0d8871 - main - sctp: improve heartbeat timer computation PR: 278666 Reviewed by: Albin Hellqvist MFC after: 3 days Pull Request: https://reviews.freebsd.org/D45107

2024-05-10 Thread Michael Tuexen
The branch main has been updated by tuexen:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=5120ea0d8871fd5d56a8fb70117b727b9d8a4e62

commit 5120ea0d8871fd5d56a8fb70117b727b9d8a4e62
Author: Michael Tuexen 
AuthorDate: 2024-05-10 18:58:01 +
Commit: Michael Tuexen 
CommitDate: 2024-05-10 19:02:56 +

sctp: improve heartbeat timer computation
PR: 278666
Reviewed by:Albin Hellqvist
MFC after:  3 days
Pull Request:   https://reviews.freebsd.org/D45107
---
 sys/netinet/sctputil.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c
index 22d45d150544..17e49b413464 100644
--- a/sys/netinet/sctputil.c
+++ b/sys/netinet/sctputil.c
@@ -2289,19 +2289,19 @@ sctp_timer_start(int t_type, struct sctp_inpcb *inp, 
struct sctp_tcb *stcb,
} else {
to_ticks = net->RTO;
}
-   rndval = sctp_select_initial_TSN(&inp->sctp_ep);
-   jitter = rndval % to_ticks;
-   if (to_ticks > 1) {
-   to_ticks >>= 1;
-   }
-   if (jitter < (UINT32_MAX - to_ticks)) {
-   to_ticks += jitter;
-   } else {
-   to_ticks = UINT32_MAX;
-   }
if (!((net->dest_state & SCTP_ADDR_UNCONFIRMED) &&
(net->dest_state & SCTP_ADDR_REACHABLE)) &&
((net->dest_state & SCTP_ADDR_PF) == 0)) {
+   if (to_ticks > 1) {
+   rndval = sctp_select_initial_TSN(&inp->sctp_ep);
+   jitter = rndval % to_ticks;
+   to_ticks >>= 1;
+   if (jitter < (UINT32_MAX - to_ticks)) {
+   to_ticks += jitter;
+   } else {
+   to_ticks = UINT32_MAX;
+   }
+   }
if (net->heart_beat_delay < (UINT32_MAX - to_ticks)) {
to_ticks += net->heart_beat_delay;
} else {



git: f75764fea34a - main - md: Merge two switch statements in mdstart_vnode

2024-05-10 Thread John Baldwin
The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f75764fea34afe59f2db338b3e973eba626243ee

commit f75764fea34afe59f2db338b3e973eba626243ee
Author: John Baldwin 
AuthorDate: 2024-05-10 20:43:23 +
Commit: John Baldwin 
CommitDate: 2024-05-10 20:43:23 +

md: Merge two switch statements in mdstart_vnode

While here, use bp->bio_cmd instead of auio.uio_rw to drive read vs
write behavior.

Reviewed by:kib
Differential Revision:  https://reviews.freebsd.org/D45155
---
 sys/dev/md/md.c | 44 
 1 file changed, 20 insertions(+), 24 deletions(-)

diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c
index 241517898ad4..267554031f23 100644
--- a/sys/dev/md/md.c
+++ b/sys/dev/md/md.c
@@ -887,23 +887,6 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
int ma_offs, npages;
bool mapped;
 
-   switch (bp->bio_cmd) {
-   case BIO_READ:
-   auio.uio_rw = UIO_READ;
-   break;
-   case BIO_WRITE:
-   auio.uio_rw = UIO_WRITE;
-   break;
-   case BIO_FLUSH:
-   break;
-   case BIO_DELETE:
-   if (sc->candelete)
-   break;
-   /* FALLTHROUGH */
-   default:
-   return (EOPNOTSUPP);
-   }
-
td = curthread;
vp = sc->vnode;
piov = NULL;
@@ -920,7 +903,14 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
 * still valid.
 */
 
-   if (bp->bio_cmd == BIO_FLUSH) {
+   switch (bp->bio_cmd) {
+   case BIO_READ:
+   auio.uio_rw = UIO_READ;
+   break;
+   case BIO_WRITE:
+   auio.uio_rw = UIO_WRITE;
+   break;
+   case BIO_FLUSH:
do {
(void)vn_start_write(vp, &mp, V_WAIT);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
@@ -929,11 +919,17 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
vn_finished_write(mp);
} while (error == ERELOOKUP);
return (error);
-   } else if (bp->bio_cmd == BIO_DELETE) {
-   error = vn_deallocate(vp, &off, &len, 0,
-   sc->flags & MD_ASYNC ? 0 : IO_SYNC, sc->cred, NOCRED);
-   bp->bio_resid = len;
-   return (error);
+   case BIO_DELETE:
+   if (sc->candelete) {
+   error = vn_deallocate(vp, &off, &len, 0,
+   sc->flags & MD_ASYNC ? 0 : IO_SYNC, sc->cred,
+   NOCRED);
+   bp->bio_resid = len;
+   return (error);
+   }
+   /* FALLTHROUGH */
+   default:
+   return (EOPNOTSUPP);
}
 
auio.uio_offset = (vm_ooffset_t)bp->bio_offset;
@@ -981,7 +977,7 @@ unmapped_step:
auio.uio_iovcnt = 1;
}
iostart = auio.uio_offset;
-   if (auio.uio_rw == UIO_READ) {
+   if (bp->bio_cmd == BIO_READ) {
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_READ(vp, &auio, 0, sc->cred);
VOP_UNLOCK(vp);



git: 473c90ac04ce - main - uio: Use switch statements when handling UIO_READ vs UIO_WRITE

2024-05-10 Thread John Baldwin
The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=473c90ac04cec0abbb414978c53e9c259c9129e8

commit 473c90ac04cec0abbb414978c53e9c259c9129e8
Author: John Baldwin 
AuthorDate: 2024-05-10 20:43:36 +
Commit: John Baldwin 
CommitDate: 2024-05-10 20:43:36 +

uio: Use switch statements when handling UIO_READ vs UIO_WRITE

This is mostly to reduce the diff with CheriBSD which adds additional
constants to enum uio_rw, but also matches the normal style used for
uio_segflg.

Reviewed by:kib, emaste
Obtained from:  CheriBSD
Differential Revision:  https://reviews.freebsd.org/D45142
---
 sys/amd64/amd64/mem.c  | 13 +++--
 sys/amd64/amd64/uio_machdep.c  | 16 
 sys/arm/arm/uio_machdep.c  | 16 
 sys/arm64/arm64/mem.c  | 13 +++--
 sys/arm64/arm64/uio_machdep.c  | 16 
 sys/compat/lindebugfs/lindebugfs.c | 33 +
 sys/dev/iicbus/iic.c   | 16 +++-
 sys/fs/procfs/procfs_osrel.c   |  7 +--
 sys/i386/i386/uio_machdep.c| 16 
 sys/kern/kern_physio.c | 14 ++
 sys/kern/subr_uio.c| 16 
 sys/kern/vfs_vnops.c   |  7 +--
 sys/powerpc/powerpc/uio_machdep.c  | 16 
 sys/riscv/riscv/mem.c  | 13 +++--
 sys/riscv/riscv/uio_machdep.c  | 16 
 sys/ufs/ffs/ffs_suspend.c  |  7 +--
 16 files changed, 174 insertions(+), 61 deletions(-)

diff --git a/sys/amd64/amd64/mem.c b/sys/amd64/amd64/mem.c
index e5285586b928..25d22805ed3e 100644
--- a/sys/amd64/amd64/mem.c
+++ b/sys/amd64/amd64/mem.c
@@ -79,6 +79,7 @@ memrw(struct cdev *dev, struct uio *uio, int flags)
struct iovec *iov;
void *p;
ssize_t orig_resid;
+   vm_prot_t prot;
u_long v, vd;
u_int c;
int error;
@@ -110,8 +111,16 @@ memrw(struct cdev *dev, struct uio *uio, int flags)
break;
}
 
-   if (!kernacc((void *)v, c, uio->uio_rw == UIO_READ ?
-   VM_PROT_READ : VM_PROT_WRITE)) {
+   switch (uio->uio_rw) {
+   case UIO_READ:
+   prot = VM_PROT_READ;
+   break;
+   case UIO_WRITE:
+   prot = VM_PROT_WRITE;
+   break;
+   }
+
+   if (!kernacc((void *)v, c, prot)) {
error = EFAULT;
break;
}
diff --git a/sys/amd64/amd64/uio_machdep.c b/sys/amd64/amd64/uio_machdep.c
index 7b5c89747bc2..83795653fa28 100644
--- a/sys/amd64/amd64/uio_machdep.c
+++ b/sys/amd64/amd64/uio_machdep.c
@@ -97,18 +97,26 @@ uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, int n, 
struct uio *uio)
switch (uio->uio_segflg) {
case UIO_USERSPACE:
maybe_yield();
-   if (uio->uio_rw == UIO_READ)
+   switch (uio->uio_rw) {
+   case UIO_READ:
error = copyout(cp, iov->iov_base, cnt);
-   else
+   break;
+   case UIO_WRITE:
error = copyin(iov->iov_base, cp, cnt);
+   break;
+   }
if (error)
goto out;
break;
case UIO_SYSSPACE:
-   if (uio->uio_rw == UIO_READ)
+   switch (uio->uio_rw) {
+   case UIO_READ:
bcopy(cp, iov->iov_base, cnt);
-   else
+   break;
+   case UIO_WRITE:
bcopy(iov->iov_base, cp, cnt);
+   break;
+   }
break;
case UIO_NOCOPY:
break;
diff --git a/sys/arm/arm/uio_machdep.c b/sys/arm/arm/uio_machdep.c
index de9bc94317e8..6b8e4352e06f 100644
--- a/sys/arm/arm/uio_machdep.c
+++ b/sys/arm/arm/uio_machdep.c
@@ -94,20 +94,28 @@ uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, int n, 
struct uio *uio)
switch (uio->uio_segflg) {
case UIO_USERSPACE:
maybe_yield();
-   if (uio->uio_rw == UIO_READ)
+   switch (uio->uio_rw) {
+   case UIO_READ:
error = copyout(cp, iov->iov_base, cnt);
-   else
+

git: 9e0164087cbf - main - vm: Change the return types of kernacc and useracc to bool

2024-05-10 Thread John Baldwin
The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=9e0164087cbf395624f63a5343357e2f6bd0370c

commit 9e0164087cbf395624f63a5343357e2f6bd0370c
Author: John Baldwin 
AuthorDate: 2024-05-10 20:43:56 +
Commit: John Baldwin 
CommitDate: 2024-05-10 20:43:56 +

vm: Change the return types of kernacc and useracc to bool

Reviewed by:kib
Differential Revision:  https://reviews.freebsd.org/D45156
---
 sys/vm/vm_extern.h | 4 ++--
 sys/vm/vm_glue.c   | 8 
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h
index b50abab7380c..8c9addda1196 100644
--- a/sys/vm/vm_extern.h
+++ b/sys/vm/vm_extern.h
@@ -83,8 +83,8 @@ void kmem_init(vm_offset_t, vm_offset_t);
 void kmem_init_zero_region(void);
 void kmeminit(void);
 
-int kernacc(void *, int, int);
-int useracc(void *, int, int);
+bool kernacc(void *, int, int);
+bool useracc(void *, int, int);
 int vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type,
 int fault_flags, vm_page_t *m_hold);
 void vm_fault_copy_entry(vm_map_t, vm_map_t, vm_map_entry_t, vm_map_entry_t,
diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c
index 979a0fc27120..641800413e68 100644
--- a/sys/vm/vm_glue.c
+++ b/sys/vm/vm_glue.c
@@ -122,7 +122,7 @@
  * just checking the vm_map_entry is sufficient within the kernel's address
  * space.
  */
-int
+bool
 kernacc(void *addr, int len, int rw)
 {
boolean_t rv;
@@ -134,7 +134,7 @@ kernacc(void *addr, int len, int rw)
 
if ((vm_offset_t)addr + len > vm_map_max(kernel_map) ||
(vm_offset_t)addr + len < (vm_offset_t)addr)
-   return (FALSE);
+   return (false);
 
prot = rw;
saddr = trunc_page((vm_offset_t)addr);
@@ -154,7 +154,7 @@ kernacc(void *addr, int len, int rw)
  * vm_fault_quick(), or copyin()/copout()/su*()/fu*() functions should be
  * used in conjunction with this call.
  */
-int
+bool
 useracc(void *addr, int len, int rw)
 {
boolean_t rv;
@@ -167,7 +167,7 @@ useracc(void *addr, int len, int rw)
map = &curproc->p_vmspace->vm_map;
if ((vm_offset_t)addr + len > vm_map_max(map) ||
(vm_offset_t)addr + len < (vm_offset_t)addr) {
-   return (FALSE);
+   return (false);
}
vm_map_lock_read(map);
rv = vm_map_check_protection(map, trunc_page((vm_offset_t)addr),



git: a7cc56b28fb1 - main - linux: Adjust rlimit SIGPENDING & MSGQUEUE behaviour to match linprocfs

2024-05-10 Thread Warner Losh
The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=a7cc56b28fb1615a8ac4ebe826312a5d8a0f17da

commit a7cc56b28fb1615a8ac4ebe826312a5d8a0f17da
Author: Ricardo Branco 
AuthorDate: 2024-05-10 14:20:16 +
Commit: Warner Losh 
CommitDate: 2024-05-10 20:50:04 +

linux: Adjust rlimit SIGPENDING & MSGQUEUE behaviour to match linprocfs

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1227
---
 sys/compat/linux/linux_misc.c | 29 +++--
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index cb62b0e70c0d..9b8ab193f2bd 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -1125,16 +1125,16 @@ linux_getgroups(struct thread *td, struct 
linux_getgroups_args *args)
 }
 
 static bool
-linux_get_dummy_limit(l_uint resource, struct rlimit *rlim)
+linux_get_dummy_limit(struct thread *td, l_uint resource, struct rlimit *rlim)
 {
+   ssize_t size;
+   int res, error;
 
if (linux_dummy_rlimits == 0)
return (false);
 
switch (resource) {
case LINUX_RLIMIT_LOCKS:
-   case LINUX_RLIMIT_SIGPENDING:
-   case LINUX_RLIMIT_MSGQUEUE:
case LINUX_RLIMIT_RTTIME:
rlim->rlim_cur = LINUX_RLIM_INFINITY;
rlim->rlim_max = LINUX_RLIM_INFINITY;
@@ -1144,6 +1144,23 @@ linux_get_dummy_limit(l_uint resource, struct rlimit 
*rlim)
rlim->rlim_cur = 0;
rlim->rlim_max = 0;
return (true);
+   case LINUX_RLIMIT_SIGPENDING:
+   error = kernel_sysctlbyname(td,
+   "kern.sigqueue.max_pending_per_proc",
+   &res, &size, 0, 0, 0, 0);
+   if (error != 0)
+   return (false);
+   rlim->rlim_cur = res;
+   rlim->rlim_max = res;
+   return (true);
+   case LINUX_RLIMIT_MSGQUEUE:
+   error = kernel_sysctlbyname(td,
+   "kern.ipc.msgmnb", &res, &size, 0, 0, 0, 0);
+   if (error != 0)
+   return (false);
+   rlim->rlim_cur = res;
+   rlim->rlim_max = res;
+   return (true);
default:
return (false);
}
@@ -1181,7 +1198,7 @@ linux_old_getrlimit(struct thread *td, struct 
linux_old_getrlimit_args *args)
struct rlimit bsd_rlim;
u_int which;
 
-   if (linux_get_dummy_limit(args->resource, &bsd_rlim)) {
+   if (linux_get_dummy_limit(td, args->resource, &bsd_rlim)) {
rlim.rlim_cur = bsd_rlim.rlim_cur;
rlim.rlim_max = bsd_rlim.rlim_max;
return (copyout(&rlim, args->rlim, sizeof(rlim)));
@@ -1222,7 +1239,7 @@ linux_getrlimit(struct thread *td, struct 
linux_getrlimit_args *args)
struct rlimit bsd_rlim;
u_int which;
 
-   if (linux_get_dummy_limit(args->resource, &bsd_rlim)) {
+   if (linux_get_dummy_limit(td, args->resource, &bsd_rlim)) {
rlim.rlim_cur = bsd_rlim.rlim_cur;
rlim.rlim_max = bsd_rlim.rlim_max;
return (copyout(&rlim, args->rlim, sizeof(rlim)));
@@ -2009,7 +2026,7 @@ linux_prlimit64(struct thread *td, struct 
linux_prlimit64_args *args)
int error;
 
if (args->new == NULL && args->old != NULL) {
-   if (linux_get_dummy_limit(args->resource, &rlim)) {
+   if (linux_get_dummy_limit(td, args->resource, &rlim)) {
lrlim.rlim_cur = rlim.rlim_cur;
lrlim.rlim_max = rlim.rlim_max;
return (copyout(&lrlim, args->old, sizeof(lrlim)));



git: 5a33598e88ad..c2a80056864d - vendor/unbound - vendor branch updated

2024-05-10 Thread Cy Schubert
The branch vendor/unbound has been updated by cy:

URL: https://cgit.FreeBSD.org/src/log/?id=5a33598e88ad..c2a80056864d

c2a80056864d unbound: Vendor import 1.20.0



git: 58569280f16a - Create tag vendor/unbound/1.20.0

2024-05-10 Thread Cy Schubert
The annotated tag vendor/unbound/1.20.0 has been created by cy:

URL: https://cgit.FreeBSD.org/src/tag/?h=vendor/unbound/1.20.0

tag vendor/unbound/1.20.0
Tagger: Cy Schubert 
TaggerDate: 2024-05-10 20:53:01 +

unbound: Tag 1.20.0

commit c2a80056864d6eda0398fd127dc0ae515b39752b
Author: Cy Schubert 
AuthorDate: 2024-05-10 20:48:53 +
Commit: Cy Schubert 
CommitDate: 2024-05-10 20:48:53 +

unbound: Vendor import 1.20.0

Release notes at
https://www.nlnetlabs.nl/news/2024/May/08/unbound-1.20.0-released/

Security:   The DNSBomb vulnerability CVE-2024-33655



git: 467e3e2f2052 - main - CONTRIBUTING.md/style: spring cleaning

2024-05-10 Thread Warner Losh
The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=467e3e2f2052faa012e6100915b6f99a0c74bfb9

commit 467e3e2f2052faa012e6100915b6f99a0c74bfb9
Author: Alexander Ziaee 
AuthorDate: 2024-05-10 06:07:59 +
Commit: Warner Losh 
CommitDate: 2024-05-10 21:07:03 +

CONTRIBUTING.md/style: spring cleaning

+ move Lua to alphabetize subsections
+ word manpages like other subsections
+ man PR's shouldn't bump document date

MFC after: (maybe MFC to BETA3 along w/ e7ff917057ea ?)
---
 CONTRIBUTING.md | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c26b1d335c5f..8e79652a09d2 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -106,19 +106,21 @@ command can help minimize churn by only formatting the 
areas nearby the changes.
 not perfect, using these tools will maximize your chances of not having style
 comments on your pull requests.
 
+For [Lua](https://www.lua.org), see
+[style.lua(9)](https://man.freebsd.org/cgi/man.cgi?query=style.lua&sektion=9)
+for details. Lua is used for the boot loader and a few scripts in the base 
system.
+
 For Makefiles changes, see
 
[style.Makefile(5)](https://man.freebsd.org/cgi/man.cgi?query=style.Makefile&sektion=5)
 for details. FreeBSD's base system uses the in-tree make, not GNU Make, so
 [make(1)](https://man.freebsd.org/cgi/man.cgi?query=make&sektion=1) is another 
useful
 resource.
 
-The project uses mdoc for all its man pages. Changes should pass `mandoc 
-Tlint` and igor (install the latter with `pkg install igor`).
-Please be sure to observe the one-sentence-per-line rule so manual pages 
properly render. Any semantic changes to the manual pages should bump the date.
-[style.mdoc(5)](https://man.freebsd.org/cgi/man.cgi?query=style.mdoc&sektion=5)
 has the all details.
-
-For [Lua](https://www.lua.org), please see
-[style.lua(9)](https://man.freebsd.org/cgi/man.cgi?query=style.lua&sektion=9)
-for details. Lua is used for the boot loader and a few scripts in the base 
system.
+For manual page changes, see
+[style.mdoc(5)](https://man.freebsd.org/cgi/man.cgi?query=style.mdoc&sektion=5)
+for details. Changes should pass `mandoc -Tlint` and igor (install the latter 
with `pkg install igor`).
+Please be sure to observe the one-sentence-per-line rule so manual pages 
properly render.
+Proposed changes to manual pages should not bump the document date until 
merged.
 
 For shell scripts, avoid using bash. The system shell (/bin/sh) is preferred.
 Shell scripts in the base system cannot use bash or bash extensions



git: 816c4d3dcf99 - main - tftpd: Add missing `-S` option to synopsis.

2024-05-10 Thread Dag-Erling Smørgrav
The branch main has been updated by des:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=816c4d3dcf99adcd40a03d93431237ddbd23bbdf

commit 816c4d3dcf99adcd40a03d93431237ddbd23bbdf
Author: Dag-Erling Smørgrav 
AuthorDate: 2024-05-10 21:15:37 +
Commit: Dag-Erling Smørgrav 
CommitDate: 2024-05-10 21:16:26 +

tftpd: Add missing `-S` option to synopsis.

MFC after:  3 days
Sponsored by:   Klara, Inc.
Reviewed by:imp, markj
Differential Revision:  https://reviews.freebsd.org/D45129
---
 libexec/tftpd/tftpd.8 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libexec/tftpd/tftpd.8 b/libexec/tftpd/tftpd.8
index d71da9f1f9ea..558f7bdf809a 100644
--- a/libexec/tftpd/tftpd.8
+++ b/libexec/tftpd/tftpd.8
@@ -25,7 +25,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd July 20, 2023
+.Dd May 8, 2024
 .Dt TFTPD 8
 .Os
 .Sh NAME
@@ -33,11 +33,11 @@
 .Nd Internet Trivial File Transfer Protocol server
 .Sh SYNOPSIS
 .Nm tftpd
-.Op Fl cdClnow
+.Op Fl CcdlnoSw
 .Op Fl F Ar strftime-format
 .Op Fl s Ar directory
-.Op Fl u Ar user
 .Op Fl U Ar umask
+.Op Fl u Ar user
 .Op Ar directory ...
 .Sh DESCRIPTION
 The



git: 1111da6b7c61 - main - tftpd: Drop unneeded includes.

2024-05-10 Thread Dag-Erling Smørgrav
The branch main has been updated by des:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=da6b7c612c571453a23a8dd02fd5e7e40b18

commit da6b7c612c571453a23a8dd02fd5e7e40b18
Author: Dag-Erling Smørgrav 
AuthorDate: 2024-05-10 21:15:42 +
Commit: Dag-Erling Smørgrav 
CommitDate: 2024-05-10 21:16:26 +

tftpd: Drop unneeded includes.

MFC after:  3 days
Sponsored by:   Klara, Inc.
Reviewed by:imp, markj
Differential Revision:  https://reviews.freebsd.org/D45130
---
 libexec/tftpd/tftp-file.h | 1 -
 libexec/tftpd/tftp-io.h   | 1 -
 libexec/tftpd/tftp-options.h  | 1 -
 libexec/tftpd/tftp-transfer.h | 1 -
 libexec/tftpd/tftp-utils.h| 1 -
 5 files changed, 5 deletions(-)

diff --git a/libexec/tftpd/tftp-file.h b/libexec/tftpd/tftp-file.h
index 0fb7f6c1decc..c424e5cbc75b 100644
--- a/libexec/tftpd/tftp-file.h
+++ b/libexec/tftpd/tftp-file.h
@@ -25,7 +25,6 @@
  * SUCH DAMAGE.
  */
 
-#include 
 intwrite_init(int fd, FILE *f, const char *mode);
 size_t write_file(char *buffer, int count);
 intwrite_close(void);
diff --git a/libexec/tftpd/tftp-io.h b/libexec/tftpd/tftp-io.h
index 85934e824a1a..1d6bc2bd8b5e 100644
--- a/libexec/tftpd/tftp-io.h
+++ b/libexec/tftpd/tftp-io.h
@@ -25,7 +25,6 @@
  * SUCH DAMAGE.
  */
 
-#include 
 #define RP_NONE0
 #defineRP_RECVFROM -1
 #defineRP_TOOSMALL -2
diff --git a/libexec/tftpd/tftp-options.h b/libexec/tftpd/tftp-options.h
index c68db53de4e2..f1b0a5cfaf32 100644
--- a/libexec/tftpd/tftp-options.h
+++ b/libexec/tftpd/tftp-options.h
@@ -25,7 +25,6 @@
  * SUCH DAMAGE.
  */
 
-#include 
 /*
  * Options
  */
diff --git a/libexec/tftpd/tftp-transfer.h b/libexec/tftpd/tftp-transfer.h
index 48431ebbc863..449f29c246e0 100644
--- a/libexec/tftpd/tftp-transfer.h
+++ b/libexec/tftpd/tftp-transfer.h
@@ -25,7 +25,6 @@
  * SUCH DAMAGE.
  */
 
-#include 
 inttftp_send(int peer, uint16_t *block, struct tftp_stats *tp);
 inttftp_receive(int peer, uint16_t *block, struct tftp_stats *tp,
struct tftphdr *firstblock, size_t fb_size);
diff --git a/libexec/tftpd/tftp-utils.h b/libexec/tftpd/tftp-utils.h
index 763b3b493c7e..f87bb71c 100644
--- a/libexec/tftpd/tftp-utils.h
+++ b/libexec/tftpd/tftp-utils.h
@@ -25,7 +25,6 @@
  * SUCH DAMAGE.
  */
 
-#include 
 /*
  */
 #defineTIMEOUT 5



git: ae285a8cbf12 - main - tftpd: Add missing include.

2024-05-10 Thread Dag-Erling Smørgrav
The branch main has been updated by des:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=ae285a8cbf1212bdc1b3f81219635bc1395fadee

commit ae285a8cbf1212bdc1b3f81219635bc1395fadee
Author: Dag-Erling Smørgrav 
AuthorDate: 2024-05-10 21:15:45 +
Commit: Dag-Erling Smørgrav 
CommitDate: 2024-05-10 21:16:26 +

tftpd: Add missing include.

This went unnoticed due to namespace pollution in our headers.

MFC after:  3 days
Sponsored by:   Klara, Inc.
Reviewed by:imp
Differential Revision:  https://reviews.freebsd.org/D45131
---
 libexec/tftpd/tests/functional.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libexec/tftpd/tests/functional.c b/libexec/tftpd/tests/functional.c
index d3d2f46ffdee..54ace29d718c 100644
--- a/libexec/tftpd/tests/functional.c
+++ b/libexec/tftpd/tests/functional.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 



git: 4d09eb87c5d5 - main - tftpd: Satisfy clang-analyzer.

2024-05-10 Thread Dag-Erling Smørgrav
The branch main has been updated by des:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=4d09eb87c5d5bec2e2832f50537e2ce6f75f4117

commit 4d09eb87c5d5bec2e2832f50537e2ce6f75f4117
Author: Dag-Erling Smørgrav 
AuthorDate: 2024-05-10 21:15:49 +
Commit: Dag-Erling Smørgrav 
CommitDate: 2024-05-10 21:16:26 +

tftpd: Satisfy clang-analyzer.

* Replace `random()` with `arc4random()`.
* Change some variable types.
* Drop some unused assignments.

MFC after:  3 days
Sponsored by:   Klara, Inc.
Reviewed by:imp, markj
Differential Revision:  https://reviews.freebsd.org/D45132
---
 libexec/tftpd/tftp-io.c| 11 ---
 libexec/tftpd/tftp-utils.c |  2 +-
 libexec/tftpd/tftp-utils.h |  2 +-
 libexec/tftpd/tftpd.c  | 13 ++---
 4 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/libexec/tftpd/tftp-io.c b/libexec/tftpd/tftp-io.c
index d43e5f5505f9..50102e652d2f 100644
--- a/libexec/tftpd/tftp-io.c
+++ b/libexec/tftpd/tftp-io.c
@@ -71,13 +71,13 @@ static struct errmsg {
 
 #define DROPPACKET(s)  \
if (packetdroppercentage != 0 &&\
-   random()%100 < packetdroppercentage) {  \
+   arc4random()%100 < packetdroppercentage) {  \
tftp_log(LOG_DEBUG, "Artificial packet drop in %s", s); \
return; \
}
 #define DROPPACKETn(s,n)   \
if (packetdroppercentage != 0 &&\
-   random()%100 < packetdroppercentage) {  \
+   arc4random()%100 < packetdroppercentage) {  \
tftp_log(LOG_DEBUG, "Artificial packet drop in %s", s); \
return (n); \
}
@@ -156,10 +156,8 @@ send_error(int peer, int error)
pe->e_msg = strerror(error - 100);
tp->th_code = EUNDEF;   /* set 'undef' errorcode */
}
-   strcpy(tp->th_msg, pe->e_msg);
-   length = strlen(pe->e_msg);
-   tp->th_msg[length] = '\0';
-   length += 5;
+   snprintf(tp->th_msg, MAXPKTSIZE - 4, "%s%n", pe->e_msg, &length);
+   length += 5; /* header and terminator */
 
if (debug & DEBUG_PACKETS)
tftp_log(LOG_DEBUG, "Sending ERROR %d: %s", error, tp->th_msg);
@@ -330,7 +328,6 @@ send_ack(int fp, uint16_t block)
DROPPACKETn("send_ack", 0);
 
tp = (struct tftphdr *)buf;
-   size = sizeof(buf) - 2;
tp->th_opcode = htons((u_short)ACK);
tp->th_block = htons((u_short)block);
size = 4;
diff --git a/libexec/tftpd/tftp-utils.c b/libexec/tftpd/tftp-utils.c
index b309a94f7653..8ce7c09c9992 100644
--- a/libexec/tftpd/tftp-utils.c
+++ b/libexec/tftpd/tftp-utils.c
@@ -204,7 +204,7 @@ struct debugs debugs[] = {
{ DEBUG_ACCESS, "access",   "TCPd access debugging" },
{ DEBUG_NONE,   NULL,   "No debugging"  },
 };
-intpacketdroppercentage = 0;
+unsigned int packetdroppercentage = 0;
 
 int
 debug_find(char *s)
diff --git a/libexec/tftpd/tftp-utils.h b/libexec/tftpd/tftp-utils.h
index f87bb71c..276dedcf74cd 100644
--- a/libexec/tftpd/tftp-utils.h
+++ b/libexec/tftpd/tftp-utils.h
@@ -99,7 +99,7 @@ struct debugs {
 };
 extern int debug;
 extern struct debugs debugs[];
-extern int packetdroppercentage;
+extern unsigned int packetdroppercentage;
 intdebug_find(char *s);
 intdebug_finds(char *s);
 const char *debug_show(int d);
diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c
index c832097e0ba0..80497738f60d 100644
--- a/libexec/tftpd/tftpd.c
+++ b/libexec/tftpd/tftpd.c
@@ -160,7 +160,7 @@ main(int argc, char *argv[])
options_extra_enabled = 0;
break;
case 'p':
-   packetdroppercentage = atoi(optarg);
+   packetdroppercentage = (unsigned int)atoi(optarg);
tftp_log(LOG_INFO,
"Randomly dropping %d out of 100 packets",
packetdroppercentage);
@@ -451,9 +451,9 @@ static char *
 parse_header(int peer, char *recvbuffer, size_t size,
char **filename, char **mode)
 {
-   char*cp;
-   int i;
struct formats *pf;
+   char*cp;
+   size_t  i;
 
*mode = NULL;
cp = recvbuffer;
@@ -470,12 +470,11 @@ parse_header(int peer, char *recvbuffer, size_t size,
 
i = get_field(peer, cp, size);
*mode = cp;
-   cp += i;
 
/* Find the file transfer mode */
-   for (cp = *mode; *cp; cp++)
-   if (isupper(*cp))
-   *cp = tolower(*cp);
+   for (; *cp; cp++)
+   if (isupper((unsigned char)*cp))
+

git: 25945af47e7a - main - tftpd: silence gcc overflow warnings

2024-05-10 Thread Dag-Erling Smørgrav
The branch main has been updated by des:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=25945af47e7a1d06c44c8c160045a866e90569ab

commit 25945af47e7a1d06c44c8c160045a866e90569ab
Author: Dag-Erling Smørgrav 
AuthorDate: 2024-05-10 21:15:54 +
Commit: Dag-Erling Smørgrav 
CommitDate: 2024-05-10 21:16:26 +

tftpd: silence gcc overflow warnings

GCC 13 complains that we might be writing too much to an on-stack buffer
when createing a filename.

In practice there is a check that filename isn't too long given the
time format and other static characters so GCC is incorrect, but GCC
isn't wrong that we're potentially trying to put a MAXPATHLEN length
string + some other characters into a MAXPATHLEN buffer (if you ignore
the check GCC can't realistically evaluate at compile time).

Switch to snprintf to populate filename to ensure that future logic
errors don't result in a stack overflow.

Shorten the questionably named mmdd buffer enough to slience the
warning (checking the snprintf return value isn't sufficent) while
preserving maximum flexibility for admins who use the -F option.

MFC after:  3 days
Sponsored by:   Klara, Inc.
Reviewed by:brooks
Differential Revision:  https://reviews.freebsd.org/D45086
---
 libexec/tftpd/tftpd.c | 43 +--
 1 file changed, 29 insertions(+), 14 deletions(-)

diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c
index 80497738f60d..3f67ad2920cf 100644
--- a/libexec/tftpd/tftpd.c
+++ b/libexec/tftpd/tftpd.c
@@ -611,12 +611,20 @@ tftp_rrq(int peer, char *recvbuffer, size_t size)
 static int
 find_next_name(char *filename, int *fd)
 {
-   int i;
+   /*
+* GCC "knows" that we might write all of mmdd plus the static
+* elemenents in the format into into newname and thus complains
+* unless we reduce the size.  This array is still too big, but since
+* the format is user supplied, it's not clear what a better limit
+* value would be and this is sufficent to silence the warnings.
+*/
+   static const int suffix_len = strlen("..00");
+   char mmdd[MAXPATHLEN - suffix_len];
+   char newname[MAXPATHLEN];
+   int i, ret;
time_t tval;
-   size_t len;
+   size_t len, namelen;
struct tm lt;
-   char mmdd[MAXPATHLEN];
-   char newname[MAXPATHLEN];
 
/* Create the MMDD part of the filename */
time(&tval);
@@ -624,26 +632,33 @@ find_next_name(char *filename, int *fd)
len = strftime(mmdd, sizeof(mmdd), newfile_format, <);
if (len == 0) {
syslog(LOG_WARNING,
-   "Filename suffix too long (%d characters maximum)",
-   MAXPATHLEN);
+   "Filename suffix too long (%zu characters maximum)",
+   sizeof(mmdd) - 1);
return (EACCESS);
}
 
/* Make sure the new filename is not too long */
-   if (strlen(filename) > MAXPATHLEN - len - 5) {
+   namelen = strlen(filename);
+   if (namelen >= sizeof(newname) - len - suffix_len) {
syslog(LOG_WARNING,
-   "Filename too long (%zd characters, %zd maximum)",
-   strlen(filename), MAXPATHLEN - len - 5);
+   "Filename too long (%zu characters, %zu maximum)",
+   namelen,
+   sizeof(newname) - len - suffix_len - 1);
return (EACCESS);
}
 
/* Find the first file which doesn't exist */
for (i = 0; i < 100; i++) {
-   sprintf(newname, "%s.%s.%02d", filename, mmdd, i);
-   *fd = open(newname,
-   O_WRONLY | O_CREAT | O_EXCL,
-   S_IRUSR | S_IWUSR | S_IRGRP |
-   S_IWGRP | S_IROTH | S_IWOTH);
+   ret = snprintf(newname, sizeof(newname), "%s.%s.%02d",
+   filename, mmdd, i);
+   /*
+* Size checked above so this can't happen, we'd use a
+* (void) cast, but gcc intentionally ignores that if
+* snprintf has __attribute__((warn_unused_result)).
+*/
+   if (ret < 0 || (size_t)ret >= sizeof(newname))
+   __unreachable();
+   *fd = open(newname, O_WRONLY | O_CREAT | O_EXCL, 0666);
if (*fd > 0)
return 0;
}



git: 335c7cda1213 - main - unbound: Vendor import 1.20.0

2024-05-10 Thread Cy Schubert
The branch main has been updated by cy:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=335c7cda12138f2aefa41fb739707612cc12a9be

commit 335c7cda12138f2aefa41fb739707612cc12a9be
Merge: 25945af47e7a c2a80056864d
Author: Cy Schubert 
AuthorDate: 2024-05-10 20:56:34 +
Commit: Cy Schubert 
CommitDate: 2024-05-10 21:23:43 +

unbound: Vendor import 1.20.0

Release notes at
https://www.nlnetlabs.nl/news/2024/May/08/unbound-1.20.0-released/

Security:   The DNSBomb vulnerability CVE-2024-33655

Merge commit 'c2a80056864d6eda0398fd127dc0ae515b39752b' into main

 contrib/unbound/Makefile.in|16 +-
 contrib/unbound/{ac_pkg_swig.m4 => ax_pkg_swig.m4} |   110 +-
 contrib/unbound/ax_pthread.m4  |   444 +-
 contrib/unbound/cachedb/cachedb.c  |   133 +-
 contrib/unbound/cachedb/cachedb.h  |16 +
 contrib/unbound/config.h.in|   105 +-
 contrib/unbound/configure  | 12872 +
 contrib/unbound/configure.ac   |16 +-
 contrib/unbound/configure~ | 26616 +++
 contrib/unbound/contrib/rc_d_unbound   | 9 +
 contrib/unbound/contrib/unbound.init   | 1 +
 contrib/unbound/contrib/unbound.init_fedora| 1 +
 contrib/unbound/contrib/unbound.init_yocto | 1 +
 contrib/unbound/daemon/cachedump.c |23 +-
 contrib/unbound/daemon/daemon.c|26 +-
 contrib/unbound/daemon/remote.c|   130 +-
 contrib/unbound/daemon/unbound.c   |39 +-
 contrib/unbound/daemon/worker.c|35 +-
 contrib/unbound/doc/Changelog  |   187 +-
 contrib/unbound/doc/README | 2 +-
 contrib/unbound/doc/example.conf.in|28 +-
 contrib/unbound/doc/libunbound.3.in| 4 +-
 contrib/unbound/doc/unbound-anchor.8.in| 2 +-
 contrib/unbound/doc/unbound-checkconf.8.in | 6 +-
 contrib/unbound/doc/unbound-control.8.in   | 8 +-
 contrib/unbound/doc/unbound-host.1.in  | 2 +-
 contrib/unbound/doc/unbound.8.in   | 4 +-
 contrib/unbound/doc/unbound.conf.5.in  |72 +-
 contrib/unbound/doc/unbound.doxygen|  2931 +-
 contrib/unbound/edns-subnet/subnetmod.c|40 +-
 contrib/unbound/iterator/iter_fwd.c|   119 +-
 contrib/unbound/iterator/iter_fwd.h|60 +-
 contrib/unbound/iterator/iter_hints.c  |95 +-
 contrib/unbound/iterator/iter_hints.h  |54 +-
 contrib/unbound/iterator/iter_utils.c  |62 +-
 contrib/unbound/iterator/iter_utils.h  | 6 +-
 contrib/unbound/iterator/iterator.c|   295 +-
 contrib/unbound/libunbound/context.c   | 8 +
 contrib/unbound/libunbound/libunbound.c| 5 +
 contrib/unbound/libunbound/libworker.c |21 +-
 contrib/unbound/services/authzone.c|10 +
 contrib/unbound/services/cache/dns.c   |52 +-
 contrib/unbound/services/cache/infra.c |   170 +-
 contrib/unbound/services/cache/infra.h |28 +
 contrib/unbound/services/cache/rrset.c |87 +
 contrib/unbound/services/cache/rrset.h |31 +
 contrib/unbound/services/listen_dnsport.c  |51 +-
 contrib/unbound/services/listen_dnsport.h  | 8 +-
 contrib/unbound/services/localzone.c   | 6 +-
 contrib/unbound/services/mesh.c|   106 +-
 contrib/unbound/services/mesh.h| 6 +
 contrib/unbound/services/rpz.c |   342 +-
 contrib/unbound/services/rpz.h | 8 +
 contrib/unbound/services/view.h| 3 +-
 contrib/unbound/smallapp/unbound-anchor.c  |70 +-
 contrib/unbound/smallapp/unbound-checkconf.c   |13 +-
 contrib/unbound/smallapp/unbound-control.c | 5 +-
 contrib/unbound/testdata/cachedb_expired.crpl  |   324 +
 .../testdata/cachedb_expired_client_timeout.crpl   |   343 +
 .../testdata/cachedb_expired_reply_ttl.crpl|   259 +
 .../unbound/testdata/cachedb_subnet_change.crpl|   304 +
 .../unbound/testdata/cachedb_subnet_expired.crpl   |   322 +
 .../testdata/cachedb_subnet_toecs_timeout.crpl |   229 +
 contrib/unbound/testdata/iter_dname_ttl.rpl|39 -
 .../testdata/iter_ghost_grandchild_delegation.rpl  |   256 +
 contrib/unbound/testdata/local_cnameother.rpl  |67 +
 contrib/unbound/testdata/rpz_clientip_override.rpl |   269 +
 contrib/unbound/testdata/rpz_cname_handle.rpl  |   779 +
 contrib/unbound/testdata/rpz_nsdname_override.rpl  |   325 +
 contrib/unbound/testdata/rpz_nsip_

Re: git: 335c7cda1213 - main - unbound: Vendor import 1.20.0

2024-05-10 Thread Cy Schubert
In message <202405102124.44alohr7099...@gitrepo.freebsd.org>, Cy Schubert 
write
s:
> The branch main has been updated by cy:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=335c7cda12138f2aefa41fb739707612
> cc12a9be
>
> commit 335c7cda12138f2aefa41fb739707612cc12a9be
> Merge: 25945af47e7a c2a80056864d
> Author: Cy Schubert 
> AuthorDate: 2024-05-10 20:56:34 +
> Commit: Cy Schubert 
> CommitDate: 2024-05-10 21:23:43 +
>
> unbound: Vendor import 1.20.0
> 
> Release notes at
> https://www.nlnetlabs.nl/news/2024/May/08/unbound-1.20.0-released
> /
> 
> Security:   The DNSBomb vulnerability CVE-2024-33655
> 
> Merge commit 'c2a80056864d6eda0398fd127dc0ae515b39752b' into main

I've put it in my calendar to MFC this in a month.


-- 
Cheers,
Cy Schubert 
FreeBSD UNIX: Web:  https://FreeBSD.org
NTP:   Web:  https://nwtime.org

e^(i*pi)+1=0





git: 38c35248fe3b - main - kern/intr: remove support for passing trap frame as argument

2024-05-10 Thread Warner Losh
The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=38c35248fe3b740e107682b4a10bebe28992590f

commit 38c35248fe3b740e107682b4a10bebe28992590f
Author: Elliott Mitchell 
AuthorDate: 2021-10-08 21:43:26 +
Commit: Warner Losh 
CommitDate: 2024-05-10 21:33:24 +

kern/intr: remove support for passing trap frame as argument

While otherwise a handy potential approach, getting the trap frame via
the argument isn't documented and isn't supposed to be used.  With all
uses removed, now remove support to end the mixed calling conventions.

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

Reviewed by: imp, mhorne
Pull Request: https://github.com/freebsd/freebsd-src/pull/1225
---
 sys/kern/kern_intr.c | 15 ---
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c
index 9073e0d7af01..008f8d1242ca 100644
--- a/sys/kern/kern_intr.c
+++ b/sys/kern/kern_intr.c
@@ -1346,8 +1346,8 @@ ithread_loop(void *arg)
  *
  * Input:
  * o ie:the event connected to this interrupt.
- * o frame: some archs (i.e. i386) pass a frame to some.
- *  handlers as their main argument.
+ * o frame: the current trap frame.
+ *
  * Return value:
  * o 0: everything ok.
  * o EINVAL:stray interrupt.
@@ -1374,9 +1374,6 @@ intr_event_handle(struct intr_event *ie, struct trapframe 
*frame)
 
/*
 * Execute fast interrupt handlers directly.
-* To support clock handlers, if a handler registers
-* with a NULL argument, then we pass it a pointer to
-* a trapframe as its argument.
 */
td->td_intr_nesting_level++;
filter = false;
@@ -1405,12 +1402,8 @@ intr_event_handle(struct intr_event *ie, struct 
trapframe *frame)
continue;
}
CTR4(KTR_INTR, "%s: exec %p(%p) for %s", __func__,
-   ih->ih_filter, ih->ih_argument == NULL ? frame :
-   ih->ih_argument, ih->ih_name);
-   if (ih->ih_argument == NULL)
-   ret = ih->ih_filter(frame);
-   else
-   ret = ih->ih_filter(ih->ih_argument);
+   ih->ih_filter, ih->ih_argument, ih->ih_name);
+   ret = ih->ih_filter(ih->ih_argument);
 #ifdef HWPMC_HOOKS
PMC_SOFT_CALL_TF( , , intr, all, frame);
 #endif



git: a2409f17377e - main - intr: Document how to get the interrupt frame

2024-05-10 Thread Warner Losh
The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=a2409f17377ebb5c6e3e522ae090a0845ee19aeb

commit a2409f17377ebb5c6e3e522ae090a0845ee19aeb
Author: Warner Losh 
AuthorDate: 2024-05-10 21:41:36 +
Commit: Warner Losh 
CommitDate: 2024-05-10 21:41:36 +

intr: Document how to get the interrupt frame

Document that the only way to get the interrupt thread is to use
curthread->td_intr_frame, rather than the old-style of having a NULL
pointer for the interrupt thread. As of 38c35248fe3b, support for that
has been removed. I neglected to update that commit message with these
details.

Suggested by: mhorne
---
 sys/kern/kern_intr.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c
index 008f8d1242ca..7a57d964acd9 100644
--- a/sys/kern/kern_intr.c
+++ b/sys/kern/kern_intr.c
@@ -1346,7 +1346,10 @@ ithread_loop(void *arg)
  *
  * Input:
  * o ie:the event connected to this interrupt.
- * o frame: the current trap frame.
+
+ * o frame: the current trap frame. If the client interrupt
+ * handler needs this frame, they should get it
+ * via curthread->td_intr_frame.
  *
  * Return value:
  * o 0: everything ok.



git: 3c414a8c2fb3 - stable/14 - nfsd: Fix Link conformance with RFC8881 for delegations

2024-05-10 Thread Rick Macklem
The branch stable/14 has been updated by rmacklem:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=3c414a8c2fb37ca37de454aaa145e7bcaefcaa05

commit 3c414a8c2fb37ca37de454aaa145e7bcaefcaa05
Author: Rick Macklem 
AuthorDate: 2024-05-04 21:30:07 +
Commit: Rick Macklem 
CommitDate: 2024-05-11 01:04:40 +

nfsd: Fix Link conformance with RFC8881 for delegations

RFC8881 specifies that, when a Link operation occurs on an
NFSv4, that file delegations issued to other clients must
be recalled.  Discovered during a recent discussion on nf...@ietf.org.

Although I have not observed a problem caused by not doing
the required delegation recall, it is definitely required
by the RFC, so this patch makes the server do the recall.

Tested during a recent NFSv4 IETF Bakeathon event.

(cherry picked from commit 3f65000b6b1460a7a23cd83014bb41a68d1a8a19)
---
 sys/fs/nfs/nfs_var.h|  2 +-
 sys/fs/nfsserver/nfs_nfsdport.c | 12 +++-
 sys/fs/nfsserver/nfs_nfsdserv.c | 11 +--
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h
index 578fb3ce1340..950e0c097457 100644
--- a/sys/fs/nfs/nfs_var.h
+++ b/sys/fs/nfs/nfs_var.h
@@ -713,7 +713,7 @@ int nfsvno_rmdirsub(struct nameidata *, int, struct ucred 
*, NFSPROC_T *,
 struct nfsexstuff *);
 int nfsvno_rename(struct nameidata *, struct nameidata *, u_int32_t,
 u_int32_t, struct ucred *, NFSPROC_T *);
-int nfsvno_link(struct nameidata *, vnode_t, struct ucred *,
+int nfsvno_link(struct nameidata *, vnode_t, nfsquad_t, struct ucred *,
 NFSPROC_T *, struct nfsexstuff *);
 int nfsvno_fsync(vnode_t, u_int64_t, int, struct ucred *, NFSPROC_T *);
 int nfsvno_statfs(vnode_t, struct statfs *);
diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c
index f8c2ddfd2a59..f4679309657b 100644
--- a/sys/fs/nfsserver/nfs_nfsdport.c
+++ b/sys/fs/nfsserver/nfs_nfsdport.c
@@ -1656,8 +1656,8 @@ out1:
  * Link vnode op.
  */
 int
-nfsvno_link(struct nameidata *ndp, struct vnode *vp, struct ucred *cred,
-struct thread *p, struct nfsexstuff *exp)
+nfsvno_link(struct nameidata *ndp, struct vnode *vp, nfsquad_t clientid,
+struct ucred *cred, struct thread *p, struct nfsexstuff *exp)
 {
struct vnode *xp;
int error = 0;
@@ -1672,9 +1672,11 @@ nfsvno_link(struct nameidata *ndp, struct vnode *vp, 
struct ucred *cred,
}
if (!error) {
NFSVOPLOCK(vp, LK_EXCLUSIVE | LK_RETRY);
-   if (!VN_IS_DOOMED(vp))
-   error = VOP_LINK(ndp->ni_dvp, vp, &ndp->ni_cnd);
-   else
+   if (!VN_IS_DOOMED(vp)) {
+   error = nfsrv_checkremove(vp, 0, NULL, clientid, p);
+   if (error == 0)
+   error = VOP_LINK(ndp->ni_dvp, vp, &ndp->ni_cnd);
+   } else
error = EPERM;
if (ndp->ni_dvp == vp) {
vrele(ndp->ni_dvp);
diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c
index 8141ee6cbdb6..0c8bda6dc6a6 100644
--- a/sys/fs/nfsserver/nfs_nfsdserv.c
+++ b/sys/fs/nfsserver/nfs_nfsdserv.c
@@ -1797,6 +1797,7 @@ nfsrvd_link(struct nfsrv_descript *nd, int isdgram,
char *bufp;
u_long *hashp;
struct thread *p = curthread;
+   nfsquad_t clientid;
 
if (nd->nd_repstat) {
nfsrv_postopattr(nd, getret, &at);
@@ -1858,8 +1859,14 @@ nfsrvd_link(struct nfsrv_descript *nd, int isdgram,
NULL);
}
}
-   if (!nd->nd_repstat)
-   nd->nd_repstat = nfsvno_link(&named, vp, nd->nd_cred, p, exp);
+   if (!nd->nd_repstat) {
+   clientid.qval = 0;
+   if ((nd->nd_flag & (ND_IMPLIEDCLID | ND_NFSV41)) ==
+   (ND_IMPLIEDCLID | ND_NFSV41))
+   clientid.qval = nd->nd_clientid.qval;
+   nd->nd_repstat = nfsvno_link(&named, vp, clientid, nd->nd_cred,
+   p, exp);
+   }
if (nd->nd_flag & ND_NFSV3)
getret = nfsvno_getattr(vp, &at, nd, p, 0, NULL);
if (dirp) {



git: 85e63d952d5d - stable/13 - nfsd: Fix Link conformance with RFC8881 for delegations

2024-05-10 Thread Rick Macklem
The branch stable/13 has been updated by rmacklem:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=85e63d952d5daf929c24874a3b309e1b2e04bebf

commit 85e63d952d5daf929c24874a3b309e1b2e04bebf
Author: Rick Macklem 
AuthorDate: 2024-05-04 21:30:07 +
Commit: Rick Macklem 
CommitDate: 2024-05-11 01:09:21 +

nfsd: Fix Link conformance with RFC8881 for delegations

RFC8881 specifies that, when a Link operation occurs on an
NFSv4, that file delegations issued to other clients must
be recalled.  Discovered during a recent discussion on nf...@ietf.org.

Although I have not observed a problem caused by not doing
the required delegation recall, it is definitely required
by the RFC, so this patch makes the server do the recall.

Tested during a recent NFSv4 IETF Bakeathon event.

(cherry picked from commit 3f65000b6b1460a7a23cd83014bb41a68d1a8a19)
---
 sys/fs/nfs/nfs_var.h|  2 +-
 sys/fs/nfsserver/nfs_nfsdport.c | 12 +++-
 sys/fs/nfsserver/nfs_nfsdserv.c | 11 +--
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h
index 8cdc08fba433..083a974516b0 100644
--- a/sys/fs/nfs/nfs_var.h
+++ b/sys/fs/nfs/nfs_var.h
@@ -707,7 +707,7 @@ int nfsvno_rmdirsub(struct nameidata *, int, struct ucred 
*, NFSPROC_T *,
 struct nfsexstuff *);
 int nfsvno_rename(struct nameidata *, struct nameidata *, u_int32_t,
 u_int32_t, struct ucred *, NFSPROC_T *);
-int nfsvno_link(struct nameidata *, vnode_t, struct ucred *,
+int nfsvno_link(struct nameidata *, vnode_t, nfsquad_t, struct ucred *,
 NFSPROC_T *, struct nfsexstuff *);
 int nfsvno_fsync(vnode_t, u_int64_t, int, struct ucred *, NFSPROC_T *);
 int nfsvno_statfs(vnode_t, struct statfs *);
diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c
index ebc560836205..46be3e051056 100644
--- a/sys/fs/nfsserver/nfs_nfsdport.c
+++ b/sys/fs/nfsserver/nfs_nfsdport.c
@@ -1675,8 +1675,8 @@ out1:
  * Link vnode op.
  */
 int
-nfsvno_link(struct nameidata *ndp, struct vnode *vp, struct ucred *cred,
-struct thread *p, struct nfsexstuff *exp)
+nfsvno_link(struct nameidata *ndp, struct vnode *vp, nfsquad_t clientid,
+struct ucred *cred, struct thread *p, struct nfsexstuff *exp)
 {
struct vnode *xp;
int error = 0;
@@ -1691,9 +1691,11 @@ nfsvno_link(struct nameidata *ndp, struct vnode *vp, 
struct ucred *cred,
}
if (!error) {
NFSVOPLOCK(vp, LK_EXCLUSIVE | LK_RETRY);
-   if (!VN_IS_DOOMED(vp))
-   error = VOP_LINK(ndp->ni_dvp, vp, &ndp->ni_cnd);
-   else
+   if (!VN_IS_DOOMED(vp)) {
+   error = nfsrv_checkremove(vp, 0, NULL, clientid, p);
+   if (error == 0)
+   error = VOP_LINK(ndp->ni_dvp, vp, &ndp->ni_cnd);
+   } else
error = EPERM;
if (ndp->ni_dvp == vp) {
vrele(ndp->ni_dvp);
diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c
index 437f4b1c685d..ccaeb4153253 100644
--- a/sys/fs/nfsserver/nfs_nfsdserv.c
+++ b/sys/fs/nfsserver/nfs_nfsdserv.c
@@ -1799,6 +1799,7 @@ nfsrvd_link(struct nfsrv_descript *nd, int isdgram,
char *bufp;
u_long *hashp;
struct thread *p = curthread;
+   nfsquad_t clientid;
 
if (nd->nd_repstat) {
nfsrv_postopattr(nd, getret, &at);
@@ -1861,8 +1862,14 @@ nfsrvd_link(struct nfsrv_descript *nd, int isdgram,
NULL);
}
}
-   if (!nd->nd_repstat)
-   nd->nd_repstat = nfsvno_link(&named, vp, nd->nd_cred, p, exp);
+   if (!nd->nd_repstat) {
+   clientid.qval = 0;
+   if ((nd->nd_flag & (ND_IMPLIEDCLID | ND_NFSV41)) ==
+   (ND_IMPLIEDCLID | ND_NFSV41))
+   clientid.qval = nd->nd_clientid.qval;
+   nd->nd_repstat = nfsvno_link(&named, vp, clientid, nd->nd_cred,
+   p, exp);
+   }
if (nd->nd_flag & ND_NFSV3)
getret = nfsvno_getattr(vp, &at, nd, p, 0, NULL);
if (dirp) {



git: c1ebd76c3f28 - main - arm64: add page-to-pte convenience macros

2024-05-10 Thread Doug Moore
The branch main has been updated by dougm:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c1ebd76c3f283b10afe6b64f29fe68c4d1be3f8c

commit c1ebd76c3f283b10afe6b64f29fe68c4d1be3f8c
Author: Doug Moore 
AuthorDate: 2024-05-11 06:04:48 +
Commit: Doug Moore 
CommitDate: 2024-05-11 06:04:48 +

arm64: add page-to-pte convenience macros

Define macros to perform pte to vm_page and vm_page to pte conversions
without composing two macros, and use the convenience macros wherever
possible.

Reviewed by:alc
Differential Revision:  https://reviews.freebsd.org/D44699
---
 sys/arm64/arm64/pmap.c | 107 ++---
 1 file changed, 48 insertions(+), 59 deletions(-)

diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index b1a85befa4e1..7780c6ec8767 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -281,6 +281,9 @@ VM_PAGE_TO_PV_LIST_LOCK(vm_page_t m)
}   \
 } while (0)
 
+#define PTE_TO_VM_PAGE(pte) PHYS_TO_VM_PAGE(PTE_TO_PHYS(pte))
+#define VM_PAGE_TO_PTE(m) PHYS_TO_PTE(VM_PAGE_TO_PHYS(m))
+
 /*
  * The presence of this flag indicates that the mapping is writeable.
  * If the ATTR_S1_AP_RO bit is also set, then the mapping is clean, otherwise
@@ -2095,7 +2098,7 @@ pmap_kenter(vm_offset_t sva, vm_size_t size, vm_paddr_t 
pa, int mode)
 */
if ((va & L2_OFFSET) == 0 && size >= L2_SIZE &&
(pa & L2_OFFSET) == 0 && vm_initialized) {
-   mpte = PHYS_TO_VM_PAGE(PTE_TO_PHYS(pmap_load(pde)));
+   mpte = PTE_TO_VM_PAGE(pmap_load(pde));
KASSERT(pmap_every_pte_zero(VM_PAGE_TO_PHYS(mpte)),
("pmap_kenter: Unexpected mapping"));
PMAP_LOCK(kernel_pmap);
@@ -2279,7 +2282,7 @@ void
 pmap_qenter(vm_offset_t sva, vm_page_t *ma, int count)
 {
pd_entry_t *pde;
-   pt_entry_t attr, old_l3e, pa, *pte;
+   pt_entry_t attr, old_l3e, *pte;
vm_offset_t va;
vm_page_t m;
int i, lvl;
@@ -2294,11 +2297,10 @@ pmap_qenter(vm_offset_t sva, vm_page_t *ma, int count)
("pmap_qenter: Invalid level %d", lvl));
 
m = ma[i];
-   pa = VM_PAGE_TO_PHYS(m);
attr = ATTR_DEFAULT | ATTR_S1_AP(ATTR_S1_AP_RW) | ATTR_S1_XN |
ATTR_KERN_GP | ATTR_S1_IDX(m->md.pv_memattr) | L3_PAGE;
pte = pmap_l2_to_l3(pde, va);
-   old_l3e |= pmap_load_store(pte, PHYS_TO_PTE(pa) | attr);
+   old_l3e |= pmap_load_store(pte, VM_PAGE_TO_PTE(m) | attr);
 
va += L3_SIZE;
}
@@ -2411,7 +2413,7 @@ _pmap_unwire_l3(pmap_t pmap, vm_offset_t va, vm_page_t m, 
struct spglist *free)
 
l1 = pmap_l1(pmap, va);
tl1 = pmap_load(l1);
-   l2pg = PHYS_TO_VM_PAGE(PTE_TO_PHYS(tl1));
+   l2pg = PTE_TO_VM_PAGE(tl1);
pmap_unwire_l3(pmap, va, l2pg, free);
} else if (m->pindex < (NUL2E + NUL1E)) {
/* We just released an l2, unhold the matching l1 */
@@ -2420,7 +2422,7 @@ _pmap_unwire_l3(pmap_t pmap, vm_offset_t va, vm_page_t m, 
struct spglist *free)
 
l0 = pmap_l0(pmap, va);
tl0 = pmap_load(l0);
-   l1pg = PHYS_TO_VM_PAGE(PTE_TO_PHYS(tl0));
+   l1pg = PTE_TO_VM_PAGE(tl0);
pmap_unwire_l3(pmap, va, l1pg, free);
}
pmap_invalidate_page(pmap, va, false);
@@ -2447,7 +2449,7 @@ pmap_unuse_pt(pmap_t pmap, vm_offset_t va, pd_entry_t 
ptepde,
if (ADDR_IS_KERNEL(va))
return (0);
KASSERT(ptepde != 0, ("pmap_unuse_pt: ptepde != 0"));
-   mpte = PHYS_TO_VM_PAGE(PTE_TO_PHYS(ptepde));
+   mpte = PTE_TO_VM_PAGE(ptepde);
return (pmap_unwire_l3(pmap, va, mpte, free));
 }
 
@@ -2610,7 +2612,7 @@ _pmap_alloc_l3(pmap_t pmap, vm_pindex_t ptepindex, struct 
rwlock **lockp)
l0p = &pmap->pm_l0[l0index];
KASSERT((pmap_load(l0p) & ATTR_DESCR_VALID) == 0,
("%s: L0 entry %#lx is valid", __func__, pmap_load(l0p)));
-   l0e = PHYS_TO_PTE(VM_PAGE_TO_PHYS(m)) | L0_TABLE;
+   l0e = VM_PAGE_TO_PTE(m) | L0_TABLE;
 
/*
 * Mark all kernel memory as not accessible from userspace
@@ -2642,7 +2644,7 @@ _pmap_alloc_l3(pmap_t pmap, vm_pindex_t ptepindex, struct 
rwlock **lockp)
return (NULL);
}
} else {
-   l1pg = PHYS_TO_VM_PAGE(PTE_TO_PHYS(tl0));
+   l1pg = PTE_TO_VM_PAGE(tl0);
l1pg->ref_count++;
}
 
@@ -2650,7 +2652,7 @@ _pmap_alloc_l3(pmap_t pmap, vm_pindex_t ptepindex, struct 
rwlock **lockp)
l1 = &l1[ptepindex & Ln_ADDR_MASK];