Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1966499imm; Thu, 24 May 2018 03:44:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrE8hdcDWWJHSuzsqCptmVE8/kWHFmE04v9pT2Xru6tx74w6RuX93ZAOue8aHI30mbY48/F X-Received: by 2002:a62:a391:: with SMTP id q17-v6mr6728597pfl.87.1527158642646; Thu, 24 May 2018 03:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527158642; cv=none; d=google.com; s=arc-20160816; b=03CQBMNeIM3hEFsDLW/JU0DqHCSMVJ6gSyWIO7+Hw45hi3hgnOjICghNEMCe99xCXG PugaEtN+P6JsRVPDKVjEJixHRO+7gGi6FCp1i47lINCkYD2USaUZ76i+U8cHJDduGfqS zehalq8/ZJOFYyLzj7Shjx2iwu+2y98LvFozf4+F+T7HnAHbKeJNn6YDsBFyhM4h2SwH jgfw3FAgdkuCHlnl6osIKjhNxr+w5H61a+xNXnwjJuWvK5ieHeDF4DmUcCIFZAGegBy1 xmu0179EqZyNrozQCHJ8WkfQymAKSG3yOD+SKVC2d/u/Nyo7Q1NxmHLT0K+zhz5QnkyD MkfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=68Uo/tV3JVn6AWrQShUV2o5MIfYv5KTEowk7aeNPzOc=; b=ljwp9oPo46AjY7NtKIw9eroqMrHdIlAiR923Z+ZKOJ5hsrjRenWi3yiUXI8DaoFRM7 Tk4Nd1N7VwUEPFwC3dYxWuEWdshARYC/M9W15FSyXZ5pRehEX5haYRhwjJsinCs4QrUs E7rRFbxYWN+JkVU6wxbEOTlIDBCI6Z8BsP3ZKT68VwHQCSfd9tWZn5eeTKZfg4+tnCJm gLEBTziu4ygxj0WuLA7UW26Jx8QZIILQ175aPd+ewmp25GxKW0X7XF7v7y24GIjDHj85 e8C4PdDIim2dh/fnfLhYnmGhIz9wO8zyUTOioBoARhrd+MM9I7RebW/v0fktClFCiZgZ PbBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=145ze/hG; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1-v6si16025425pgo.437.2018.05.24.03.43.47; Thu, 24 May 2018 03:44:02 -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; dkim=pass header.i=@kernel.org header.s=default header.b=145ze/hG; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032340AbeEXKnH (ORCPT + 99 others); Thu, 24 May 2018 06:43:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:38258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030238AbeEXJ6Y (ORCPT ); Thu, 24 May 2018 05:58:24 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 97C222088E; Thu, 24 May 2018 09:58:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155904; bh=xWoiN37cgr0QuJNvPDuKAEQGV9g9DrZtGrALzKH72GU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=145ze/hGJxThLkWXeFaaKJ0AtNdRppP+arEWAOehYXW5JoM3eVIRMRXbMTJ8J+nW6 xhK/0ALy8/BgmJqT2OltO73dqDJCd1lUfB4PORCgGBbV/HidX75gFLFRRQdHSIJwGp 4rW+laRWFI8wMcKIWy/zaF4kVt4uQiUDaK5ljJ2I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Alexandre Belloni , Sasha Levin Subject: [PATCH 4.14 160/165] rtc: hctosys: Ensure system time doesnt overflow time_t Date: Thu, 24 May 2018 11:39:26 +0200 Message-Id: <20180524093628.562607570@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexandre Belloni [ Upstream commit b3a5ac42ab18b7d1a8f2f072ca0ee76a3b754a43 ] On 32bit platforms, time_t is still a signed 32bit long. If it is overflowed, userspace and the kernel cant agree on the current system time. This causes multiple issues, in particular with systemd: https://github.com/systemd/systemd/issues/1143 A good workaround is to simply avoid using hctosys which is something I greatly encourage as the time is better set by userspace. However, many distribution enable it and use systemd which is rendering the system unusable in case the RTC holds a date after 2038 (and more so after 2106). Many drivers have workaround for this case and they should be eliminated so there is only one place left to fix when userspace is able to cope with dates after the 31bit overflow. Acked-by: Arnd Bergmann Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/rtc/hctosys.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/rtc/hctosys.c +++ b/drivers/rtc/hctosys.c @@ -49,6 +49,11 @@ static int __init rtc_hctosys(void) tv64.tv_sec = rtc_tm_to_time64(&tm); +#if BITS_PER_LONG == 32 + if (tv64.tv_sec > INT_MAX) + goto err_read; +#endif + err = do_settimeofday64(&tv64); dev_info(rtc->dev.parent,