about summary refs log tree commit diff
path: root/sysdeps/unix/sysv
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-02-21 08:32:32 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-05-16 15:03:49 -0300
commitb46d250656794e63a2946c481fda29271342dd1a (patch)
treec2e056aa6ae5eb18f79a356b4bbd2f645446291c /sysdeps/unix/sysv
parent97a912f7a832a662960749948049e15f3aecb2a7 (diff)
downloadglibc-b46d250656794e63a2946c481fda29271342dd1a.tar.gz
glibc-b46d250656794e63a2946c481fda29271342dd1a.tar.xz
glibc-b46d250656794e63a2946c481fda29271342dd1a.zip
Remove kernel version check
The kernel version check is used to avoid glibc to run on older
kernels where some syscall are not available and fallback code are
not enabled to handle graciously fail.  However, it does not prevent
if the kernel does not correctly advertise its version through
vDSO note, uname or procfs.

Also kernel version checks are sometime not desirable by users,
where they want to deploy on different system with different kernel
version knowing the minimum set of syscall is always presented on
such systems.

The kernel version check has been removed along with the
LD_ASSUME_KERNEL environment variable.  The minimum kernel used to
built glibc is still provided through NT_GNU_ABI_TAG ELF note and
also printed when libc.so is issued.

Checked on x86_64-linux-gnu.
Diffstat (limited to 'sysdeps/unix/sysv')
-rw-r--r--sysdeps/unix/sysv/linux/configure5
-rw-r--r--sysdeps/unix/sysv/linux/configure.ac2
-rw-r--r--sysdeps/unix/sysv/linux/dl-librecon.h59
-rw-r--r--sysdeps/unix/sysv/linux/dl-osinfo.h25
-rw-r--r--sysdeps/unix/sysv/linux/dl-sysdep.c93
-rw-r--r--sysdeps/unix/sysv/linux/dl-sysdep.h7
-rw-r--r--sysdeps/unix/sysv/linux/i386/dl-librecon.h2
7 files changed, 7 insertions, 186 deletions
diff --git a/sysdeps/unix/sysv/linux/configure b/sysdeps/unix/sysv/linux/configure
index 4ff02c9b6d..312055c469 100644
--- a/sysdeps/unix/sysv/linux/configure
+++ b/sysdeps/unix/sysv/linux/configure
@@ -70,6 +70,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kernel header at least $minimum_kernel" >&5
 $as_echo_n "checking for kernel header at least $minimum_kernel... " >&6; }
 decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
+abinumstr=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1.\2.\3/'`;
 abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -99,6 +100,10 @@ if test "$libc_minimum_kernel" = ok; then
 _ACEOF
 
   cat >>confdefs.h <<_ACEOF
+#define __LINUX_KERNEL_VERSION_STR "$abinumstr"
+_ACEOF
+
+  cat >>confdefs.h <<_ACEOF
 #define __ABI_TAG_VERSION $abinum
 _ACEOF
 
diff --git a/sysdeps/unix/sysv/linux/configure.ac b/sysdeps/unix/sysv/linux/configure.ac
index 197b7e66c8..5896d1135b 100644
--- a/sysdeps/unix/sysv/linux/configure.ac
+++ b/sysdeps/unix/sysv/linux/configure.ac
@@ -50,6 +50,7 @@ fi
 AC_MSG_CHECKING(for kernel header at least $minimum_kernel)
 changequote(,)dnl
 decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
+abinumstr=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1.\2.\3/'`;
 abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
 changequote([,])dnl
 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[#include <linux/version.h>
@@ -59,6 +60,7 @@ AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[#include <linux/version.h>
 AC_MSG_RESULT($libc_minimum_kernel)
 if test "$libc_minimum_kernel" = ok; then
   AC_DEFINE_UNQUOTED(__LINUX_KERNEL_VERSION, $decnum)
+  AC_DEFINE_UNQUOTED(__LINUX_KERNEL_VERSION_STR, "$abinumstr")
   AC_DEFINE_UNQUOTED(__ABI_TAG_VERSION, $abinum)
 else
   AC_MSG_ERROR([*** The available kernel headers are older than the requested
diff --git a/sysdeps/unix/sysv/linux/dl-librecon.h b/sysdeps/unix/sysv/linux/dl-librecon.h
deleted file mode 100644
index dfebcea4d8..0000000000
--- a/sysdeps/unix/sysv/linux/dl-librecon.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Optional code to distinguish library flavours.
-   Copyright (C) 2001-2022 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
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef _DL_LIBRECON_H
-#define _DL_LIBRECON_H	1
-
-static inline void __attribute__ ((unused, always_inline))
-_dl_osversion_init (char *assume_kernel)
-{
-  unsigned long int i, j, osversion = 0;
-  char *p = assume_kernel, *q;
-
-  for (i = 0; i < 3; i++, p = q + 1)
-    {
-      j = _dl_strtoul (p, &q);
-      if (j >= 255 || p == q || (i < 2 && *q && *q != '.'))
-	{
-	  osversion = 0;
-	  break;
-	}
-      osversion |= j << (16 - 8 * i);
-      if (!*q)
-	break;
-    }
-  if (osversion)
-    GLRO(dl_osversion) = osversion;
-}
-
-/* Recognizing extra environment variables.  */
-#define EXTRA_LD_ENVVARS_13 \
-    if (memcmp (envline, "ASSUME_KERNEL", 13) == 0)			      \
-      {									      \
-	_dl_osversion_init (&envline[14]);				      \
-	break;								      \
-      }
-
-#define DL_OSVERSION_INIT \
-  do {									      \
-    char *assume_kernel = getenv ("LD_ASSUME_KERNEL");			      \
-    if (assume_kernel)							      \
-      _dl_osversion_init (assume_kernel);				      \
-  } while (0)
-
-#endif /* dl-librecon.h */
diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h
index 349d93e8ed..7888915f12 100644
--- a/sysdeps/unix/sysv/linux/dl-osinfo.h
+++ b/sysdeps/unix/sysv/linux/dl-osinfo.h
@@ -22,31 +22,6 @@
 #include <stdint.h>
 #include <not-cancel.h>
 
-#ifndef MIN
-# define MIN(a,b) (((a)<(b))?(a):(b))
-#endif
-
-#define DL_SYSDEP_OSCHECK(FATAL)					      \
-  do {									      \
-    /* Test whether the kernel is new enough.  This test is only performed    \
-       if the library is not compiled to run on all kernels.  */	      \
-									      \
-    int version = _dl_discover_osversion ();				      \
-    if (__glibc_likely (version >= 0))					      \
-      {									      \
-	if (__builtin_expect (GLRO(dl_osversion) == 0, 1)		      \
-	    || GLRO(dl_osversion) > version)				      \
-	  GLRO(dl_osversion) = version;					      \
-									      \
-	/* Now we can test with the required version.  */		      \
-	if (__LINUX_KERNEL_VERSION > 0 && version < __LINUX_KERNEL_VERSION)   \
-	  /* Not sufficent.  */						      \
-	  FATAL ("FATAL: kernel too old\n");				      \
-      }									      \
-    else if (__LINUX_KERNEL_VERSION > 0)				      \
-      FATAL ("FATAL: cannot determine kernel version\n");		      \
-  } while (0)
-
 static inline uintptr_t __attribute__ ((always_inline))
 _dl_setup_stack_chk_guard (void *dl_random)
 {
diff --git a/sysdeps/unix/sysv/linux/dl-sysdep.c b/sysdeps/unix/sysv/linux/dl-sysdep.c
index a67c454673..9e15c5bf69 100644
--- a/sysdeps/unix/sysv/linux/dl-sysdep.c
+++ b/sysdeps/unix/sysv/linux/dl-sysdep.c
@@ -250,96 +250,3 @@ _dl_show_auxv (void)
 }
 
 #endif /* SHARED */
-
-
-int
-attribute_hidden
-_dl_discover_osversion (void)
-{
-#ifdef SHARED
-  if (GLRO(dl_sysinfo_map) != NULL)
-    {
-      /* If the kernel-supplied DSO contains a note indicating the kernel's
-	 version, we don't need to call uname or parse any strings.  */
-
-      static const struct
-      {
-	ElfW(Nhdr) hdr;
-	char vendor[8];
-      } expected_note = { { sizeof "Linux", sizeof (ElfW(Word)), 0 }, "Linux" };
-      const ElfW(Phdr) *const phdr = GLRO(dl_sysinfo_map)->l_phdr;
-      const ElfW(Word) phnum = GLRO(dl_sysinfo_map)->l_phnum;
-      for (unsigned int i = 0; i < phnum; ++i)
-	if (phdr[i].p_type == PT_NOTE)
-	  {
-	    const ElfW(Addr) start = (phdr[i].p_vaddr
-				      + GLRO(dl_sysinfo_map)->l_addr);
-	    const ElfW(Nhdr) *note = (const void *) start;
-	    while ((ElfW(Addr)) (note + 1) - start < phdr[i].p_memsz)
-	      {
-		if (!memcmp (note, &expected_note, sizeof expected_note))
-		  return *(const ElfW(Word) *) ((const void *) note
-						+ sizeof expected_note);
-#define ROUND(len) (((len) + sizeof note->n_type - 1) & -sizeof note->n_type)
-		note = ((const void *) (note + 1)
-			+ ROUND (note->n_namesz) + ROUND (note->n_descsz));
-#undef ROUND
-	      }
-	  }
-    }
-#endif /* SHARED */
-
-  char bufmem[64];
-  char *buf = bufmem;
-  unsigned int version;
-  int parts;
-  char *cp;
-  struct utsname uts;
-
-  /* Try the uname system call.  */
-  if (__uname (&uts))
-    {
-      /* This was not successful.  Now try reading the /proc filesystem.  */
-      int fd = __open64_nocancel ("/proc/sys/kernel/osrelease", O_RDONLY);
-      if (fd < 0)
-	return -1;
-      ssize_t reslen = __read_nocancel (fd, bufmem, sizeof (bufmem));
-      __close_nocancel (fd);
-      if (reslen <= 0)
-	/* This also didn't work.  We give up since we cannot
-	   make sure the library can actually work.  */
-	return -1;
-      buf[MIN (reslen, (ssize_t) sizeof (bufmem) - 1)] = '\0';
-    }
-  else
-    buf = uts.release;
-
-  /* Now convert it into a number.  The string consists of at most
-     three parts.  */
-  version = 0;
-  parts = 0;
-  cp = buf;
-  while ((*cp >= '0') && (*cp <= '9'))
-    {
-      unsigned int here = *cp++ - '0';
-
-      while ((*cp >= '0') && (*cp <= '9'))
-	{
-	  here *= 10;
-	  here += *cp++ - '0';
-	}
-
-      ++parts;
-      version <<= 8;
-      version |= here;
-
-      if (*cp++ != '.' || parts == 3)
-	/* Another part following?  */
-	break;
-    }
-
-  if (parts < 3)
-    version <<= 8 * (3 - parts);
-
-  return version;
-}
diff --git a/sysdeps/unix/sysv/linux/dl-sysdep.h b/sysdeps/unix/sysv/linux/dl-sysdep.h
index cb8bf7e6b1..b3ae5cb637 100644
--- a/sysdeps/unix/sysv/linux/dl-sysdep.h
+++ b/sysdeps/unix/sysv/linux/dl-sysdep.h
@@ -24,10 +24,3 @@
    we aren't making direct use of it.  So enable this across the board.  */
 
 #define NEED_DL_SYSINFO_DSO	1
-
-
-#ifndef __ASSEMBLER__
-/* Get version of the OS.  */
-extern int _dl_discover_osversion (void) attribute_hidden;
-# define HAVE_DL_DISCOVER_OSVERSION	1
-#endif
diff --git a/sysdeps/unix/sysv/linux/i386/dl-librecon.h b/sysdeps/unix/sysv/linux/i386/dl-librecon.h
index 7882679f20..78e3f0d02d 100644
--- a/sysdeps/unix/sysv/linux/i386/dl-librecon.h
+++ b/sysdeps/unix/sysv/linux/i386/dl-librecon.h
@@ -18,8 +18,6 @@
 
 #ifndef _DL_LIBRECON_H
 
-#include <sysdeps/unix/sysv/linux/dl-librecon.h>
-
 #define DISTINGUISH_LIB_VERSIONS \
   do									      \
     {									      \