[PATCH 1/2] Remove kernel version check
Adhemerval Zanella
adhemerval.zanella@linaro.org
Fri Mar 4 12:42:28 GMT 2022
On 28/02/2022 16:00, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
>
>> 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.
>
> Missing Linux: prefix in the commit subject, I would.
>
>> diff --git a/NEWS b/NEWS
>> index 626eeabf5d..bbbcc55b0c 100644
>> --- a/NEWS
>> +++ b/NEWS
>> @@ -17,6 +17,11 @@ Deprecated and removed features, and other changes affecting compatibility:
>> removal of the LD_TRACE_PRELINKING, and LD_USE_LOAD_BIAS, environment
>> variables and their functionality in the dynamic loader.
>>
>> +* 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 directly.
>
> Mention “Linux” here?
I changed to "The Linux kernel version check ..."
>
>> index 892e8ef2f6..ba175a0035 100644
>> --- a/elf/dl-load.c
>> +++ b/elf/dl-load.c
>> @@ -1631,7 +1631,6 @@ open_verify (const char *name, int fd,
>> ElfW(Phdr) *phdr, *ph;
>> ElfW(Word) *abi_note;
>> ElfW(Word) *abi_note_malloced = NULL;
>> - unsigned int osversion;
>> size_t maplength;
>>
>> /* We successfully opened the file. Now verify it is a file
>> @@ -1695,13 +1694,16 @@ open_verify (const char *name, int fd,
>> #endif
>> )
>> errstring = N_("invalid ELF header");
>> +
>> else if (ehdr->e_ident[EI_CLASS] != ELFW(CLASS))
>> {
>> /* This is not a fatal error. On architectures where
>> 32-bit and 64-bit binaries can be run this might
>> happen. */
>> *found_other_class = true;
>> - goto close_and_out;
>> + __close_nocancel (fd);
>> + __set_errno (ENOENT);
>> + return -1;
>> }
>> else if (ehdr->e_ident[EI_DATA] != byteorder)
>> {
>> @@ -1736,7 +1738,11 @@ open_verify (const char *name, int fd,
>> goto lose;
>> }
>> if (! __glibc_likely (elf_machine_matches_host (ehdr)))
>> - goto close_and_out;
>> + {
>> + __close_nocancel (fd);
>> + __set_errno (ENOENT);
>> + return -1;
>> + }
>> else if (__glibc_unlikely (ehdr->e_type != ET_DYN
>> && ehdr->e_type != ET_EXEC))
>> {
>> @@ -1768,7 +1774,11 @@ open_verify (const char *name, int fd,
>> if (__glibc_unlikely (elf_machine_reject_phdr_p
>> (phdr, ehdr->e_phnum, fbp->buf, fbp->len,
>> loader, fd)))
>> - goto close_and_out;
>> + {
>> + __close_nocancel (fd);
>> + __set_errno (ENOENT);
>> + return -1;
>> + }
>>
>> /* Check .note.ABI-tag if present. */
>> for (ph = phdr; ph < &phdr[ehdr->e_phnum]; ++ph)
>> @@ -1820,18 +1830,6 @@ open_verify (const char *name, int fd,
>> if (size == 0)
>> continue;
>>
>> - osversion = (abi_note[5] & 0xff) * 65536
>> - + (abi_note[6] & 0xff) * 256
>> - + (abi_note[7] & 0xff);
>> - if (abi_note[4] != __ABI_TAG_OS
>> - || (GLRO(dl_osversion) && GLRO(dl_osversion) < osversion))
>> - {
>> - close_and_out:
>> - __close_nocancel (fd);
>> - __set_errno (ENOENT);
>> - fd = -1;
>> - }
>> -
>> break;
>> }
>> free (abi_note_malloced);
>
> Hmm. I think you can delete the entire program header loop now?
> Nothing reads abi_note after these changes.
Indeed, I will removed it as well.
>
> And there's now an unused
>
> unsigned int _dl_osversion;
>
> in elf/dl-support.c.
Ack.
>
> I assume you want to handle the ldconfig changes separately? I think we
> discussed that during Monday's call last week.
Yes, I forget to clean up this up. I will add another patch to do so.
More information about the Libc-alpha
mailing list