FreeBSD/src 99d295elib/libc/stdlib realpath.c

realpath: Improve prev_len logic

* Save prev_len after having checked for and appended a trailing slash,
  not before.  This requires us to back up if we end up returning a
  partial result, but previously we would sometimes return a partial
  result with a trailing slash and sometimes without.

* Replace strlcat() with a faster strlcpy() since we know exactly how
  far into the buffer we are.

MFC after:      1 week
Sponsored by:   Klara, Inc.
Reviewed by:    kevans
Differential Revision:  https://reviews.freebsd.org/D55914
DeltaFile
+7-3lib/libc/stdlib/realpath.c
+7-31 files

FreeBSD/src 1aecb32lib/libc/stdlib realpath.3

realpath: Improve manual page

* Try to make the RETURN VALUES section flow better.

* Add basename(3), dirname(3), free(3) to the SEE ALSO section.

* Drop the CAVEATS section, which was obsolete the moment realpath(3)
  was added to the Single Unix Specification in 1994.

MFC after:      1 week
Sponsored by:   Klara, Inc.
Reviewed by:    kevans
Differential Revision:  https://reviews.freebsd.org/D55928
DeltaFile
+12-24lib/libc/stdlib/realpath.3
+12-241 files

FreeBSD/src dad6e6fsys/vm vm_mmap.c

Provide more precise error explanations for mmap(2) EINVAL errors.

Reviewed by:  kib
Differential Revision: https://reviews.freebsd.org/D55888
MFC-after:    1 week
Sponsored by: Netflix
DeltaFile
+23-13sys/vm/vm_mmap.c
+23-131 files

FreeBSD/src 51446d3sys/vm vm_mmap.c

Delete error-check code that can never happen.

Near the top of kern_mmap() that implements the mmap(2) system call,
it sets

        prot = PROT_EXTRACT(prot);

with

So prot can only be the three PROT_ flags.

The following test of the user's mmap(2) parameters (near line 275
in vm/vm_mmap.c):

        if (prot != PROT_NONE &&
            (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) != 0) {
                return (EXTERROR(EINVAL, "invalid prot %#jx", prot));
        }


    [7 lines not shown]
DeltaFile
+0-4sys/vm/vm_mmap.c
+0-41 files

FreeBSD/src 8f41ee9sys/dev/cxgbe/common t4_hw.c

cxgbe(4): decode the T7 MC interrupt correctly

The layout for the main INT_CAUSE is a bit different for T7.

MFC after:      1 week
Sponsored by:   Chelsio Communications
DeltaFile
+10-0sys/dev/cxgbe/common/t4_hw.c
+10-01 files

FreeBSD/src 6317122sys/dev/cxgbe/common t4_hw.c

cxgbe(4): adjustments to the output of the slow interrupt handler

- Display an appropriate alert character instead of a question mark for
  unknown bits.
- Display all fatal bits for a register and not just the ones that are
  currently set.

MFC after:      1 week
Sponsored by:   Chelsio Communications
DeltaFile
+5-4sys/dev/cxgbe/common/t4_hw.c
+5-41 files

FreeBSD/src 85cf26csys/netinet in_var.h

in_var.h: fixup comments that mention use by ifmcstat(8)
DeltaFile
+1-4sys/netinet/in_var.h
+1-41 files

FreeBSD/src ad0e698usr.sbin/ifmcstat ifmcstat.c ifmcstat.8

ifmcstat: remove libkvm(3) code

It has been broken and disabled for over 10 years.  Remove mentions of the
kvm(3) from the manual page.
DeltaFile
+2-500usr.sbin/ifmcstat/ifmcstat.c
+1-44usr.sbin/ifmcstat/ifmcstat.8
+3-5442 files

FreeBSD/src 1acf507release/tools ec2.conf

EC2: Don't use unicode in boot loader

The boot loader menu is disabled by default in EC2, but if it is ever
turned on, the default (unicode) output breaks EC2's web interface to
the serial console.

Set loader_menu_frame="ascii" instead.

MFC after:      3 days
Sponsored by:   Amazon

(cherry picked from commit 277830b4d3ae9999c80bf915b5491850e91c6516)
(cherry picked from commit 251907ca480eff7f6177f52959b71a6cfce45579)
DeltaFile
+4-1release/tools/ec2.conf
+4-11 files

FreeBSD/src c25839csys/kern subr_intr.c

intrng: Shuffle unhandled interrupts too

When interrupt vectors are first allocated, they get assigned to
CPU #0; at SI_SUB_SMP / SI_ORDER_SECOND (aka once we have multiple
CPUs), the intr_irq_shuffle SYSINIT clears their CPU sets with the
effect of forcing them to be assigned to new CPUs later.

In case where interrupt vectors were allocated *but not yet bound*
this code did not run, with the effect that those interrupts would
remain pinned to CPU #0 forever.  This affected the ena(4) driver,
which allocates interrupts for I/O when the device is attached but
doesn't set them up until the interface is brought up much later in
the boot process (and, crucially, long after intr_irq_shuffle runs).

Adjust intr_irq_shuffle to clear the CPU set for an interrupt source
even if it currently has no handlers, so that it will be properly
assigned to a CPU when it is used later.

Reviewed by:    andrew, mhorne

    [5 lines not shown]
DeltaFile
+13-1sys/kern/subr_intr.c
+13-11 files

FreeBSD/src 660a79erelease/tools ec2.conf

EC2: Don't use unicode in boot loader

The boot loader menu is disabled by default in EC2, but if it is ever
turned on, the default (unicode) output breaks EC2's web interface to
the serial console.

Set loader_menu_frame="ascii" instead.

MFC after:      3 days
Sponsored by:   Amazon

(cherry picked from commit 277830b4d3ae9999c80bf915b5491850e91c6516)
(cherry picked from commit 251907ca480eff7f6177f52959b71a6cfce45579)
DeltaFile
+4-1release/tools/ec2.conf
+4-11 files

FreeBSD/src b109809sys/kern subr_intr.c

intrng: Shuffle unhandled interrupts too

When interrupt vectors are first allocated, they get assigned to
CPU #0; at SI_SUB_SMP / SI_ORDER_SECOND (aka once we have multiple
CPUs), the intr_irq_shuffle SYSINIT clears their CPU sets with the
effect of forcing them to be assigned to new CPUs later.

In case where interrupt vectors were allocated *but not yet bound*
this code did not run, with the effect that those interrupts would
remain pinned to CPU #0 forever.  This affected the ena(4) driver,
which allocates interrupts for I/O when the device is attached but
doesn't set them up until the interface is brought up much later in
the boot process (and, crucially, long after intr_irq_shuffle runs).

Adjust intr_irq_shuffle to clear the CPU set for an interrupt source
even if it currently has no handlers, so that it will be properly
assigned to a CPU when it is used later.

Reviewed by:    andrew, mhorne

    [5 lines not shown]
DeltaFile
+13-1sys/kern/subr_intr.c
+13-11 files

FreeBSD/src 3ee08abmodule/os/linux/zfs zpl_super.c

linux/super: flatten zpl_fill_super into zpl_get_tree

Target of opportunity; with no other callers, there's no need for it to
be a static function.

Sponsored-by: TrueNAS
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18339
DeltaFile
+6-17module/os/linux/zfs/zpl_super.c
+6-171 files

FreeBSD/src 96a0b20module/os/linux/zfs zpl_super.c

linux/super: flatten zpl_mount_impl into zpl_get_tree

Target of opportunity; with no other callers, there's no need for it to
be a static function.

Sponsored-by: TrueNAS
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18339
DeltaFile
+69-75module/os/linux/zfs/zpl_super.c
+69-751 files

FreeBSD/src 5ebb9ffmodule/os/linux/zfs zpl_super.c

linux/super: flatten mount/remount into get_tree/reconfigure

With the old API gone, there's no need to massage new-style calls into
its shape and call another function; we can just make those handlers
work directly.

Sponsored-by: TrueNAS
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18339
DeltaFile
+17-40module/os/linux/zfs/zpl_super.c
+17-401 files

FreeBSD/src f828aebmodule/os/linux/zfs zpl_super.c

linux/super: remove support for old mount API

Removing the HAVE_FS_CONTEXT gates and anything that would be used if it
wasn't set.

Sponsored-by: TrueNAS
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18339
DeltaFile
+0-11module/os/linux/zfs/zpl_super.c
+0-111 files

FreeBSD/src 188888aconfig kernel-fs-context.m4

config: refuse to build without fs_context

Sponsored-by: TrueNAS
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #18339
DeltaFile
+3-0config/kernel-fs-context.m4
+3-01 files

FreeBSD/src cc66722tests/sys/netinet raw.c

tests/netinet/raw: fix ssize_t printf(3) format

Fixes:  c1481c9f4a425db7295332be87f837bfb7d127df
DeltaFile
+1-1tests/sys/netinet/raw.c
+1-11 files

FreeBSD/src f259a47man/man8 zpool-iostat.8

zpool-iostat.8: clarify first report shows per-second averages

The first report printed by zpool iostat shows average per-second
values since boot, not cumulative totals. Clarify this in the man
page to avoid user confusion.

Reviewed-by: Tony Hutter <hutter2 at llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Christos Longros <chris.longros at gmail.com>
Closes #18337
DeltaFile
+2-2man/man8/zpool-iostat.8
+2-21 files

FreeBSD/src c1481c9tests/sys/netinet raw.c Makefile

tests/netinet: provide test for raw_ip.c:rip_input()

The test creates differently bound SOCK_RAW sockets and sends different
probe packets.  There is expected results matrix that every probe is
checked against.
DeltaFile
+219-0tests/sys/netinet/raw.c
+3-0tests/sys/netinet/Makefile
+222-02 files

FreeBSD/src b0b6364sys/fs/tarfs tarfs_io.c

tarfs: swap deprecated ZSTD_resetDStream() with ZSTD_DCtx_reset()

ZSTD_resetDStream() is deprecated since 1.5.4: https://github.com/facebook/zstd/commit/5d8cfa6b96a6442ab1251f9de3b47a0eb12561a0

This change is needed to MFV zstd 1.5.7.

Approved by:    emaste (mentor)
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D55835

(cherry picked from commit 922d73540d2d9897e5e8160c445cefa13581564e)
DeltaFile
+2-2sys/fs/tarfs/tarfs_io.c
+2-21 files

FreeBSD/src 317c242sys/fs/tarfs tarfs_io.c

tarfs: swap deprecated ZSTD_resetDStream() with ZSTD_DCtx_reset()

ZSTD_resetDStream() is deprecated since 1.5.4: https://github.com/facebook/zstd/commit/5d8cfa6b96a6442ab1251f9de3b47a0eb12561a0

This change is needed to MFV zstd 1.5.7.

Approved by:    emaste (mentor)
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D55835

(cherry picked from commit 922d73540d2d9897e5e8160c445cefa13581564e)
DeltaFile
+2-2sys/fs/tarfs/tarfs_io.c
+2-21 files

FreeBSD/src 9031b83sbin/pfctl pfctl.8 pfctl.c

pfctl: consistency

% pfctl -F ethernet
Ethernet rules cleared

% pfctl -s ethernet
pfctl: Unknown show modifier 'ethernet'

pfctl accepts 'ethernet' (or any prefix of it) in the -F flag but
accepts only 'ether' (or any prefix of it) in the -s flag, which seems
inconsistent.  This change brings the two to parity while remaining
backwards compatible.

Reviewed by:    kp
MFC after:      2 weeks
Signed-off-by: Seth Hoffert <seth.hoffert at gmail.com>
(cherry picked from commit 36acf1bd32ed5749af4a9f735aeea1a3434fe42f)
DeltaFile
+1-1sbin/pfctl/pfctl.8
+1-1sbin/pfctl/pfctl.c
+2-22 files

FreeBSD/src d8c08a1module/os/linux/zfs zpl_file.c

Linux 7.0: also set setlease handler on directories (#18331)

It turns out the kernel can also take directory leases, most notably in
the NFS server. Without a setlease handler on the directory file ops,
attempts to open a directory over NFS can fail with EINVAL.

Adding a directory setlease handler was missed in 168023b603. This fixes
that, allowing directories to be properly accessed over NFS.

Sponsored-by: TrueNAS
Reported-by: Satadru Pramanik <satadru at gmail.com>

Signed-off-by: Rob Norris <rob.norris at truenas.com>
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
DeltaFile
+1-0module/os/linux/zfs/zpl_file.c
+1-01 files

FreeBSD/src 2353fa1sys/compat/linuxkpi/common/include/linux fs.h

LinuxKPI: Fix simple_read_from_buffer for zero-size and off-the-end reads

I noticed that the buf_size < 0 check can never be true (it's a
size_t) and decided to check for this condition by an alternate
expression, and I also noticed that a read_size of 0 would incorrectly
return -EFAULT.  Instead, return success for both of these cases as
reading beyond the EOF of a normal file also returns EOF, not EINVAL.

Reviewed by:    bz
Sponsored by:   AFRL, DARPA
Differential Revision:  https://reviews.freebsd.org/D55845
DeltaFile
+2-2sys/compat/linuxkpi/common/include/linux/fs.h
+2-21 files

FreeBSD/src 2cf1514sys/compat/lindebugfs lindebugfs.c, sys/compat/linuxkpi/common/include/linux fs.h seq_file.h

lindebugfs: Pass user buffer pointers to the read/write file operations

The Linux file_operations API expects the read and write operations
to take a single user buffer pointer (along with the length and the
file offset as an in/out parameter).

However, the debugfs_fill function was violating this part of the
contract as it was passing down kernel pointers instead.  An earlier
commit (5668c22a13c6befa9b8486387d38457c40ce7af4) hacked around this
by modifying simple_read_from_buffer() to treat its user pointer
argument as a kernel pointer instead.  However, other commits keep
tripping over this same API mismatch
(e.g. 78e25e65bf381303c8bdac9a713ab7b26a854b8c passes a kernel pointer
to copy_from_user in fops_str_write).

Instead, change debugfs_fill to use the "raw" pseudofs mode where the
uio is passed down to directly to the fill callback rather than an
sbuf.  debufs_fill now iterates over the iovec in the uio similar to
the implementation of uiomove invoking the read or write operation on

    [24 lines not shown]
DeltaFile
+54-27sys/compat/lindebugfs/lindebugfs.c
+23-12sys/compat/linuxkpi/common/src/linux_simple_attr.c
+13-15sys/compat/linuxkpi/common/include/linux/fs.h
+1-1sys/compat/linuxkpi/common/include/linux/seq_file.h
+1-1sys/compat/linuxkpi/common/src/linux_seq_file.c
+92-565 files

FreeBSD/src 14e9744sys/arm64/arm64 trap.c

arm64: Have a common call to userret

Rather than each exception calling userret use a common copy. As
syscallret already calls userret we need to skip it in that case.

Reviewed by:    kib
Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D55250
DeltaFile
+9-21sys/arm64/arm64/trap.c
+9-211 files

FreeBSD/src 58d74d7sys/compat/linuxkpi/common/src linux_simple_attr.c linux_seq_file.c

LinuxKPI: Use simple_read_from_buffer in simple_attr_read and seq_read

Reviewed by:    bz
Sponsored by:   AFRL, DARPA
Differential Revision:  https://reviews.freebsd.org/D55879
DeltaFile
+2-11sys/compat/linuxkpi/common/src/linux_simple_attr.c
+2-9sys/compat/linuxkpi/common/src/linux_seq_file.c
+4-202 files

FreeBSD/src c181c8fsys/compat/linuxkpi/common/src linux_seq_file.c

LinuxKPI: Clear the sbuf at the start of each call to seq_read

Each invocation of seq_read invokes the seq_file.show callback which
writes into the sbuf.  Then it invokes sbuf_finish before copying the
data into the caller's buffer.  Without this, a second call to
seq_read on the same file would try to append data to a finished sbuf.

Reviewed by:    bz
Sponsored by:   AFRL, DARPA
DeltaFile
+1-0sys/compat/linuxkpi/common/src/linux_seq_file.c
+1-01 files

FreeBSD/src edc9c3eusr.sbin/virtual_oss/virtual_oss main.c

virtual_oss: Combine -d, -l and -L option getopt code

Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D55671

(cherry picked from commit a2b601343bf9261c4ada51e4d4c30c5b9320bb2b)
DeltaFile
+3-21usr.sbin/virtual_oss/virtual_oss/main.c
+3-211 files