Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2013106imm; Thu, 24 May 2018 04:31:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZox3WdazN1ObuKDKY8j70tQ5X75/8te5JTbXXVNPEpFxnlkIrspcE6qht9WL6BWl9BQgACv X-Received: by 2002:a17:902:ab98:: with SMTP id f24-v6mr6861765plr.144.1527161464795; Thu, 24 May 2018 04:31:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527161464; cv=none; d=google.com; s=arc-20160816; b=jga6E5810btA3cdLqjl/nLUWy/gkVk0sw8kvIZiobNQm15nEnBxhiq2N00VUAg212b MqVHr2Ffj29fDAKhkKklU52Urk2mgNKfnVmEQuxUxSV7TCTk4eTJXuH8iZfs6Ak7vjdd Q/5J+7DsVuNt8CetQpd1kdoMdD6VpRtAbVvHFEzx0MEpWcI5Pejgf9jrtaAgqkuBT7A+ WvVkaOfYOJ4zIKtpfG0HLph+ySnEoIPb/tGba3SUyLYmqhAFQNUp+sLjkgL8D7VkEstu XEGLKkvqNy+csY1lgPa9z5WUr3+7jeEaH2fKChfvq1UPyM4KF3a1W0EMScmTiqYExX+Y XfJw== 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=BuNqoH6U7UdLXXqss1ALRqD9Xpg08AjdqHgO57hiRnw=; b=J9tm3j0LPDwS+pcUQJb3CUq9uW/dgXqS6IA9HItIg7lCzViqrvzqWfA0SLkx9yS0IL VMibc11n4LNMR+kPau/VS5PF4YR5ZwsrmxF2wBXTFVwqkGFLggknDhpG94jO2pegkPkQ tmKWK8MGepv5nTIiAZFiIcuUfWrAucn/iYFjYJE+3qKW9CeWrDY3Zo1svZYcOQ/wBBlT XDkd4piT2THlrojHeIam6UOStL40/NTSoo8iMPQINDSe95afeNgiEmfgOju6XiEN97W6 /LFN2hSuvGyOoqyVQyBxcOqQIaOrtSOdPuCBosdYJc52FFEAnruytQlAnlfMJb9xPprr DOUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GzYGSp0L; 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 s24-v6si86560pgn.194.2018.05.24.04.30.50; Thu, 24 May 2018 04:31:04 -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=GzYGSp0L; 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 S968927AbeEXLaJ (ORCPT + 99 others); Thu, 24 May 2018 07:30:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:45026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967642AbeEXJvI (ORCPT ); Thu, 24 May 2018 05:51:08 -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 8C26720891; Thu, 24 May 2018 09:51:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155468; bh=f98wzy9+IJ0kbMR77OPv0lwydR7BJkZQ5EhAsba4mvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GzYGSp0LixtmnDWcwKpIbFIJ2BFCD4skiQz0Cedl1IeB/aImvpaVeJ2t2POofDdcU 9LDvbCwzgkTR6vA6YblFwT7LWszMnvWr9pDUF0pqWbIE3dTbDZ/BRvfpF8LsDJ3no2 q92cnCX6xEJ9ueU7txHHiIJrS9tGbY24llD7g9jI= 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.9 95/96] rtc: hctosys: Ensure system time doesnt overflow time_t Date: Thu, 24 May 2018 11:39:18 +0200 Message-Id: <20180524093611.362464008@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093605.602125311@linuxfoundation.org> References: <20180524093605.602125311@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.9-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,