freebsd-dev/config
Richard Yao 7584fbe846
Cleanup: Switch to strlcpy from strncpy
Coverity found a bug in `zfs_secpolicy_create_clone()` where it is
possible for us to pass an unterminated string when `zfs_get_parent()`
returns an error. Upon inspection, it is clear that using `strlcpy()`
would have avoided this issue.

Looking at the codebase, there are a number of other uses of `strncpy()`
that are unsafe and even when it is used safely, switching to
`strlcpy()` would make the code more readable. Therefore, we switch all
instances where we use `strncpy()` to use `strlcpy()`.

Unfortunately, we do not portably have access to `strlcpy()` in
tests/zfs-tests/cmd/zfs_diff-socket.c because it does not link to
libspl. Modifying the appropriate Makefile.am to try to link to it
resulted in an error from the naming choice used in the file. Trying to
disable the check on the file did not work on FreeBSD because Clang
ignores `#undef` when a definition is provided by `-Dstrncpy(...)=...`.
We workaround that by explictly including the C file from libspl into
the test. This makes things build correctly everywhere.

We add a deprecation warning to `config/Rules.am` and suppress it on the
remaining `strncpy()` usage. `strlcpy()` is not portably avaliable in
tests/zfs-tests/cmd/zfs_diff-socket.c, so we use `snprintf()` there as a
substitute.

This patch does not tackle the related problem of `strcpy()`, which is
even less safe. Thankfully, a quick inspection found that it is used far
more correctly than strncpy() was used. A quick inspection did not find
any problems with `strcpy()` usage outside of zhack, but it should be
said that I only checked around 90% of them.

Lastly, some of the fields in kstat_t varied in size by 1 depending on
whether they were in userspace or in the kernel. The origin of this
discrepancy appears to be 04a479f706 where
it was made for no apparent reason. It conflicts with the comment on
KSTAT_STRLEN, so we shrink the kernel field sizes to match the userspace
field sizes.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13876
2022-09-27 16:35:29 -07:00
..
.gitignore Prepare SPL repo to merge with ZFS repo 2018-05-29 14:51:39 -07:00
always-arch.m4 Introduce BLAKE3 checksums as an OpenZFS feature 2022-06-08 15:55:57 -07:00
always-compiler-options.m4 Silence -Winfinite-recursion warning in luaD_throw() 2022-06-27 14:18:50 -07:00
always-cppcheck.m4 autoconf: use include directives instead of recursing down lib 2022-05-10 10:18:11 -07:00
always-parallel.m4 config: check for parallel(1), use it for cstyle 2022-01-06 12:46:42 -08:00
always-python.m4 Removed Python 2 and Python 3.5- support 2022-01-13 09:51:12 -07:00
always-pyzfs.m4 Removed Python 2 and Python 3.5- support 2022-01-13 09:51:12 -07:00
always-sed.m4 Add compatibility for busybox mktemp 2020-12-03 10:01:16 -08:00
always-shellcheck.m4 Turn checkbashisms into a make target 2021-06-01 11:38:54 -07:00
always-system.m4 autoconf: use include directives instead of recursing down lib 2022-05-10 10:18:11 -07:00
ax_code_coverage.m4 Updated the lz4 decompressor 2022-01-07 10:36:49 -08:00
ax_count_cpus.m4 cppcheck: integrete cppcheck 2021-01-26 16:12:26 -08:00
ax_python_devel.m4 Python 3.10 fixes, part 2 2021-10-29 15:36:01 -07:00
ax_restore_flags.m4 config: better libtirpc detection 2019-03-02 16:19:05 -08:00
ax_save_flags.m4 config: better libtirpc detection 2019-03-02 16:19:05 -08:00
config.rpath Add config.rpath for AM_GNU_GETTEXT 2020-07-10 14:26:12 -07:00
CppCheck.am cppcheck: explicitly exclude kernel code from userspace checks 2022-05-10 10:20:55 -07:00
deb.am rpm -> deb doesn't fail when optional packages are missing 2022-04-20 13:43:42 -07:00
find_system_library.m4 Spruce up pkg-config files for libzfs/libzfs_core 2020-09-04 11:11:18 -07:00
gettext.m4 config: libintl/libiconv for gettext() detection 2019-04-19 12:09:29 -07:00
host-cpu-c-abi.m4 config: libintl/libiconv for gettext() detection 2019-04-19 12:09:29 -07:00
iconv.m4 Clarify comments in config/*.m4, vdev_geom.c, zfs_allow_*.ksh 2020-06-22 09:46:37 -07:00
intlmacosx.m4 config: libintl/libiconv for gettext() detection 2019-04-19 12:09:29 -07:00
kernel-access-ok-type.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-acl.m4 Linux 5.15 compat: get_acl() 2021-09-09 09:38:35 -07:00
kernel-add-disk.m4 Fix clang 13 compilation errors 2022-06-15 14:20:28 -07:00
kernel-aio-fsync.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-automount.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-bdi.m4 Minor fix to configure on s390x 2021-05-27 22:39:53 -07:00
kernel-bio_max_segs.m4 Linux 5.12 update: bio_max_segs() replaces BIO_MAX_PAGES 2021-03-19 22:33:42 -07:00
kernel-bio.m4 autoconf: AC_MSG_CHECKING consistency 2022-06-01 09:59:37 -07:00
kernel-blk-queue.m4 zvol: Support blk-mq for better performance 2022-06-09 08:10:38 -06:00
kernel-blkdev.m4 Linux 5.20 compat: bdevname() 2022-08-04 16:57:33 -07:00
kernel-block-device-operations.m4 libtpool: -Wno-clobbered 2022-02-18 09:34:25 -08:00
kernel-clear-inode.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-commit-metadata.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-config-defined.m4 autoconf: Pretend CONFIG_MODULES is always on 2022-04-26 10:47:09 -07:00
kernel-copy-from-user-inatomic.m4 autoconf: Fail when __copy_from_user_inatomic is a non-GPL symbol 2022-05-11 10:32:51 -07:00
kernel-current-time.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-declare-event-class.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-dentry-operations.m4 Partially revert 5a6ac4c 2019-11-18 13:05:56 -08:00
kernel-dirty-inode.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-discard-granularity.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-encode-fh-inode.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-evict-inode.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-fadvise.m4 Add Linux posix_fadvise support 2022-09-08 10:29:41 -07:00
kernel-fallocate.m4 Add support for FALLOC_FL_ZERO_RANGE 2022-01-24 12:59:25 -08:00
kernel-file-dentry.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-file-inode.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-fmode-t.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-follow-down-one.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-fpu.m4 Linux 5.19 compat: asm/fpu/internal.h 2022-06-01 09:59:15 -07:00
kernel-fst-mount.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-fsync.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-generic_fadvise.m4 Add Linux posix_fadvise support 2022-09-08 10:29:41 -07:00
kernel-generic_fillattr.m4 Fix various typos 2021-04-02 18:52:15 -07:00
kernel-generic_io_acct.m4 Linux 5.19 compat: bdev_start_io_acct() / bdev_end_io_acct() 2022-05-31 12:04:35 -07:00
kernel-generic_readlink.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-genhd-flags.m4 Linux 5.17 compat: GENHD_FL_EXT_DEVT / GENHD_FL_NO_PART_SCAN 2022-04-19 10:38:04 -07:00
kernel-get-disk-ro.m4 libtpool: -Wno-clobbered 2022-02-18 09:34:25 -08:00
kernel-get-link.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-global_page_state.m4 egrep -> grep -E 2022-04-01 17:58:07 -07:00
kernel-group-info.m4 Strengthen Linux kernel capabilities detection 2022-04-21 09:37:11 -07:00
kernel-hotplug.m4 Implement memory and CPU hotplug 2020-12-10 14:09:23 -08:00
kernel-in-compat-syscall.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-inode-create.m4 Linux 5.12 compat: idmapped mounts 2021-03-19 21:00:59 -07:00
kernel-inode-getattr.m4 Linux 5.12 compat: idmapped mounts 2021-03-19 21:00:59 -07:00
kernel-inode-lock.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-inode-lookup.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-inode-permission.m4 Linux optimize access checks when ACL is trivial 2022-04-01 09:53:54 -07:00
kernel-inode-set-flags.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-inode-set-iversion.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-inode-times.m4 config/kernel-inode-times: initialize timespec 2020-05-04 15:25:48 -07:00
kernel-insert-inode-locked.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-is_owner_or_cap.m4 Various Linux kABI cosmetics 2021-05-26 15:26:06 -07:00
kernel-kmap-atomic-args.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-kmem-cache.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-kmem.m4 Linux 5.16 compat: Check slab.h for kvmalloc 2022-01-24 12:57:50 -08:00
kernel-kstrtoul.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-kthread.m4 Linux 5.17 compat: dequeue_signal() takes a 4th argument 2022-01-25 12:52:51 -08:00
kernel-ktime.m4 Linux 5.6 compat: ktime_get_raw_ts64() 2020-02-27 09:30:45 -08:00
kernel-kuid-helpers.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-kuidgid.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-lseek-execute.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-make-request-fn.m4 Linux 5.20 compat: blk_cleanup_disk() 2022-08-04 16:57:49 -07:00
kernel-misc-minor.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-mkdir.m4 Add missing AC_MSG_RESULT(no) to configure 2022-05-12 09:12:32 -07:00
kernel-mknod.m4 Linux 5.12 compat: idmapped mounts 2021-03-19 21:00:59 -07:00
kernel-mod-param.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-objtool.m4 Linux 5.10 compat: frame.h renamed objtool.h 2020-11-02 22:01:10 +00:00
kernel-pagemap-folio_wait_bit.m4 autoconf: AC_MSG_CHECKING consistency 2022-06-01 09:59:37 -07:00
kernel-pde-data.m4 Linux 5.17 compat: PDE_DATA() renamed to pde_data() 2022-01-25 12:53:00 -08:00
kernel-percpu.m4 Introduce write-mostly sums 2021-05-27 14:27:29 -06:00
kernel-proc-operations.m4 Linux 5.6 compat: struct proc_ops 2020-02-07 11:03:53 -08:00
kernel-put-link.m4 Fix typos 2020-06-09 21:24:09 -07:00
kernel-readpages.m4 autoconf: AC_MSG_CHECKING consistency 2022-06-01 09:59:37 -07:00
kernel-rename.m4 Fixing m4 iops rename check 2021-04-01 08:37:41 -07:00
kernel-revalidate-disk-size.m4 Linux 5.18 compat: replace genhd.h with blkdev.h includes 2022-03-28 09:52:55 -07:00
kernel-rw.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-rwsem.m4 Delete rw_semaphore.wait_lock configure check 2020-12-09 21:22:54 -08:00
kernel-sched.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-security-inode-init.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-set-nlink.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-setattr-prepare.m4 Linux 5.12 compat: idmapped mounts 2021-03-19 21:00:59 -07:00
kernel-sget-args.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-show-options.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-shrink.m4 Linux 6.0 compat: register_shrinker() now var-arg 2022-08-08 16:18:30 -07:00
kernel-siginfo.m4 Add SIGSTOP and SIGTSTP handling to issig 2021-04-15 13:34:35 -07:00
kernel-signal-stop.m4 Add SIGSTOP and SIGTSTP handling to issig 2021-04-15 13:34:35 -07:00
kernel-special-state.m4 Add SIGSTOP and SIGTSTP handling to issig 2021-04-15 13:34:35 -07:00
kernel-stdarg.m4 Linux 5.15 compat: standalone <linux/stdarg.h> 2021-09-08 12:59:43 -07:00
kernel-super-userns.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-symlink.m4 Linux 5.12 compat: idmapped mounts 2021-03-19 21:00:59 -07:00
kernel-sysfs.m4 autoconf: AC_MSG_CHECKING consistency 2022-06-01 09:59:37 -07:00
kernel-timer.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-tmpfile.m4 Update tmpfile() existence detection 2021-05-20 16:02:36 -07:00
kernel-totalhigh_pages.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-totalram-pages-func.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-truncate-setsize.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-user-ns-inum.m4 Add Linux namespace delegation support 2022-06-10 09:51:46 -07:00
kernel-userns-capabilities.m4 Linux 4.10 compat: has_capability() 2020-07-19 09:56:21 -07:00
kernel-usleep_range.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-vfs-direct_IO.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-vfs-filemap_dirty_folio.m4 autoconf: AC_MSG_CHECKING consistency 2022-06-01 09:59:37 -07:00
kernel-vfs-fsync.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel-vfs-getattr.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-vfs-iov_iter.m4 Linux 5.19 compat: bdev_max_discard_sectors() 2022-05-31 12:04:17 -07:00
kernel-vfs-iterate.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-vfs-read_folio.m4 autoconf: AC_MSG_CHECKING consistency 2022-06-01 09:59:37 -07:00
kernel-vfs-rw-iterate.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-vfs-set_page_dirty.m4 autoconf: AC_MSG_CHECKING consistency 2022-06-01 09:59:37 -07:00
kernel-wait.m4 Perform KABI checks in parallel 2019-10-01 12:50:34 -07:00
kernel-xattr-handler.m4 Add xattr_handler support for Android kernels 2022-09-06 10:02:18 -07:00
kernel-zero_page.m4 Adding ZERO_PAGE detection 2022-03-14 12:37:39 -07:00
kernel-zlib.m4 Linux compat: Minimum kernel version 3.10 2019-11-12 08:59:06 -08:00
kernel.m4 Add Linux posix_fadvise support 2022-09-08 10:29:41 -07:00
lib-ld.m4 config: libintl/libiconv for gettext() detection 2019-04-19 12:09:29 -07:00
lib-link.m4 Clarify comments in config/*.m4, vdev_geom.c, zfs_allow_*.ksh 2020-06-22 09:46:37 -07:00
lib-prefix.m4 Clarify comments in config/*.m4, vdev_geom.c, zfs_allow_*.ksh 2020-06-22 09:46:37 -07:00
mount-helper.m4 Autoconf 2.70 compatibility 2021-01-02 16:55:55 -08:00
nls.m4 config: libintl/libiconv for gettext() detection 2019-04-19 12:09:29 -07:00
pkg.m4 Fix typos in config/ 2019-08-30 09:40:30 -07:00
po.m4 config: libintl/libiconv for gettext() detection 2019-04-19 12:09:29 -07:00
progtest.m4 config: libintl/libiconv for gettext() detection 2019-04-19 12:09:29 -07:00
rpm.am config/zfs-build.m4: never define _initramfs in RPM_DEFINE_UTIL 2020-09-12 08:22:07 -07:00
Rules.am Cleanup: Switch to strlcpy from strncpy 2022-09-27 16:35:29 -07:00
Shellcheck.am autoconf: use include directives instead of recursing down tests (mostly) 2022-05-10 10:20:09 -07:00
Substfiles.am Replace EXTRA_DIST with dist_noinst_DATA 2022-05-26 09:24:50 -07:00
tgz.am Make RPM_DEFINE_KMOD conditional on CONFIG_KERNEL 2020-07-14 17:32:21 -07:00
toolchain-simd.m4 Linux 5.16 compat: don't use XSTATE_XSAVE to save FPU state 2022-02-09 12:50:10 -08:00
user-aio.h.m4 config: user: check for <aio.h> 2022-03-28 10:24:22 -07:00
user-clock_gettime.m4 Clean up lib dependencies 2020-07-10 14:26:00 -07:00
user-dracut.m4 Autoconf 2.70 compatibility 2021-01-02 16:55:55 -08:00
user-gettext.m4 Add config.rpath for AM_GNU_GETTEXT 2020-07-10 14:26:12 -07:00
user-libaio.m4 config: user: check for <aio.h> 2022-03-28 10:24:22 -07:00
user-libatomic.m4 config/libatomic: require -latomic iff atomic.c doesn't link w/o it 2021-07-13 13:50:48 -07:00
user-libblkid.m4 Fix up FIND_SYSTEM_LIBRARY to work with cross-compiling 2020-07-10 14:26:40 -07:00
user-libcrypto.m4 Fix up FIND_SYSTEM_LIBRARY to work with cross-compiling 2020-07-10 14:26:40 -07:00
user-libexec.m4 Autoconf 2.70 compatibility 2021-01-02 16:55:55 -08:00
user-libfetch.m4 libfetch: unquote @LIBFETCH_SONAME@ subst 2022-01-06 11:26:40 -08:00
user-libtirpc.m4 Fix up FIND_SYSTEM_LIBRARY to work with cross-compiling 2020-07-10 14:26:40 -07:00
user-libudev.m4 Fix up FIND_SYSTEM_LIBRARY to work with cross-compiling 2020-07-10 14:26:40 -07:00
user-libuuid.m4 Fix up FIND_SYSTEM_LIBRARY to work with cross-compiling 2020-07-10 14:26:40 -07:00
user-makedev.m4 Autoconf 2.70 compatibility 2021-01-02 16:55:55 -08:00
user-pam.m4 Use correct prefix for share/pam-configs 2020-07-30 09:09:46 -07:00
user-runstatedir.m4 Add defs for makefile installation dir vars 2014-03-31 16:11:13 -07:00
user-systemd.m4 autoconf: use include directives instead of recursing down etc 2022-05-10 10:19:58 -07:00
user-sysvinit.m4 autoconf: use include directives instead of recursing down etc 2022-05-10 10:19:58 -07:00
user-udev.m4 Autoconf 2.70 compatibility 2021-01-02 16:55:55 -08:00
user-zlib.m4 Fix up FIND_SYSTEM_LIBRARY to work with cross-compiling 2020-07-10 14:26:40 -07:00
user.m4 config: user: drop ZONENAME, avoid lying about being Linux-only 2022-05-10 10:17:55 -07:00
zfs-build.m4 Silence -Winfinite-recursion warning in luaD_throw() 2022-06-27 14:18:50 -07:00
zfs-meta.m4 Remove basename(1). Clean up/shorten some coreutils pipelines 2021-11-11 13:27:37 -07:00