mirror_zfs/lib/libzfs
Richard Yao 73968defdd
Reject streams that set ->drr_payloadlen to unreasonably large values
In the zstream code, Coverity reported:

"The argument could be controlled by an attacker, who could invoke the
function with arbitrary values (for example, a very high or negative
buffer size)."

It did not report this in the kernel. This is likely because the
userspace code stored this in an int before passing it into the
allocator, while the kernel code stored it in a uint32_t.

However, this did reveal a potentially real problem. On 32-bit systems
and systems with only 4GB of physical memory or less in general, it is
possible to pass a large enough value that the system will hang. Even
worse, on Linux systems, the kernel memory allocator is not able to
support allocations up to the maximum 4GB allocation size that this
allows.

This had already been limited in userspace to 64MB by
`ZFS_SENDRECV_MAX_NVLIST`, but we need a hard limit in the kernel to
protect systems. After some discussion, we settle on 256MB as a hard
upper limit. Attempting to receive a stream that requires more memory
than that will result in E2BIG being returned to user space.

Reported-by: Coverity (CID-1529836)
Reported-by: Coverity (CID-1529837)
Reported-by: Coverity (CID-1529838)
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14285
2023-01-23 13:16:22 -08:00
..
os FreeBSD: do_mount() passes wrong string length to helper 2022-11-18 11:34:25 -08:00
.gitignore Clean up lib dependencies 2020-07-10 14:26:00 -07:00
libzfs_changelist.c zfs list: Allow more fields in ZFS_ITER_SIMPLE mode 2022-12-13 17:27:54 -08:00
libzfs_config.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
libzfs_crypto.c zfs list: Allow more fields in ZFS_ITER_SIMPLE mode 2022-12-13 17:27:54 -08:00
libzfs_dataset.c zfs list: Allow more fields in ZFS_ITER_SIMPLE mode 2022-12-13 17:27:54 -08:00
libzfs_diff.c Add color output to zfs diff. 2022-12-15 10:14:32 -08:00
libzfs_impl.h Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
libzfs_import.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
libzfs_iter.c zfs list: Allow more fields in ZFS_ITER_SIMPLE mode 2022-12-13 17:27:54 -08:00
libzfs_mount.c zfs list: Allow more fields in ZFS_ITER_SIMPLE mode 2022-12-13 17:27:54 -08:00
libzfs_pool.c Configure zed's diagnosis engine with vdev properties 2023-01-23 13:14:25 -08:00
libzfs_sendrecv.c Reject streams that set ->drr_payloadlen to unreasonably large values 2023-01-23 13:16:22 -08:00
libzfs_status.c deadlock between spa_errlog_lock and dp_config_rwlock 2022-12-22 11:48:49 -08:00
libzfs_util.c Configure zed's diagnosis engine with vdev properties 2023-01-23 13:14:25 -08:00
libzfs.abi Configure zed's diagnosis engine with vdev properties 2023-01-23 13:14:25 -08:00
libzfs.pc.in Spruce up pkg-config files for libzfs/libzfs_core 2020-09-04 11:11:18 -07:00
libzfs.suppr Library ABI tracking with abigail 2020-11-17 09:18:52 -08:00
Makefile.am Replace EXTRA_DIST with dist_noinst_DATA 2022-05-26 09:24:50 -07:00
THIRDPARTYLICENSE.openssl Fix typos in lib/ 2019-09-02 17:53:27 -07:00
THIRDPARTYLICENSE.openssl.descrip Encryption patch follow-up 2017-10-11 16:54:48 -04:00