Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1934198imm; Thu, 24 May 2018 03:11:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqZkgOIM80zAO1KyAesMkJoWbPGhP0KHKQ05AxV+Y90F/+3WIY9sn2FD4q6pxq8eelDusEG X-Received: by 2002:a17:902:6a89:: with SMTP id n9-v6mr6685569plk.41.1527156663160; Thu, 24 May 2018 03:11:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527156663; cv=none; d=google.com; s=arc-20160816; b=HrF+PUyLcfFmmL9568Y97CKHL/VRU6XQGsTV7n11CK06Ed08koBoVA59wW0Uw0ab38 HSbAXMdFZ+7Oza+2U64sd2oZGvlLAckUEi76Bva9ajSR10qQ0pjC67BfUyuORviGoMTT sSB8XPG3PSyt8Y8RiCCS764bI80Ucvqp85YP975A/BajtfZhBoFFt6JRwkZzVtfjr7ze raiNkW8i+f93w+QNHDHN6m9mfnA+PEGshcePwc1XlaDBEUNcPih77c7awZXzLYqXMIhD yTu+ZOugGTPU7bpeJbvS70LtntHtj3bLuhnxj8+bN/cqJWTyFq7qVnZ+kHcIqdl/Sir6 mkVA== 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=CE+kouUcWUsalEOckoJXoYJ90qIzFe8SnWRxJBfIgAA=; b=our764Is42T60AcEebJgrwKBOkPyn9wWCWX/KNj5/7Ay4+SHfe+OwfhqqjSKpaNpDg Hx59ZiN8hupC7N5KR1mPB1LDg+QBY2i0+mLcZQfcTH7ASWRpj7kKMd1JxX0Z5to9rYaw XCsfbMS6JwAmL0PdNGOdpSB+wlMXaozpVjjL+h/t/60F2rXeGZZYlfbn9w0A2erL/6Um V8Yem/w+zgE0/mAU/nJs/cFNVUbrl+ak8kh4PeZbPwffPJlAiHnXR3uW6l3CxcrqsUME +4uo16v1NRs3fSuAdm6JKXXwNh5PNK/1gK9AnuYnF/52QDEeLDKZRUUUHIX6hFUuEdX/ 3QRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Wurec2he; 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 f5-v6si14865945pgn.453.2018.05.24.03.10.47; Thu, 24 May 2018 03:11:03 -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=Wurec2he; 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 S1031729AbeEXKJo (ORCPT + 99 others); Thu, 24 May 2018 06:09:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:54962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031638AbeEXKFy (ORCPT ); Thu, 24 May 2018 06:05:54 -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 1BB7220870; Thu, 24 May 2018 10:05:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156353; bh=RUYNwXwBPElyQvKvTFPN1KaxDdhGDFtkMiIeE+O/8Io=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wurec2he4qnvoy8a16Ux33QPen/+E/FSGWKTt1YAirC+muQmV/OIQCNZiQFSliH/7 Nx6ZCTynyIUPghzbMHzIRTmYBQ9jqNcJL2UqKSCc9jAamZ7OW5AXiSYvDyWXIrPvwm 0Vti0AO1Kl3rhXlJ1WUfuKrFnwPk0/FT7SPM1kSM= 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.16 156/161] rtc: hctosys: Ensure system time doesnt overflow time_t Date: Thu, 24 May 2018 11:39:41 +0200 Message-Id: <20180524093036.909880365@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@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.16-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,