[PATCH] uts: Don't randomize "struct uts_namespace".

From: Tetsuo Handa
Date: Fri Jul 06 2018 - 06:09:30 EST


I noticed that makedumpfile utility is failing to check kernel version, for
it depends on offset of "struct uts_namespace"->name being sizeof(int).

----------
int
check_release(void)
{
unsigned long utsname;

/*
* Get the kernel version.
*/
if (SYMBOL(system_utsname) != NOT_FOUND_SYMBOL) {
utsname = SYMBOL(system_utsname);
} else if (SYMBOL(init_uts_ns) != NOT_FOUND_SYMBOL) {
utsname = SYMBOL(init_uts_ns) + sizeof(int);
} else {
ERRMSG("Can't get the symbol of system_utsname.\n");
return FALSE;
}
if (!readmem(VADDR, utsname, &info->system_utsname,
sizeof(struct utsname))) {
ERRMSG("Can't get the address of system_utsname.\n");
return FALSE;
}
----------

Since there is no way to tell the offset to userspace, let's not randomize
"struct uts_namespace".

Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
Fixes: 3859a271a003aba0 ("randstruct: Mark various structs for randomization")
Cc: stable <stable@xxxxxxxxxxxxxxx> # v4.13+
---
include/linux/utsname.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/utsname.h b/include/linux/utsname.h
index 44429d9..85c206f 100644
--- a/include/linux/utsname.h
+++ b/include/linux/utsname.h
@@ -27,7 +27,7 @@ struct uts_namespace {
struct user_namespace *user_ns;
struct ucounts *ucounts;
struct ns_common ns;
-} __randomize_layout;
+};
extern struct uts_namespace init_uts_ns;

#ifdef CONFIG_UTS_NS
--
1.8.3.1