-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zlua is a maintenance problem with low bang/buck as implemented...? #13948
Comments
@adamdmoss It made certain things faster by eliminating syscall overhead. That said, I was worried about lua being a source of bugs since the beginning, but it is behind the A quick check finds that the imported lua code is vulnerable to GHSA-v3hh-4h88-w4mr (which is unfortunate considering that the patch was available when the lua code was merged). All of the existing CVEs probably need to be checked to see if they apply: https://www.opencve.io/cve?vendor=lua A LUA update might be a good idea too, but I am not very familiar with the LUA code, so I am taking things one step at a time. I do not feel strongly about keeping/ejecting LUA (since putting it behind I am slowly working my way through all of the coverity reports. My current plan is to keep patching things until static analyzers stop telling us that there are problems (and there are no more bug reports). That is actually my current plan for the entire codebase, so there is nothing about it that is unique to the lua code. |
It occurs to me that if people start sharing lua scripts for ZCP, then it would be possible for someone to share a malicious script that would exploit a LUA bug. This makes getting the LUA interpreter correct very important. |
In hindsight, I am curious why Lua was used rather than the D interpreter from DTrace. DTrace’s D interpreter was designed for use inside the kernel and is presumably less buggy. |
Given that when Oracle landed DTrace in the Linux kernel, it had (and perhaps still has? I haven't checked, and I thought they ported that to using an eBPF backend anyway) a problem with regularly panicking, perhaps that was limited to how well it was integrated in Solaris. |
Something I've been wondering about lately is why libzfs does zcp_check() to check that channel programs see the same property values as whatever ioctl the value came from, just so it can print a warning when they differ. It's also been on my mind recently that our Lua supports only int64_t numbers, so any property that has a uint64_t numeric value has to be explicitly cast to the right type after pulling it out of the results nvlist. This is easily noticeable when using the json ouput of I think channel programs are a pretty neat idea, being able to construct complex operations in a simple language and even use them with a single ioctl from userspace, but there still is not a whole lot you can actually do with them in practice. Try to implement It was interesting to see #13802 come through recently. Now you can rename a snapshot in a channel program. You still can't rename a dataset though. I hope to eventually see channel programs be capable of more. The less I have to rely on libzfs the better. Channel programs give you one ioctl that has the potential to be incredibly flexible and powerful. But it is true that right now it's a pretty big chunk of code that doesn't do much. |
This issue has been automatically marked as "stale" because it has not had any activity for a while. It will be closed in 90 days if no further activity occurs. Thank you for your contributions. |
As a Python developer who stumbled upon Lua in ZFS while trying to get ZFS data into JSON format...all I can say is I hate Lua with a passion. I've been banging around for about 6 hours now trying to get some pretty simple stuff out of ZFS, but I had to learn that Lua can't do I think it's a shame that JSON output for the zfs and zpool commands was dumped in favor of adding this horrific abomination of a programming language where you have to upload a script to a machine, then execute
|
@darkpixel the upcoming OpenZFS 2.3 series has JSON support and will do what you suggest, see #16217. (the rest is largely irrelevant; whatever the channel program facility is, it is not really anything to do with getting information out of the system, and it certainly wasn't implemented "in favour of" support for JSON command output). |
Thanks @robn. That's great news.
That's just walking all the datasets under tank and grabbing the snapshots. If I do something slightly smaller like recursively grabbing properties from all the datasets it works perfectly. I'm sure there's a knob somewhere that sets how much memory the lua script gets, but I'll just patiently wait for JSON support. |
|
Oops--I totally missed that in the man page. So what are channel programs for then? The man page shows they basically get/set datasets, properties, snapshots, bookmarks, etc... |
@darkpixel the idea is to be able run complex, bulk and/or multi-step administrative processes "atomically" by loading a program into ZFS itself, which it can then run as a group, under a single lock, without other administrative operations getting in the way. A really contrived example might be to destroy and then recreate a dataset. In a shell script, that would be I'm deliberately not speaking to the general usefulness, implementation details, etc, because this issue is not really the right place for that. Suffice to say, there's lots of different ways this could be done; loading Lua scripts into the ZFS module is the one we have right now. |
Thanks @robn. Sounds like it's just a handy way of performing multiple steps as a single "transaction". |
@darkpixel perfect summary 👍 |
I admire and enjoy Lua.
I don't know what it's really doing in ZFS though (channel programs? wha?), and least of all why we need to put it in the darn kernel if it's not twiddling hardware bits or deeply coupled to kernel structures. It's a frickin' interpreter for a scripting language to support one feature, and as small and elegant as Lua is it hurts my head to think of it in ring-zero.
So while I admit my caveman brain is having a knee-jerk reaction to something I don't fully understand, nonetheless
zlua
is 15KLloc of code which:The text was updated successfully, but these errors were encountered: