From 076f09afbac1aa57756faa7a8feadb7936a724e4 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 15 Apr 2020 17:17:32 +0200 Subject: Linux: Remove and the sysctl function Linux 5.5 remove the system call in commit 61a47c1ad3a4dc6882f01ebdc88138ac62d0df03 ("Linux: Remove "). Therefore, the compat function is just a stub that sets ENOSYS. Due to SHLIB_COMPAT, new ports will not add the sysctl function anymore automatically. x32 already lacks the sysctl function, so an empty sysctl.c file is used to suppress it. Otherwise, a new compat symbol would be added. Reviewed-by: Adhemerval Zanella --- sysdeps/unix/sysv/linux/Makefile | 8 +-- sysdeps/unix/sysv/linux/Versions | 2 + sysdeps/unix/sysv/linux/bits/sysctl.h | 1 - sysdeps/unix/sysv/linux/generic/sysctl.c | 32 --------- sysdeps/unix/sysv/linux/microblaze/sysctl.c | 29 +++++++++ .../unix/sysv/linux/powerpc/powerpc64/le/sysctl.c | 29 +++++++++ sysdeps/unix/sysv/linux/sys/sysctl.h | 76 ---------------------- sysdeps/unix/sysv/linux/sysctl.c | 35 +++++----- sysdeps/unix/sysv/linux/sysctl.mk | 3 - sysdeps/unix/sysv/linux/x86/bits/sysctl.h | 20 ------ sysdeps/unix/sysv/linux/x86_64/x32/sysctl.c | 2 + sysdeps/unix/sysv/linux/x86_64/x32/sysctl.mk | 1 - 12 files changed, 80 insertions(+), 158 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/bits/sysctl.h delete mode 100644 sysdeps/unix/sysv/linux/generic/sysctl.c create mode 100644 sysdeps/unix/sysv/linux/microblaze/sysctl.c create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/le/sysctl.c delete mode 100644 sysdeps/unix/sysv/linux/sys/sysctl.h delete mode 100644 sysdeps/unix/sysv/linux/sysctl.mk delete mode 100644 sysdeps/unix/sysv/linux/x86/bits/sysctl.h create mode 100644 sysdeps/unix/sysv/linux/x86_64/x32/sysctl.c delete mode 100644 sysdeps/unix/sysv/linux/x86_64/x32/sysctl.mk (limited to 'sysdeps/unix/sysv/linux') diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 60dc5cf9e5..089a4899d5 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -54,9 +54,7 @@ CFLAGS-malloc.c += -DMORECORE_CLEARS=2 endif ifeq ($(subdir),misc) -include $(firstword $(wildcard $(sysdirs:=/sysctl.mk))) - -sysdep_routines += adjtimex clone umount umount2 readahead \ +sysdep_routines += adjtimex clone umount umount2 readahead sysctl \ setfsuid setfsgid epoll_pwait signalfd \ eventfd eventfd_read eventfd_write prlimit \ personality epoll_wait tee vmsplice splice \ @@ -71,7 +69,7 @@ CFLAGS-open_by_handle_at.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-sync_file_range.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-tst-writev.c += "-DARTIFICIAL_LIMIT=(0x80000000-sysconf(_SC_PAGESIZE))" -sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \ +sysdep_headers += sys/mount.h sys/acct.h \ sys/klog.h \ sys/user.h sys/prctl.h \ sys/kd.h sys/soundcard.h sys/vt.h \ @@ -81,7 +79,7 @@ sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \ bits/a.out.h sys/inotify.h sys/signalfd.h sys/eventfd.h \ sys/timerfd.h sys/fanotify.h bits/eventfd.h bits/inotify.h \ bits/signalfd.h bits/timerfd.h bits/epoll.h \ - bits/socket_type.h bits/syscall.h bits/sysctl.h \ + bits/socket_type.h bits/syscall.h \ bits/mman-linux.h bits/mman-shared.h bits/ptrace-shared.h \ bits/siginfo-arch.h bits/siginfo-consts-arch.h \ bits/procfs.h bits/procfs-id.h bits/procfs-extra.h \ diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index d385085c61..9a58dda9f2 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -177,6 +177,8 @@ libc { GLIBC_2.30 { getdents64; gettid; tgkill; } + GLIBC_2.32 { + } GLIBC_PRIVATE { # functions used in other libraries __syscall_rt_sigqueueinfo; diff --git a/sysdeps/unix/sysv/linux/bits/sysctl.h b/sysdeps/unix/sysv/linux/bits/sysctl.h deleted file mode 100644 index 81447b2f74..0000000000 --- a/sysdeps/unix/sysv/linux/bits/sysctl.h +++ /dev/null @@ -1 +0,0 @@ -/* Empty file. */ diff --git a/sysdeps/unix/sysv/linux/generic/sysctl.c b/sysdeps/unix/sysv/linux/generic/sysctl.c deleted file mode 100644 index e7d5a3cf93..0000000000 --- a/sysdeps/unix/sysv/linux/generic/sysctl.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 2011-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Chris Metcalf , 2011. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include - -#include -#include - -/* This deprecated syscall is no longer used (replaced with /proc/sys). */ -int -sysctl (int *name, int nlen, void *oldval, size_t *oldlenp, - void *newval, size_t newlen) -{ - __set_errno (ENOSYS); - return -1; -} -stub_warning (sysctl) diff --git a/sysdeps/unix/sysv/linux/microblaze/sysctl.c b/sysdeps/unix/sysv/linux/microblaze/sysctl.c new file mode 100644 index 0000000000..d35dd8ef1e --- /dev/null +++ b/sysdeps/unix/sysv/linux/microblaze/sysctl.c @@ -0,0 +1,29 @@ +/* sysctl function stub. microblaze version. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* microblaze is special because it has an ABI baseline of 2.18, but + still includes the __sysctl symbol. */ + +#ifdef SHARED + +# include + +strong_alias (___sysctl, ___sysctl2) +compat_symbol (libc, ___sysctl2, __sysctl, GLIBC_2_2); + +#endif diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/sysctl.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/sysctl.c new file mode 100644 index 0000000000..25203e4aa4 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/sysctl.c @@ -0,0 +1,29 @@ +/* sysctl function stub. powerpc64le version. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* powerpc64le is special because it has an ABI baseline of 2.17, but + still includes the __sysctl symbol. */ + +#ifdef SHARED + +# include + +strong_alias (___sysctl, ___sysctl2) +compat_symbol (libc, ___sysctl2, __sysctl, GLIBC_2_2); + +#endif diff --git a/sysdeps/unix/sysv/linux/sys/sysctl.h b/sysdeps/unix/sysv/linux/sys/sysctl.h deleted file mode 100644 index 1ead597244..0000000000 --- a/sysdeps/unix/sysv/linux/sys/sysctl.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (C) 1996-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#ifndef _SYS_SYSCTL_H -#define _SYS_SYSCTL_H 1 - -#warning "The header is deprecated and will be removed." - -#include -#define __need_size_t -#include -/* Prevent more kernel headers than necessary to be included. */ -#ifndef _LINUX_KERNEL_H -# define _LINUX_KERNEL_H 1 -# define __undef_LINUX_KERNEL_H -#endif -#ifndef _LINUX_TYPES_H -# define _LINUX_TYPES_H 1 -# define __undef_LINUX_TYPES_H -#endif -#ifndef _LINUX_LIST_H -# define _LINUX_LIST_H 1 -# define __undef_LINUX_LIST_H -#endif -#ifndef __LINUX_COMPILER_H -# define __LINUX_COMPILER_H 1 -# define __user -# define __undef__LINUX_COMPILER_H -#endif - -#include - -#ifdef __undef_LINUX_KERNEL_H -# undef _LINUX_KERNEL_H -# undef __undef_LINUX_KERNEL_H -#endif -#ifdef __undef_LINUX_TYPES_H -# undef _LINUX_TYPES_H -# undef __undef_LINUX_TYPES_H -#endif -#ifdef __undef_LINUX_LIST_H -# undef _LINUX_LIST_H -# undef __undef_LINUX_LIST_H -#endif -#ifdef __undef__LINUX_COMPILER_H -# undef __LINUX_COMPILER_H -# undef __user -# undef __undef__LINUX_COMPILER_H -#endif - -#include - -__BEGIN_DECLS - -/* Read or write system parameters. */ -extern int sysctl (int *__name, int __nlen, void *__oldval, - size_t *__oldlenp, void *__newval, size_t __newlen) __THROW - __attribute_deprecated__; - -__END_DECLS - -#endif /* _SYS_SYSCTL_H */ diff --git a/sysdeps/unix/sysv/linux/sysctl.c b/sysdeps/unix/sysv/linux/sysctl.c index 5ea8be8da1..389b958226 100644 --- a/sysdeps/unix/sysv/linux/sysctl.c +++ b/sysdeps/unix/sysv/linux/sysctl.c @@ -1,4 +1,4 @@ -/* Read or write system information. Linux version. +/* sysctl function stub. Copyright (C) 1996-2020 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -17,25 +17,20 @@ . */ #include -#include +#include -#include -#include - -int -__sysctl (int *name, int nlen, void *oldval, size_t *oldlenp, - void *newval, size_t newlen) +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_32) +int attribute_compat_text_section +___sysctl (int *name, int nlen, void *oldval, size_t *oldlenp, + void *newval, size_t newlen) { - struct __sysctl_args args = - { - .name = name, - .nlen = nlen, - .oldval = oldval, - .oldlenp = oldlenp, - .newval = newval, - .newlen = newlen - }; - - return INLINE_SYSCALL (_sysctl, 1, &args); + __set_errno (ENOSYS); + return -1; } -weak_alias (__sysctl, sysctl) +compat_symbol (libc, ___sysctl, sysctl, GLIBC_2_0); + +# if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_17) +strong_alias (___sysctl, ___sysctl2) +compat_symbol (libc, ___sysctl2, __sysctl, GLIBC_2_2); +# endif +#endif diff --git a/sysdeps/unix/sysv/linux/sysctl.mk b/sysdeps/unix/sysv/linux/sysctl.mk deleted file mode 100644 index 8d04d12e25..0000000000 --- a/sysdeps/unix/sysv/linux/sysctl.mk +++ /dev/null @@ -1,3 +0,0 @@ -# sysctl system call has been deprecated. It is provided for backward -# compatility. New target shouldn't add it (see x86_64/x32/sysctl.mk). -sysdep_routines += sysctl diff --git a/sysdeps/unix/sysv/linux/x86/bits/sysctl.h b/sysdeps/unix/sysv/linux/x86/bits/sysctl.h deleted file mode 100644 index 873a2af109..0000000000 --- a/sysdeps/unix/sysv/linux/x86/bits/sysctl.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (C) 2012-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#if defined __x86_64__ && defined __ILP32__ -# error "sysctl system call is unsupported in x32 kernel" -#endif diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/sysctl.c b/sysdeps/unix/sysv/linux/x86_64/x32/sysctl.c new file mode 100644 index 0000000000..88f2f741cf --- /dev/null +++ b/sysdeps/unix/sysv/linux/x86_64/x32/sysctl.c @@ -0,0 +1,2 @@ +/* Despite the old base symbol version, x32 does not have a sysctl + function. */ diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/sysctl.mk b/sysdeps/unix/sysv/linux/x86_64/x32/sysctl.mk deleted file mode 100644 index da018fe624..0000000000 --- a/sysdeps/unix/sysv/linux/x86_64/x32/sysctl.mk +++ /dev/null @@ -1 +0,0 @@ -# X32 doesn't support sysctl. -- cgit 1.4.1