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

TOMOYO Linux Cross Reference
Linux/arch/arm64/kernel/pointer_auth.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 /arch/arm64/kernel/pointer_auth.c (Version linux-6.12-rc7) and /arch/i386/kernel/pointer_auth.c (Version linux-5.15.171)


  1 // SPDX-License-Identifier: GPL-2.0                 1 
  2                                                   
  3 #include <linux/compat.h>                         
  4 #include <linux/errno.h>                          
  5 #include <linux/prctl.h>                          
  6 #include <linux/random.h>                         
  7 #include <linux/sched.h>                          
  8 #include <asm/cpufeature.h>                       
  9 #include <asm/pointer_auth.h>                     
 10                                                   
 11 int ptrauth_prctl_reset_keys(struct task_struc    
 12 {                                                 
 13         struct ptrauth_keys_user *keys = &tsk-    
 14         unsigned long addr_key_mask = PR_PAC_A    
 15                                       PR_PAC_A    
 16         unsigned long key_mask = addr_key_mask    
 17                                                   
 18         if (!system_supports_address_auth() &&    
 19                 return -EINVAL;                   
 20                                                   
 21         if (is_compat_thread(task_thread_info(    
 22                 return -EINVAL;                   
 23                                                   
 24         if (!arg) {                               
 25                 ptrauth_keys_init_user(keys);     
 26                 return 0;                         
 27         }                                         
 28                                                   
 29         if (arg & ~key_mask)                      
 30                 return -EINVAL;                   
 31                                                   
 32         if (((arg & addr_key_mask) && !system_    
 33             ((arg & PR_PAC_APGAKEY) && !system    
 34                 return -EINVAL;                   
 35                                                   
 36         if (arg & PR_PAC_APIAKEY)                 
 37                 get_random_bytes(&keys->apia,     
 38         if (arg & PR_PAC_APIBKEY)                 
 39                 get_random_bytes(&keys->apib,     
 40         if (arg & PR_PAC_APDAKEY)                 
 41                 get_random_bytes(&keys->apda,     
 42         if (arg & PR_PAC_APDBKEY)                 
 43                 get_random_bytes(&keys->apdb,     
 44         if (arg & PR_PAC_APGAKEY)                 
 45                 get_random_bytes(&keys->apga,     
 46         ptrauth_keys_install_user(keys);          
 47                                                   
 48         return 0;                                 
 49 }                                                 
 50                                                   
 51 static u64 arg_to_enxx_mask(unsigned long arg)    
 52 {                                                 
 53         u64 sctlr_enxx_mask = 0;                  
 54                                                   
 55         WARN_ON(arg & ~PR_PAC_ENABLED_KEYS_MAS    
 56         if (arg & PR_PAC_APIAKEY)                 
 57                 sctlr_enxx_mask |= SCTLR_ELx_E    
 58         if (arg & PR_PAC_APIBKEY)                 
 59                 sctlr_enxx_mask |= SCTLR_ELx_E    
 60         if (arg & PR_PAC_APDAKEY)                 
 61                 sctlr_enxx_mask |= SCTLR_ELx_E    
 62         if (arg & PR_PAC_APDBKEY)                 
 63                 sctlr_enxx_mask |= SCTLR_ELx_E    
 64         return sctlr_enxx_mask;                   
 65 }                                                 
 66                                                   
 67 int ptrauth_set_enabled_keys(struct task_struc    
 68                              unsigned long ena    
 69 {                                                 
 70         u64 sctlr;                                
 71                                                   
 72         if (!system_supports_address_auth())      
 73                 return -EINVAL;                   
 74                                                   
 75         if (is_compat_thread(task_thread_info(    
 76                 return -EINVAL;                   
 77                                                   
 78         if ((keys & ~PR_PAC_ENABLED_KEYS_MASK)    
 79                 return -EINVAL;                   
 80                                                   
 81         preempt_disable();                        
 82         sctlr = tsk->thread.sctlr_user;           
 83         sctlr &= ~arg_to_enxx_mask(keys);         
 84         sctlr |= arg_to_enxx_mask(enabled);       
 85         tsk->thread.sctlr_user = sctlr;           
 86         if (tsk == current)                       
 87                 update_sctlr_el1(sctlr);          
 88         preempt_enable();                         
 89                                                   
 90         return 0;                                 
 91 }                                                 
 92                                                   
 93 int ptrauth_get_enabled_keys(struct task_struc    
 94 {                                                 
 95         int retval = 0;                           
 96                                                   
 97         if (!system_supports_address_auth())      
 98                 return -EINVAL;                   
 99                                                   
100         if (is_compat_thread(task_thread_info(    
101                 return -EINVAL;                   
102                                                   
103         if (tsk->thread.sctlr_user & SCTLR_ELx    
104                 retval |= PR_PAC_APIAKEY;         
105         if (tsk->thread.sctlr_user & SCTLR_ELx    
106                 retval |= PR_PAC_APIBKEY;         
107         if (tsk->thread.sctlr_user & SCTLR_ELx    
108                 retval |= PR_PAC_APDAKEY;         
109         if (tsk->thread.sctlr_user & SCTLR_ELx    
110                 retval |= PR_PAC_APDBKEY;         
111                                                   
112         return retval;                            
113 }                                                 
114                                                   

~ [ 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