Subject: Re: glibc 2.26 refuses to run on CentOS 6.8

From: [email-masked] (Ludovic Courtès)
Date: Fri, 23 Feb 2018 23:26:12 +0100

Hello,

Ricardo Wurmus <[email-masked]> skribis:

> I have a bad day.  After the upgrade to glibc 2.26 none of the
> Guix-installed software runs on the HPC cluster running CentOS 6.8.

Bah.  :-(

> The glibc 2.26 expects a minimum kernel version of 3.x on x86_64, but
> CentOS 6.8 only comes with a heavily patched 2.6.32.

It’s annoying, but we can surely apply the patch you sent (though rather
by passing ‘--enable-kernel’ if possible, as Danny suggested.)

personality(2) has a knob to change the kernel version reported by
uname(2) to 2.6.  Here it’s a case where we’d need the reverse:
reporting 3.2 instead of 2.6.  That doesn’t seem to exist.

Looking for other hacks (or kludges), I found the kernel module below at
<https://www.linuxquestions.org/questions/linux-general-1/uname-hack-modules-in-kernel-2-6-a-172167/>,
which could be adjusted to report a different kernel version:

--8<---------------cut here---------------start------------->8---
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/utsname.h>

#ifndef UNAME_DUMB_STEPPING
#define UNAME_DUMB_STEPPING '5';
#endif

MODULE_AUTHOR("The one who invented the uname hack");
MODULE_DESCRIPTION("Changes the uname output");
MODULE_LICENSE("GPL");

static int uname_hack_init() {
	save = system_utsname.machine[1];
	system_utsname.machine[1] = UNAME_DUMB_STEPPING;
	return 0;
}

static void uname_hack_cleanup() {
	system_utsname.machine[1] = save;
}

module_init(uname_hack_init);
module_exit(uname_hack_cleanup);
--8<---------------cut here---------------end--------------->8---

Another option would be to ptrace processes, handle the first ‘uname’
call, and then PTRACE_DETACH.  Ugly.

Ludo’.