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

TOMOYO Linux Cross Reference
Linux/arch/s390/kernel/compat_linux.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/s390/kernel/compat_linux.c (Architecture mips) and /arch/alpha/kernel/compat_linux.c (Architecture alpha)


  1 // SPDX-License-Identifier: GPL-2.0                 1 
  2 /*                                                
  3  *  S390 version                                  
  4  *    Copyright IBM Corp. 2000                    
  5  *    Author(s): Martin Schwidefsky (schwidefs    
  6  *               Gerhard Tonn (ton@de.ibm.com)    
  7  *               Thomas Spatzier (tspat@de.ibm    
  8  *                                                
  9  *  Conversion between 31bit and 64bit native     
 10  *                                                
 11  * Heavily inspired by the 32-bit Sparc compat    
 12  * Copyright (C) 1997,1998 Jakub Jelinek (jj@s    
 13  * Copyright (C) 1997 David S. Miller (davem@c    
 14  *                                                
 15  */                                               
 16                                                   
 17                                                   
 18 #include <linux/kernel.h>                         
 19 #include <linux/sched.h>                          
 20 #include <linux/fs.h>                             
 21 #include <linux/mm.h>                             
 22 #include <linux/file.h>                           
 23 #include <linux/signal.h>                         
 24 #include <linux/resource.h>                       
 25 #include <linux/times.h>                          
 26 #include <linux/smp.h>                            
 27 #include <linux/sem.h>                            
 28 #include <linux/msg.h>                            
 29 #include <linux/shm.h>                            
 30 #include <linux/uio.h>                            
 31 #include <linux/quota.h>                          
 32 #include <linux/poll.h>                           
 33 #include <linux/personality.h>                    
 34 #include <linux/stat.h>                           
 35 #include <linux/filter.h>                         
 36 #include <linux/highmem.h>                        
 37 #include <linux/mman.h>                           
 38 #include <linux/ipv6.h>                           
 39 #include <linux/in.h>                             
 40 #include <linux/icmpv6.h>                         
 41 #include <linux/syscalls.h>                       
 42 #include <linux/sysctl.h>                         
 43 #include <linux/binfmts.h>                        
 44 #include <linux/capability.h>                     
 45 #include <linux/compat.h>                         
 46 #include <linux/vfs.h>                            
 47 #include <linux/ptrace.h>                         
 48 #include <linux/fadvise.h>                        
 49 #include <linux/ipc.h>                            
 50 #include <linux/slab.h>                           
 51                                                   
 52 #include <asm/types.h>                            
 53 #include <linux/uaccess.h>                        
 54                                                   
 55 #include <net/scm.h>                              
 56 #include <net/sock.h>                             
 57                                                   
 58 #include "compat_linux.h"                         
 59                                                   
 60 #ifdef CONFIG_SYSVIPC                             
 61 COMPAT_SYSCALL_DEFINE5(s390_ipc, uint, call, i    
 62                 compat_ulong_t, third, compat_    
 63 {                                                 
 64         if (call >> 16)         /* hack for ba    
 65                 return -EINVAL;                   
 66         return compat_ksys_ipc(call, first, se    
 67 }                                                 
 68 #endif                                            
 69                                                   
 70 COMPAT_SYSCALL_DEFINE3(s390_truncate64, const     
 71 {                                                 
 72         return ksys_truncate(path, (unsigned l    
 73 }                                                 
 74                                                   
 75 COMPAT_SYSCALL_DEFINE3(s390_ftruncate64, unsig    
 76 {                                                 
 77         return ksys_ftruncate(fd, (unsigned lo    
 78 }                                                 
 79                                                   
 80 COMPAT_SYSCALL_DEFINE5(s390_pread64, unsigned     
 81                        compat_size_t, count, u    
 82 {                                                 
 83         if ((compat_ssize_t) count < 0)           
 84                 return -EINVAL;                   
 85         return ksys_pread64(fd, ubuf, count, (    
 86 }                                                 
 87                                                   
 88 COMPAT_SYSCALL_DEFINE5(s390_pwrite64, unsigned    
 89                        compat_size_t, count, u    
 90 {                                                 
 91         if ((compat_ssize_t) count < 0)           
 92                 return -EINVAL;                   
 93         return ksys_pwrite64(fd, ubuf, count,     
 94 }                                                 
 95                                                   
 96 COMPAT_SYSCALL_DEFINE4(s390_readahead, int, fd    
 97 {                                                 
 98         return ksys_readahead(fd, (unsigned lo    
 99 }                                                 
100                                                   
101 struct stat64_emu31 {                             
102         unsigned long long  st_dev;               
103         unsigned int    __pad1;                   
104 #define STAT64_HAS_BROKEN_ST_INO        1         
105         u32             __st_ino;                 
106         unsigned int    st_mode;                  
107         unsigned int    st_nlink;                 
108         u32             st_uid;                   
109         u32             st_gid;                   
110         unsigned long long  st_rdev;              
111         unsigned int    __pad3;                   
112         long            st_size;                  
113         u32             st_blksize;               
114         unsigned char   __pad4[4];                
115         u32             __pad5;     /* future     
116         u32             st_blocks;  /* Number     
117         u32             st_atime;                 
118         u32             __pad6;                   
119         u32             st_mtime;                 
120         u32             __pad7;                   
121         u32             st_ctime;                 
122         u32             __pad8;     /* will be    
123         unsigned long   st_ino;                   
124 };                                                
125                                                   
126 static int cp_stat64(struct stat64_emu31 __use    
127 {                                                 
128         struct stat64_emu31 tmp;                  
129                                                   
130         memset(&tmp, 0, sizeof(tmp));             
131                                                   
132         tmp.st_dev = huge_encode_dev(stat->dev    
133         tmp.st_ino = stat->ino;                   
134         tmp.__st_ino = (u32)stat->ino;            
135         tmp.st_mode = stat->mode;                 
136         tmp.st_nlink = (unsigned int)stat->nli    
137         tmp.st_uid = from_kuid_munged(current_    
138         tmp.st_gid = from_kgid_munged(current_    
139         tmp.st_rdev = huge_encode_dev(stat->rd    
140         tmp.st_size = stat->size;                 
141         tmp.st_blksize = (u32)stat->blksize;      
142         tmp.st_blocks = (u32)stat->blocks;        
143         tmp.st_atime = (u32)stat->atime.tv_sec    
144         tmp.st_mtime = (u32)stat->mtime.tv_sec    
145         tmp.st_ctime = (u32)stat->ctime.tv_sec    
146                                                   
147         return copy_to_user(ubuf,&tmp,sizeof(t    
148 }                                                 
149                                                   
150 COMPAT_SYSCALL_DEFINE2(s390_stat64, const char    
151 {                                                 
152         struct kstat stat;                        
153         int ret = vfs_stat(filename, &stat);      
154         if (!ret)                                 
155                 ret = cp_stat64(statbuf, &stat    
156         return ret;                               
157 }                                                 
158                                                   
159 COMPAT_SYSCALL_DEFINE2(s390_lstat64, const cha    
160 {                                                 
161         struct kstat stat;                        
162         int ret = vfs_lstat(filename, &stat);     
163         if (!ret)                                 
164                 ret = cp_stat64(statbuf, &stat    
165         return ret;                               
166 }                                                 
167                                                   
168 COMPAT_SYSCALL_DEFINE2(s390_fstat64, unsigned     
169 {                                                 
170         struct kstat stat;                        
171         int ret = vfs_fstat(fd, &stat);           
172         if (!ret)                                 
173                 ret = cp_stat64(statbuf, &stat    
174         return ret;                               
175 }                                                 
176                                                   
177 COMPAT_SYSCALL_DEFINE4(s390_fstatat64, unsigne    
178                        struct stat64_emu31 __u    
179 {                                                 
180         struct kstat stat;                        
181         int error;                                
182                                                   
183         error = vfs_fstatat(dfd, filename, &st    
184         if (error)                                
185                 return error;                     
186         return cp_stat64(statbuf, &stat);         
187 }                                                 
188                                                   
189 /*                                                
190  * Linux/i386 didn't use to be able to handle     
191  * 4 system call parameters, so these system c    
192  * block for parameter passing..                  
193  */                                               
194                                                   
195 struct mmap_arg_struct_emu31 {                    
196         compat_ulong_t addr;                      
197         compat_ulong_t len;                       
198         compat_ulong_t prot;                      
199         compat_ulong_t flags;                     
200         compat_ulong_t fd;                        
201         compat_ulong_t offset;                    
202 };                                                
203                                                   
204 COMPAT_SYSCALL_DEFINE1(s390_old_mmap, struct m    
205 {                                                 
206         struct mmap_arg_struct_emu31 a;           
207                                                   
208         if (copy_from_user(&a, arg, sizeof(a))    
209                 return -EFAULT;                   
210         if (a.offset & ~PAGE_MASK)                
211                 return -EINVAL;                   
212         return ksys_mmap_pgoff(a.addr, a.len,     
213                                a.offset >> PAG    
214 }                                                 
215                                                   
216 COMPAT_SYSCALL_DEFINE1(s390_mmap2, struct mmap    
217 {                                                 
218         struct mmap_arg_struct_emu31 a;           
219                                                   
220         if (copy_from_user(&a, arg, sizeof(a))    
221                 return -EFAULT;                   
222         return ksys_mmap_pgoff(a.addr, a.len,     
223 }                                                 
224                                                   
225 COMPAT_SYSCALL_DEFINE3(s390_read, unsigned int    
226 {                                                 
227         if ((compat_ssize_t) count < 0)           
228                 return -EINVAL;                   
229                                                   
230         return ksys_read(fd, buf, count);         
231 }                                                 
232                                                   
233 COMPAT_SYSCALL_DEFINE3(s390_write, unsigned in    
234 {                                                 
235         if ((compat_ssize_t) count < 0)           
236                 return -EINVAL;                   
237                                                   
238         return ksys_write(fd, buf, count);        
239 }                                                 
240                                                   
241 /*                                                
242  * 31 bit emulation wrapper functions for sys_    
243  * These need to rewrite the advise values for    
244  * because the 31 bit values differ from the 6    
245  */                                               
246                                                   
247 COMPAT_SYSCALL_DEFINE5(s390_fadvise64, int, fd    
248 {                                                 
249         if (advise == 4)                          
250                 advise = POSIX_FADV_DONTNEED;     
251         else if (advise == 5)                     
252                 advise = POSIX_FADV_NOREUSE;      
253         return ksys_fadvise64_64(fd, (unsigned    
254                                  advise);         
255 }                                                 
256                                                   
257 struct fadvise64_64_args {                        
258         int fd;                                   
259         long long offset;                         
260         long long len;                            
261         int advice;                               
262 };                                                
263                                                   
264 COMPAT_SYSCALL_DEFINE1(s390_fadvise64_64, stru    
265 {                                                 
266         struct fadvise64_64_args a;               
267                                                   
268         if ( copy_from_user(&a, args, sizeof(a    
269                 return -EFAULT;                   
270         if (a.advice == 4)                        
271                 a.advice = POSIX_FADV_DONTNEED    
272         else if (a.advice == 5)                   
273                 a.advice = POSIX_FADV_NOREUSE;    
274         return ksys_fadvise64_64(a.fd, a.offse    
275 }                                                 
276                                                   
277 COMPAT_SYSCALL_DEFINE6(s390_sync_file_range, i    
278                        u32, nhigh, u32, nlow,     
279 {                                                 
280         return ksys_sync_file_range(fd, ((loff    
281                                    ((u64)nhigh    
282 }                                                 
283                                                   
284 COMPAT_SYSCALL_DEFINE6(s390_fallocate, int, fd    
285                        u32, lenhigh, u32, lenl    
286 {                                                 
287         return ksys_fallocate(fd, mode, ((loff    
288                               ((u64)lenhigh <<    
289 }                                                 
290                                                   

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