scalar.c revision b81078b6eb55919b12d2279da9485c1a4f5b58a8
1#include "../../memcheck.h"
2#include "scalar.h"
3#include <unistd.h>
4#include <sched.h>
5#include <signal.h>
6#include <sys/shm.h>
7
8// See memcheck/tests/x86-linux/scalar.c for an explanation of what this test
9// is doing.
10
11int main(void)
12{
13   // uninitialised, but we know px[0] is 0x0
14   long* px  = malloc(sizeof(long));
15   long  x0  = px[0];
16   long  res;
17
18   VALGRIND_MAKE_MEM_NOACCESS(0, 0x1000);
19
20   // __NR_syscall 0
21   // XXX
22
23   GO(__NR_exit, 1, "below");
24   // (see below)
25
26   GO(__NR_fork, 2, "other");
27   // (sse scalar_fork.c)
28
29   // Nb: here we are also getting an error from the syscall arg itself.
30   GO(__NR_read, 3, "1+3s 1m");
31   SY(__NR_read+(int)x0, x0, x0, x0+1); FAILx(EFAULT);
32
33   GO(__NR_write, 4, "3s 1m");
34   SY(__NR_write, x0, x0, x0+1); FAIL;
35   //res = write(x0, x0, x0+1); FAIL;
36
37   GO(__NR_open, 5, "(2-args) 2s 1m");
38   SY(__NR_open, x0, x0); FAIL;
39   // Only 1s 0m errors -- the other 2s 1m have been checked in the previous
40   // open test, and if we test them they may be commoned up but they also
41   // may not.
42   GO(__NR_open, 5, "(3-args) 1s 0m");
43   SY(__NR_open, "scalar.c", O_CREAT|O_EXCL, x0); FAIL;
44
45   GO(__NR_close, 6, "1s 0m");
46   SY(__NR_close, x0-1); FAIL;
47
48   GO(__NR_wait4, 7, "4s 2m");
49   SY(__NR_wait4, x0, x0+1, x0, x0+1); FAIL;
50
51   GO_UNIMP(8, "old creat");
52
53   GO(__NR_link, 9, "2s 2m");
54   SY(__NR_link, x0, x0); FAIL;
55
56   GO(__NR_unlink, 10, "1s 1m");
57   SY(__NR_unlink, x0); FAIL;
58
59   GO_UNIMP(11, "old execv");
60
61   GO(__NR_chdir, 12, "1s 1m");
62   SY(__NR_chdir, x0); FAIL;
63
64   GO(__NR_fchdir, 13, "1s 0m");
65   SY(__NR_fchdir, x0-1); FAIL;
66
67   GO(__NR_mknod, 14, "3s 1m");
68   SY(__NR_mknod, x0, x0, x0); FAIL;
69
70   GO(__NR_chmod, 15, "2s 1m");
71   SY(__NR_chmod, x0, x0); FAIL;
72
73   GO(__NR_chown, 16, "3s 1m");
74   SY(__NR_chown, x0, x0, x0); FAIL;
75
76   GO_UNIMP(17, "old break");
77
78   GO(__NR_getfsstat, 18, "3s 1m");
79   SY(__NR_getfsstat, x0+1, x0+1, x0); SUCC; // This should fail...
80
81   GO_UNIMP(19, "old lseek");
82
83   // __NR_getpid 20
84
85   GO_UNIMP(21, "old mount");
86
87   GO_UNIMP(22, "old umount");
88
89   // __NR_setuid 23
90   // __NR_getuid 24
91   // __NR_geteuid 25
92   // __NR_ptrace 26
93   // __NR_recvmsg 27
94   // __NR_sendmsg 28
95   // __NR_recvfrom 29
96   // __NR_accept 30
97   // __NR_getpeername 31
98   // __NR_getsockname 32
99   // __NR_access 33
100   // __NR_chflags 34
101   // __NR_fchflags 35
102   // __NR_sync 36
103   // __NR_kill 37
104
105   GO_UNIMP(38, "old stat");
106
107   // __NR_getppid 39
108
109   GO_UNIMP(40, "old lstat");
110
111   // __NR_dup 41
112   // __NR_pipe           VG_DARWIN_SYSCALL_CONSTRUCT_UX64(42
113   // __NR_getegid 43
114   // __NR_profil 44
115
116   GO_UNIMP(45, "old ktrace");
117
118   // __NR_sigaction 46
119   // __NR_getgid 47
120   // __NR_sigprocmask 48
121   // __NR_getlogin 49
122   // __NR_setlogin 50
123   // __NR_acct 51
124   // __NR_sigpending 52
125   // __NR_sigaltstack 53
126   // __NR_ioctl 54
127   // __NR_reboot 55
128   // __NR_revoke 56
129   // __NR_symlink 57
130   // __NR_readlink 58
131   // __NR_execve 59
132   // __NR_umask 60
133   // __NR_chroot 61
134
135   GO_UNIMP(62, "old fstat");
136
137   GO_UNIMP(63, "used internally, reserved");
138
139   GO_UNIMP(64, "old getpagesize");
140
141   // __NR_msync 65
142   // __NR_vfork 66
143
144   GO_UNIMP(67, "old vread");
145
146   GO_UNIMP(68, "old vwrite");
147
148   GO_UNIMP(69, "old sbrk");
149
150   GO_UNIMP(70, "old sstk");
151
152   GO_UNIMP(71, "old mmap");
153
154   GO_UNIMP(72, "old vadvise");
155
156   // __NR_munmap 73
157   // __NR_mprotect 74
158   // __NR_madvise 75
159
160   GO_UNIMP(76, "old vhangup");
161
162   GO_UNIMP(77, "old vlimit");
163
164   GO(__NR_mincore, 78, "3s 1m");
165   SY(__NR_mincore, x0, x0+40960, x0); FAIL;
166
167   // __NR_getgroups 79
168   // __NR_setgroups 80
169   // __NR_getpgrp 81
170
171   GO(__NR_setpgid, 82, "2s 0m");
172   SY(__NR_setpgid, x0-1, x0-1); FAIL;
173
174   // __NR_setitimer 83
175
176   GO_UNIMP(78, "old wait");
177
178   // __NR_swapon 85
179   // __NR_getitimer 86
180
181   GO_UNIMP(87, "old gethostname");
182
183   GO_UNIMP(88, "old sethostname");
184
185   // __NR_getdtablesize 89
186   // __NR_dup2 90
187
188   GO_UNIMP(91, "old getdopt");
189
190   // __NR_fcntl 92
191   // __NR_select 93
192
193   GO_UNIMP(94, "old setdopt");
194
195   // __NR_fsync 95
196   // __NR_setpriority 96
197   // __NR_socket 97
198   // __NR_connect 98
199
200   GO_UNIMP(99, "old accept");
201
202   // __NR_getpriority 100
203
204   GO_UNIMP(101, "old send");
205
206   GO_UNIMP(102, "old recv");
207
208   GO_UNIMP(103, "old sigreturn");
209
210   // __NR_bind 104
211
212   GO(__NR_setsockopt, 105, "5s 1m");
213   SY(__NR_setsockopt, x0, x0, x0, x0+1, x0+1); FAIL;
214
215   // __NR_listen 106
216
217   GO_UNIMP(107, "old vtimes");
218
219   GO_UNIMP(108, "old sigvec");
220
221   GO_UNIMP(109, "old sigblock");
222
223   GO_UNIMP(110, "old sigsetmask");
224
225   // __NR_sigsuspend 111
226
227   GO_UNIMP(112, "old sigstack");
228
229   GO_UNIMP(113, "old recvmsg");
230
231   GO_UNIMP(114, "old sendmsg");
232
233   GO_UNIMP(115, "old vtrace");
234
235   // __NR_gettimeofday 116
236   // __NR_getrusage 117
237
238   // Nb: there's no "getsockopt(optlen) points to unaddressable byte(s)";
239   // difficult to get with arg4 being checked with buf_and_len_pre_check.
240   GO(__NR_getsockopt, 118, "5s 1m");
241   SY(__NR_getsockopt, x0, x0, x0, x0+1, x0+&px[1]); FAIL;
242
243   GO_UNIMP(119, "old resuba");
244
245   // __NR_readv 120
246   // __NR_writev 121
247   // __NR_settimeofday 122
248   // __NR_fchown 123
249   // __NR_fchmod 124
250
251   GO_UNIMP(125, "old recvfrom");
252
253   // __NR_setreuid 126
254   // __NR_setregid 127
255   // __NR_rename 128
256
257   GO_UNIMP(129, "old truncate");
258
259   GO_UNIMP(130, "old ftruncate");
260
261   // __NR_flock 131
262   // __NR_mkfifo 132
263   // __NR_sendto 133
264   // __NR_shutdown 134
265   // __NR_socketpair 135
266   // __NR_mkdir 136
267   // __NR_rmdir 137
268   // __NR_utimes 138
269   // __NR_futimes 139
270   // __NR_adjtime 140
271
272   GO_UNIMP(141, "old getpeername");
273
274   // __NR_gethostuuid 142
275
276   GO_UNIMP(143, "old sethostid");
277
278   GO_UNIMP(144, "old getrlimit");
279
280   GO_UNIMP(145, "old setrlimit");
281
282   GO_UNIMP(146, "old killpg");
283
284   // __NR_setsid 147
285
286   GO_UNIMP(148, "old setquota");
287
288   GO_UNIMP(149, "old qquota");
289
290   GO_UNIMP(150, "old getsockname");
291
292   // __NR_getpgid 151
293   // __NR_setprivexec 152
294   // __NR_pread 153
295   // __NR_pwrite 154
296   // __NR_nfssvc 155
297
298   GO_UNIMP(156, "old getdirentries");
299
300   // __NR_statfs 157
301   // __NR_fstatfs 158
302   // __NR_unmount 159
303
304   GO_UNIMP(160, "old async_daemon");
305
306   // __NR_getfh 161
307
308   GO_UNIMP(162, "old getdomainname");
309
310   GO_UNIMP(163, "old setdomainname");
311
312   // /* 164 */
313
314   // __NR_quotactl 165
315
316   GO_UNIMP(166, "old exportfs");
317
318   GO(__NR_mount, 167, "4s 2m");
319   SY(__NR_mount, x0, x0, x0, x0); FAIL;
320
321   GO_UNIMP(168, "old ustat");
322
323   GO(__NR_csops, 169, "4s 1m");
324   SY(__NR_csops, x0, x0, x0+1, x0+1); FAILx(EFAULT);
325
326   GO_UNIMP(170, "old table");
327
328   GO_UNIMP(171, "old wait3");
329
330   GO_UNIMP(172, "old rpause");
331
332   // __NR_waitid 173
333
334   GO_UNIMP(174, "old getdents");
335
336   GO_UNIMP(175, "old gc_control");
337
338   // __NR_add_profil 176
339
340   GO_UNIMP(177-179, "unused");
341
342   // __NR_kdebug_trace 180
343   // __NR_setgid 181
344   // __NR_setegid 182
345   // __NR_seteuid 183
346   // __NR_sigreturn 184
347   // __NR_chud 185
348
349   GO_UNIMP(186-187, "unused");
350
351   // __NR_stat 188
352   // __NR_fstat 189
353   // __NR_lstat 190
354   // __NR_pathconf 191
355   // __NR_fpathconf 192
356
357   GO_UNIMP(193, "unused");
358
359   // __NR_getrlimit 194
360   // __NR_setrlimit 195
361   // __NR_getdirentries 196
362   // __NR_mmap 197
363
364   // /* 198  __syscall */
365
366   // __NR_lseek          VG_DARWIN_SYSCALL_CONSTRUCT_UX64(199
367   // __NR_truncate 200
368   // __NR_ftruncate 201
369   // __NR___sysctl 202
370   // __NR_mlock 203
371   // __NR_munlock 204
372   // __NR_undelete 205
373   // __NR_ATsocket 206
374   // __NR_ATgetmsg 207
375   // __NR_ATputmsg 208
376   // __NR_ATPsndreq 209
377   // __NR_ATPsndrsp 210
378   // __NR_ATPgetreq 211
379   // __NR_ATPgetrsp 212
380
381   GO_UNIMP(213, "reserved for AppleTalk");
382
383   // __NR_kqueue_from_portset_np 214
384   // __NR_kqueue_portset_np 215
385   // __NR_mkcomplex 216
386   // __NR_statv 217
387   // __NR_lstatv 218
388   // __NR_fstatv 219
389   // __NR_getattrlist 220
390   // __NR_setattrlist 221
391   // __NR_getdirentriesattr 222
392
393   GO(__NR_exchangedata, 223, "3s 2m");
394   SY(__NR_exchangedata, x0, x0, x0); FAIL;
395
396   // /* 224  checkuseraccess */
397
398   // __NR_searchfs 225
399   // __NR_delete 226
400   // __NR_copyfile 227
401
402   GO_UNIMP(228-229, "unused");
403
404   // __NR_poll 230
405   // __NR_watchevent 231
406   // __NR_waitevent 232
407   // __NR_modwatch 233
408   // __NR_getxattr 234
409   // __NR_fgetxattr 235
410   // __NR_setxattr 236
411   // __NR_fsetxattr 237
412   // __NR_removexattr 238
413   // __NR_fremovexattr 239
414   // __NR_listxattr 240
415   // __NR_flistxattr 241
416   // __NR_fsctl 242
417   // __NR_initgroups 243
418   // __NR_posix_spawn 244
419
420   GO_UNIMP(245-246, "unused");
421
422   // __NR_nfsclnt 247
423   // __NR_fhopen 248
424
425   GO_UNIMP(249, "unused");
426
427   // __NR_minherit 250
428   // __NR_semsys 251
429   // __NR_msgsys 252
430   // __NR_shmsys 253
431   // __NR_semctl 254
432   // __NR_semget 255
433   // __NR_semop 256
434
435   GO_UNIMP(257, "unused");
436
437   // __NR_msgctl 258
438   // __NR_msgget 259
439   // __NR_msgsnd 260
440   // __NR_msgrcv 261
441
442   GO(__NR_shmat, 262, "3s 0m");
443   SY(__NR_shmat, x0, x0, x0); FAIL;
444
445   GO(__NR_shmctl, 263, "3s 1m");
446   SY(__NR_shmctl, x0, x0+IPC_STAT, x0+1); FAIL;
447
448   GO(__NR_shmdt, 264, "1s 0m");
449   SY(__NR_shmdt, x0); FAIL;
450
451   GO(__NR_shmget, 265, "3s 0m");
452   SY(__NR_shmget, x0, x0, x0); FAIL;
453
454   // __NR_shm_open 266
455   // __NR_shm_unlink 267
456
457   GO(__NR_sem_open, 268, "2s 1m");
458   SY(__NR_sem_open, x0, x0); FAIL;
459
460   GO(__NR_sem_open, 268, "(4-args) 2s 0m");
461   SY(__NR_sem_open, "my_sem", O_CREAT|O_EXCL, x0, x0); SUCC_OR_FAIL;
462
463   // Nb: we add 0x12345 to make sure it's not a valid semaphore descriptor.
464   GO(__NR_sem_close, 269, "1s 0m");
465   SY(__NR_sem_close, x0+0x12345); FAIL;
466
467   GO(__NR_sem_unlink, 270, "1s 1m");
468   SY(__NR_sem_unlink, x0); FAIL;
469
470   GO(__NR_sem_wait, 271, "1s 0m");
471   SY(__NR_sem_wait, x0); FAIL;
472
473   GO(__NR_sem_trywait, 272, "1s 0m");
474   SY(__NR_sem_trywait, x0); FAIL;
475
476   GO(__NR_sem_post, 273, "1s 0m");
477   SY(__NR_sem_post, x0); FAIL;
478
479   // __NR_sem_getvalue 274
480
481   GO(__NR_sem_init, 275, "3s 1m");
482   SY(__NR_sem_init, x0+1, x0, x0); FAILx(ENOSYS);
483
484   GO(__NR_sem_destroy, 276, "1s 1m");
485   SY(__NR_sem_destroy, x0+1); FAILx(ENOSYS);
486
487   // __NR_open_extended 277
488   // __NR_umask_extended 278
489
490   {
491      size_t one = 1;
492      GO(__NR_stat_extended, 279, "4s 4m");
493      SY(__NR_stat_extended, x0, x0, x0, x0); FAIL;
494      // Go again to get a complaint about where the 3rd arg points;  it
495      // requires the 4th arg to point to a valid value.
496      SY(__NR_stat_extended, 0, 0, 0, &one); FAIL;
497
498      GO(__NR_lstat_extended, 280, "4s 4m");
499      SY(__NR_lstat_extended, x0, x0, x0, x0); FAIL;
500      // Go again to get a complaint about where the 3rd arg points;  it
501      // requires the 4th arg to point to a valid value.
502      SY(__NR_lstat_extended, 0, 0, 0, &one); FAIL;
503
504      GO(__NR_fstat_extended, 280, "4s 3m");
505      SY(__NR_fstat_extended, x0, x0, x0, x0); FAIL;
506      // Go again to get a complaint about where the 3rd arg points;  it
507      // requires the 4th arg to point to a valid value.
508      SY(__NR_fstat_extended, 0, 0, 0, &one); FAIL;
509   }
510
511   // __NR_chmod_extended 282
512   // __NR_fchmod_extended 283
513   // __NR_access_extended 284
514   // __NR_settid 285
515   // __NR_gettid 286
516   // __NR_setsgroups 287
517   // __NR_getsgroups 288
518   // __NR_setwgroups 289
519   // __NR_getwgroups 290
520   // __NR_mkfifo_extended 291
521   // __NR_mkdir_extended 292
522   // __NR_identitysvc 293
523   // __NR_shared_region_check_np 294
524   // __NR_shared_region_map_np 295
525
526   GO_UNIMP(296, "old load_shared_file");
527
528   GO_UNIMP(297, "old reset_shared_file");
529
530   GO_UNIMP(298, "old new_system_shared_regions");
531
532   GO_UNIMP(299, "old shared_region_map_file_np");
533
534   GO_UNIMP(300, "old shared_region_make_private_np");
535
536   // __NR___pthread_mutex_destroy 301
537   // __NR___pthread_mutex_init 302
538   // __NR___pthread_mutex_lock 303
539   // __NR___pthread_mutex_trylock 304
540   // __NR___pthread_mutex_unlock 305
541   // __NR___pthread_cond_init 306
542   // __NR___pthread_cond_destroy 307
543   // __NR___pthread_cond_broadcast 308
544   // __NR___pthread_cond_signal 309
545   // __NR_getsid 310
546   // __NR_settid_with_pid 311
547   // __NR___pthread_cond_timedwait 312
548   // __NR_aio_fsync 313
549
550   GO(__NR_aio_return, 314, "1s 0m");
551   SY(__NR_aio_return, x0); FAIL;
552
553   GO(__NR_aio_suspend, 315, "1s 0m");
554   SY(__NR_aio_suspend, x0, x0+1, x0); FAIL;
555
556   // __NR_aio_cancel 316
557
558   GO(__NR_aio_error, 317, "1s 0m");
559   SY(__NR_aio_error, x0); FAIL;
560
561   GO(__NR_aio_read, 318, "1s 1m");
562   SY(__NR_aio_read, x0); FAIL;
563
564   GO(__NR_aio_write, 319, "1s 1m");
565   SY(__NR_aio_write, x0); FAIL;
566
567   // __NR_lio_listio 320
568   // __NR___pthread_cond_wait 321
569   // __NR_iopolicysys 322
570
571   GO_UNIMP(323, "unused");
572
573   // __NR_mlockall 324
574   // __NR_munlockall 325
575
576   GO_UNIMP(326, "unused");
577
578   // __NR_issetugid 327
579   // __NR___pthread_kill 328
580   // __NR___pthread_sigmask 329
581   // __NR___sigwait 330
582   // __NR_sigwait 330) // GrP fixme hack
583   // __NR___disable_threadsignal 331
584   // __NR___pthread_markcancel 332
585   // __NR___pthread_canceled 333
586   // __NR___semwait_signal 334
587
588   GO_UNIMP(335, "old utrace");
589
590   // __NR_proc_info 336
591   // __NR_sendfile 337
592   // __NR_stat64 338
593   // __NR_fstat64 339
594   // __NR_lstat64 340
595
596   {
597      size_t one = 1;
598      GO(__NR_stat64_extended, 341, "4s 4m");
599      SY(__NR_stat64_extended, x0, x0, x0, x0); FAIL;
600      // Go again to get a complaint about where the 3rd arg points;  it
601      // requires the 4th arg to point to a valid value.
602      SY(__NR_stat64_extended, 0, 0, 0, &one); FAIL;
603
604      GO(__NR_lstat64_extended, 342, "4s 4m");
605      SY(__NR_lstat64_extended, x0, x0, x0, x0); FAIL;
606      // Go again to get a complaint about where the 3rd arg points;  it
607      // requires the 4th arg to point to a valid value.
608      SY(__NR_lstat64_extended, 0, 0, 0, &one); FAIL;
609
610      GO(__NR_fstat64_extended, 342, "4s 3m");
611      SY(__NR_fstat64_extended, x0, x0, x0, x0); FAIL;
612      // Go again to get a complaint about where the 3rd arg points;  it
613      // requires the 4th arg to point to a valid value.
614      SY(__NR_fstat64_extended, 0, 0, 0, &one); FAIL;
615   }
616
617   // __NR_fstat64_extended 343
618   // __NR_getdirentries64 344
619   // __NR_statfs64 345
620   // __NR_fstatfs64 346
621
622   GO(__NR_getfsstat64, 347, "3s 1m");
623   SY(__NR_getfsstat64, x0+1, x0+1, x0); SUCC; // This should fail...
624
625   // __NR___pthread_chdir 348
626   // __NR___pthread_fchdir 349
627   // __NR_audit 350
628   // __NR_auditon 351
629
630   // /* 352 */
631
632   // __NR_getauid 353
633   // __NR_setauid 354
634   // __NR_getaudit 355
635   // __NR_setaudit 356
636   // __NR_getaudit_addr 357
637   // __NR_setaudit_addr 358
638   // __NR_auditctl 359
639   // __NR_bsdthread_create 360
640   // __NR_bsdthread_terminate 361
641   // __NR_kqueue 362
642   // __NR_kevent 363
643   // __NR_lchown 364
644   // __NR_stack_snapshot 365
645   // __NR_bsdthread_register 366
646   // __NR_workq_open 367
647   // __NR_workq_ops 368
648
649   GO_UNIMP(369-379, "unused");
650
651   // __NR___mac_execve 380
652   // __NR___mac_syscall 381
653   // __NR___mac_get_file 382
654   // __NR___mac_set_file 383
655   // __NR___mac_get_link 384
656   // __NR___mac_set_link 385
657   // __NR___mac_get_proc 386
658   // __NR___mac_set_proc 387
659   // __NR___mac_get_fd 388
660   // __NR___mac_set_fd 389
661   // __NR___mac_get_pid 390
662   // __NR___mac_get_lcid 391
663   // __NR___mac_get_lctx 392
664   // __NR___mac_set_lctx 393
665   // __NR_setlcid 394
666   // __NR_getlcid 395
667
668   // The nocancel syscalls (396--423) are tested in scalar_nocancel.c.
669
670   // __NR___mac_mount 424
671   // __NR___mac_get_mount 425
672   // __NR___mac_getfsstat 426
673   // __NR_MAXSYSCALL 427
674
675#if 0
676   // XXX: all these are copied from x86-linux/scalar.c.
677
678   // __NR_creat 8
679   GO(__NR_creat, "2s 1m");
680   SY(__NR_creat, x0, x0); FAIL;
681
682   // __NR_execve 11
683   // Nb: could have 3 memory errors if we pass x0+1 as the 2nd and 3rd
684   // args, except for bug #93174.
685   GO(__NR_execve, "3s 1m");
686   SY(__NR_execve, x0, x0, x0); FAIL;
687
688   // __NR_time 13
689   GO(__NR_time, "1s 1m");
690   SY(__NR_time, x0+1); FAIL;
691
692   // __NR_lchown 16
693   GO(__NR_lchown, "n/a");
694 //SY(__NR_lchown); // (Not yet handled by Valgrind) FAIL;
695
696   // __NR_break 17
697   GO(__NR_break, "ni");
698   SY(__NR_break); FAIL;
699
700   // __NR_oldstat 18
701   GO(__NR_oldstat, "n/a");
702   // (obsolete, not handled by Valgrind)
703
704   // __NR_lseek 19
705   GO(__NR_lseek, "3s 0m");
706   SY(__NR_lseek, x0-1, x0, x0); FAILx(EBADF);
707
708   // __NR_getpid 20
709   GO(__NR_getpid, "0s 0m");
710   SY(__NR_getpid); SUCC;
711
712   // __NR_mount 21
713   GO(__NR_mount, "5s 3m");
714   SY(__NR_mount, x0, x0, x0, x0, x0); FAIL;
715
716   // __NR_umount 22
717   GO(__NR_umount, "1s 1m");
718   SY(__NR_umount, x0); FAIL;
719
720   // __NR_setuid 23
721   GO(__NR_setuid, "1s 0m");
722   SY(__NR_setuid, x0); FAIL;
723
724   // __NR_getuid 24
725   GO(__NR_getuid, "0s 0m");
726   SY(__NR_getuid); SUCC;
727
728   // __NR_stime 25
729   GO(__NR_stime, "n/a");
730 //SY(__NR_stime); // (Not yet handled by Valgrind) FAIL;
731
732   // __NR_ptrace 26
733   // XXX: memory pointed to be arg3 goes unchecked... otherwise would be 2m
734   GO(__NR_ptrace, "4s 1m");
735   SY(__NR_ptrace, x0+PTRACE_GETREGS, x0, x0, x0); FAIL;
736
737   // __NR_alarm 27
738   GO(__NR_alarm, "1s 0m");
739   SY(__NR_alarm, x0); SUCC;
740
741   // __NR_oldfstat 28
742   GO(__NR_oldfstat, "n/a");
743   // (obsolete, not handled by Valgrind)
744
745   // __NR_pause 29
746   GO(__NR_pause, "ignore");
747   // (hard to test, and no args so not much to be gained -- don't bother)
748
749   // __NR_utime 30
750   GO(__NR_utime, "2s 2m");
751   SY(__NR_utime, x0, x0+1); FAIL;
752
753   // __NR_stty 31
754   GO(__NR_stty, "ni");
755   SY(__NR_stty); FAIL;
756
757   // __NR_gtty 32
758   GO(__NR_gtty, "ni");
759   SY(__NR_gtty); FAIL;
760
761   // __NR_access 33
762   GO(__NR_access, "2s 1m");
763   SY(__NR_access, x0, x0); FAIL;
764
765   // __NR_nice 34
766   GO(__NR_nice, "1s 0m");
767   SY(__NR_nice, x0); SUCC;
768
769   // __NR_ftime 35
770   GO(__NR_ftime, "ni");
771   SY(__NR_ftime); FAIL;
772
773   // __NR_sync 36
774   GO(__NR_sync, "0s 0m");
775   SY(__NR_sync); SUCC;
776
777   // __NR_kill 37
778   GO(__NR_kill, "2s 0m");
779   SY(__NR_kill, x0, x0); SUCC;
780
781   // __NR_rename 38
782   GO(__NR_rename, "2s 2m");
783   SY(__NR_rename, x0, x0); FAIL;
784
785   // __NR_mkdir 39
786   GO(__NR_mkdir, "2s 1m");
787   SY(__NR_mkdir, x0, x0); FAIL;
788
789   // __NR_rmdir 40
790   GO(__NR_rmdir, "1s 1m");
791   SY(__NR_rmdir, x0); FAIL;
792
793   // __NR_dup 41
794   GO(__NR_dup, "1s 0m");
795   SY(__NR_dup, x0-1); FAIL;
796
797   // __NR_pipe 42
798   GO(__NR_pipe, "1s 1m");
799   SY(__NR_pipe, x0); FAIL;
800
801   // __NR_times 43
802   GO(__NR_times, "1s 1m");
803   SY(__NR_times, x0+1); FAIL;
804
805   // __NR_prof 44
806   GO(__NR_prof, "ni");
807   SY(__NR_prof); FAIL;
808
809   // __NR_brk 45
810   GO(__NR_brk, "1s 0m");
811   SY(__NR_brk, x0); SUCC;
812
813   // __NR_setgid 46
814   GO(__NR_setgid, "1s 0m");
815   SY(__NR_setgid, x0); FAIL;
816
817   // __NR_getgid 47
818   GO(__NR_getgid, "0s 0m");
819   SY(__NR_getgid); SUCC;
820
821   // __NR_signal 48
822   GO(__NR_signal, "n/a");
823 //SY(__NR_signal); // (Not yet handled by Valgrind) FAIL;
824
825   // __NR_geteuid 49
826   GO(__NR_geteuid, "0s 0m");
827   SY(__NR_geteuid); SUCC;
828
829   // __NR_getegid 50
830   GO(__NR_getegid, "0s 0m");
831   SY(__NR_getegid); SUCC;
832
833   // __NR_acct 51
834   GO(__NR_acct, "1s 1m");
835   SY(__NR_acct, x0); FAIL;
836
837   // __NR_umount2 52
838   GO(__NR_umount2, "2s 1m");
839   SY(__NR_umount2, x0, x0); FAIL;
840
841   // __NR_lock 53
842   GO(__NR_lock, "ni");
843   SY(__NR_lock); FAIL;
844
845   // __NR_ioctl 54
846   #include <asm/ioctls.h>
847   GO(__NR_ioctl, "3s 1m");
848   SY(__NR_ioctl, x0, x0+TCSETS, x0); FAIL;
849
850   // __NR_fcntl 55
851   // As with sys_open(), the 'fd' error is suppressed for the later ones.
852   // For F_GETFD the 3rd arg is ignored
853   GO(__NR_fcntl, "(GETFD) 2s 0m");
854   SY(__NR_fcntl, x0-1, x0+F_GETFD, x0); FAILx(EBADF);
855
856   // For F_DUPFD the 3rd arg is 'arg'.  We don't check the 1st two args
857   // because any errors may or may not be commoned up with the ones from
858   // the previous fcntl call.
859   GO(__NR_fcntl, "(DUPFD) 1s 0m");
860   SY(__NR_fcntl, -1, F_DUPFD, x0); FAILx(EBADF);
861
862   // For F_GETLK the 3rd arg is 'lock'.  On x86, this fails w/EBADF.  But
863   // on amd64 in 32-bit mode it fails w/EFAULT.  We don't check the 1st two
864   // args for the reason given above.
865   GO(__NR_fcntl, "(GETLK) 1s 0m");
866   SY(__NR_fcntl, -1, F_GETLK, x0); FAIL; //FAILx(EBADF);
867
868   // __NR_mpx 56
869   GO(__NR_mpx, "ni");
870   SY(__NR_mpx); FAIL;
871
872   // __NR_setpgid 57
873   GO(__NR_setpgid, "2s 0m");
874   SY(__NR_setpgid, x0, x0-1); FAIL;
875
876   // __NR_ulimit 58
877   GO(__NR_ulimit, "ni");
878   SY(__NR_ulimit); FAIL;
879
880   // __NR_oldolduname 59
881   GO(__NR_oldolduname, "n/a");
882   // (obsolete, not handled by Valgrind)
883
884   // __NR_umask 60
885   GO(__NR_umask, "1s 0m");
886   SY(__NR_umask, x0+022); SUCC;
887
888   // __NR_chroot 61
889   GO(__NR_chroot, "1s 1m");
890   SY(__NR_chroot, x0); FAIL;
891
892   // __NR_ustat 62
893   GO(__NR_ustat, "n/a");
894   // (deprecated, not handled by Valgrind)
895
896   // __NR_dup2 63
897   GO(__NR_dup2, "2s 0m");
898   SY(__NR_dup2, x0-1, x0); FAIL;
899
900   // __NR_getppid 64
901   GO(__NR_getppid, "0s 0m");
902   SY(__NR_getppid); SUCC;
903
904   // __NR_getpgrp 65
905   GO(__NR_getpgrp, "0s 0m");
906   SY(__NR_getpgrp); SUCC;
907
908   // __NR_setsid 66
909   GO(__NR_setsid, "0s 0m");
910   SY(__NR_setsid); SUCC_OR_FAIL;
911
912   // __NR_sigaction 67
913   GO(__NR_sigaction, "3s 4m");
914   SY(__NR_sigaction, x0, x0+&px[1], x0+&px[1]); FAIL;
915
916   // __NR_sgetmask 68 sys_sgetmask()
917   GO(__NR_sgetmask, "n/a");
918 //SY(__NR_sgetmask); // (Not yet handled by Valgrind) FAIL;
919
920   // __NR_ssetmask 69
921   GO(__NR_ssetmask, "n/a");
922 //SY(__NR_ssetmask); // (Not yet handled by Valgrind) FAIL;
923
924   // __NR_setreuid 70
925   GO(__NR_setreuid, "2s 0m");
926   SY(__NR_setreuid, x0, x0); FAIL;
927
928   // __NR_setregid 71
929   GO(__NR_setregid, "2s 0m");
930   SY(__NR_setregid, x0, x0); FAIL;
931
932   // __NR_sigsuspend 72
933   // XXX: how do you use this function?
934   GO(__NR_sigsuspend, "ignore");
935   // (I don't know how to test this...)
936
937   // __NR_sigpending 73
938   GO(__NR_sigpending, "1s 1m");
939   SY(__NR_sigpending, x0); FAIL;
940
941   // __NR_sethostname 74
942   GO(__NR_sethostname, "n/a");
943 //SY(__NR_sethostname); // (Not yet handled by Valgrind) FAIL;
944
945   // __NR_setrlimit 75
946   GO(__NR_setrlimit, "2s 1m");
947   SY(__NR_setrlimit, x0, x0); FAIL;
948
949   // __NR_getrlimit 76
950   GO(__NR_getrlimit, "2s 1m");
951   SY(__NR_getrlimit, x0, x0); FAIL;
952
953   // __NR_getrusage 77
954   GO(__NR_getrusage, "2s 1m");
955   SY(__NR_getrusage, x0, x0); FAIL;
956
957   // __NR_gettimeofday 78
958   GO(__NR_gettimeofday, "2s 2m");
959   SY(__NR_gettimeofday, x0, x0+1); FAIL;
960
961   // __NR_settimeofday 79
962   GO(__NR_settimeofday, "2s 2m");
963   SY(__NR_settimeofday, x0, x0+1); FAIL;
964
965   // __NR_getgroups 80
966   GO(__NR_getgroups, "2s 1m");
967   SY(__NR_getgroups, x0+1, x0+1); FAIL;
968
969   // __NR_setgroups 81
970   GO(__NR_setgroups, "2s 1m");
971   SY(__NR_setgroups, x0+1, x0+1); FAIL;
972
973   // __NR_select 82
974   {
975      long args[5] = { x0+8, x0+0xffffffee, x0+1, x0+1, x0+1 };
976      GO(__NR_select, "1s 5m");
977      SY(__NR_select, args+x0); FAIL;
978   }
979
980   // __NR_symlink 83
981   GO(__NR_symlink, "2s 2m");
982   SY(__NR_symlink, x0, x0); FAIL;
983
984   // __NR_oldlstat 84
985   GO(__NR_oldlstat, "n/a");
986   // (obsolete, not handled by Valgrind)
987
988   // __NR_readlink 85
989   GO(__NR_readlink, "3s 2m");
990   SY(__NR_readlink, x0+1, x0+1, x0+1); FAIL;
991
992   // __NR_uselib 86
993   GO(__NR_uselib, "n/a");
994 //SY(__NR_uselib); // (Not yet handled by Valgrind) FAIL;
995
996   // __NR_swapon 87
997   GO(__NR_swapon, "n/a");
998 //SY(__NR_swapon); // (Not yet handled by Valgrind) FAIL;
999
1000   // __NR_reboot 88
1001   GO(__NR_reboot, "n/a");
1002 //SY(__NR_reboot); // (Not yet handled by Valgrind) FAIL;
1003
1004   // __NR_readdir 89
1005   GO(__NR_readdir, "n/a");
1006   // (superseded, not handled by Valgrind)
1007
1008   // __NR_mmap 90
1009   {
1010      long args[6] = { x0, x0, x0, x0, x0-1, x0 };
1011      GO(__NR_mmap, "1s 1m");
1012      SY(__NR_mmap, args+x0); FAIL;
1013   }
1014
1015   // __NR_munmap 91
1016   GO(__NR_munmap, "2s 0m");
1017   SY(__NR_munmap, x0, x0); FAIL;
1018
1019   // __NR_truncate 92
1020   GO(__NR_truncate, "2s 1m");
1021   SY(__NR_truncate, x0, x0); FAIL;
1022
1023   // __NR_ftruncate 93
1024   GO(__NR_ftruncate, "2s 0m");
1025   SY(__NR_ftruncate, x0, x0); FAIL;
1026
1027   // __NR_fchmod 94
1028   GO(__NR_fchmod, "2s 0m");
1029   SY(__NR_fchmod, x0-1, x0); FAIL;
1030
1031   // __NR_fchown 95
1032   GO(__NR_fchown, "3s 0m");
1033   SY(__NR_fchown, x0, x0, x0); FAIL;
1034
1035   // __NR_getpriority 96
1036   GO(__NR_getpriority, "2s 0m");
1037   SY(__NR_getpriority, x0-1, x0); FAIL;
1038
1039   // __NR_setpriority 97
1040   GO(__NR_setpriority, "3s 0m");
1041   SY(__NR_setpriority, x0-1, x0, x0); FAIL;
1042
1043   // __NR_profil 98
1044   GO(__NR_profil, "ni");
1045   SY(__NR_profil); FAIL;
1046
1047   // __NR_statfs 99
1048   GO(__NR_statfs, "2s 2m");
1049   SY(__NR_statfs, x0, x0); FAIL;
1050
1051   // __NR_fstatfs 100
1052   GO(__NR_fstatfs, "2s 1m");
1053   SY(__NR_fstatfs, x0, x0); FAIL;
1054
1055   // __NR_ioperm 101
1056   GO(__NR_ioperm, "3s 0m");
1057   SY(__NR_ioperm, x0, x0, x0); FAIL;
1058
1059   // __NR_socketcall 102
1060   GO(__NR_socketcall, "XXX");
1061   // (XXX: need to do all sub-cases properly)
1062
1063   // __NR_syslog 103
1064   GO(__NR_syslog, "3s 1m");
1065   SY(__NR_syslog, x0+2, x0, x0+1); FAIL;
1066
1067   // __NR_setitimer 104
1068   GO(__NR_setitimer, "3s 2m");
1069   SY(__NR_setitimer, x0, x0+1, x0+1); FAIL;
1070
1071   // __NR_getitimer 105
1072   GO(__NR_getitimer, "2s 1m");
1073   SY(__NR_getitimer, x0, x0, x0); FAIL;
1074
1075   // __NR_stat 106
1076   GO(__NR_stat, "2s 2m");
1077   SY(__NR_stat, x0, x0); FAIL;
1078
1079   // __NR_lstat 107
1080   GO(__NR_lstat, "2s 2m");
1081   SY(__NR_lstat, x0, x0); FAIL;
1082
1083   // __NR_fstat 108
1084   GO(__NR_fstat, "2s 1m");
1085   SY(__NR_fstat, x0, x0); FAIL;
1086
1087   // __NR_olduname 109
1088   GO(__NR_olduname, "n/a");
1089   // (obsolete, not handled by Valgrind)
1090
1091   // __NR_iopl 110
1092   GO(__NR_iopl, "1s 0m");
1093   SY(__NR_iopl, x0+100); FAIL;
1094
1095   // __NR_vhangup 111
1096   GO(__NR_vhangup, "0s 0m");
1097   SY(__NR_vhangup); SUCC_OR_FAIL;  // Will succeed for superuser
1098
1099   // __NR_idle 112
1100   GO(__NR_idle, "ni");
1101   SY(__NR_idle); FAIL;
1102
1103   // __NR_vm86old 113
1104   GO(__NR_vm86old, "n/a");
1105   // (will probably never be handled by Valgrind)
1106
1107   // __NR_swapoff 115
1108   GO(__NR_swapoff, "n/a");
1109 //SY(__NR_swapoff); // (Not yet handled by Valgrind) FAIL;
1110
1111   // __NR_sysinfo 116
1112   GO(__NR_sysinfo, "1s 1m");
1113   SY(__NR_sysinfo, x0); FAIL;
1114
1115   // __NR_ipc 117
1116   // XXX: This is simplistic -- need to do all the sub-cases properly.
1117   // XXX: Also, should be 6 scalar errors, except glibc's syscall() doesn't
1118   //      use the 6th one!
1119   GO(__NR_ipc, "5s 0m");
1120   SY(__NR_ipc, x0+4, x0, x0, x0, x0, x0); FAIL;
1121
1122   // __NR_fsync 118
1123   GO(__NR_fsync, "1s 0m");
1124   SY(__NR_fsync, x0-1); FAIL;
1125
1126   // __NR_sigreturn 119
1127   GO(__NR_sigreturn, "n/a");
1128 //SY(__NR_sigreturn); // (Not yet handled by Valgrind) FAIL;
1129
1130   // __NR_clone 120
1131#ifndef CLONE_PARENT_SETTID
1132#define CLONE_PARENT_SETTID   0x00100000
1133#endif
1134   // XXX: should really be "4s 2m"?  Not sure... (see PRE(sys_clone))
1135   GO(__NR_clone, "4s 0m");
1136   SY(__NR_clone, x0|CLONE_PARENT_SETTID|SIGCHLD, x0, x0, x0); FAIL;
1137   if (0 == res) {
1138      SY(__NR_exit, 0); FAIL;
1139   }
1140
1141   // __NR_setdomainname 121
1142   GO(__NR_setdomainname, "n/a");
1143 //SY(__NR_setdomainname); // (Not yet handled by Valgrind) FAIL;
1144
1145   // __NR_uname 122
1146   GO(__NR_uname, "1s 1m");
1147   SY(__NR_uname, x0); FAIL;
1148
1149   // __NR_modify_ldt 123
1150   GO(__NR_modify_ldt, "3s 1m");
1151   SY(__NR_modify_ldt, x0+1, x0, x0+1); FAILx(EINVAL);
1152
1153   // __NR_adjtimex 124
1154   // XXX: need to do properly, but deref'ing NULL causing Valgrind to crash...
1155     GO(__NR_adjtimex, "XXX");
1156//   SY(__NR_adjtimex, x0); FAIL;
1157
1158   // __NR_mprotect 125
1159   GO(__NR_mprotect, "3s 0m");
1160   SY(__NR_mprotect, x0+1, x0, x0); FAILx(EINVAL);
1161
1162   // __NR_sigprocmask 126
1163   GO(__NR_sigprocmask, "3s 2m");
1164   SY(__NR_sigprocmask, x0, x0+&px[1], x0+&px[1]); SUCC;
1165
1166   // __NR_create_module 127
1167   GO(__NR_create_module, "ni");
1168   SY(__NR_create_module); FAIL;
1169
1170   // __NR_init_module 128
1171   GO(__NR_init_module, "3s 2m");
1172   SY(__NR_init_module, x0, x0+1, x0); FAIL;
1173
1174   // __NR_delete_module 129
1175   GO(__NR_delete_module, "n/a");
1176 //SY(__NR_delete_module); // (Not yet handled by Valgrind) FAIL;
1177
1178   // __NR_get_kernel_syms 130
1179   GO(__NR_get_kernel_syms, "ni");
1180   SY(__NR_get_kernel_syms); FAIL;
1181
1182   // __NR_quotactl 131
1183   GO(__NR_quotactl, "4s 1m");
1184   SY(__NR_quotactl, x0, x0, x0, x0); FAIL;
1185
1186   // __NR_getpgid 132
1187   GO(__NR_getpgid, "1s 0m");
1188   SY(__NR_getpgid, x0-1); FAIL;
1189
1190   // __NR_bdflush 134
1191   GO(__NR_bdflush, "n/a");
1192 //SY(__NR_bdflush); // (Not yet handled by Valgrind) FAIL;
1193
1194   // __NR_sysfs 135
1195   GO(__NR_sysfs, "n/a");
1196 //SY(__NR_sysfs); // (Not yet handled by Valgrind) FAIL;
1197
1198   // __NR_personality 136
1199   GO(__NR_personality, "1s 0m");
1200   SY(__NR_personality, x0+0xffffffff); SUCC;
1201
1202   // __NR_afs_syscall 137
1203   GO(__NR_afs_syscall, "ni");
1204   SY(__NR_afs_syscall); FAIL;
1205
1206   // __NR_setfsuid 138
1207   GO(__NR_setfsuid, "1s 0m");
1208   SY(__NR_setfsuid, x0); SUCC;  // This syscall has a stupid return value
1209
1210   // __NR_setfsgid 139
1211   GO(__NR_setfsgid, "1s 0m");
1212   SY(__NR_setfsgid, x0); SUCC;  // This syscall has a stupid return value
1213
1214   // __NR__llseek 140
1215   GO(__NR__llseek, "5s 1m");
1216   SY(__NR__llseek, x0, x0, x0, x0, x0); FAIL;
1217
1218   // __NR_getdents 141
1219   GO(__NR_getdents, "3s 1m");
1220   SY(__NR_getdents, x0, x0, x0+1); FAIL;
1221
1222   // __NR__newselect 142
1223   GO(__NR__newselect, "5s 4m");
1224   SY(__NR__newselect, x0+8, x0+0xffffffff, x0+1, x0+1, x0+1); FAIL;
1225
1226   // __NR_flock 143
1227   GO(__NR_flock, "2s 0m");
1228   SY(__NR_flock, x0, x0); FAIL;
1229
1230   // __NR_msync 144
1231   GO(__NR_msync, "3s 1m");
1232   SY(__NR_msync, x0, x0+1, x0); FAIL;
1233
1234   // __NR_readv 145
1235   GO(__NR_readv, "3s 1m");
1236   SY(__NR_readv, x0, x0, x0+1); FAIL;
1237
1238   // __NR_writev 146
1239   GO(__NR_writev, "3s 1m");
1240   SY(__NR_writev, x0, x0, x0+1); FAIL;
1241
1242   // __NR_getsid 147
1243   GO(__NR_getsid, "1s 0m");
1244   SY(__NR_getsid, x0-1); FAIL;
1245
1246   // __NR_fdatasync 148
1247   GO(__NR_fdatasync, "1s 0m");
1248   SY(__NR_fdatasync, x0-1); FAIL;
1249
1250   // __NR__sysctl 149
1251   GO(__NR__sysctl, "1s 1m");
1252   SY(__NR__sysctl, x0); FAIL;
1253
1254   // __NR_mlock 150
1255   GO(__NR_mlock, "2s 0m");
1256   SY(__NR_mlock, x0, x0+1); FAIL;
1257
1258   // __NR_munlock 151
1259   GO(__NR_munlock, "2s 0m");
1260   SY(__NR_munlock, x0, x0+1); FAIL;
1261
1262   // __NR_mlockall 152
1263   GO(__NR_mlockall, "1s 0m");
1264   SY(__NR_mlockall, x0-1); FAIL;
1265
1266   // __NR_munlockall 153
1267   GO(__NR_munlockall, "0s 0m");
1268   SY(__NR_munlockall); SUCC_OR_FAILx(EPERM);
1269
1270   // __NR_sched_setparam 154
1271   GO(__NR_sched_setparam, "2s 1m");
1272   SY(__NR_sched_setparam, x0, x0); FAIL;
1273
1274   // __NR_sched_getparam 155
1275   GO(__NR_sched_getparam, "2s 1m");
1276   SY(__NR_sched_getparam, x0, x0); FAIL;
1277
1278   // __NR_sched_setscheduler 156
1279   GO(__NR_sched_setscheduler, "3s 1m");
1280   SY(__NR_sched_setscheduler, x0-1, x0, x0+1); FAIL;
1281
1282   // __NR_sched_getscheduler 157
1283   GO(__NR_sched_getscheduler, "1s 0m");
1284   SY(__NR_sched_getscheduler, x0-1); FAIL;
1285
1286   // __NR_sched_yield 158
1287   GO(__NR_sched_yield, "0s 0m");
1288   SY(__NR_sched_yield); SUCC;
1289
1290   // __NR_sched_get_priority_max 159
1291   GO(__NR_sched_get_priority_max, "1s 0m");
1292   SY(__NR_sched_get_priority_max, x0-1); FAIL;
1293
1294   // __NR_sched_get_priority_min 160
1295   GO(__NR_sched_get_priority_min, "1s 0m");
1296   SY(__NR_sched_get_priority_min, x0-1); FAIL;
1297
1298   // __NR_sched_rr_get_interval 161
1299   GO(__NR_sched_rr_get_interval, "n/a");
1300 //SY(__NR_sched_rr_get_interval); // (Not yet handled by Valgrind) FAIL;
1301
1302   // __NR_nanosleep 162
1303   GO(__NR_nanosleep, "2s 2m");
1304   SY(__NR_nanosleep, x0, x0+1); FAIL;
1305
1306   // __NR_mremap 163
1307   GO(__NR_mremap, "5s 0m");
1308   SY(__NR_mremap, x0+1, x0, x0, x0+MREMAP_FIXED, x0); FAILx(EINVAL);
1309
1310   // __NR_setresuid 164
1311   GO(__NR_setresuid, "3s 0m");
1312   SY(__NR_setresuid, x0, x0, x0); FAIL;
1313
1314   // __NR_getresuid 165
1315   GO(__NR_getresuid, "3s 3m");
1316   SY(__NR_getresuid, x0, x0, x0); FAIL;
1317
1318   // __NR_vm86 166
1319   GO(__NR_vm86, "n/a");
1320   // (will probably never be handled by Valgrind)
1321
1322   // __NR_query_module 167
1323   GO(__NR_query_module, "ni");
1324   SY(__NR_query_module); FAIL;
1325
1326   // __NR_poll 168
1327   GO(__NR_poll, "3s 1m");
1328   SY(__NR_poll, x0, x0+1, x0); FAIL;
1329
1330   // __NR_nfsservctl 169
1331   GO(__NR_nfsservctl, "n/a");
1332 //SY(__NR_nfsservctl); // (Not yet handled by Valgrind) FAIL;
1333
1334   // __NR_setresgid 170
1335   GO(__NR_setresgid, "3s 0m");
1336   SY(__NR_setresgid, x0, x0, x0); FAIL;
1337
1338   // __NR_getresgid 171
1339   GO(__NR_getresgid, "3s 3m");
1340   SY(__NR_getresgid, x0, x0, x0); FAIL;
1341
1342   // __NR_prctl 172
1343   GO(__NR_prctl, "5s 0m");
1344   SY(__NR_prctl, x0, x0, x0, x0, x0); FAIL;
1345
1346   // __NR_rt_sigreturn 173
1347   GO(__NR_rt_sigreturn, "n/a");
1348 //SY(__NR_rt_sigreturn); // (Not yet handled by Valgrind) FAIL;
1349
1350   // __NR_rt_sigaction 174
1351   GO(__NR_rt_sigaction, "4s 4m");
1352   SY(__NR_rt_sigaction, x0, x0+&px[2], x0+&px[2], x0); FAIL;
1353
1354   // __NR_rt_sigprocmask 175
1355   GO(__NR_rt_sigprocmask, "4s 2m");
1356   SY(__NR_rt_sigprocmask, x0, x0+1, x0+1, x0); FAIL;
1357
1358   // __NR_rt_sigpending 176
1359   GO(__NR_rt_sigpending, "2s 1m");
1360   SY(__NR_rt_sigpending, x0, x0+1); FAIL;
1361
1362   // __NR_rt_sigtimedwait 177
1363   GO(__NR_rt_sigtimedwait, "4s 3m");
1364   SY(__NR_rt_sigtimedwait, x0+1, x0+1, x0+1, x0); FAIL;
1365
1366   // __NR_rt_sigqueueinfo 178
1367   GO(__NR_rt_sigqueueinfo, "3s 1m");
1368   SY(__NR_rt_sigqueueinfo, x0, x0+1, x0); FAIL;
1369
1370   // __NR_rt_sigsuspend 179
1371   GO(__NR_rt_sigsuspend, "ignore");
1372   // (I don't know how to test this...)
1373
1374   // __NR_pread64 180
1375   GO(__NR_pread64, "5s 1m");
1376   SY(__NR_pread64, x0, x0, x0+1, x0, x0); FAIL;
1377
1378   // __NR_pwrite64 181
1379   GO(__NR_pwrite64, "5s 1m");
1380   SY(__NR_pwrite64, x0, x0, x0+1, x0, x0); FAIL;
1381
1382   // __NR_getcwd 183
1383   GO(__NR_getcwd, "2s 1m");
1384   SY(__NR_getcwd, x0, x0+1); FAIL;
1385
1386   // __NR_capget 184
1387   GO(__NR_capget, "2s 2m");
1388   SY(__NR_capget, x0, x0); FAIL;
1389
1390   // __NR_capset 185
1391   GO(__NR_capset, "2s 2m");
1392   SY(__NR_capset, x0, x0); FAIL;
1393
1394   // __NR_sigaltstack 186
1395   {
1396      struct our_sigaltstack {
1397              void *ss_sp;
1398              int ss_flags;
1399              size_t ss_size;
1400      } ss;
1401      ss.ss_sp     = NULL;
1402      ss.ss_flags  = 0;
1403      ss.ss_size   = 0;
1404      VALGRIND_MAKE_MEM_NOACCESS(& ss, sizeof(struct our_sigaltstack));
1405      GO(__NR_sigaltstack, "2s 2m");
1406      SY(__NR_sigaltstack, x0+&ss, x0+&ss); SUCC;
1407   }
1408
1409   // __NR_sendfile 187
1410   GO(__NR_sendfile, "4s 1m");
1411   SY(__NR_sendfile, x0, x0, x0+1, x0); FAIL;
1412
1413   // __NR_getpmsg 188
1414   // Could do 5s 4m with more effort, but I can't be bothered for this
1415   // crappy non-standard syscall.
1416   GO(__NR_getpmsg, "5s 0m");
1417   SY(__NR_getpmsg, x0, x0, x0, x0); FAIL;
1418
1419   // __NR_putpmsg 189
1420   // Could do 5s 2m with more effort, but I can't be bothered for this
1421   // crappy non-standard syscall.
1422   GO(__NR_putpmsg, "5s 0m");
1423   SY(__NR_putpmsg, x0, x0, x0, x0, x0); FAIL;
1424
1425   // __NR_vfork 190
1426   GO(__NR_vfork, "other");
1427   // (sse scalar_vfork.c)
1428
1429   // __NR_ugetrlimit 191
1430   GO(__NR_ugetrlimit, "2s 1m");
1431   SY(__NR_ugetrlimit, x0, x0); FAIL;
1432
1433   // __NR_mmap2 192
1434   GO(__NR_mmap2, "6s 0m");
1435   SY(__NR_mmap2, x0, x0, x0, x0, x0-1, x0); FAIL;
1436
1437   // __NR_truncate64 193
1438   GO(__NR_truncate64, "3s 1m");
1439   SY(__NR_truncate64, x0, x0, x0); FAIL;
1440
1441   // __NR_ftruncate64 194
1442   GO(__NR_ftruncate64, "3s 0m");
1443   SY(__NR_ftruncate64, x0, x0, x0); FAIL;
1444
1445   // __NR_stat64 195
1446   GO(__NR_stat64, "2s 2m");
1447   SY(__NR_stat64, x0, x0); FAIL;
1448
1449   // __NR_lstat64 196
1450   GO(__NR_lstat64, "2s 2m");
1451   SY(__NR_lstat64, x0, x0); FAIL;
1452
1453   // __NR_fstat64 197
1454   GO(__NR_fstat64, "2s 1m");
1455   SY(__NR_fstat64, x0, x0); FAIL;
1456
1457   // __NR_lchown32 198
1458   GO(__NR_lchown32, "3s 1m");
1459   SY(__NR_lchown32, x0, x0, x0); FAIL;
1460
1461   // __NR_getuid32 199
1462   GO(__NR_getuid32, "0s 0m");
1463   SY(__NR_getuid32); SUCC;
1464
1465   // __NR_getgid32 200
1466   GO(__NR_getgid32, "0s 0m");
1467   SY(__NR_getgid32); SUCC;
1468
1469   // __NR_geteuid32 201
1470   GO(__NR_geteuid32, "0s 0m");
1471   SY(__NR_geteuid32); SUCC;
1472
1473   // __NR_getegid32 202
1474   GO(__NR_getegid32, "0s 0m");
1475   SY(__NR_getegid32); SUCC;
1476
1477   // __NR_setreuid32 203
1478   GO(__NR_setreuid32, "2s 0m");
1479   SY(__NR_setreuid32, x0, x0); FAIL;
1480
1481   // __NR_setregid32 204
1482   GO(__NR_setregid32, "2s 0m");
1483   SY(__NR_setregid32, x0, x0); FAIL;
1484
1485   // __NR_getgroups32 205
1486   GO(__NR_getgroups32, "2s 1m");
1487   SY(__NR_getgroups32, x0+1, x0+1); FAIL;
1488
1489   // __NR_setgroups32 206
1490   GO(__NR_setgroups32, "2s 1m");
1491   SY(__NR_setgroups32, x0+1, x0+1); FAIL;
1492
1493   // __NR_fchown32 207
1494   GO(__NR_fchown32, "3s 0m");
1495   SY(__NR_fchown32, x0, x0, x0); FAIL;
1496
1497   // __NR_setresuid32 208
1498   GO(__NR_setresuid32, "3s 0m");
1499   SY(__NR_setresuid32, x0, x0, x0); FAIL;
1500
1501   // __NR_getresuid32 209
1502   GO(__NR_getresuid32, "3s 3m");
1503   SY(__NR_getresuid32, x0, x0, x0); FAIL;
1504
1505   // __NR_setresgid32 210
1506   GO(__NR_setresgid32, "3s 0m");
1507   SY(__NR_setresgid32, x0, x0, x0); FAIL;
1508
1509   // __NR_getresgid32 211
1510   GO(__NR_getresgid32, "3s 3m");
1511   SY(__NR_getresgid32, x0, x0, x0); FAIL;
1512
1513   // __NR_chown32 212
1514   GO(__NR_chown32, "3s 1m");
1515   SY(__NR_chown32, x0, x0, x0); FAIL;
1516
1517   // __NR_setuid32 213
1518   GO(__NR_setuid32, "1s 0m");
1519   SY(__NR_setuid32, x0); FAIL;
1520
1521   // __NR_setgid32 214
1522   GO(__NR_setgid32, "1s 0m");
1523   SY(__NR_setgid32, x0); FAIL;
1524
1525   // __NR_setfsuid32 215
1526   GO(__NR_setfsuid32, "1s 0m");
1527   SY(__NR_setfsuid32, x0); SUCC;  // This syscall has a stupid return value
1528
1529   // __NR_setfsgid32 216
1530   GO(__NR_setfsgid32, "1s 0m");
1531   SY(__NR_setfsgid32, x0); SUCC;  // This syscall has a stupid return value
1532
1533   // __NR_pivot_root 217
1534   GO(__NR_pivot_root, "n/a");
1535 //SY(__NR_pivot_root); // (Not yet handled by Valgrind) FAIL;
1536
1537   // __NR_mincore 218
1538   GO(__NR_mincore, "3s 1m");
1539   SY(__NR_mincore, x0, x0+40960, x0); FAIL;
1540
1541   // __NR_madvise 219
1542   GO(__NR_madvise, "3s 0m");
1543   SY(__NR_madvise, x0, x0+1, x0); FAILx(ENOMEM);
1544
1545   // __NR_getdents64 220
1546   GO(__NR_getdents64, "3s 1m");
1547   SY(__NR_getdents64, x0, x0, x0+1); FAIL;
1548
1549   // __NR_fcntl64 221
1550   // As with sys_open(), we don't trigger errors for the 1st two args for
1551   // the later ones.
1552   // For F_GETFD the 3rd arg is ignored.
1553   GO(__NR_fcntl64, "(GETFD) 2s 0m");
1554   SY(__NR_fcntl64, x0-1, x0+F_GETFD, x0); FAILx(EBADF);
1555
1556   // For F_DUPFD the 3rd arg is 'arg'
1557   GO(__NR_fcntl64, "(DUPFD) 1s 0m");
1558   SY(__NR_fcntl64, -1, F_DUPFD, x0); FAILx(EBADF);
1559
1560   // For F_GETLK the 3rd arg is 'lock'.
1561   // On x86, this fails w/EBADF.  But on amd64 in 32-bit mode it fails
1562   // w/EFAULT.
1563   GO(__NR_fcntl64, "(GETLK) 1s 0m");
1564   SY(__NR_fcntl64, -1, +F_GETLK, x0); FAIL; //FAILx(EBADF);
1565
1566   // 222
1567   GO(222, "ni");
1568   SY(222); FAIL;
1569
1570   // 223
1571   GO(223, "ni");
1572   SY(223); FAIL;
1573
1574   // __NR_gettid 224
1575   GO(__NR_gettid, "n/a");
1576 //SY(__NR_gettid); // (Not yet handled by Valgrind) FAIL;
1577
1578   // __NR_readahead 225
1579   GO(__NR_readahead, "n/a");
1580 //SY(__NR_readahead); // (Not yet handled by Valgrind) FAIL;
1581
1582   // __NR_setxattr 226
1583   GO(__NR_setxattr, "5s 3m");
1584   SY(__NR_setxattr, x0, x0, x0, x0+1, x0); FAIL;
1585
1586   // __NR_lsetxattr 227
1587   GO(__NR_lsetxattr, "5s 3m");
1588   SY(__NR_lsetxattr, x0, x0, x0, x0+1, x0); FAIL;
1589
1590   // __NR_fsetxattr 228
1591   GO(__NR_fsetxattr, "5s 2m");
1592   SY(__NR_fsetxattr, x0, x0, x0, x0+1, x0); FAIL;
1593
1594   // __NR_getxattr 229
1595   GO(__NR_getxattr, "4s 3m");
1596   SY(__NR_getxattr, x0, x0, x0, x0+1); FAIL;
1597
1598   // __NR_lgetxattr 230
1599   GO(__NR_lgetxattr, "4s 3m");
1600   SY(__NR_lgetxattr, x0, x0, x0, x0+1); FAIL;
1601
1602   // __NR_fgetxattr 231
1603   GO(__NR_fgetxattr, "4s 2m");
1604   SY(__NR_fgetxattr, x0, x0, x0, x0+1); FAIL;
1605
1606   // __NR_listxattr 232
1607   GO(__NR_listxattr, "3s 2m");
1608   SY(__NR_listxattr, x0, x0, x0+1); FAIL;
1609
1610   // __NR_llistxattr 233
1611   GO(__NR_llistxattr, "3s 2m");
1612   SY(__NR_llistxattr, x0, x0, x0+1); FAIL;
1613
1614   // __NR_flistxattr 234
1615   GO(__NR_flistxattr, "3s 1m");
1616   SY(__NR_flistxattr, x0-1, x0, x0+1); FAIL; /* kernel returns EBADF, but both seem correct */
1617
1618   // __NR_removexattr 235
1619   GO(__NR_removexattr, "2s 2m");
1620   SY(__NR_removexattr, x0, x0); FAIL;
1621
1622   // __NR_lremovexattr 236
1623   GO(__NR_lremovexattr, "2s 2m");
1624   SY(__NR_lremovexattr, x0, x0); FAIL;
1625
1626   // __NR_fremovexattr 237
1627   GO(__NR_fremovexattr, "2s 1m");
1628   SY(__NR_fremovexattr, x0, x0); FAIL;
1629
1630   // __NR_tkill 238
1631   GO(__NR_tkill, "n/a");
1632 //SY(__NR_tkill); // (Not yet handled by Valgrind) FAIL;
1633
1634   // __NR_sendfile64 239
1635   GO(__NR_sendfile64, "4s 1m");
1636   SY(__NR_sendfile64, x0, x0, x0+1, x0); FAIL;
1637
1638   // __NR_futex 240
1639   #ifndef FUTEX_WAIT
1640   #define FUTEX_WAIT   0
1641   #endif
1642   // XXX: again, glibc not doing 6th arg means we have only 5s errors
1643   GO(__NR_futex, "5s 2m");
1644   SY(__NR_futex, x0+FUTEX_WAIT, x0, x0, x0+1, x0, x0); FAIL;
1645
1646   // __NR_sched_setaffinity 241
1647   GO(__NR_sched_setaffinity, "3s 1m");
1648   SY(__NR_sched_setaffinity, x0, x0+1, x0); FAIL;
1649
1650   // __NR_sched_getaffinity 242
1651   GO(__NR_sched_getaffinity, "3s 1m");
1652   SY(__NR_sched_getaffinity, x0, x0+1, x0); FAIL;
1653
1654   // __NR_set_thread_area 243
1655   GO(__NR_set_thread_area, "1s 1m");
1656   SY(__NR_set_thread_area, x0); FAILx(EFAULT);
1657
1658   // __NR_get_thread_area 244
1659   GO(__NR_get_thread_area, "1s 1m");
1660   SY(__NR_get_thread_area, x0); FAILx(EFAULT);
1661
1662   // __NR_io_setup 245
1663   GO(__NR_io_setup, "2s 1m");
1664   SY(__NR_io_setup, x0, x0); FAIL;
1665
1666   // __NR_io_destroy 246
1667   {
1668      // jump through hoops to prevent the PRE(io_destroy) wrapper crashing.
1669      struct fake_aio_ring {
1670        unsigned        id;     /* kernel internal index number */
1671        unsigned        nr;     /* number of io_events */
1672        // There are more fields in the real aio_ring, but the 'nr' field is
1673        // the only one used by the PRE() wrapper.
1674      } ring = { 0, 0 };
1675      struct fake_aio_ring* ringptr = &ring;
1676      GO(__NR_io_destroy, "1s 0m");
1677      SY(__NR_io_destroy, x0+&ringptr); FAIL;
1678   }
1679
1680   // __NR_io_getevents 247
1681   GO(__NR_io_getevents, "5s 2m");
1682   SY(__NR_io_getevents, x0, x0, x0+1, x0, x0+1); FAIL;
1683
1684   // __NR_io_submit 248
1685   GO(__NR_io_submit, "3s 1m");
1686   SY(__NR_io_submit, x0, x0+1, x0); FAIL;
1687
1688   // __NR_io_cancel 249
1689   GO(__NR_io_cancel, "3s 2m");
1690   SY(__NR_io_cancel, x0, x0, x0); FAIL;
1691
1692   // __NR_fadvise64 250
1693   GO(__NR_fadvise64, "n/a");
1694 //SY(__NR_fadvise64); // (Not yet handled by Valgrind) FAIL;
1695
1696   // 251
1697   GO(251, "ni");
1698   SY(251); FAIL;
1699
1700   // __NR_exit_group 252
1701   GO(__NR_exit_group, "other");
1702   // (see scalar_exit_group.c)
1703
1704   // __NR_lookup_dcookie 253
1705   GO(__NR_lookup_dcookie, "4s 1m");
1706   SY(__NR_lookup_dcookie, x0, x0, x0, x0+1); FAIL;
1707
1708   // __NR_epoll_create 254
1709   GO(__NR_epoll_create, "1s 0m");
1710   SY(__NR_epoll_create, x0); SUCC_OR_FAIL;
1711
1712   // __NR_epoll_ctl 255
1713   GO(__NR_epoll_ctl, "4s 1m");
1714   SY(__NR_epoll_ctl, x0, x0, x0, x0); FAIL;
1715
1716   // __NR_epoll_wait 256
1717   GO(__NR_epoll_wait, "4s 1m");
1718   SY(__NR_epoll_wait, x0, x0, x0+1, x0); FAIL;
1719
1720   // __NR_remap_file_pages 257
1721   GO(__NR_remap_file_pages, "n/a");
1722 //SY(__NR_remap_file_pages); // (Not yet handled by Valgrind) FAIL;
1723
1724   // __NR_set_tid_address 258
1725   GO(__NR_set_tid_address, "1s 0m");
1726   SY(__NR_set_tid_address, x0); SUCC_OR_FAILx(ENOSYS);
1727
1728   // __NR_timer_create 259
1729   GO(__NR_timer_create, "3s 2m");
1730   SY(__NR_timer_create, x0, x0+1, x0); FAIL;
1731
1732   // __NR_timer_settime (__NR_timer_create+1)
1733   GO(__NR_timer_settime, "4s 2m");
1734   SY(__NR_timer_settime, x0, x0, x0, x0+1); FAIL;
1735
1736   // __NR_timer_gettime (__NR_timer_create+2)
1737   GO(__NR_timer_gettime, "2s 1m");
1738   SY(__NR_timer_gettime, x0, x0); FAIL;
1739
1740   // __NR_timer_getoverrun (__NR_timer_create+3)
1741   GO(__NR_timer_getoverrun, "1s 0m");
1742   SY(__NR_timer_getoverrun, x0); FAIL;
1743
1744   // __NR_timer_delete (__NR_timer_create+4)
1745   GO(__NR_timer_delete, "1s 0m");
1746   SY(__NR_timer_delete, x0); FAIL;
1747
1748   // __NR_clock_settime (__NR_timer_create+5)
1749   GO(__NR_clock_settime, "2s 1m");
1750   SY(__NR_clock_settime, x0, x0);  FAIL; FAIL;
1751
1752   // __NR_clock_gettime (__NR_timer_create+6)
1753   GO(__NR_clock_gettime, "2s 1m");
1754   SY(__NR_clock_gettime, x0, x0); FAIL;
1755
1756   // __NR_clock_getres (__NR_timer_create+7)
1757   GO(__NR_clock_getres, "2s 1m");
1758   SY(__NR_clock_getres, x0+1, x0+1); FAIL; FAIL;
1759
1760   // __NR_clock_nanosleep (__NR_timer_create+8)
1761   GO(__NR_clock_nanosleep, "n/a");
1762 //SY(__NR_clock_nanosleep); // (Not yet handled by Valgrind) FAIL;
1763
1764   // __NR_statfs64 268
1765   GO(__NR_statfs64, "3s 2m");
1766   SY(__NR_statfs64, x0, x0+1, x0); FAIL;
1767
1768   // __NR_fstatfs64 269
1769   GO(__NR_fstatfs64, "3s 1m");
1770   SY(__NR_fstatfs64, x0, x0+1, x0); FAIL;
1771
1772   // __NR_tgkill 270
1773   GO(__NR_tgkill, "n/a");
1774 //SY(__NR_tgkill); // (Not yet handled by Valgrind) FAIL;
1775
1776   // __NR_utimes 271
1777   GO(__NR_utimes, "2s 2m");
1778   SY(__NR_utimes, x0, x0+1); FAIL;
1779
1780   // __NR_fadvise64_64 272
1781   GO(__NR_fadvise64_64, "n/a");
1782 //SY(__NR_fadvise64_64); // (Not yet handled by Valgrind) FAIL;
1783
1784   // __NR_vserver 273
1785   GO(__NR_vserver, "ni");
1786   SY(__NR_vserver); FAIL;
1787
1788   // __NR_mbind 274
1789   GO(__NR_mbind, "n/a");
1790 //SY(__NR_mbind); // (Not yet handled by Valgrind) FAIL;
1791
1792   // __NR_get_mempolicy 275
1793   GO(__NR_get_mempolicy, "n/a");
1794 //SY(__NR_get_mempolicy); // (Not yet handled by Valgrind) FAIL;
1795
1796   // __NR_set_mempolicy 276
1797   GO(__NR_set_mempolicy, "n/a");
1798 //SY(__NR_set_mempolicy); // (Not yet handled by Valgrind) FAIL;
1799
1800   // __NR_mq_open 277
1801   GO(__NR_mq_open, "4s 3m");
1802   SY(__NR_mq_open, x0, x0+O_CREAT, x0, x0+1); FAIL;
1803
1804   // __NR_mq_unlink (__NR_mq_open+1)
1805   GO(__NR_mq_unlink, "1s 1m");
1806   SY(__NR_mq_unlink, x0); FAIL;
1807
1808   // __NR_mq_timedsend (__NR_mq_open+2)
1809   GO(__NR_mq_timedsend, "5s 2m");
1810   SY(__NR_mq_timedsend, x0, x0, x0+1, x0, x0+1); FAIL;
1811
1812   // __NR_mq_timedreceive (__NR_mq_open+3)
1813   GO(__NR_mq_timedreceive, "5s 3m");
1814   SY(__NR_mq_timedreceive, x0, x0, x0+1, x0+1, x0+1); FAIL;
1815
1816   // __NR_mq_notify (__NR_mq_open+4)
1817   GO(__NR_mq_notify, "2s 1m");
1818   SY(__NR_mq_notify, x0, x0+1); FAIL;
1819
1820   // __NR_mq_getsetattr (__NR_mq_open+5)
1821   GO(__NR_mq_getsetattr, "3s 2m");
1822   SY(__NR_mq_getsetattr, x0, x0+1, x0+1); FAIL;
1823
1824   // __NR_sys_kexec_load 283
1825   GO(__NR_sys_kexec_load, "ni");
1826   SY(__NR_sys_kexec_load); FAIL;
1827#endif
1828
1829   // no such syscall...
1830   GO(9999, 9999, "1e");
1831   SY(9999); FAIL;
1832
1833   // __NR_exit 1
1834   GO(__NR_exit, 1, "1s 0m");
1835   SY(__NR_exit, x0); FAIL;
1836
1837   assert(0);
1838}
1839
1840