Name Date Size #Lines LOC

..--

setjmp/H--944526

README.zfsH A D24-Aug-20263.4 KiB7862

lapi.cH A D27-Mar-202530.4 KiB1,3241,062

lapi.hH A D27-Mar-2025577 2611

lauxlib.cH A D27-Mar-202522.2 KiB800548

lbaselib.cH A D27-Mar-20257.2 KiB296232

lcode.cH A D27-Mar-202522.1 KiB888730

lcode.hH A D27-Mar-20253.1 KiB8555

lcompat.cH A D27-Mar-20251.5 KiB10385

lcorolib.cH A D27-Mar-20253.6 KiB159124

lctype.cH A D27-Mar-20252.3 KiB5240

lctype.hH A D27-Mar-20251.8 KiB9438

ldebug.cH A D27-Mar-202516.1 KiB609501

ldebug.hH A D27-Mar-20251.1 KiB3617

ldo.cH A D27-Mar-202522.6 KiB764616

ldo.hH A D27-Mar-20251.5 KiB4726

lfunc.cH A D27-Mar-20254.2 KiB160123

lfunc.hH A D27-Mar-20251 KiB3518

lgc.cH A D27-Mar-202536.9 KiB1,218841

lgc.hH A D27-Mar-20255.3 KiB15977

llex.cH A D27-Mar-202515 KiB531420

llex.hH A D27-Mar-20252.2 KiB8349

llimits.hH A D27-Mar-20257.7 KiB314150

lmem.cH A D27-Mar-20252.6 KiB9855

lmem.hH A D27-Mar-20251.8 KiB5628

lobject.cH A D27-Mar-20257.7 KiB282223

lobject.hH A D27-Mar-202514.6 KiB608316

lopcodes.cH A D27-Mar-20253 KiB10889

lopcodes.hH A D27-Mar-20258.3 KiB290124

lparser.cH A D27-Mar-202545.2 KiB1,6431,269

lparser.hH A D27-Mar-20253.3 KiB12181

lstate.cH A D27-Mar-20257.5 KiB320228

lstate.hH A D27-Mar-20257.5 KiB230140

lstring.cH A D27-Mar-20254.8 KiB186122

lstring.hH A D27-Mar-20251.3 KiB4820

lstrlib.cH A D27-Mar-202528.3 KiB1,040849

ltable.cH A D27-Mar-202516.2 KiB592413

ltable.hH A D27-Mar-20251.4 KiB4727

ltablib.cH A D27-Mar-20257.6 KiB289222

ltm.cH A D27-Mar-20251.8 KiB7652

ltm.hH A D27-Mar-20251.1 KiB5934

lvm.cH A D27-Mar-202530.1 KiB931787

lvm.hH A D27-Mar-20251.5 KiB4625

lzio.cH A D27-Mar-20251.6 KiB7454

lzio.hH A D27-Mar-20251.5 KiB6734

README.zfs

1# SPDX-License-Identifier: CDDL-1.0
2#
3# This file and its contents are supplied under the terms of the
4# Common Development and Distribution License ("CDDL"), version 1.0.
5# You may only use this file in accordance with the terms of version
6# 1.0 of the CDDL.
7#
8# A full copy of the text of the CDDL should have accompanied this
9# source.  A copy of the CDDL is also available via the Internet at
10# https://opensource.org/license/CDDL-1.0.
11#
12
13#
14# Copyright (c) 2017 by Delphix. All rights reserved.
15#
16
17Introduction
18------------
19
20This README describes the Lua interpreter source code that lives in the ZFS
21source tree to enable execution of ZFS channel programs, including its
22maintenance policy, the modifications that have been made to it, and how it
23should (and should not) be used.
24
25For a description of the Lua language and features exposed by ZFS channel
26programs, please refer to the zfs-program(1m) man page instead.
27
28
29Maintenance policy
30------------------
31
32The Lua runtime is considered stable software. Channel programs don't need much
33complicated logic, so updates to the Lua runtime from upstream are viewed as
34nice-to-have, but not required for channel programs to be well-supported. As
35such, the Lua runtime in ZFS should be updated on an as-needed basis for
36security vulnerabilities, but not much else.
37
38
39Modifications to Lua
40--------------------
41
42The version of the Lua runtime we're using in ZFS has been modified in a variety
43of ways to make it more useful for the specific purpose of running channel
44programs. These changes include:
45
461. "Normal" Lua uses floating point for all numbers it stores, but those aren't
47   useful inside ZFS / the kernel. We have changed the runtime to use int64_t
48   throughout for all numbers.
492. Some of the Lua standard libraries do file I/O or spawn processes, but
50   neither of these make sense from inside channel programs. We have removed
51   those libraries rather than reimplementing them using kernel APIs.
523. The "normal" Lua runtime handles errors by failing fatally, but since this
53   version of Lua runs inside the kernel we must handle these failures and
54   return meaningful error codes to userland. We have customized the Lua
55   failure paths so that they aren't fatal.
564. Running poorly-vetted code inside the kernel is always a risk; even if the
57   ability to do so is restricted to the root user, it's still possible to write
58   an incorrect program that results in an infinite loop or massive memory use.
59   We've added new protections into the Lua interpreter to limit the runtime
60   (measured in number of Lua instructions run) and memory overhead of running
61   a channel program.
625. The Lua bytecode is not designed to be secure / safe, so it would be easy to
63   pass invalid bytecode which can panic the kernel. By comparison, the parser
64   is hardened and fails gracefully on invalid input. Therefore, we only accept
65   Lua source code at the ioctl level and then interpret it inside the kernel.
66
67Each of these modifications have been tested in the zfs-test suite. If / when
68new modifications are made, new tests should be added to the suite located in
69zfs-tests/tests/functional/channel_program/lua_core.
70
71
72How to use this Lua interpreter
73-------------------------------
74
75From the above, it should be clear that this is not a general-purpose Lua
76interpreter. Additional work would be required to extricate this custom version
77of Lua from ZFS and make it usable by other areas of the kernel.
78