opnsense-src/sys/contrib/openzfs/module/lua
Martin Matuska d411c1d696 zfs: merge openzfs/zfs@d96e29576
Notable upstream pull request merges:

  #11680 Add support for zpool user properties
  #14145 Storage device expansion "silently" fails on degraded vdev
  #14405 Create zap for root vdev
  #14659 Allow MMP to bypass waiting for other threads
  #14674 Miscellaneous FreBSD compilation bugfixes
  #14692 Fix some signedness issues in arc_evict()
  #14702 Fix typo in check_clones()
  #14715 module: small fixes for FreeBSD/aarch64
  #14716 Trim needless zeroes from checksum events
  #14719 vdev: expose zfs_vdev_max_ms_shift as a module parameter
  #14722 Fix "Detach spare vdev in case if resilvering does not happen"
  #14723 freebsd clone range fixes
  #14728 Fix BLAKE3 aarch64 assembly for FreeBSD and macOS
  #14735 Fix in check_filesystem()
  #14739 Fix data corruption when cloning embedded blocks
  #14758 Fix VERIFY(!zil_replaying(zilog, tx)) panic
  #14761 Revert "ZFS_IOC_COUNT_FILLED does unnecessary txg_wait_synced()"
  #14774 FreeBSD .zfs fixups
  #14776 FreeBSD: make zfs_vfs_held() definition consistent with declaration
  #14779 powerpc64: Support ELFv2 asm on Big Endian
  #14788 FreeBSD: add missing vop_fplookup assignments
  #14789 PAM: support the authentication facility
  #14790 Revert "Fix data race between zil_commit() and zil_suspend()"
  #14795 Fix positive ABD size assertion in abd_verify()
  #14798 Mark TX_COMMIT transaction with TXG_NOTHROTTLE
  #14804 Correct ABD size for split block ZIOs
  #14806 Use correct block pointer in block cloning case.
  #14808 blake3: fix up bogus checksums in face of cpu migration

Obtained from:	OpenZFS
OpenZFS commit:	d96e29576c
2023-05-03 12:04:55 +02: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@a86e08941 (master) into main 2022-03-08 18:53:02 +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.