smack_lsm.c (2612e3bbc0386368a850140a6c9b990cd496a5ec) | smack_lsm.c (d80a8f1b58c2bc8d7c6bfb65401ea4f7ec8cddc2) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Simplified MAC Kernel (smack) security module 4 * 5 * This file contains the smack hook function implementations. 6 * 7 * Authors: 8 * Casey Schaufler <casey@schaufler-ca.com> --- 601 unchanged lines hidden (view full) --- 610 return 0; 611 612out_opt_err: 613 pr_warn("Smack: duplicate mount options\n"); 614 return -EINVAL; 615} 616 617/** | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Simplified MAC Kernel (smack) security module 4 * 5 * This file contains the smack hook function implementations. 6 * 7 * Authors: 8 * Casey Schaufler <casey@schaufler-ca.com> --- 601 unchanged lines hidden (view full) --- 610 return 0; 611 612out_opt_err: 613 pr_warn("Smack: duplicate mount options\n"); 614 return -EINVAL; 615} 616 617/** |
618 * smack_fs_context_submount - Initialise security data for a filesystem context 619 * @fc: The filesystem context. 620 * @reference: reference superblock 621 * 622 * Returns 0 on success or -ENOMEM on error. 623 */ 624static int smack_fs_context_submount(struct fs_context *fc, 625 struct super_block *reference) 626{ 627 struct superblock_smack *sbsp; 628 struct smack_mnt_opts *ctx; 629 struct inode_smack *isp; 630 631 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 632 if (!ctx) 633 return -ENOMEM; 634 fc->security = ctx; 635 636 sbsp = smack_superblock(reference); 637 isp = smack_inode(reference->s_root->d_inode); 638 639 if (sbsp->smk_default) { 640 ctx->fsdefault = kstrdup(sbsp->smk_default->smk_known, GFP_KERNEL); 641 if (!ctx->fsdefault) 642 return -ENOMEM; 643 } 644 645 if (sbsp->smk_floor) { 646 ctx->fsfloor = kstrdup(sbsp->smk_floor->smk_known, GFP_KERNEL); 647 if (!ctx->fsfloor) 648 return -ENOMEM; 649 } 650 651 if (sbsp->smk_hat) { 652 ctx->fshat = kstrdup(sbsp->smk_hat->smk_known, GFP_KERNEL); 653 if (!ctx->fshat) 654 return -ENOMEM; 655 } 656 657 if (isp->smk_flags & SMK_INODE_TRANSMUTE) { 658 if (sbsp->smk_root) { 659 ctx->fstransmute = kstrdup(sbsp->smk_root->smk_known, GFP_KERNEL); 660 if (!ctx->fstransmute) 661 return -ENOMEM; 662 } 663 } 664 return 0; 665} 666 667/** |
|
618 * smack_fs_context_dup - Duplicate the security data on fs_context duplication 619 * @fc: The new filesystem context. 620 * @src_fc: The source filesystem context being duplicated. 621 * 622 * Returns 0 on success or -ENOMEM on error. 623 */ 624static int smack_fs_context_dup(struct fs_context *fc, 625 struct fs_context *src_fc) --- 4245 unchanged lines hidden (view full) --- 4871 .lbs_superblock = sizeof(struct superblock_smack), 4872}; 4873 4874static struct security_hook_list smack_hooks[] __ro_after_init = { 4875 LSM_HOOK_INIT(ptrace_access_check, smack_ptrace_access_check), 4876 LSM_HOOK_INIT(ptrace_traceme, smack_ptrace_traceme), 4877 LSM_HOOK_INIT(syslog, smack_syslog), 4878 | 668 * smack_fs_context_dup - Duplicate the security data on fs_context duplication 669 * @fc: The new filesystem context. 670 * @src_fc: The source filesystem context being duplicated. 671 * 672 * Returns 0 on success or -ENOMEM on error. 673 */ 674static int smack_fs_context_dup(struct fs_context *fc, 675 struct fs_context *src_fc) --- 4245 unchanged lines hidden (view full) --- 4921 .lbs_superblock = sizeof(struct superblock_smack), 4922}; 4923 4924static struct security_hook_list smack_hooks[] __ro_after_init = { 4925 LSM_HOOK_INIT(ptrace_access_check, smack_ptrace_access_check), 4926 LSM_HOOK_INIT(ptrace_traceme, smack_ptrace_traceme), 4927 LSM_HOOK_INIT(syslog, smack_syslog), 4928 |
4929 LSM_HOOK_INIT(fs_context_submount, smack_fs_context_submount), |
|
4879 LSM_HOOK_INIT(fs_context_dup, smack_fs_context_dup), 4880 LSM_HOOK_INIT(fs_context_parse_param, smack_fs_context_parse_param), 4881 4882 LSM_HOOK_INIT(sb_alloc_security, smack_sb_alloc_security), 4883 LSM_HOOK_INIT(sb_free_mnt_opts, smack_free_mnt_opts), 4884 LSM_HOOK_INIT(sb_eat_lsm_opts, smack_sb_eat_lsm_opts), 4885 LSM_HOOK_INIT(sb_statfs, smack_sb_statfs), 4886 LSM_HOOK_INIT(sb_set_mnt_opts, smack_set_mnt_opts), --- 223 unchanged lines hidden --- | 4930 LSM_HOOK_INIT(fs_context_dup, smack_fs_context_dup), 4931 LSM_HOOK_INIT(fs_context_parse_param, smack_fs_context_parse_param), 4932 4933 LSM_HOOK_INIT(sb_alloc_security, smack_sb_alloc_security), 4934 LSM_HOOK_INIT(sb_free_mnt_opts, smack_free_mnt_opts), 4935 LSM_HOOK_INIT(sb_eat_lsm_opts, smack_sb_eat_lsm_opts), 4936 LSM_HOOK_INIT(sb_statfs, smack_sb_statfs), 4937 LSM_HOOK_INIT(sb_set_mnt_opts, smack_set_mnt_opts), --- 223 unchanged lines hidden --- |