cgit v1.2.2'/>
aboutsummaryrefslogblamecommitdiffstats
path: root/security/commoncap.c
blob: e4c4b3fc0c04e49e553610a8bd4d433e55e9212a (plain) (tree)
1
2
3
4
5
6
7
8
9
                                                              







                                                                            
                             








                           




                          
                        
                        

                             
 





                                                          
                                                  
 
                                                      





                                





                                                                      














                                                         
                                                                       

                                                                














                                                                        





                                                                    


                                               


                 













                                                                     


                                                                 
           
                                                        

 

                                                              



                                                                        



                                                


                                                  


                                                                          







                                                                    

                              





                                                                 























                                                                           

                                                             
                                                 




























                                                                        

                                                                         

                        
                           
                
 
                                     

                               
                                                 

                                                      









                                            


                               






                                                  

























                                                                        

         





                                                                          






                                                   
                                  











                                                           

                                                                   







                                                  
                                             
                          
                                                                            
                                                     


























                                                          

                                                     
                
 
                                  
 








                                                                           
                                                            





                                                                           
                 
         

                   



                                                                 
                                                                         

                                                        
                                                         
                                           





                                                           
                                                         


                                                                              









                                                                     
                                       
                                                                       
                                        
                                                                               

                                                          



                                                                   
                                                                



                                                   


                                        
                                                                


                                 



                                                

                                                                 
 




                                                        





                                                           
                                                                  
 




                                                        








































                                                                              
                                          



































                                                                                   


                                                                            

                                                                            



                                                                            










                                 













                                                                      
                                   



















                                                             






                                                            
                                             







                                          
 













                                                             

      






















































































                                                                               

                                                      


                                           
                                           









                                                                 
                                                          




                                                     
                                                            

 
/* Common capabilities, needed by capability.o and root_plug.o
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation; either version 2 of the License, or
 *	(at your option) any later version.
 *
 */

#include <linux/capability.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/security.h>
#include <linux/file.h>
#include <linux/mm.h>
#include <linux/mman.h>
#include <linux/pagemap.h>
#include <linux/swap.h>
#include <linux/skbuff.h>
#include <linux/netlink.h>
#include <linux/ptrace.h>
#include <linux/xattr.h>
#include <linux/hugetlb.h>
#include <linux/mount.h>
#include <linux/sched.h>
#include <linux/prctl.h>
#include <linux/securebits.h>

int cap_netlink_send(struct sock *sk, struct sk_buff *skb)
{
	NETLINK_CB(skb).eff_cap = current->cap_effective;
	return 0;
}

int cap_netlink_recv(struct sk_buff *skb, int cap)
{
	if (!cap_raised(NETLINK_CB(skb).eff_cap, cap))
		return -EPERM;
	return 0;
}

EXPORT_SYMBOL(cap_netlink_recv);

/*
 * NOTE WELL: cap_capable() cannot be used like the kernel's capable()
 * function.  That is, it has the reverse semantics: cap_capable()
 * returns 0 when a task has a capability, but the kernel's capable()
 * returns 1 for this case.
 */
int cap_capable (struct task_struct *tsk, int cap)
{