security/smack/smack_lsm.c
Source file repositories/reference/linux-study-clean/security/smack/smack_lsm.c
File Facts
- System
- Linux kernel
- Corpus path
security/smack/smack_lsm.c- Extension
.c- Size
- 134470 bytes
- Lines
- 5381
- Domain
- Core OS
- Bucket
- Security And Isolation
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/xattr.hlinux/pagemap.hlinux/mount.hlinux/stat.hlinux/kd.hasm/ioctls.hlinux/ip.hlinux/tcp.hlinux/udp.hlinux/icmpv6.hlinux/slab.hlinux/mutex.hnet/cipso_ipv4.hnet/ip.hnet/ipv6.hlinux/audit.hlinux/magic.hlinux/dcache.hlinux/personality.hlinux/msg.hlinux/shm.huapi/linux/shm.hlinux/binfmts.hlinux/parser.hlinux/fs_context.hlinux/fs_parser.hlinux/watch_queue.hlinux/io_uring/cmd.huapi/linux/lsm.hsmack.h
Detected Declarations
struct smack_mnt_optsfunction match_opt_prefixfunction smk_bu_modefunction smk_bu_notefunction smk_bu_currentfunction smk_bu_taskfunction smk_bu_inodefunction smk_bu_filefunction smk_bu_credfilefunction init_inode_smackfunction init_task_smackfunction smk_copy_rulesfunction list_for_each_entry_rcufunction smk_copy_relabelfunction list_for_each_entryfunction smk_ptrace_modefunction smk_ptrace_rule_checkfunction smack_ptrace_access_checkfunction smack_ptrace_tracemefunction smack_syslogfunction smack_sb_alloc_securityfunction smack_free_mnt_optsfunction smack_add_optfunction smack_fs_context_submountfunction smack_fs_context_dupfunction smack_fs_context_parse_paramfunction smack_sb_eat_lsm_optsfunction smack_set_mnt_optsfunction smack_sb_statfsfunction smack_bprm_creds_for_execfunction smack_inode_alloc_securityfunction smk_rule_transmutesfunction xattr_dupvalfunction smack_inode_init_securityfunction smack_inode_permissionfunction smack_inode_linkfunction smack_inode_unlinkfunction smack_inode_rmdirfunction smack_inode_renamefunction smack_inode_permissionfunction smack_inode_setattrfunction smack_inode_getattrfunction smack_inode_xattr_skipcapfunction smack_inode_setxattrfunction strcmpfunction strcmpfunction smack_inode_post_setxattrfunction smack_inode_getxattr
Annotated Snippet
struct smack_mnt_opts {
const char *fsdefault;
const char *fsfloor;
const char *fshat;
const char *fsroot;
const char *fstransmute;
};
static void smack_free_mnt_opts(void *mnt_opts)
{
kfree(mnt_opts);
}
static int smack_add_opt(int token, const char *s, void **mnt_opts)
{
struct smack_mnt_opts *opts = *mnt_opts;
struct smack_known *skp;
if (!opts) {
opts = kzalloc_obj(struct smack_mnt_opts);
if (!opts)
return -ENOMEM;
*mnt_opts = opts;
}
if (!s)
return -ENOMEM;
skp = smk_import_entry(s, 0);
if (IS_ERR(skp))
return PTR_ERR(skp);
switch (token) {
case Opt_fsdefault:
if (opts->fsdefault)
goto out_opt_err;
opts->fsdefault = skp->smk_known;
break;
case Opt_fsfloor:
if (opts->fsfloor)
goto out_opt_err;
opts->fsfloor = skp->smk_known;
break;
case Opt_fshat:
if (opts->fshat)
goto out_opt_err;
opts->fshat = skp->smk_known;
break;
case Opt_fsroot:
if (opts->fsroot)
goto out_opt_err;
opts->fsroot = skp->smk_known;
break;
case Opt_fstransmute:
if (opts->fstransmute)
goto out_opt_err;
opts->fstransmute = skp->smk_known;
break;
}
return 0;
out_opt_err:
pr_warn("Smack: duplicate mount options\n");
return -EINVAL;
}
/**
* smack_fs_context_submount - Initialise security data for a filesystem context
* @fc: The filesystem context.
* @reference: reference superblock
*
* Returns 0 on success or -ENOMEM on error.
*/
static int smack_fs_context_submount(struct fs_context *fc,
struct super_block *reference)
{
struct superblock_smack *sbsp;
struct smack_mnt_opts *ctx;
struct inode_smack *isp;
ctx = kzalloc_obj(*ctx);
if (!ctx)
return -ENOMEM;
fc->security = ctx;
sbsp = smack_superblock(reference);
isp = smack_inode(reference->s_root->d_inode);
if (sbsp->smk_default) {
ctx->fsdefault = kstrdup(sbsp->smk_default->smk_known, GFP_KERNEL);
if (!ctx->fsdefault)
Annotation
- Immediate include surface: `linux/xattr.h`, `linux/pagemap.h`, `linux/mount.h`, `linux/stat.h`, `linux/kd.h`, `asm/ioctls.h`, `linux/ip.h`, `linux/tcp.h`.
- Detected declarations: `struct smack_mnt_opts`, `function match_opt_prefix`, `function smk_bu_mode`, `function smk_bu_note`, `function smk_bu_current`, `function smk_bu_task`, `function smk_bu_inode`, `function smk_bu_file`, `function smk_bu_credfile`, `function init_inode_smack`.
- Atlas domain: Core OS / Security And Isolation.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.