summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* Don't leak packed recieved proprtiesBrooks Davis2022-12-011-7/+10
| | | | | | | | | | When local properties (e.g., from -o and -x) are provided, don't leak the packed representation of the received properties due to variable reuse. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Brooks Davis <[email protected]> Closes #14197
* linux: libspl: zone: () -> (void)наб2022-12-011-1/+1
| | | | | | Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #12968
* Make 1-bit bitfields unsignedBrooks Davis2022-12-011-2/+2
| | | | | | | | | | | | | | | | This fixes -Wsingle-bit-bitfield-constant-conversion warning from clang-16 like: lib/libzfs/libzfs_dataset.c:4529:19: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] flags.nounmount = B_TRUE; ^ ~~~~~~ Reviewed-by: Matthew Ahrens <[email protected]> Reviewed-by: Richard Yao <[email protected]> Signed-off-by: Brooks Davis <[email protected]> Closes #14125
* Fix theoretical use of uninitialized valuesRichard Yao2022-12-011-3/+2
| | | | | | | | | | | | | | | | | Clang's static analyzer complains about this. In get_configs(), if we have an invalid configuration that has no top level vdevs, we can read a couple of uninitialized variables. Aborting upon seeing this would break the userland tools for healthy pools, so we instead initialize the two variables to 0 to allow the userland tools to continue functioning for the pools with valid configurations. In zfs_do_wait(), if no wait activities are enabled, we read an uninitialized error variable. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Richard Yao <[email protected]> Closes #14043
* set_global_var() should not pass NULL pointers to dlclose()Richard Yao2022-12-011-1/+2
| | | | | | | | Both Coverity and Clang's static analyzer caught this. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Richard Yao <[email protected]> Closes #14044
* Fix potential NULL pointer dereference in lzc_ioctl()Richard Yao2022-12-011-1/+1
| | | | | | | | | | | | | Users are allowed to pass NULL to resultp, but we unconditionally assume that they never do. When an external user does pass NULL to resultp, we dereference a NULL pointer. Clang's static analyzer complained about this. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: Richard Yao <[email protected]> Closes #14008
* set_global_var_parse_kv() should pass the pointer from strdup()Richard Yao2022-12-011-2/+3
| | | | | | | | | | | | | | | | | | A comment says that the caller should free k_out, but the pointer passed via k_out is not the same pointer we received from strdup(). Instead, it is a pointer into the region we received from strdup(). The free function should always be called with the original pointer, so this is likely a bug. We solve this by calling `strdup()` a second time and then freeing the original pointer. Coverity reported this as a memory leak. Reviewed-by: Neal Gompa <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Richard Yao <[email protected]> Closes #13867
* Call va_end() before return in zpool_standard_error_fmt()Richard Yao2022-12-011-1/+1
| | | | | | | | | | | | | | | | | | Commit ecd6cf800b63704be73fb264c3f5b6e0dafc068d by marks in OpenSolaris at Tue Jun 26 07:44:24 2007 -0700 introduced a bug where we fail to call `va_end()` before returning. The man page for va_start() says: "Each invocation of va_start() must be matched by a corresponding invocation of va_end() in the same function." Coverity complained about this. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Chunwei Chen <[email protected]> Signed-off-by: Richard Yao <[email protected]> Closes #13904
* Handle ECKSUM as new EZFS_CKSUM ‒ "insufficient replicas"наб2022-12-011-0/+6
| | | | | | | | | | | Add a meaningful error message for ECKSUM to common error messages. Reviewed-by: Richard Yao <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #6805 Closes #13808 Closes #13898
* Remove incorrect free() in zfs_get_pci_slots_sys_path()Richard Yao2022-12-011-1/+0
| | | | | | | | | | | Coverity found this. We attempted to free tmp, which is a pointer to a string that should be freed by the caller. Reviewed-by: Neal Gompa <[email protected]> Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Richard Yao <[email protected]> Closes #13864
* zpool_load_compat() should create strings of length ZFS_MAXPROPLENRichard Yao2022-12-011-2/+2
| | | | | | | | | | | Otherwise, `strlcat()` can overflow them. Coverity found this. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Neal Gompa <[email protected]> Signed-off-by: Richard Yao <[email protected]> Closes #13866
* libzfs recv: Check if user prop before inheritableRyan Moeller2022-11-301-2/+2
| | | | | | | | | | User props trigger an assert in zfs_prop_inheritable(), we must check if the prop is a user prop first. Signed-off-by: Ryan Moeller <[email protected]> Backported as snippit from: 63652e1 Add --enable-asan and --enable-ubsan switches
* Ask libtool to stop hiding some errorsRich Ercolani2022-09-2115-0/+43
| | | | | | | | | | | | | | For #13083, curiously, it did not print the actual error, just that the compile failed with "Error 1". In theory, this flag should cause it to report errors twice sometimes. In practice, I'm pretty okay with reporting some twice if it avoids reporting some never. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Damian Szuberski <[email protected]> Signed-off-by: Rich Ercolani <[email protected]> Closes #13086
* Importing from cachefile can trip assertionGeorge Wilson2022-09-131-0/+2
| | | | | | | | | | | | | When importing from cachefile, it is possible that the builtin retry logic will trip an assertion because it also fails to find the pool. This fix addresses that case and returns the correct error message to the user. Reviewed-by: Richard Yao <[email protected]> Reviewed-by: Serapheim Dimitropoulos <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: George Wilson <[email protected]> Closes #13781
* libtpool: -Wno-clobberedнаб2022-07-274-6/+3
| | | | | | | | | | Also remove -Wno-unused-but-set-variable Upstream-bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61118 Reviewed-by: Alejandro Colomar <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #13110
* Remove sha1 hashing from OpenZFS, it's not used anywhere.Tino Reichardt2022-07-261-3/+0
| | | | | | | | | | Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Attila Fülöp <[email protected]> Signed-off-by: Tino Reichardt <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #12895 Closes #12902 Signed-off-by: Rich Ercolani <[email protected]>
* libzfs: Fail making a dataset handle gracefullyRyan Moeller2022-06-061-4/+9
| | | | | | | | | | | | | | When a dataset is in the process of being received it gets marked as inconsistent and should not be used. We should check for this when opening a dataset handle in libzfs and return with an appropriate error set, rather than hitting an abort because of the incomplete data. zfs_open() passes errno to zfs_standard_error() after observing make_dataset_handle() fail, which ends up aborting if errno is 0. Set errno before returning where we know it has not been set already. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #13077
* libzfs: mount: don't leak mnt_param_t if mnt_func failsнаб2022-06-061-1/+3
| | | | | | Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #12968
* Reject zfs send -RI with nonexistent fromsnapRich Ercolani2022-06-061-0/+17
| | | | | | | | | Right now, zfs send -I dataset@nonexistent dataset@existent fails, but zfs send -RI dataset@nonexistent dataset@existent does not. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Rich Ercolani <[email protected]> Closes #12574 Closes #12575
* FreeBSD: libspl: Add locking around statfs globalsRyan Moeller2022-05-271-1/+15
| | | | | | | | | | Makes getmntent and getmntany thread-safe for external consumers of libzfs zpool_disable_datasets, zfs_iter_mounted, libzfs_mnttab_update, libzfs_mnttab_find. Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #13484
* libzfs: zfs_send: remove unused variableнаб2022-05-021-12/+0
| | | | | | | Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #12187
* libzutil: zpool_find_config: remove unused variableнаб2022-05-021-4/+1
| | | | | | | Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #12187
* libzfs: import: zpool_clear_label: actually fail if clearing l2arc header failsнаб2022-04-151-10/+10
| | | | | | | | | Found with -Wunused-but-set-variable on Clang trunk Upstream-commit: a4e0cee1780cbd8f2cb9a263a0ed8d91dbe68b4a Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #13304
* libzfs: sendrecv: always cancel progress thread in zfs_send_one()наб2022-04-111-2/+1
| | | | | | | | | This is in line with all the other uses of the progress thread Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #11560 Closes #13284
* libzfs: diff: stream_bytes: use fputc, %hho formats charsнаб2022-04-011-2/+2
| | | | | | | | Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Rich Ercolani <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Upstream-commit: a72129edcb7353f5301096ea9541e8e345f052d4 Closes #12829
* zfs, libzfs: diff: accept -h/ZFS_DIFF_NO_MANGLE, disabling path escapingнаб2022-04-011-2/+8
| | | | | | | | Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Rich Ercolani <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Upstream-commit: 344bbc82e7054f61d5e7b3610b119820285fd2cb Closes #12829
* zed: Fix mpath autoreplace on Centos 7Tony Hutter2022-03-181-7/+4
| | | | | | | | | | | | | | | | A prior commit included a udev check for MPATH_DEVICE_READY to determine if a path was multipath when doing an autoreplace: f2f6c18 zed: Misc multipath autoreplace fixes However, MPATH_DEVICE_READY is not provided by the older version of udev that's on Centos 7 (it is on Centos 8). This patch instead looks for 'mpath-' in the UUID, which works on both Centos 7 and 8. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Tony Hutter <[email protected]> Closes #13222
* zed: Misc multipath autoreplace fixesTony Hutter2022-03-181-10/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We recently had a case where our operators replaced a bad multipathed disk, only to see it fail to autoreplace. The zed logs showed that the multipath replacement disk did not pass the 'is_dm' test in zfs_process_add() even though it should have. is_dm is set if there exists a sysfs entry for to the underlying /dev/sd* paths for the multipath disk. It's possible this path didn't exist due to a race condition where the sysfs paths weren't created at the time the udev event came in to zed, but this was never verified. This patch updates the check to look for udev properties that indicate if the new autoreplace disk is an empty multipath disk, rather than looking for the underlying sysfs entries. It also adds in additional logging, and fixes a bug where zed allowed you to use an already zfs-formatted disk from another pool as a multipath auto-replacement disk. Furthermore, while testing this patch, I also ran across a case where a force-faulted disk did not have a ZPOOL_CONFIG_PHYS_PATH entry in its config. This prevented it from being autoreplaced. I added additional logic to derive the PHYS_PATH from the PATH if the PATH was a /dev/disk/by-vdev/ path. For example, if PATH was /dev/disk/by-vdev/L28, then PHYS_PATH would be L28. This is safe since by-vdev paths represent physical locations and do not change between boots. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Tony Hutter <[email protected]> Closes #13023
* get_key_material_https: removed bogus free() callнаб2022-03-171-1/+0
| | | | | | | | | | | The get_key_material_https() function error code path had a bogus free() call, either resulting in double-free or free() of undefined pointer. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Ahelenia Ziemia<C5><84>ska <[email protected]> Co-authored-by: Harry Sintonen <[email protected]> Signed-off-by: Harry Sintonen <[email protected]> Closes #13198
* libzfs: add keylocation=https://, backed by fetch(3) or libcurlнаб2022-02-164-21/+248
| | | | | | | | | | | | Add support for http and https to the keylocation properly to allow encryption keys to be fetched from the specified URL. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Issue #9543 Closes #9947 Closes #11956
* libzfs_sendrecv: Fix leaked holds nvlistRyan Moeller2022-02-031-4/+3
| | | | | | | | | There is no need to allocate a holds nvlist. lzc_get_holds does that for us. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #12967
* libzfs_sendrecv: Avoid extra avl_findRyan Moeller2022-02-031-2/+3
| | | | | | | | | avl_add does avl_find internally, then avl_insert. We're already doing the avl_find, so using avl_insert directly avoids repeating the search. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #12967
* FreeBSD: Fix leaked strings in libspl mnttabRyan Moeller2022-02-031-9/+16
| | | | | | | | | | | | | | | | | | | | The FreeBSD implementations of various libspl functions for getting mounted device information were found to leak several strings which were being allocated in statfs2mnttab but never freed. The Solaris getmntany(3C) and related interfaces are expected to return strings residing in static buffers that need to be copied rather than freed by the caller. Use static thread-local storage to stash the mnttab structure strings from FreeBSD's statfs info rather than strings allocated on the heap by strdup(3). While here, remove some stray commented out lines. Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Rich Ercolani <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #12961
* linux: libzfs: mount: fix uninitialised flagsнаб2022-02-031-1/+1
| | | | | | | | | | They're later |=d with constants, but never reset Caught by valgrind while investigating https://github.com/openzfs/zfs/pull/12928#issuecomment-1007496550 Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #12954
* FreeBSD: fix world build after 143476ce8Martin Matuška2022-02-031-1/+1
| | | | | | | | Do not redefine the fallthrough macro when building with libcpp. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Martin Matuska <[email protected]> Closes #12880
* Fix error propagation from lzc_send_redactedPhilipp Riederer2022-02-031-1/+1
| | | | | | | | | | Any error from lzc_send_redacted is overwritten by the error of send_conclusion_record; skip writing the conclusion record if there was an earlier error. Reviewed-by: Paul Dagnelie <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Philipp Riederer <[email protected]> Closes #12766
* freebsd/libshare: nfs: don't send SIGHUP to all processesнаб2022-02-031-1/+7
| | | | | | | | | | | | | | pidfile_open() sets *pidptr to -1 if the process currently holding the lock is between pidfile_open() and pidfile_write(), the subsequent kill(mountdpid) would potentially SIGHUP all non-system processes except init: just sleep for half a millisecond and try again in that case Reviewed-by: Don Brady <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: John Kennedy <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #12067
* Upgrade to libabigail 2.0.0Dimitri John Ledkov2021-11-055-7719/+6056
| | | | | | | | | Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: George Melikov <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Dimitri John Ledkov <[email protected]> Closes #12722 Closes #12739
* zed: Control NVMe fault LEDsTony Hutter2021-11-052-3/+152
| | | | | | | | | | The ZED code currently can only turn on the fault LED for a faulted disk in a JBOD enclosure. This extends support for faulted NVMe disks as well. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Tony Hutter <[email protected]> Closes #12648 Closes #12695
* Rescan enclosure sysfs path on importTony Hutter2021-11-023-13/+127
| | | | | | | | | | | | | | | When you create a pool, zfs writes vd->vdev_enc_sysfs_path with the enclosure sysfs path to the fault LEDs, like: vdev_enc_sysfs_path = /sys/class/enclosure/0:0:1:0/SLOT8 However, this enclosure path doesn't get updated on successive imports even if enclosure path to the disk changes. This patch fixes the issue. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Tony Hutter <[email protected]> Closes #11950 Closes #12095
* Use fallthrough macroBrian Behlendorf2021-11-027-9/+19
| | | | | | | | | | | | | | | | As of the Linux 5.9 kernel a fallthrough macro has been added which should be used to anotate all intentional fallthrough paths. Once all of the kernel code paths have been updated to use fallthrough the -Wimplicit-fallthrough option will because the default. To avoid warnings in the OpenZFS code base when this happens apply the fallthrough macro. Additional reading: https://lwn.net/Articles/794944/ Reviewed-by: Tony Nguyen <[email protected]> Reviewed-by: George Melikov <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #12441
* Detect HAVE_LARGE_STACKS at compile time (#12584)Kevin Bowling2021-11-012-0/+4
| | | | | | | | | | Move HAVE_LARGE_STACKS definitions to header and set when appropriate. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Allan Jude <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: Kevin Bowling <[email protected]> Closes #12350
* Update ABI files via new libabigail versionGeorge Melikov2021-09-145-10160/+16155
| | | | | | | Reviewed-by: John Kennedy <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: George Melikov <[email protected]> Closes #12529
* Make get_key_material_file fail more verboselyRich Ercolani2021-09-141-1/+1
| | | | | | | | | | It turns out, there are a lot of possible reasons for fopen to fail. Let's share which reason we failed for today. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Tony Nguyen <[email protected]> Signed-off-by: Rich Ercolani <[email protected]> Closes #12410
* Remove old orig_fd variable from zfs sendJorgen Lundman2021-09-141-2/+1
| | | | | | | | | | | | | Possibly required in the past, but is currently fills no purpose. Ordinarily such tiny cleanup is not generally worth it, however on the macOS port, in a future commit, we do unspeakable things to the "fd" for send/recv, and it would be easier to only have to deal with one "fd" instead of two. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Tony Nguyen <[email protected]> Signed-off-by: Jorgen Lundman <[email protected]> Closes #12404
* file reference counts can get corruptedGeorge Wilson2021-09-141-11/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | Callers of zfs_file_get and zfs_file_put can corrupt the reference counts for the file structure resulting in a panic or a soft lockup. When zfs send/recv runs, it will add a reference count to the open file, and begin to send or recv the stream. If the file descriptor is closed, then when dmu_recv_stream() or dmu_send() return we will call zfs_file_put to remove the reference we placed on the file structure. Unfortunately, because zfs_file_put() uses the file descriptor to lookup the file structure, it may end up finding that the file descriptor table no longer contains the file struct, thus leaking the file structure. Or it might end up finding a file descriptor for a different file and blindly updating its reference counts. Other failure modes probably exists. This change reworks the zfs_file_[get|put] interface to not rely on the file descriptor but instead pass the zfs_file_t pointer around. Reviewed-by: Matthew Ahrens <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Mark Maybee <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Co-authored-by: Allan Jude <[email protected]> Signed-off-by: George Wilson <[email protected]> External-issue: DLPX-76119 Closes #12299
* Replace strchrnul() with strrchr()Jorgen Lundman2021-09-141-1/+3
| | | | | | | | | | | | Could have gone either way with this one, either adding it to macOS/Windows SPL, or returning it to "classic" usage with strrchr(). Since the new special way isn't really used, and only used once, we have this commit. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: Jorgen Lundman <[email protected]> Closes #12312
* Fix flag copying in resume casePaul Dagnelie2021-06-241-0/+4
| | | | | | | | | A couple flags weren't being copied in the case where we're doing size estimation on a resume. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Matthew Ahrens <[email protected]> Signed-off-by: Paul Dagnelie <[email protected]> Closes: #12266
* Annotated dprintf as printf-likeRich Ercolani2021-06-241-1/+1
| | | | | | | | | | ZFS loves using %llu for uint64_t, but that requires a cast to not be noisy - which is even done in many, though not all, places. Also a couple places used %u for uint64_t, which were promoted to %llu. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Rich Ercolani <[email protected]> Closes #12233
* libspl: implement atomics in terms of atomicsнаб2021-06-215-1696/+48
| | | | | | | | | | | | | | | | This replaces the generic libspl atomic.c atomics implementation with one based on builtin gcc atomics. This functionality was added as an experimental feature in gcc 4.4. Today even CentOS 7 ships with gcc 4.8 as the default compiler we can make this the default. Furthermore, the builtin atomics are as good or better than our hand-rolled implementation so it's reasonable to drop that custom code. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #11904 Closes #12252 Closes #12244