Linux Security Modules (LSM) is a framework in the Linux kernel that provides a set of hooks to support the implementation of mandatory access control (MAC) security models as loadable kernel modules. It allows security policies like SELinux, AppArmor, and Smack to be integrated into the kernel to enforce fine-grained, system-wide rules on object access and process operations, extending beyond traditional discretionary access control (DAC). The framework acts as a mediator, enabling these modules to authorize or deny security-sensitive operations.
Glossary
Linux Security Modules (LSM)

What is Linux Security Modules (LSM)?
A technical definition of the Linux kernel framework for implementing mandatory access control (MAC) security policies.
In the context of secure enclave execution for AI agents, LSM is a critical sandboxing mechanism. It can confine tool-calling processes by restricting their filesystem access, network capabilities, and system calls, enforcing the principle of least privilege. This isolation mitigates risks if an agent is compromised, preventing lateral movement. While distinct from hardware-based Trusted Execution Environments (TEEs) like Intel SGX, LSM operates at the OS level to provide a robust, configurable layer of mandatory security policy enforcement for containerized and native workloads.
Core Architectural Features of LSM
The Linux Security Modules (LSM) framework provides a standardized, modular architecture for implementing mandatory access control (MAC) security policies directly within the Linux kernel.
Hook-Based Architecture
LSM implements security by inserting hooks at critical points in the kernel where a user-space object (file, task, socket) is about to be accessed. Before the kernel proceeds with the operation, it calls the LSM framework, which passes the request to the loaded security module (e.g., SELinux, AppArmor) for a policy decision.
- Example Hooks:
file_open,inode_permission,task_kill,socket_bind. - The module evaluates the request against its internal policy and returns an allow or deny decision.
- This design centralizes security logic without scattering checks throughout the kernel source code.
Module Stacking (Since Linux 5.1)
Historically, only one LSM could be active at boot time. Modern kernels support LSM stacking, allowing multiple security modules to be loaded simultaneously. Hooks are processed in a defined order, with each module getting a chance to make a decision.
- Key Use Case: Combining a comprehensive MAC system like SELinux with a simpler, path-based module like AppArmor for specific applications.
- The final decision is a logical AND; all modules must allow the action for it to proceed.
- This enables defense-in-depth by layering distinct security models.
Blob Management
LSM modules often need to store security state (labels, contexts) associated with kernel objects like tasks, inodes, and files. The framework provides opaque security blobs—pointers to module-specific data structures—attached to these kernel objects.
- The kernel allocates and manages the pointer storage, but the module manages the actual data.
- Example: SELinux stores a security context (e.g.,
user_u:role_r:type_t) in the inode's security blob. - This mechanism isolates module data, preventing interference between stacked modules.
Capabilities Integration
LSM hooks integrate with and extend the traditional Linux Capabilities model. While capabilities are a form of discretionary access control (DAC) granting privileges to processes, LSM modules can make finer-grained decisions.
- A hook can override a capability check. For instance, a process might have the
CAP_NET_BIND_SERVICEcapability, but SELinux policy could still deny a specificsocket_bindoperation. - This allows policies to enforce rules that are more specific than broad privilege flags.
Network Security Hooks
Beyond files and processes, LSM provides hooks for regulating network operations. This allows security modules to implement policies for sockets, packets, and network interfaces.
- Socket Hooks: Control creation (
socket_create), binding (socket_bind), and connecting (socket_connect) based on security context. - Packet Hooks: Authorize transmission/reception of individual packets (
socket_sendmsg,socket_recvmsg). - Netfilter Integration: Modules like SELinux can label packets via
secmarkfor consistent policy enforcement across the network stack.
Userspace Object Labeling
A core function of LSM modules is to assign and manage security labels on all system objects. These persistent labels are the basis for access decisions.
- Filesystem Labeling: Labels are stored in extended attributes (e.g.,
security.selinux) on supported filesystems. - Dynamic Translation: Modules provide rules to assign initial labels to new objects (e.g., a process inherits its parent's label, a new file gets its creating process's label).
- Tools: Userspace utilities (e.g.,
chcon,aa-status) allow administrators to query and modify these labels according to policy.
How the LSM Framework Works
The Linux Security Modules (LSM) framework is a kernel-level architecture that provides hooks for implementing mandatory access control (MAC) security policies.
The Linux Security Modules (LSM) framework is a lightweight, general-purpose hook-based architecture integrated into the Linux kernel. It places security decision points at critical kernel operations—such as file access, task creation, and socket binding—allowing a loaded security module to intercept these calls and enforce policy. This design enables mandatory access control (MAC) systems like SELinux and AppArmor to be implemented as kernel modules without requiring extensive kernel patches, providing a standardized interface for security extensions.
When a system call triggers a protected operation, the kernel executes the relevant LSM hook, which calls the currently active security module's callback function. The module evaluates the request against its internal policy—checking labels, contexts, or rules—and returns a decision to allow or deny the action. Only one MAC module can be active at a time, ensuring deterministic policy enforcement. The framework's core provides only the hook infrastructure; all security logic and policy management are delegated to the loadable module, separating mechanism from policy.
Frequently Asked Questions
Linux Security Modules (LSM) is a kernel framework that enables mandatory access control (MAC) for the Linux operating system. These FAQs address its core mechanisms, use cases, and relationship to secure enclave execution for AI agents.
Linux Security Modules (LSM) is a framework in the Linux kernel that provides hooks for implementing mandatory access control (MAC) security models. It works by inserting security hooks at critical points in the kernel—such as file operations, task creation, and network socket actions—allowing a loaded security module to make authorization decisions before an operation proceeds. Unlike traditional Discretionary Access Control (DAC), which relies on user/group ownership, LSM enables system-wide policies that enforce rules regardless of user discretion. The framework itself is policy-agnostic; the enforcement logic is defined by the loaded module, such as SELinux, AppArmor, or Smack. When a system call triggers a hooked operation, the kernel queries the active LSM, which can allow or deny the action based on its security policy.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Linux Security Modules (LSM) is a kernel framework for implementing mandatory access control (MAC). The following terms represent its core mechanisms, related security features, and the broader ecosystem of system hardening.
Mandatory Access Control (MAC)
Mandatory Access Control (MAC) is a security policy where access decisions are made by a central authority based on system-wide rules, not user discretion. It is the primary security model implemented by LSMs.
- Contrasts with DAC: Unlike Discretionary Access Control (DAC), where owners control permissions, MAC policies are enforced uniformly.
- LSM's Role: The LSM framework provides the hooks in the kernel (e.g., for file operations, task creation) that MAC implementations like SELinux use to enforce their policies.
- Example Policy: A MAC rule might state "the web server process (subject) cannot write to the database configuration file (object)," regardless of file ownership.
SELinux (Security-Enhanced Linux)
SELinux is a prominent, label-based LSM implementation developed by the NSA. It enforces MAC using security contexts attached to all subjects (processes) and objects (files, ports).
- Core Mechanism: Every process and system resource has a security context (e.g.,
user:role:type:level). Access is allowed only if explicitly granted by a policy rule. - Policy Types: Primarily uses a Type Enforcement (TE) model, where rules define allowed interactions between types (e.g.,
httpd_tcan readhttpd_log_t). - Modes: Operates in Enforcing (blocks violations), Permissive (logs only), or Disabled states. It is the default LSM on Red Hat Enterprise Linux, Fedora, and Android.
AppArmor
AppArmor is a pathname-based LSM that confines individual applications to a defined set of resources. It uses human-readable profiles instead of system-wide labels.
- Path-Based Security: Rules specify filesystem paths (e.g.,
/etc/nginx/** r, /var/log/nginx/* w) the application can access. - Ease of Use: Profiles are simpler to write and audit than SELinux policies, making it popular for application containment.
- Deployment: Default LSM on Ubuntu, SUSE Linux Enterprise, and many other distributions. It is often used to sandbox network-facing daemons like Nginx or MySQL.
Seccomp (Secure Computing Mode)
Seccomp is a Linux kernel feature that restricts the system calls a process can make, providing a strict sandbox. It is often used in conjunction with LSMs for defense-in-depth.
- Operation Modes: Seccomp-bpf allows filtering of system calls using Berkeley Packet Filter (BPF) rules to allow, log, or kill based on call arguments.
- Narrowing Attack Surface: While an LSM controls access to resources, seccomp controls which kernel interfaces (syscalls) are available at all.
- Common Use: Heavily utilized by container runtimes (like Docker and Kubernetes) to limit the kernel API available to containerized workloads.
Capabilities
Linux Capabilities split the omnipotent power of the root user into distinct units, allowing processes to be granted specific privileges without full superuser access. LSMs can further restrict capability use.
- Granular Privileges: Examples include
CAP_NET_BIND_SERVICE(bind to ports < 1024) andCAP_SYS_ADMIN(broad admin rights). - Interaction with LSM: An LSM can veto the effective use of a capability. A process might have
CAP_DAC_OVERRIDEbut an SELinux policy could still deny a file write. - Hardening Practice: Dropping unnecessary capabilities is a fundamental container and daemon hardening step, reducing the impact of a compromise.
Namespaces
Linux Namespaces are a kernel feature that isolates and virtualizes system resources for a collection of processes, providing a form of lightweight virtualization. They are the foundational isolation mechanism for containers.
- Types of Isolation: Key namespaces include PID (process IDs), Network (interfaces, routing), Mount (filesystem hierarchy), and User (UID/GID mapping).
- Synergy with LSM: Namespaces provide isolation boundaries, while an LSM like AppArmor enforces access control within those boundaries. For example, a container can have its own network namespace and be confined by an AppArmor profile.
- Container Foundation: Tools like Docker and LXC combine namespaces, cgroups, and LSMs to create secure, isolated runtime environments.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us