Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2445102imm; Mon, 28 May 2018 08:12:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoI4al+r4PYVksuvxFh7dq+Uuw+q3OV074EZS44a7BIxRb81cIaR+tFTPHraUBsteD5BiXG X-Received: by 2002:a17:902:4301:: with SMTP id i1-v6mr14050457pld.280.1527520367120; Mon, 28 May 2018 08:12:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527520367; cv=none; d=google.com; s=arc-20160816; b=PvnbeVEPf9WbLxYPdDbo+IriJESdufO9iu6WIgknvH3V32h9iG37KQ3ih7cTV9uTVx Nwzw7XLZzcaFvV8UsZaOOSru5v3Fy2ipgEMsFL9C1F9/fWEvLYMMPZBixQ9CTHOJf5rW hK/mFBDoMkIXJQ0/EmBGZLA05S37F2H6qt71u7EzGA840gBTHloYneT4Je+QkP+jDoKq oXjEDVSiDWf0OrRpQ3dQb1EF1zrYbk8lViHrnaUWzp80r2YYMxIGkdjHyMY/XDcE4YPs 8LKJdfWBogTxtjl//pNV3YgLdom7Bn2WouJVHyK2y+Q2luE33OHnZsMZ5h8pmTccz0DX yZVw== 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=+IqQXyFxp2EwSKMrH8pHBx+BoihypxhmvQcoE8uRUqo=; b=I48sFDIiHh5hRuoz5soZp89xEbZdfs7yVYkUt11/ecqwWecev4/0Y5XwWnmkD4cNqd R4KxdfZe3WNOFPCELVQWfDxMvzkfR4mlP8evUYsWYiHPBUdd+4z+g5OAvhljT1bwhRes Jhh0frRCmZ+aI7QBU3S7CdLEGZqj11zjOe4Jtl5xxeVclXBRKlQPDfdK1K0pqx+TEL69 bs0ZrzI8w1FwUtfhcV8wgEmRS8CyUA2G3W9FHAgedXxJEHFGhD4SRximSG60PcYYRL/r lYut83KqXTFjSPJ1e+d69yMW26Y+Hdw7QbaXPutXcgMYr/M9PQtn/6OP68x/ljav6SI9 gwFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G2gV+B2i; 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 ay10-v6si30234790plb.120.2018.05.28.08.12.31; Mon, 28 May 2018 08:12:47 -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=G2gV+B2i; 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 S1166039AbeE1PKu (ORCPT + 99 others); Mon, 28 May 2018 11:10:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:43278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033743AbeE1KX5 (ORCPT ); Mon, 28 May 2018 06:23:57 -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 3F5692088E; Mon, 28 May 2018 10:23:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527503036; bh=W3nP7EXedr9U6LCH0V7A2FIPXA07zpV8YmYdnfCCDdg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G2gV+B2ipr4lT/El6XqiRAdOGcoDWK6yoJ0UUU2ymzKO9XjxCxC7kjyNOmiENqgdi x2unyZGPc0sDsuOM48Uv33xju5oB8uWG/JQvxBtwa/MOPove8po76ARBM0jjRdv6Z+ AWK81izEurrJBC3d8CsOuzsolGHd61o4Z/D2kxug= 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.4 189/268] rtc: hctosys: Ensure system time doesnt overflow time_t Date: Mon, 28 May 2018 12:02:43 +0200 Message-Id: <20180528100223.765558420@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100202.045206534@linuxfoundation.org> References: <20180528100202.045206534@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.4-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,