Received: by 10.213.65.68 with SMTP id h4csp226803imn; Fri, 30 Mar 2018 04:28:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Bik9bLUvPWBEoA2Qs6N7ZkvfVxg9BXYWes+CNPXE/V87X4jhSb7tdmGHnajgPf31/aN9D X-Received: by 2002:a17:902:a70f:: with SMTP id w15-v6mr12733988plq.344.1522409281129; Fri, 30 Mar 2018 04:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522409281; cv=none; d=google.com; s=arc-20160816; b=CEUngS9Y9LoQ5Eh2NoG5AcUlUBwg7v1n1nrwCUme2Yx66vMZvEoZWZqVCoGmzWf/jt qeRIKvH0u7WJeOXnWgiAxGbmCe6TYDjrqbuCVjfdpjw5gVQAJeoGJdf5Qy0JcXJ3i282 AntfL+RwBoCfuijxOSuwGOFIfrB2V4kA4MqJHNVOqmEziuhoWZh6MDfxYbJHvqNatxbb Rj+j/xj4Jo5hkS0Iz9jjlNGFIkViX63Bq4P+K5+ZMQiz55zNllMaKy/pDmDoXyOIHGUJ JAe5cPO//OhyUxjWmHW2mTMBT1eK5ICDfAO2VbAvXfQGAlAaXyAoCOiCEe8oGeqk5C2T x5nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=1/BVC9YAhW0RhJK4YIUbEzZ+DTCOX8AFxO2sdSb2rPU=; b=FGtTcfF2J+iRcdGzr02yfA7Eoh1mXzdgj4Oq51Fna6BF/GcF2D4jQOyTSD3W8vk30Z HrMY5BEe9izkBF76PIgtPJAwcTT7VDFeKsIBwWIhs9jDi1CDAmJSiNSU4GAcfOB/Fs/8 lMAHZSVDMLD+CHRzZi6QaNeEyqQjWddI/TskRFGVzFsZAUoHZ52G/qrJbb4I7G3AwZHP KEMXcQ9mE4/pWDM2SD+pchrCg9gzfuEogk2fCDjaSpwD4m1A+QEuPGPyYCQELytYgY9x 8Lvh5Aw5b4apZafIA4mT7Pg+2iszdnbSoAlASDZsdtIR6uS8K8QzlFN8j/zvC5ejSl7g XcsA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kyup.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w69si756521pfd.332.2018.03.30.04.27.46; Fri, 30 Mar 2018 04:28:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kyup.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751277AbeC3L0b (ORCPT + 99 others); Fri, 30 Mar 2018 07:26:31 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34931 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751129AbeC3L0a (ORCPT ); Fri, 30 Mar 2018 07:26:30 -0400 Received: by mail-wm0-f65.google.com with SMTP id r82so16404159wme.0 for ; Fri, 30 Mar 2018 04:26:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1/BVC9YAhW0RhJK4YIUbEzZ+DTCOX8AFxO2sdSb2rPU=; b=SyxwB64t7txlriJH9GMNdopXB9hFRTtZjRrDcYsBR/vzSP5HY5nY0XGMtIe0P3CY+g bfjvvsQ9ubj3GJsJkvxBsfRUheW/0PzUVigAHIXsAerxeqtf1oF9/s0CzBOmOgsRSpfZ dlyfvRFUuw3U0NU8aClEPLX0FuE6MWKOKeUkPaaQar+zhfdrBeTicC4qK79vTbtC807t JfkQKlPfsoFWobX2zpEBUVone4OT5sJb3ffBBwWh8iggQU/eZ5mFj8oryDxL22NyNCci kgnBWrQxh2fiY4KG/uOaq8KRl3Y8ayJhXz15T/xYHZqTRlDRUjrMSGTQBrJu3xoVEn5T +M7Q== X-Gm-Message-State: AElRT7HS1eXSFOke3NKu27UpaSAsd6YmIuIy1ZgtvlLcLbtC1gHUZkDY YOgfEYx7q65bO5MttCn1vUHFtmoZ X-Received: by 10.28.239.8 with SMTP id n8mr2153821wmh.120.1522409186413; Fri, 30 Mar 2018 04:26:26 -0700 (PDT) Received: from kernighan.sgvps.net ([82.118.240.140]) by smtp.gmail.com with ESMTPSA id u3sm10400214wrf.3.2018.03.30.04.26.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 Mar 2018 04:26:24 -0700 (PDT) From: Angel Shtilianov To: linux-kernel@vger.kernel.org Cc: Angel Shtilianov Subject: [PATCH] uts_namespace: Move boot_id in uts namespace Date: Fri, 30 Mar 2018 14:17:00 +0300 Message-Id: <1522408620-10578-1-git-send-email-kernel@kyup.com> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently the same boot_id is reported for all containers running on a host node, including the host node itself. Even after restarting a container it will still have the same persistent boot_id. This can cause troubles in cases where you have multiple containers from the same cluster on one host node. The software inside each container will get the same boot_id and thus fail to join the cluster, after the first container from the node has already joined. UTS namespace on other hand keeps the machine specific data, so it seems to be the correct place to move the boot_id and instantiate it, so each container will have unique id for its own boot lifetime, if it has its own uts namespace. Signed-off-by: Angel Shtilianov --- drivers/char/random.c | 4 ++++ include/linux/utsname.h | 1 + kernel/utsname.c | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index ec42c8bb9b0d..e05daf7f38f4 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1960,6 +1960,10 @@ static int proc_do_uuid(struct ctl_table *table, int write, unsigned char buf[64], tmp_uuid[16], *uuid; uuid = table->data; +#ifdef CONFIG_UTS_NS + if (!!uuid && (uuid == (unsigned char *)sysctl_bootid)) + uuid = current->nsproxy->uts_ns->sysctl_bootid; +#endif if (!uuid) { uuid = tmp_uuid; generate_random_uuid(uuid); diff --git a/include/linux/utsname.h b/include/linux/utsname.h index c8060c2ecd04..f704aca3e95a 100644 --- a/include/linux/utsname.h +++ b/include/linux/utsname.h @@ -27,6 +27,7 @@ struct uts_namespace { struct user_namespace *user_ns; struct ucounts *ucounts; struct ns_common ns; + char sysctl_bootid[16]; } __randomize_layout; extern struct uts_namespace init_uts_ns; diff --git a/kernel/utsname.c b/kernel/utsname.c index 913fe4336d2b..f1749cdcd341 100644 --- a/kernel/utsname.c +++ b/kernel/utsname.c @@ -34,8 +34,10 @@ static struct uts_namespace *create_uts_ns(void) struct uts_namespace *uts_ns; uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL); - if (uts_ns) + if (uts_ns) { kref_init(&uts_ns->kref); + memset(uts_ns->sysctl_bootid, 0, 16); + } return uts_ns; } -- 2.5.0