~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/security/lsm_syscalls.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /security/lsm_syscalls.c (Version linux-6.12-rc7) and /security/lsm_syscalls.c (Version linux-5.10.228)


** Warning: Cannot open xref database.

  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 /*                                                
  3  * System calls implementing the Linux Securit    
  4  *                                                
  5  *  Copyright (C) 2022 Casey Schaufler <casey@    
  6  *  Copyright (C) 2022 Intel Corporation          
  7  */                                               
  8                                                   
  9 #include <asm/current.h>                          
 10 #include <linux/compiler_types.h>                 
 11 #include <linux/err.h>                            
 12 #include <linux/errno.h>                          
 13 #include <linux/security.h>                       
 14 #include <linux/stddef.h>                         
 15 #include <linux/syscalls.h>                       
 16 #include <linux/types.h>                          
 17 #include <linux/lsm_hooks.h>                      
 18 #include <uapi/linux/lsm.h>                       
 19                                                   
 20 /**                                               
 21  * lsm_name_to_attr - map an LSM attribute nam    
 22  * @name: name of the attribute                   
 23  *                                                
 24  * Returns the LSM attribute value associated     
 25  * there is no mapping.                           
 26  */                                               
 27 u64 lsm_name_to_attr(const char *name)            
 28 {                                                 
 29         if (!strcmp(name, "current"))             
 30                 return LSM_ATTR_CURRENT;          
 31         if (!strcmp(name, "exec"))                
 32                 return LSM_ATTR_EXEC;             
 33         if (!strcmp(name, "fscreate"))            
 34                 return LSM_ATTR_FSCREATE;         
 35         if (!strcmp(name, "keycreate"))           
 36                 return LSM_ATTR_KEYCREATE;        
 37         if (!strcmp(name, "prev"))                
 38                 return LSM_ATTR_PREV;             
 39         if (!strcmp(name, "sockcreate"))          
 40                 return LSM_ATTR_SOCKCREATE;       
 41         return LSM_ATTR_UNDEF;                    
 42 }                                                 
 43                                                   
 44 /**                                               
 45  * sys_lsm_set_self_attr - Set current task's     
 46  * @attr: which attribute to set                  
 47  * @ctx: the LSM contexts                         
 48  * @size: size of @ctx                            
 49  * @flags: reserved for future use                
 50  *                                                
 51  * Sets the calling task's LSM context. On suc    
 52  * returns 0. If the attribute specified canno    
 53  * value indicating the reason for the error i    
 54  */                                               
 55 SYSCALL_DEFINE4(lsm_set_self_attr, unsigned in    
 56                 ctx, u32, size, u32, flags)       
 57 {                                                 
 58         return security_setselfattr(attr, ctx,    
 59 }                                                 
 60                                                   
 61 /**                                               
 62  * sys_lsm_get_self_attr - Return current task    
 63  * @attr: which attribute to return               
 64  * @ctx: the user-space destination for the in    
 65  * @size: pointer to the size of space availab    
 66  * @flags: special handling options. LSM_FLAG_    
 67  * attributes associated with the LSM identifi    
 68  * reported.                                      
 69  *                                                
 70  * Returns the calling task's LSM contexts. On    
 71  * function returns the number of @ctx array e    
 72  * may be zero if there are no LSM contexts as    
 73  * insufficient to contain the return data -E2    
 74  * @size is set to the minimum required size.     
 75  * a negative value indicating the error is re    
 76  */                                               
 77 SYSCALL_DEFINE4(lsm_get_self_attr, unsigned in    
 78                 ctx, u32 __user *, size, u32,     
 79 {                                                 
 80         return security_getselfattr(attr, ctx,    
 81 }                                                 
 82                                                   
 83 /**                                               
 84  * sys_lsm_list_modules - Return a list of the    
 85  * @ids: the LSM module ids                       
 86  * @size: pointer to size of @ids, updated on     
 87  * @flags: reserved for future use, must be ze    
 88  *                                                
 89  * Returns a list of the active LSM ids. On su    
 90  * returns the number of @ids array elements.     
 91  * if there are no LSMs active. If @size is in    
 92  * the return data -E2BIG is returned and @siz    
 93  * required size. In all other cases a negativ    
 94  * error is returned.                             
 95  */                                               
 96 SYSCALL_DEFINE3(lsm_list_modules, u64 __user *    
 97                 u32, flags)                       
 98 {                                                 
 99         u32 total_size = lsm_active_cnt * size    
100         u32 usize;                                
101         int i;                                    
102                                                   
103         if (flags)                                
104                 return -EINVAL;                   
105                                                   
106         if (get_user(usize, size))                
107                 return -EFAULT;                   
108                                                   
109         if (put_user(total_size, size) != 0)      
110                 return -EFAULT;                   
111                                                   
112         if (usize < total_size)                   
113                 return -E2BIG;                    
114                                                   
115         for (i = 0; i < lsm_active_cnt; i++)      
116                 if (put_user(lsm_idlist[i]->id    
117                         return -EFAULT;           
118                                                   
119         return lsm_active_cnt;                    
120 }                                                 
121                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php