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