Skip to content

lua-lsm: expose shared dictionaries through securityfs - #2

Merged
heyu-233 merged 3 commits into
lua-lsmfrom
ospp/securityfs-shared-dict
Aug 25, 2026
Merged

lua-lsm: expose shared dictionaries through securityfs#2
heyu-233 merged 3 commits into
lua-lsmfrom
ospp/securityfs-shared-dict

Conversation

@heyu-233

@heyu-233 heyu-233 commented Aug 24, 2026

Copy link
Copy Markdown
Owner

改动概述

  • 为共享字典增加不可变、引用计数管理的字符串值,并提供稳定的快照读取接口
  • 增加带模块生命周期保护的共享字典访问封装:完整操作期间持有模块锁,并仅允许访问 LIVE 状态的模块
  • 增加实验性的 securityfs 控制文件 /sys/kernel/security/lua/shdict,支持用户态按类型执行 getset
  • 新增 tools/testing/selftests/lua_lsm 测试,并登记到 kselftest 顶层目标

本 PoC 已跑通完整链路:

加载 Lua 策略 → Hook 创建共享字典 → 用户态通过 securityfs 读写 → Lua Hook 立即读取新值并改变访问结果

整个过程不需要重新加载模块。

验证结果

  • RISC-V 内核交叉编译:通过
  • QEMU riscv64 自测试:54/54 PASS
  • git diff --check:通过
  • checkpatch.pl:0 errors

测试覆盖以下场景:

  • bool、number、普通字符串和含 NUL 字符串的读写
  • 同一 key 覆盖后立即可见
  • 用户态更新共享字典后,Lua Hook 行为即时改变
  • 非法输入、超长输入及权限检查
  • 禁止向用户态暴露 lightuserdata 内核指针
  • Lua 侧删除节点后的引用计数和资源回收
  • LIVE 模块访问返回 -ESHUTDOWN

当前范围

该接口目前明确作为 PoC/不稳定接口,不视为正式 ABI。本次改动暂不包含:

上游 PR openanolis#16 所处理的 Lua 侧卸载生命周期问题仍保持在本次改动范围之外。

@heyu-233
heyu-233 merged commit 0729561 into lua-lsm Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant