From 825fb24ff1731a1aa84ac0c16fce2e57d150aed7 Mon Sep 17 00:00:00 2001 From: pierretom Date: Wed, 28 Jan 2026 13:11:23 +0100 Subject: [PATCH] place some syscalls with access to a clock, used for time reading, theoretical resolution and sleep functions into `@default-keep` Also move `stime` into `@obsolete`, see `man 2 stime`. --- etc/templates/syscalls.txt | 6 ++-- src/lib/syscall.c | 56 ++++++++++++++++---------------------- 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/etc/templates/syscalls.txt b/etc/templates/syscalls.txt index f78b4ea58..832d9657a 100644 --- a/etc/templates/syscalls.txt +++ b/etc/templates/syscalls.txt @@ -29,11 +29,11 @@ Definition of groups @aio=io_cancel,io_destroy,io_getevents,io_pgetevents,io_pgetevents_time64,io_setup,io_submit,io_uring_enter,io_uring_register,io_uring_setup @basic-io=_llseek,close,close_range,dup,dup2,dup3,lseek,pread64,preadv,preadv2,pwrite64,pwritev,pwritev2,read,readv,write,writev @chown=chown,chown32,fchown,fchown32,fchownat,lchown,lchown32 -@clock=adjtimex,clock_adjtime,clock_adjtime64,clock_getres,clock_getres_time64,clock_gettime,clock_gettime64,clock_nanosleep,clock_nanosleep_time64,clock_settime,clock_settime64,gettimeofday,old_adjtimex,osf_gettimeofday,osf_settimeofday,settimeofday,stime,time +@clock=adjtimex,clock_adjtime,clock_adjtime64,clock_settime,clock_settime64,old_adjtimex,osf_settimeofday,settimeofday @cpu-emulation=modify_ldt,subpage_prot,switch_endian,vm86,vm86old @debug=lookup_dcookie,perf_event_open,pidfd_getfd,process_vm_writev,rtas,s390_runtime_instr,sys_debug_setcontext,uprobe,uretprobe @default=@clock,@cpu-emulation,@debug,@module,@mount,@obsolete,@raw-io,@reboot,@swap,acct,add_key,bpf,fanotify_init,io_cancel,io_destroy,io_getevents,io_setup,io_submit,ioprio_set,keyctl,mbind,migrate_pages,move_pages,name_to_handle_at,nfsservctl,open_by_handle_at,remap_file_pages,request_key,set_mempolicy,setdomainname,sethostname,syslog,userfaultfd,vhangup,vmsplice -@default-keep=arch_prctl,execv,execve,execveat,exit,futex,mmap,mmap2,mprotect,prctl +@default-keep=arch_prctl,clock_getres,clock_getres_time64,clock_gettime,clock_gettime64,clock_nanosleep,clock_nanosleep_time64,execv,execve,execveat,exit,futex,gettimeofday,mmap,mmap2,mprotect,osf_gettimeofday,prctl,time @default-nodebuggers=@default,personality,process_vm_readv,ptrace @file-system=access,cachestat,chdir,chmod,close,close_range,creat,faccessat,faccessat2,fallocate,fanotify_mark,fchdir,fchmod,fchmodat,fchmodat2,fcntl,fcntl64,fgetxattr,file_getattr,file_setattr,flistxattr,fremovexattr,fsetxattr,fstat,fstat64,fstatat64,fstatfs,fstatfs64,ftruncate,ftruncate64,futimesat,getcwd,getdents,getdents64,getxattr,getxattrat,inotify_add_watch,inotify_init,inotify_init1,inotify_rm_watch,lgetxattr,link,linkat,listxattr,listxattrat,llistxattr,lremovexattr,lsetxattr,lstat,lstat64,mkdir,mkdirat,mknod,mknodat,munmap,newfstatat,oldfstat,oldlstat,oldstat,open,openat,openat2,osf_fstat,osf_fstatfs,osf_fstatfs64,osf_getdirentries,osf_lstat,osf_proplist_syscall,osf_utimes,quotactl_fd,readlink,readlinkat,removexattr,removexattrat,rename,renameat,renameat2,rmdir,setxattr,setxattrat,stat,stat64,statfs,statfs64,statx,symlink,symlinkat,truncate,truncate64,unlink,unlinkat,utime,utimensat,utimes @io-event=_newselect,epoll_create,epoll_create1,epoll_ctl,epoll_pwait,epoll_pwait2,epoll_wait,eventfd,eventfd2,osf_select,poll,ppoll,ppoll_time64,pselect6,pselect6_time64,select @@ -44,7 +44,7 @@ Definition of groups @module=delete_module,finit_module,init_module @mount=chroot,fsconfig,fsmount,fsopen,fspick,listmount,mount,mount_setattr,move_mount,oldumount,open_tree,open_tree_attr,osf_mount,pivot_root,statmount,umount,umount2 @network-io=accept,accept4,bind,connect,getpeername,getsockname,getsockopt,listen,recv,recvfrom,recvmmsg,recvmmsg_time64,recvmsg,send,sendmmsg,sendmsg,sendto,setsockopt,shutdown,socket,socketcall,socketpair -@obsolete=_sysctl,afs_syscall,bdflush,break,create_module,dipc,epoll_ctl_old,epoll_wait_old,exec_with_loader,ftime,get_kernel_syms,getpmsg,gtty,idle,llseek,lock,mpx,multiplexer,osf_adjtime,osf_afs_syscall,osf_alt_plock,osf_alt_setsid,osf_alt_sigpending,osf_asynch_daemon,osf_audcntl,osf_audgen,osf_chflags,osf_execve,osf_exportfs,osf_fchflags,osf_fdatasync,osf_fpathconf,osf_fuser,osf_getaddressconf,osf_getfh,osf_getfsstat,osf_gethostid,osf_getlogin,osf_getmnt,osf_kloadcall,osf_kmodcall,osf_memcntl,osf_mincore,osf_mremap,osf_msfs_syscall,osf_msleep,osf_mvalid,osf_mwakeup,osf_naccept,osf_nfssvc,osf_ngetpeername,osf_ngetsockname,osf_nrecvfrom,osf_nrecvmsg,osf_nsendmsg,osf_ntp_adjtime,osf_ntp_gettime,osf_old_creat,osf_old_fstat,osf_old_getpgrp,osf_old_killpg,osf_old_lstat,osf_old_open,osf_old_sigaction,osf_old_sigblock,osf_old_sigreturn,osf_old_sigsetmask,osf_old_sigvec,osf_old_stat,osf_old_vadvise,osf_old_vtrace,osf_old_wait,osf_oldquota,osf_pathconf,osf_pid_block,osf_pid_unblock,osf_plock,osf_priocntlset,osf_profil,osf_reboot,osf_revoke,osf_sbrk,osf_security,osf_set_speculative,osf_sethostid,osf_setlogin,osf_signal,osf_sigsendset,osf_sigwaitprim,osf_sstk,osf_stat,osf_statfs,osf_statfs64,osf_subsys_info,osf_swapctl,osf_table,osf_uadmin,osf_uswitch,osf_utc_adjtime,osf_utc_gettime,osf_waitid,perfctr,prof,profil,putpmsg,query_module,security,sgetmask,spill,ssetmask,stty,sysfs,timerfd,tuxcall,ulimit,uselib,ustat,vserver,xtensa +@obsolete=_sysctl,afs_syscall,bdflush,break,create_module,dipc,epoll_ctl_old,epoll_wait_old,exec_with_loader,ftime,get_kernel_syms,getpmsg,gtty,idle,llseek,lock,mpx,multiplexer,osf_adjtime,osf_afs_syscall,osf_alt_plock,osf_alt_setsid,osf_alt_sigpending,osf_asynch_daemon,osf_audcntl,osf_audgen,osf_chflags,osf_execve,osf_exportfs,osf_fchflags,osf_fdatasync,osf_fpathconf,osf_fuser,osf_getaddressconf,osf_getfh,osf_getfsstat,osf_gethostid,osf_getlogin,osf_getmnt,osf_kloadcall,osf_kmodcall,osf_memcntl,osf_mincore,osf_mremap,osf_msfs_syscall,osf_msleep,osf_mvalid,osf_mwakeup,osf_naccept,osf_nfssvc,osf_ngetpeername,osf_ngetsockname,osf_nrecvfrom,osf_nrecvmsg,osf_nsendmsg,osf_ntp_adjtime,osf_ntp_gettime,osf_old_creat,osf_old_fstat,osf_old_getpgrp,osf_old_killpg,osf_old_lstat,osf_old_open,osf_old_sigaction,osf_old_sigblock,osf_old_sigreturn,osf_old_sigsetmask,osf_old_sigvec,osf_old_stat,osf_old_vadvise,osf_old_vtrace,osf_old_wait,osf_oldquota,osf_pathconf,osf_pid_block,osf_pid_unblock,osf_plock,osf_priocntlset,osf_profil,osf_reboot,osf_revoke,osf_sbrk,osf_security,osf_set_speculative,osf_sethostid,osf_setlogin,osf_signal,osf_sigsendset,osf_sigwaitprim,osf_sstk,osf_stat,osf_statfs,osf_statfs64,osf_subsys_info,osf_swapctl,osf_table,osf_uadmin,osf_uswitch,osf_utc_adjtime,osf_utc_gettime,osf_waitid,perfctr,prof,profil,putpmsg,query_module,security,sgetmask,spill,ssetmask,stime,stty,sysfs,timerfd,tuxcall,ulimit,uselib,ustat,vserver,xtensa @privileged=@chown,@clock,@module,@raw-io,@reboot,@swap,_sysctl,acct,bpf,capset,chroot,fanotify_init,mount,nfsservctl,open_by_handle_at,pivot_root,quotactl,setdomainname,setfsuid,setfsuid32,setgroups,setgroups32,sethostname,setresuid,setresuid32,setreuid,setreuid32,setuid,setuid32,umount2,vhangup @process=arc_gettls,arc_settls,arc_usr_cmpxchg,atomic_barrier,atomic_cmpxchg_32,cachectl,cacheflush,capget,clone,clone3,exit_group,fork,futex_requeue,futex_time64,futex_wait,futex_waitv,futex_wake,get_robust_list,get_thread_area,getegid,getegid32,geteuid,geteuid32,getgid,getgid32,getgroups,getgroups32,getpgid,getpgrp,getpid,getppid,getresgid,getresgid32,getresuid,getresuid32,getsid,gettid,getuid,getuid32,getxgid,getxpid,getxuid,kill,membarrier,or1k_atomic,osf_set_program_attributes,osf_wait4,pidfd_open,pidfd_send_signal,riscv_flush_icache,rseq,rt_sigqueueinfo,rt_tgsigqueueinfo,s390_guarded_storage,sched_get_affinity,set_robust_list,set_thread_area,set_tid_address,sethae,setns,setpgrp,setpriority,spu_create,spu_run,swapcontext,tgkill,times,tkill,unshare,utimensat_time64,vfork,wait4,waitid,waitpid @raw-io=ioperm,iopl,pciconfig_iobase,pciconfig_read,pciconfig_write,s390_pci_mmio_read,s390_pci_mmio_write diff --git a/src/lib/syscall.c b/src/lib/syscall.c index b50580ea9..6ef5f734f 100644 --- a/src/lib/syscall.c +++ b/src/lib/syscall.c @@ -253,51 +253,21 @@ static const SyscallGroupList sysgroups[] = { #ifdef SYS_clock_adjtime64 "clock_adjtime64," #endif -#ifdef SYS_clock_getres - "clock_getres," -#endif - //groupfix: #ifdef SYS_clock_getres_time64 - //groupfix: "clock_getres_time64," - //groupfix: #endif - //groupfix: #ifdef SYS_clock_gettime - //groupfix: "clock_gettime," - //groupfix: #endif - //groupfix: #ifdef SYS_clock_gettime64 - //groupfix: "clock_gettime64," - //groupfix: #endif - //groupfix: #ifdef SYS_clock_nanosleep - //groupfix: "clock_nanosleep," - //groupfix: #endif - //groupfix: #ifdef SYS_clock_nanosleep_time64 - //groupfix: "clock_nanosleep_time64," - //groupfix: #endif #ifdef SYS_clock_settime "clock_settime," #endif #ifdef SYS_clock_settime64 "clock_settime64," #endif - //groupfix: #ifdef SYS_gettimeofday - //groupfix: "gettimeofday," - //groupfix: #endif #ifdef SYS_old_adjtimex "old_adjtimex," #endif - //groupfix: #ifdef SYS_osf_gettimeofday - //groupfix: "osf_gettimeofday," - //groupfix: #endif #ifdef SYS_osf_settimeofday "osf_settimeofday," #endif #ifdef SYS_settimeofday - "settimeofday," + "settimeofday" #endif -#ifdef SYS_stime - "stime," -#endif - //groupfix: #ifdef SYS_time - //groupfix: "time" - //groupfix: #endif }, { .name = "@cpu-emulation", .list = #ifdef SYS_modify_ldt @@ -441,6 +411,18 @@ static const SyscallGroupList sysgroups[] = { { .name = "@default-keep", .list = #ifdef SYS_arch_prctl "arch_prctl," // breaks glibc, i386 and x86_64 only +#endif + "clock_getres," // clokc_getres*, stop programs that try to read theoretical resolution +#ifdef SYS_clock_getres_time64 + "clock_getres_time64," +#endif + "clock_gettime," // clokc_gettime*, *gettimeofday and time, stop programs that try to read time +#ifdef SYS_clock_gettime64 + "clock_gettime64," +#endif + "clock_nanosleep," // clock_nanosleep*, stop programs that try to use sleep functions +#ifdef SYS_clock_nanosleep_time64 + "clock_nanosleep_time64," #endif #ifdef SYS_execv "execv," // sparc only @@ -449,6 +431,7 @@ static const SyscallGroupList sysgroups[] = { "execveat," // commonly used by fexecve "exit," // breaks most Qt applications "futex," // frequently used and causes breakages + "gettimeofday," #ifdef SYS_mmap "mmap," // cannot load shared libraries #endif @@ -456,7 +439,13 @@ static const SyscallGroupList sysgroups[] = { "mmap2," #endif "mprotect," // cannot load shared libraries - "prctl" +#ifdef SYS_osf_gettimeofday + "osf_gettimeofday," +#endif + "prctl," +#ifdef SYS_time + "time" +#endif }, { .name = "@default-nodebuggers", .list = "@default," @@ -1389,6 +1378,9 @@ static const SyscallGroupList sysgroups[] = { #ifdef SYS_ssetmask "ssetmask," #endif +#ifdef SYS_stime + "stime," +#endif #ifdef SYS_stty "stty," #endif