opnsense-src/sys/contrib/openzfs/module/lua
Martin Matuska 81be5a55d9 zfs: merge openzfs/zfs@c883088df (zfs-2.2-release) into stable/14
OpenZFS release 2.2.3

Notable upstream pull request merges:
 #15428 2a59b6bfa ABD: Be more assertive in iterators
 #15486 c34fe8dcb Update the kstat dataset_name when renaming a zvol
 #15495 f13593619 FreeBSD: Optimize large kstat outputs
 #15517 ad47eca19 ZIL: Assert record sizes in different places
 #15519 2e259c6f0 L2ARC: Restrict write size to 1/4 of the device
 #15544 121924575 Allow block cloning across encrypted datasets
 #15553 e48195c81 ZIO: Add overflow checks for linear buffers
 #15612 3b8f22736 ZIL: Remove TX_CLONE_RANGE replay for ZVOLs
 #15617 e11b3eb1c ZIL: Do not clone blocks from the future
 #15625 e09356fa0 BRT: Limit brt_vdev_dump() to only one vdev
 #15629 dea2d3c6c zdb: Dump encrypted write and clone ZIL records
 #15630 3425484eb Fix file descriptor leak on pool import
 #15634 1e1d748ca ZIL: Remove 128K into 2x68K LWB split optimization
 #15644 b13c91bb2 DMU: Fix lock leak on dbuf_hold() error
 #15653 a701548eb dbuf: Handle arcbuf assignment after block cloning
 #15656 9c40ae021 dbuf: Set dr_data when unoverriding after clone
 #15660 4db88c37c fix(mount): do not truncate shares not zfs mount
 #15665 c0c4866f8 dmu: Allow buffer fills to fail
 #15675 db2db50e3 spa: make read/write queues configurable
 #15677 f71c16a66 Don't panic on unencrypted block in encrypted dataset
 #15719 9181e94f0 spa: Fix FreeBSD sysctl handlers
 #15719 a00231a3f spa: Let spa_taskq_param_get()'s addition of a newline be optional
 #15721 4d4972ed9 Stop wasting time on malloc in snprintf_zstd_header
 #15726 7bccf98a7 Make zdb -R scale less poorly
 #15732 ac592318b Fix livelist assertions for dedup and cloning
 #15735 152a775ea Improve block sizes checks during cloning
 #15737 52cee9a3e fix: Uber block label not always found for aux vdevs
 #15737 eb4a36bce Extend aux label to add path information
 #15737 a2e71db66 Add path handling for aux vdevs in `label_path`
 #15747 2006ac1f4 Fix "out of memory" error
 #15752 8b1c6db3d Fix a potential use-after-free in zfs_setsecattr()
 #15769 40e20d808 Add 'zpool status -e' flag to see unhealthy vdevs
 #15772 ef527958c Fix cloning into mmaped and cached file
 #15780 09a796136 FreeBSD: Fix bootstrapping tools under Linux/musl
 #15781 07cf973fe Autotrim High Load Average Fix
 #15783 c1161e285 fix: variable type with zfs-tests/cmd/clonefile.c
 #15816 dd3a0a271 Update vdev devid and physpath if changed between imports
 #15818 ab653603f Don't assert mg_initialized due to device addition race
 #15823 acc7cd8e9 Update man pages to time(1) from time(2)
 #15825 0606ce205 zpool wait: print timestamp before the header
 #15847 d22bf6a9b LUA: Backport CVE-2020-24370's patch
 #15864 36116b461 zfs list: add '-t fs' and '-t vol' options
 #15874 fc3d34bd0 BRT: Fix slop space calculation with block cloning
 #15882 a4978d260 zdb: Fix false leak report for BRT objects

Obtained from:	OpenZFS
OpenZFS commit:	c883088df8
OpenZFS tag:	zfs-2.2.3
2024-02-23 19:37:36 +01:00
..
setjmp zfs: merge openzfs/zfs@d96e29576 2023-05-03 12:04:55 +02:00
lapi.c zfs: merge openzfs/zfs@2163cde45 2022-11-16 21:27:42 +01:00
lapi.h zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lauxlib.c zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lbaselib.c zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lcode.c zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lcode.h zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lcompat.c
lcorolib.c zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lctype.c zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lctype.h zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
ldebug.c zfs: merge openzfs/zfs@c883088df (zfs-2.2-release) into stable/14 2024-02-23 19:37:36 +01:00
ldebug.h zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
ldo.c zfs: merge openzfs/zfs@d96e29576 2023-05-03 12:04:55 +02:00
ldo.h zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lfunc.c zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lfunc.h zfs: merge openzfs/zfs@9cd71c860 (master) 2023-01-25 19:50:29 +01:00
lgc.c zfs: merge openzfs/zfs@9cd71c860 (master) 2023-01-25 19:50:29 +01:00
lgc.h zfs: merge openzfs/zfs@9cd71c860 (master) 2023-01-25 19:50:29 +01:00
llex.c zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
llex.h zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
llimits.h zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lmem.c zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lmem.h zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lobject.c zfs: merge openzfs/zfs@59493b63c (master) 2022-12-07 14:10:46 +01:00
lobject.h zfs: merge openzfs/zfs@9cd71c860 (master) 2023-01-25 19:50:29 +01:00
lopcodes.c zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lopcodes.h zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lparser.c zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lparser.h zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lstate.c zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lstate.h zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lstring.c zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lstring.h zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lstrlib.c zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
ltable.c zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
ltable.h zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
ltablib.c zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
ltm.c zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
ltm.h zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lvm.c zfs: merge openzfs/zfs@9cd71c860 (master) 2023-01-25 19:50:29 +01:00
lvm.h zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lzio.c zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
lzio.h zfs: merge openzfs/zfs@a86e08941 (master) into main 2022-03-08 18:53:02 +01:00
README.zfs

#
# CDDL HEADER START
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# CDDL HEADER END
#

#
# Copyright (c) 2017 by Delphix. All rights reserved.
#

Introduction
------------

This README describes the Lua interpreter source code that lives in the ZFS
source tree to enable execution of ZFS channel programs, including its
maintenance policy, the modifications that have been made to it, and how it
should (and should not) be used.

For a description of the Lua language and features exposed by ZFS channel
programs, please refer to the zfs-program(1m) man page instead.


Maintenance policy
------------------

The Lua runtime is considered stable software. Channel programs don't need much
complicated logic, so updates to the Lua runtime from upstream are viewed as
nice-to-have, but not required for channel programs to be well-supported. As
such, the Lua runtime in ZFS should be updated on an as-needed basis for
security vulnerabilities, but not much else.


Modifications to Lua
--------------------

The version of the Lua runtime we're using in ZFS has been modified in a variety
of ways to make it more useful for the specific purpose of running channel
programs. These changes include:

1. "Normal" Lua uses floating point for all numbers it stores, but those aren't
   useful inside ZFS / the kernel. We have changed the runtime to use int64_t
   throughout for all numbers.
2. Some of the Lua standard libraries do file I/O or spawn processes, but
   neither of these make sense from inside channel programs. We have removed
   those libraries rather than reimplementing them using kernel APIs.
3. The "normal" Lua runtime handles errors by failing fatally, but since this
   version of Lua runs inside the kernel we must handle these failures and
   return meaningful error codes to userland. We have customized the Lua
   failure paths so that they aren't fatal.
4. Running poorly-vetted code inside the kernel is always a risk; even if the
   ability to do so is restricted to the root user, it's still possible to write
   an incorrect program that results in an infinite loop or massive memory use.
   We've added new protections into the Lua interpreter to limit the runtime
   (measured in number of Lua instructions run) and memory overhead of running
   a channel program.
5. The Lua bytecode is not designed to be secure / safe, so it would be easy to
   pass invalid bytecode which can panic the kernel. By comparison, the parser
   is hardened and fails gracefully on invalid input. Therefore, we only accept
   Lua source code at the ioctl level and then interpret it inside the kernel.

Each of these modifications have been tested in the zfs-test suite. If / when
new modifications are made, new tests should be added to the suite located in
zfs-tests/tests/functional/channel_program/lua_core.


How to use this Lua interpreter
-------------------------------

From the above, it should be clear that this is not a general-purpose Lua
interpreter. Additional work would be required to extricate this custom version
of Lua from ZFS and make it usable by other areas of the kernel.