From patchwork Thu Oct 19 11:29:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 10016515 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 11C7F60215 for ; Thu, 19 Oct 2017 11:29:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECA0C28CC4 for ; Thu, 19 Oct 2017 11:29:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E088D28CC7; Thu, 19 Oct 2017 11:29:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C1C928CC4 for ; Thu, 19 Oct 2017 11:29:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752827AbdJSL3T (ORCPT ); Thu, 19 Oct 2017 07:29:19 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:65431 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752585AbdJSL3T (ORCPT ); Thu, 19 Oct 2017 07:29:19 -0400 Received: from fsav410.sakura.ne.jp (fsav410.sakura.ne.jp [133.242.250.109]) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id v9JBT1ML016939; Thu, 19 Oct 2017 20:29:01 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav410.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav410.sakura.ne.jp); Thu, 19 Oct 2017 20:29:01 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav410.sakura.ne.jp) Received: from AQUA (softbank126072090071.bbtec.net [126.72.90.71]) (authenticated bits=0) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id v9JBT0nY016935; Thu, 19 Oct 2017 20:29:00 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) To: arnd@arndb.de Cc: takedakn@nttdata.co.jp, james.l.morris@oracle.com, serge@hallyn.com, y2038@lists.linaro.org, deepa.kernel@gmail.com, mingo@kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] tomoyo: fix timestamping for y2038 From: Tetsuo Handa References: <20171019095405.689783-1-arnd@arndb.de> In-Reply-To: <20171019095405.689783-1-arnd@arndb.de> Message-Id: <201710192029.BGI60474.SOOVtFOHMLQFJF@I-love.SAKURA.ne.jp> X-Mailer: Winbiff [Version 2.51 PL2] X-Accept-Language: ja,en,zh Date: Thu, 19 Oct 2017 20:29:01 +0900 Mime-Version: 1.0 Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Arnd Bergmann wrote: > Tomoyo uses an open-coded version of time_to_tm() to create a timestamp > from the current time as read by get_seconds(). This will overflow and > give wrong results on 32-bit systems in 2038. > > To correct this, this changes the code to use ktime_get_real_seconds() > and the generic time64_to_tm() function that are both y2038-safe. > Using the library function avoids adding an expensive 64-bit division > in this code and can benefit from any optimizations we do in common > code. > > Signed-off-by: Arnd Bergmann > --- > security/tomoyo/audit.c | 2 +- > security/tomoyo/common.c | 4 ++-- > security/tomoyo/common.h | 2 +- > security/tomoyo/util.c | 39 +++++++++------------------------------ > 4 files changed, 13 insertions(+), 34 deletions(-) Thank you. Please fold below diff into your patch, for year calculation is wrong. #0047/10/19 20:08:17# profile=1 mode=learning granted=no (global-pid=1) task={ pid=1 ppid=0 uid=0 gid=0 euid=0 egid=0 suid=0 sgid=0 fsuid=0 fsgid=0 } path1={ uid=0 gid=0 ino=639202 major=8 minor=1 perm=0755 type=file } path1.parent={ uid=0 gid=0 ino=155 perm=0755 } exec={ realpath="/usr/lib/systemd/systemd" argc=5 envc=0 argv[]={ "/usr/lib/systemd/systemd" "--switched-root" "--system" "--deserialize" "21" } envp[]={ } } Then, you can add Acked-by: Tetsuo Handa --- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/security/tomoyo/util.c +++ b/security/tomoyo/util.c @@ -96,7 +96,7 @@ void tomoyo_convert_time(time64_t time64, struct tomoyo_time *stamp) stamp->hour = tm.tm_hour; stamp->day = tm.tm_mday; stamp->month = tm.tm_mon + 1; - stamp->year = tm.tm_year - (1970 - 1900); + stamp->year = tm.tm_year + 1900; } /**