Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
d3b90d8
Revert "gen_init_cpio: attempt copy_file_range for file data"
uudiin Mar 24, 2026
dd7dd7e
macos: use gnu-sed instead of sed
uudiin Sep 9, 2025
6fe169b
build on macOS with Apple Silicon
uudiin Oct 9, 2024
f62891f
file: Call security_file_alloc() after initializing the filp
uudiin Nov 27, 2025
c855d13
x86/lib: Add setjmp/longjmp implementation
uudiin Jan 26, 2024
d91f876
arm64/lib: Add setjmp/longjmp implementation
uudiin Mar 9, 2025
77abccc
lib: Introduced Lua 5.1 language interpreter
uudiin Mar 7, 2025
89edf7c
headers: move to common directory
uudiin Mar 9, 2025
590dd95
include: lua - fixes for kernel
uudiin Aug 22, 2025
3f709af
lib: lua - fixes
uudiin Aug 22, 2025
6f2930d
lib: lua - add makefile
uudiin Aug 22, 2025
7b6f290
lib: lua - remove unused files from Makefile
uudiin Aug 22, 2025
0ad2265
lib: build lua library
uudiin Aug 22, 2025
0704b3c
lua-lsm: lib - add queue/tree/bitmap header
uudiin Mar 27, 2025
0edf337
lua-lsm: lib - fixes for build on linux
uudiin Mar 28, 2025
cbcd244
lua-lsm: add common auxiliary library
uudiin Aug 22, 2025
ebc332f
lua-lsm: add type definition header files
uudiin Aug 22, 2025
9a34db7
lua-lsm: api - add commonly used constant definitions
uudiin Aug 22, 2025
eac9574
lua-lsm: api - add kernel library
uudiin Aug 22, 2025
67f1cc4
lua-lsm: api - add filesystem library
uudiin Aug 22, 2025
df875ca
lua-lsm: api - add net library
uudiin Aug 22, 2025
3bef0ac
lua-lsm: Wrapper all LSM functions
uudiin Aug 22, 2025
f5ee236
security: Add Lua based LSM
uudiin Aug 26, 2025
b7f983f
lua-lsm: Fix deadlock on modules_lock
uudiin Aug 27, 2025
5252b52
lua-lsm: Fix potential deadlock
uudiin Aug 29, 2025
5e4644f
lua-lsm: optimizate dict free
uudiin Sep 3, 2025
d9a4446
lua-lsm: dont swap the module and Lua VM memeory
uudiin Sep 5, 2025
c3db729
lua-lsm: add DEBUG config
uudiin Sep 5, 2025
2840f9b
lua-lsm: kvcache - Dont disable irq on lock
uudiin Sep 9, 2025
3da7919
lua-lsm: kvcache - kmalloc in atomic context
uudiin Sep 9, 2025
b79078e
lua-lsm: display more information on unregister
uudiin Sep 9, 2025
c10e915
lua-lsm: Donot initialize securityfs if LSM is not initialized
uudiin Sep 11, 2025
5c8aec4
lua-lsm: fix: prevent returning true for non-existent key
HOCOOH Sep 17, 2025
7d48dee
lua-lsm: api - add securebits
HOCOOH Sep 17, 2025
43f7d46
lua-lsm: add refcount.h
uudiin Sep 15, 2025
a8e90c6
lua-lsm: kvcache - Remove table type
uudiin Sep 15, 2025
e9ce649
lua-lsm: kvcache - lock on node
uudiin Sep 15, 2025
124e21c
lua-lsm: kvcache - Remove string type
uudiin Sep 15, 2025
71dfc5d
lua-lsm: replace tailq with linux list
uudiin Sep 16, 2025
d37570c
lua-lsm: lockess modules with srcu
uudiin Sep 17, 2025
669358a
lua-lsm: lockess shdict with rcu
uudiin Sep 17, 2025
f4a6d8e
lua-lsm: kvcache - Eliminating Inconsistent Locks
uudiin Sep 17, 2025
e2b1efc
lua-lsm: always show traceback
uudiin Sep 18, 2025
24d94a5
lua-lsm: use separate Lua VM for softirq
uudiin Sep 18, 2025
31b296c
lua-lsm: remove rcu api
uudiin Oct 14, 2025
d906986
lua-lsm: Add missing updates for exist node
uudiin Oct 14, 2025
b235c17
lua-lsm: Fix mismatched build configuration name
uudiin Oct 14, 2025
edc8336
lua-lsm: Fix crash caused by incomplete kvnodes free when module is u…
uudiin Oct 19, 2025
2d69260
lua-lsm: add refcount to per task LuaVM
uudiin Oct 20, 2025
e9a9386
lua-lsm: Fixes srcu read on modules list
uudiin Oct 21, 2025
1e43476
lua-lsm: add loaded_count for lua_module
uudiin Oct 21, 2025
a79c1d4
lua-lsm: safe unregister module under freeze LuaVM
uudiin Oct 23, 2025
c86bc1c
lua-lsm: Synchronize kvnode garbage collection
uudiin Oct 27, 2025
48d40ee
lua-lsm: Fixed invalid pointer when multi-unregister busy module
uudiin Oct 28, 2025
cc7e8fb
lua-lsm: Avoid recursive calls to the capable
uudiin Nov 10, 2025
de28578
lua-lsm: api - exepath/cmdline and inode mode
uudiin Nov 10, 2025
a772302
lua-lsm: pretty show lsm_funcs & module
uudiin Nov 14, 2025
fe489b2
lua-lsm: Make tostring overloadable
uudiin Nov 27, 2025
d69f677
lua-lsm: add extra two metatables for raw and gc object
uudiin Nov 28, 2025
308d791
lua-lsm: Strengthen file object using layered metatables
uudiin Dec 9, 2025
ef40c03
lua-lsm: Simplify module register function
uudiin Dec 11, 2025
e7137b5
lua-lsm: rename lua_module to lua_lsm_module
uudiin Dec 11, 2025
d65fe9a
lua-lsm: Fixes for object missing environment
uudiin Dec 11, 2025
166b195
lua-lsm: api - make sockaddr readable
uudiin Dec 12, 2025
91ccd2c
lua-lsm: Add type() method for all userdata
uudiin Dec 12, 2025
6f63f2f
lua-lsm: Rewrite statistics codes
uudiin Dec 15, 2025
aaf2eb8
lua-lsm: refactor securityfs
uudiin Dec 16, 2025
16a5eaa
lua-lsm: api - Keep semantic consistency with math.random
uudiin Dec 17, 2025
6a4e278
lua-lsm: add has_kvcache result for type method
uudiin Dec 18, 2025
faef660
lua-lsm: extend api
uudiin Dec 23, 2025
c430d42
lua-lsm: silent key/ib/tundev/perfevent kvcache
uudiin Dec 23, 2025
656f37b
fix(lua-lsm): Resolve missing header dependencies for x86_64 build
chenzongyao200127 Dec 24, 2025
0d72757
lua-lsm: add pid_alive method & inode_init_security_anon hook
uudiin Jan 16, 2026
b28c709
lua-lsm: simplify module environment for userdata
uudiin Jan 16, 2026
b9f6e75
lua-lsm: pretty show sockaddr
uudiin Jan 16, 2026
dbb7b7f
lua-lsm: Count with atomic64_t
uudiin Jan 19, 2026
2a66d0b
lua-lsm: return busy if task alloc_lock held
chenzongyao200127 Feb 10, 2026
b220126
lua-lsm: add lvm pool support
chenzongyao200127 Jan 26, 2026
b261699
lua-lsm: reset pooled VM modules by table keys
chenzongyao200127 Feb 12, 2026
4936ad1
lua-lsm: add lua-lsm documentation
chenzongyao200127 Feb 12, 2026
fd30df4
lua-lsm: add bdev_setintegrity payload handling
chenzongyao200127 Feb 26, 2026
c12d17c
lua-lsm: Port from 6.17 to 6.19
uudiin Mar 24, 2026
b593b90
lua-lsm: style cleanups
chenzongyao200127 Mar 26, 2026
da0cbb4
lua-lsm: auxlib: add forward declarations
chenzongyao200127 Mar 26, 2026
b40a8ba
lua-lsm: auxlib: guard optional path buffer free
chenzongyao200127 Mar 26, 2026
fb90bbf
lua-lsm: rename debug symbol to avoid allyesconfig conflict
chenzongyao200127 Mar 30, 2026
cd33b81
lib: expose LUA in Kconfig
chenzongyao200127 Apr 1, 2026
12a7d0e
docs: update Lua-LSM config docs
chenzongyao200127 Apr 1, 2026
6ef700d
lua-lsm: guard blob-backed object access on rollback
chenzongyao200127 Apr 9, 2026
295eb05
lua-lsm: Correct header file pach
chenzongyao200127 Apr 9, 2026
c47e272
lua-lsm: move hook stats accounting to percpu
chenzongyao200127 Apr 16, 2026
fdfff25
lua-lsm: make lvm pool size configurable
chenzongyao200127 Apr 21, 2026
da2d7ac
docs: document Lua-LSM lvm pool cmdline
chenzongyao200127 Apr 21, 2026
8ce60df
lua-lsm: set default lvm pool size to 32
chenzongyao200127 Apr 21, 2026
1169633
lua-lsm: stop registering legacy procattr hooks
chenzongyao200127 Apr 23, 2026
05260f9
lua-lsm: do not register lsmprop_to_secctx
chenzongyao200127 Apr 23, 2026
85d88b5
lua-lsm: hide unsupported hooks from modules and introspection
chenzongyao200127 Apr 23, 2026
2a921f7
docs: describe Lua-LSM supported hook surface
chenzongyao200127 Apr 23, 2026
9707c71
lua-lsm: validate inode_init_security xattr output
chenzongyao200127 May 8, 2026
ae861cc
lua-lsm: own inode_init_security xattr name storage
chenzongyao200127 May 8, 2026
69ec178
lua-lsm: document OCFS2 xattr name lifetime issue
chenzongyao200127 May 8, 2026
583c9b9
macos: make git config core.symlinks to true
uudiin May 12, 2026
0d1bb50
lua: rewrite kconfig dependencies
uudiin May 12, 2026
4eded36
lua-lsm: put looked-up task after descendant walk
chenzongyao200127 May 11, 2026
3dcc78f
lua-lsm: validate numeric capability arguments
chenzongyao200127 May 11, 2026
3ab7fe1
lua-lsm: return nil for missing wrapped objects
chenzongyao200127 May 11, 2026
e686d3b
lua-lsm: don't store filp_open errors in file userdata
chenzongyao200127 May 9, 2026
9224ea6
lua-lsm: fix length handling for Lua string buffers
chenzongyao200127 May 8, 2026
2d8b56b
lua-lsm: wait for SRCU readers before freeing module
chenzongyao200127 May 9, 2026
40da5d4
lua-lsm: fix AF_UNIX sockaddr marshalling lengths
chenzongyao200127 May 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,15 @@ config ARCH_HAS_SET_MEMORY
config ARCH_HAS_SET_DIRECT_MAP
bool

# Select if arch has all setjmp/longjmp() functions
config ARCH_HAS_SETJMP
bool

config ARCH_SETJMP
bool
depends on ARCH_HAS_SETJMP
default n

#
# Select if the architecture provides the arch_dma_set_uncached symbol to
# either provide an uncached segment alias for a DMA allocation, or
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ config ARM64
select ARCH_HAS_SETUP_DMA_OPS
select ARCH_HAS_SET_DIRECT_MAP
select ARCH_HAS_SET_MEMORY
select ARCH_HAS_SETJMP
select ARCH_HAS_FORCE_DMA_UNENCRYPTED
select ARCH_STACKWALK
select ARCH_HAS_STRICT_KERNEL_RWX
Expand Down
15 changes: 15 additions & 0 deletions arch/arm64/include/asm/setjmp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_ARM64_SETJMP_H
#define _ASM_ARM64_SETJMP_H

#include <linux/types.h>

struct label_t {
/* ABI x19 .. x30 (lr), sp */
uint64_t regs[13];
};

extern int setjmp(struct label_t *label);
extern void longjmp(struct label_t *label, int val);

#endif /* _ASM_ARM64_SETJMP_H */
2 changes: 2 additions & 0 deletions arch/arm64/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ obj-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
obj-$(CONFIG_ARM64_MTE) += mte.o

obj-$(CONFIG_KASAN_SW_TAGS) += kasan_sw_tags.o

obj-$(CONFIG_ARCH_SETJMP) += setjmp.o
44 changes: 44 additions & 0 deletions arch/arm64/lib/setjmp.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (C) 2025 Alibaba Group.
*/

#include <linux/linkage.h>
#include <asm/assembler.h>


/*
* int setjmp(struct label_t *label);
*/
.align 3
SYM_FUNC_START(setjmp)
stp x19, x20, [x0, #(0 * 8)]
stp x21, x22, [x0, #(2 * 8)]
stp x23, x24, [x0, #(4 * 8)]
stp x25, x26, [x0, #(6 * 8)]
stp x27, x28, [x0, #(8 * 8)]
stp x29, x30, [x0, #(10 * 8)]
mov x1, sp
str x1, [x0, #(12 * 8)]
mov x0, #0
ret
SYM_FUNC_END(setjmp)
EXPORT_SYMBOL(setjmp)

/*
* void longjmp(struct label_t *label, int val);
*/
.align 3
SYM_FUNC_START(longjmp)
ldp x19, x20, [x0, #(0 * 8)]
ldp x21, x22, [x0, #(2 * 8)]
ldp x23, x24, [x0, #(4 * 8)]
ldp x25, x26, [x0, #(6 * 8)]
ldp x27, x28, [x0, #(8 * 8)]
ldp x29, x30, [x0, #(10 * 8)]
ldr x0, [x0, #(12 * 8)]
mov sp, x0
mov x0, x1
ret
SYM_FUNC_END(longjmp)
EXPORT_SYMBOL(longjmp)
1 change: 1 addition & 0 deletions arch/x86/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ config X86
select ARCH_HAS_COPY_MC if X86_64
select ARCH_HAS_SET_MEMORY
select ARCH_HAS_SET_DIRECT_MAP
select ARCH_HAS_SETJMP
select ARCH_HAS_STRICT_KERNEL_RWX
select ARCH_HAS_STRICT_MODULE_RWX
select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
Expand Down
20 changes: 20 additions & 0 deletions arch/x86/include/asm/setjmp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_X86_SETJMP_H
#define _ASM_X86_SETJMP_H

#include <linux/types.h>

struct label_t {
#ifdef CONFIG_X86_32
/* ABI (ebx, esp, ebp, esi, edi) and eip. */
uint32_t regs[6];
#else
/* ABI (rbx, rsp, rbp, r12-r15) and rip. */
uint64_t regs[8];
#endif
};

extern int setjmp(struct label_t *label);
extern void longjmp(struct label_t *label, int val);

#endif /* _ASM_X86_SETJMP_H */
2 changes: 2 additions & 0 deletions arch/x86/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ lib-$(CONFIG_MITIGATION_RETPOLINE) += retpoline.o
obj-y += msr.o msr-reg.o msr-reg-export.o hweight.o
obj-y += iomem.o

obj-$(CONFIG_ARCH_SETJMP) += setjmp_$(BITS).o

ifeq ($(CONFIG_X86_32),y)
obj-y += atomic64_32.o
lib-y += atomic64_cx8_32.o
Expand Down
39 changes: 39 additions & 0 deletions arch/x86/lib/setjmp_32.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* SPDX-License-Identifier: GPL-2.0 */

#include <linux/export.h>
#include <linux/linkage.h>

/*
* int setjmp(struct label_t *label);
*/
SYM_FUNC_START(setjmp)
movl 4(%esp), %eax
movl %ebx, (%eax) /* save ebx */
movl %esp, 4(%eax) /* save esp */
movl %ebp, 8(%eax) /* save ebp */
movl %esi, 12(%eax) /* save esi */
movl %edi, 16(%eax) /* save edi */
movl (%esp), %edx /* get retaddr */
movl %edx, 20(%eax) /* save eip */
xorl %eax, %eax /* return 0 */
RET
SYM_FUNC_END(setjmp)
EXPORT_SYMBOL(setjmp)

/*
* void longjmp(struct label_t *label, int val);
*/
SYM_FUNC_START(longjmp)
movl 4(%esp), %eax
movl 8(%esp), %edx
movl (%eax), %ebx /* restore ebx */
movl 4(%eax), %esp /* restore esp */
movl 8(%eax), %ebp /* restore ebp */
movl 12(%eax), %esi /* restore esi */
movl 16(%eax), %edi /* restore edi */
movl 20(%eax), %eax /* get retaddr */
movl %eax, (%esp) /* put in return frame */
movl %edx, %eax /* return val */
RET
SYM_FUNC_END(longjmp)
EXPORT_SYMBOL(longjmp)
50 changes: 50 additions & 0 deletions arch/x86/lib/setjmp_64.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* SPDX-License-Identifier: GPL-2.0 */

#include <linux/export.h>
#include <linux/linkage.h>

.section .noinstr.text, "ax"

/*
* int setjmp(struct label_t *label);
*/
SYM_FUNC_START(setjmp)
/*
* Only save registers that must be preserved across function
* calls according to the ABI (%rbx, %rsp, %rbp, %r12-%r15)
* and %rip.
*/
movq %rdi, %rax
movq %rbx, (%rax)
movq %rsp, 8(%rax)
movq %rbp, 16(%rax)
movq %r12, 24(%rax)
movq %r13, 32(%rax)
movq %r14, 40(%rax)
movq %r15, 48(%rax)
movq (%rsp), %rdx
movq %rdx, 56(%rax)
xorq %rax, %rax
RET
SYM_FUNC_END(setjmp)
EXPORT_SYMBOL(setjmp)

/*
* void longjmp(struct label_t *label, int val);
*/
SYM_FUNC_START(longjmp)
movq %rdi, %rax
movq (%rax), %rbx
movq 8(%rax), %rsp
movq 16(%rax), %rbp
movq 24(%rax), %r12
movq 32(%rax), %r13
movq 40(%rax), %r14
movq 48(%rax), %r15
movq 56(%rax), %rdx
movq %rdx, (%rsp)
movq %rsi, %rax
RET
SYM_FUNC_END(longjmp)
EXPORT_SYMBOL(longjmp)

27 changes: 27 additions & 0 deletions env_macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh


#brew install coreutils findutils gnu-sed gnu-tar grep llvm make pkg-config


export PATH="$(brew --prefix make)/libexec/gnubin:$PATH"
export PATH="$(brew --prefix llvm)/bin:$PATH"
export PATH="$(brew --prefix lld)/bin:$PATH"


# UUID_T and GETHOSTUUID_H Eliminate compile errors of scripts/mod/file2alias.c
# O_LARGEFILE Eliminate compile errors of usr/gen_init_cpio.c
export HOSTCFLAGS="-D_UUID_T -D__GETHOSTUUID_H -DO_LARGEFILE=0"


# Use gnu coreutils instead of builtin tools
alias sed='gsed'


# Maybe the symlink is missed on macOS
# git config --global core.symlinks true

#make ARCH=arm64 LLVM=1

#make LLVM=1 menuconfig
#make LLVM=1 -j8
13 changes: 8 additions & 5 deletions fs/file_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,6 @@ static int init_file(struct file *f, int flags, const struct cred *cred)
int error;

f->f_cred = get_cred(cred);
error = security_file_alloc(f);
if (unlikely(error)) {
put_cred(f->f_cred);
return error;
}

spin_lock_init(&f->f_lock);
/*
Expand Down Expand Up @@ -202,6 +197,14 @@ static int init_file(struct file *f, int flags, const struct cred *cred)
* They may be enabled later by fsnotify_open_perm_and_set_mode().
*/
file_set_fsnotify_mode(f, FMODE_NONOTIFY_PERM);

error = security_file_alloc(f);
if (unlikely(error)) {
mutex_destroy(&f->f_pos_lock);
put_cred(f->f_cred);
return error;
}

return 0;
}

Expand Down
5 changes: 5 additions & 0 deletions include/asm-generic/asm-prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ extern void *memset(void *, int, __kernel_size_t);
extern void *memcpy(void *, const void *, __kernel_size_t);
#undef memmove
extern void *memmove(void *, const void *, __kernel_size_t);
struct label_t;
#undef setjmp
extern int setjmp(struct label_t *);
#undef longjmp
extern void longjmp(struct label_t *, int);
Loading