FreeBSD src
Go to file
Eric van Gyzen 11ed0a95bf zfs tests: stop writing to arbitrary devices
TL;DR:  Three ZFS tests created ZFS pools on all unmounted devices listed
in /etc/fstab, corrupting their contents.  Stop that.

Imagine my surprise when the ESP on my main dev/test VM would "randomly"
become corrupted, making it unbootable.  Three tests collect various devices
from the system and try to add them to a test pool.  The test expects this
to fail because it _assumes_ these devices are in use and ZFS will correctly
reject the request.

My /etc/fstab has two entries for devices in /dev:

    /dev/gpt/swap0  none        swap    sw,trimonce,late
    /dev/gpt/esp0   /boot/efi   msdosfs rw,noauto

Note the `noauto` on the ESP.  In a remarkable example of irony, I chose
this because it should keep the ESP more protected from corruption;
in fact, mounting it would have protected it from this case.

The tests added all of these devices to a test pool in a _single command_,
expecting the command to fail.  The swap device was in use, so the command
correctly failed, but the ESP was added and therefore corrupted.  However,
since the command correctly failed, the test didn't notice the ESP problem.
If each device had been added with its own command, the test _might_ have
noticed that one of them incorrectly succeeded.  However, two of these
tests would not have noticed:

hotspare_create_001_neg was incorrectly specified as needing the Solaris
dumpadm command, so it was skipped.  _Some_ of the test needs that command,
but it checks for its presence and runs fine without it.

Due to bug 241070, zpool_add_005_pos was marked as an expected failure.
Due to the coarse level of integration with ATF, this test would still
"pass" even if it failed for the wrong reason.  I wrote bug 267554 to
reconsider the use of atf_expect_fail in these tests.

Let's further consider the use of various devices found around the system.
In addition to devices in /etc/fstab, the tests also used mounted devices
listed by the `mount` command.  If ZFS behaves correctly, it will refuse
to added mounted devices and swap devices to a pool.  However, these are
unit tests used by developers to ensure that ZFS still works after they
modify it, so it's reasonable to expect ZFS to do the _wrong_ thing
sometimes.  Using random host devices is unsafe.

Fix the root problem by using only the disks provided via the "disks"
variable in kyua.conf.  Use one to create a UFS file system and mount it.
Use another as a swap device.  Use a third as a dump device, but expect
it to fail due to bug 241070.

While I'm here:

Due to commit 6b6e2954dd, we can simply add a second dump device and
remove it in cleanup.  We no longer need to save, replace, and restore the
pre-existing dump device.

The cleanup_devices function used `camcontrol inquiry` to distinguish disks
from other devices, such as partitions.  That works fine for SCSI, but not
for ATA or VirtIO block.  Use `geom disk list` instead.

PR:		241070
PR:		267554
Reviewed by:	asomers
Sponsored by:	Dell Inc.
Differential Revision:	https://reviews.freebsd.org/D37257
2022-11-11 14:43:47 -06:00
.cirrus-ci Cirrus-CI: add some timing info on pkg install failure 2021-08-04 15:02:00 -04:00
.github .github: Attempt to fix and increase robustness of macOS action 2022-06-30 21:03:26 +01:00
bin ls(1): add a -v flag to sort naturally 2022-10-31 00:00:42 +01:00
cddl pkgbase: Put zfs utilities and lib in their own package 2022-10-26 19:46:30 +02:00
contrib rc.sendmail: remove unused script 2022-11-09 16:55:18 +01:00
crypto ssh: update comment text to match upstream 2022-11-09 11:32:47 -05:00
etc mktemp: add -p/--tmpdir argument 2022-10-30 22:55:46 -05:00
gnu libdialog: Bump shared library version to 10. 2021-10-27 09:30:24 -07:00
include include: put includes into -dev packages 2022-11-09 22:20:38 -06:00
kerberos5 kerberos5: retire now-unused MIPS support 2022-11-02 13:16:18 -04:00
lib lib/libsecureboot: Fix some typos 2022-11-11 10:38:39 -05:00
libexec rtld: add support for the $LIB token 2022-11-11 12:06:30 +02:00
release release(7): Enable zpoolupgrade rc script in ZFS based VM images 2022-11-07 11:47:33 +08:00
rescue rescue: Link libzutil after libzfs. 2022-10-03 16:10:42 -07:00
sbin nvmecontrol: fix wrong temperature unit for INTEL SSDs. 2022-11-11 12:15:52 -07:00
secure caroot: Update VCS instructions 2022-11-07 19:24:09 +08:00
share ddb(4): document some missing commands 2022-11-11 14:25:39 -04:00
stand Sort list of supported features for more easy handling 2022-11-10 09:47:23 +01:00
sys linuxkpi: Define ZERO_OR_NULL_PTR() in <linux/slab.h> 2022-11-11 21:03:25 +01:00
targets Put OPIE to rest. 2022-10-02 03:37:29 +02:00
tests zfs tests: stop writing to arbitrary devices 2022-11-11 14:43:47 -06:00
tools stress2: Add SU+J as a test. Save fsck_ffs core dump, if any 2022-11-10 10:12:46 +01:00
usr.bin tcp: account sent/received IP ECN markings independently 2022-11-10 11:35:35 +01:00
usr.sbin bhyve: Cast away const when fetching a config nvlist 2022-11-11 10:02:42 -05:00
.arcconfig arcanist: use FreeBSD/git project repository instead of FreeBSD/svn 2022-08-23 14:16:41 +00:00
.arclint arc lint: ignore /tests/ in chmod 2017-12-19 03:38:06 +00:00
.cirrus.yml Cirrus-CI: move QEMU pkg installation to test script 2022-09-07 13:32:12 -04:00
.clang-format clang-format: Add bitset loop macros 2021-09-21 12:08:01 -04:00
.gitattributes Add a basic clang-format configuration file 2019-06-07 15:23:52 +00:00
.gitignore Update wireguard-tools to 139aac59a5ab7 2022-11-04 22:43:12 -05:00
COPYRIGHT Welcome 2022, update copyrights. 2022-01-01 09:49:49 -07:00
LOCKS LOCKS: update current locks 2018-06-09 03:08:04 +00:00
MAINTAINERS Remove myself from bhyve maintenance; ENOTIME. 2021-11-19 07:09:30 +10:00
Makefile Makefile: replace mergemaster references with etcupdate 2022-10-06 20:19:16 +02:00
Makefile.inc1 build: Use rm -fv for BATCH_DELETE_OLD_FILES 2022-10-25 11:18:55 -04:00
Makefile.libcompat Install working pkgconfig .pc files for compat libraries 2022-08-11 23:18:34 +01:00
Makefile.sys.inc AUTO_OBJ: For all top-level targets enforce using an OBJDIR. 2017-12-05 21:29:47 +00:00
ObsoleteFiles.inc ObsoleteFiles: add missing '+' 2022-11-10 14:04:54 +01:00
README.md README.md: link to the list of supported platforms 2022-11-01 12:20:55 -03:00
RELNOTES RELNOTES: document the switch from sendmail to dma 2022-11-07 12:52:20 +01:00
UPDATING UPDATING: correct spearate typo 2022-10-26 14:25:12 -04:00

FreeBSD Source:

This is the top level of the FreeBSD source directory.

FreeBSD is an operating system used to power modern servers, desktops, and embedded platforms. A large community has continually developed it for more than thirty years. Its advanced networking, security, and storage features have made FreeBSD the platform of choice for many of the busiest web sites and most pervasive embedded networking and storage devices.

For copyright information, please see the file COPYRIGHT in this directory. Additional copyright information also exists for some sources in this tree - please see the specific source directories for more information.

The Makefile in this directory supports a number of targets for building components (or all) of the FreeBSD source tree. See build(7), config(8), FreeBSD handbook on building userland, and Handbook for kernels for more information, including setting make(1) variables.

For information on the CPU architectures and platforms supported by FreeBSD, see the FreeBSD website's Platforms page.

Source Roadmap:

Directory Description
bin System/user commands.
cddl Various commands and libraries under the Common Development and Distribution License.
contrib Packages contributed by 3rd parties.
crypto Cryptography stuff (see crypto/README).
etc Template files for /etc.
gnu Commands and libraries under the GNU General Public License (GPL) or Lesser General Public License (LGPL). Please see gnu/COPYING and gnu/COPYING.LIB for more information.
include System include files.
kerberos5 Kerberos5 (Heimdal) package.
lib System libraries.
libexec System daemons.
release Release building Makefile & associated tools.
rescue Build system for statically linked /rescue utilities.
sbin System commands.
secure Cryptographic libraries and commands.
share Shared resources.
stand Boot loader sources.
sys Kernel sources (see sys/README.md).
targets Support for experimental DIRDEPS_BUILD
tests Regression tests which can be run by Kyua. See tests/README for additional information.
tools Utilities for regression testing and miscellaneous tasks.
usr.bin User commands.
usr.sbin System administration commands.

For information on synchronizing your source tree with one or more of the FreeBSD Project's development branches, please see FreeBSD Handbook.