Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp961427pxu; Wed, 7 Oct 2020 22:43:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPKZ8T2RhkMddo8uVX5TttRqyy7m01+jcSBkb5ycbqDMDAG7T+wTe0ckgUUFpfIXYyghnt X-Received: by 2002:a17:906:1a04:: with SMTP id i4mr7310476ejf.24.1602135781453; Wed, 07 Oct 2020 22:43:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602135781; cv=none; d=google.com; s=arc-20160816; b=dMIzERWvMWcwphfegD4A/HLN+itn+/k/XBDV8G8NqDDKfVdQd69D6Yxnd48wpF849y ATHBmU3ApH2dAbmqmb5MZTAHDhN4IURYCunNuAm0TLejFHvoiH6rQLFkv9fgoE90b/or neIDjYO07NLwky8flf4iRM2MsfT7f1pte+oMvTXvXp7HognvfHkyqyjpmLUKjIVGzUsV uOPfdnIIiPa2flNgdnoLBb9cTw686yzXR5Jxv5pEIrhd5RxrwSdO46j+/pJpTzhzee1N NZcI0bgsadMqcfi2J4QRnxRKW9Np4f12/KwZh7cqPqpVRs1lGnfG68xfRI1r6AvTDJzT J2GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=2o7xuAu+kDSQ78l9qdPfFAtXboGdR5E9ghGqOpAJ1RU=; b=L0TeF7UyoKWnnkHJgioW631vLKATKQYp+DwBTdL3BtpaCuf2z5naFf241iXW31V4p/ a88oYUg1hh8hA6DvKE8nGpb/VWGXeR+EYYmJgVB/7716s/myCrh7HA3dNGyGg91D8W+O b1G1Fy9Shox7EjUsUX8mfEuZ3c5+ykv80WSQSD6hzBypqWqPrGImuqke5llV6HUUyrq4 +rMcGmBcevDR3k2REGOas26caKxtcBrSp17vjiB37oSG9PD6JfZEbrHtnp4rXR1NPPLi Y44XEfKzADRBxZ56LKBUNR63ccIiUVdZjn9Rglx/aJQLOreIWZxsWTwGlmEILC7VzVFh 7KYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p6si3188210ejb.26.2020.10.07.22.42.36; Wed, 07 Oct 2020 22:43:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728565AbgJHFkk (ORCPT + 99 others); Thu, 8 Oct 2020 01:40:40 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:52377 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728466AbgJHFkg (ORCPT ); Thu, 8 Oct 2020 01:40:36 -0400 Received: from weisslap.m4st3rnet.de ([178.27.102.19]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MY60L-1jsdAo1wJ3-00YR6S; Thu, 08 Oct 2020 07:40:23 +0200 From: =?UTF-8?q?Michael=20Wei=C3=9F?= To: Thomas Gleixner , Andrei Vagin , Dmitry Safonov <0x7f454c46@gmail.com>, Christian Brauner Cc: linux-kernel@vger.kernel.org, =?UTF-8?q?Michael=20Wei=C3=9F?= , kernel test robot Subject: [PATCH v2 0/4] time namespace aware system boot time Date: Thu, 8 Oct 2020 07:39:40 +0200 Message-Id: <20201008053944.32718-1-michael.weiss@aisec.fraunhofer.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-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9Y31p8lPQQNd6jQ6+c96bX46X+NYijNPOd1nIWa60jp 3ia7qOBbQFZ7ZwetY/GdIraAyWEp8NJEoxRBlnYNm6JHplBHNFyFDiS3YsqRZT7ku8gfmXy/w LMHrvF0wfzuQerg2c7nw== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Time namespaces make it possible to virtualize time inside of containers, e.g., it is feasible to reset the uptime of a container to zero by setting the time namespace offset for boottime to the negated current value of the CLOCK_BOOTTIME. However, the boot time stamp provided by getboottime64() does not take care of time namespaces. The resulting boot time stamp 'btime' provided by /proc/stat does not show a plausible time stamp inside the time namespace of a container. We address this by shifting the value returned by getboottime64() by subtracting the boottime offset of the time namespace. (A selftest to check the expected /proc/stat 'btime' inside the namespace is provided.) Further, to avoid to show processes as time travelers inside of the time namespace the boottime offset then needs to be added to the start_bootime provided by the task_struct. v2 Changes: Fixed compile errors with TIME_NS not set in config Reported-by: kernel test robot Michael Weiß (4): timens: additional helper function to add boottime in nsec time: make getboottime64 aware of time namespace fs/proc: apply timens offset for start_boottime of processes selftests/timens: added selftest for /proc/stat btime fs/proc/array.c | 6 ++- include/linux/time_namespace.h | 13 ++++++ kernel/time/timekeeping.c | 3 ++ tools/testing/selftests/timens/procfs.c | 58 ++++++++++++++++++++++++- 4 files changed, 77 insertions(+), 3 deletions(-) -- 2.20.1