Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1573517pxb; Tue, 8 Feb 2022 22:45:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKHVU7PrK3IpfgOKUZUjNQLWFQGT0Bg3vJ8jo15T2KR4T1L6pbGiep9TEf10MeySeo29kg X-Received: by 2002:a05:6a00:174d:: with SMTP id j13mr817732pfc.58.1644389141136; Tue, 08 Feb 2022 22:45:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644389141; cv=none; d=google.com; s=arc-20160816; b=v3EF5wmGLCFoswzCHD8+i6PdiqwQcj5Tsfj/rP+MAIPizYDNmH42+S2XM66OK+GdMm J08unC4KKiUbzx1BPIylBbbhnzEh90MpU1rJuFn9cIPCrRiSWSG0eEoYkGxalo6ZoTLC EJ/lMBQGONb854ScWHGgFp2SYhDDTJbJEdXVwSmdRd2Ue6WfeQxCzuZ4Sh8CWoj1s+MJ 9XP3LHoOZN1G08wpY9syRWF38qzjhRHhVvTv5OkK7kzB81KRtwsl2aKItR9DZVzRcyGh 4lWHRc0E0jFk4GjdDTXRK5m0GDdR3gl13G8ut41J/UDHpVVaTsNVm9/5oan1E3gqmdhd gt8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PLY2ONfX7JrHSzP80J+LjTJK2AN7h3S/JPxT5h0+nog=; b=ZY3NYOZHYSaiCx8TI8TYMujczKiKKLxuT58mUbmMpaCycGpAcfUHUbFqqEsZ6r4LnQ jAfvlMslMMVJHms/EnUmxw4hPPrne5Dzm/gqyYD8dS2AK+DI3hDk+Rc30ToqYpGrqTVB G6UNkLwq/Km+4aClvxfh/vYPNXW5m4+eJG/gwGMyJ1pbAtOE9KGsCxY2YX88zkABIP81 hc2d5Inx335IEaCniFC1g/qqB8bnULvF/PrDKj2oBK5KZ7JClEy+zMt0nbQBv8k9K4sv wC/GdKX5f85xrvjp//1y3WOYmvm061VAEPC4F7lfT00P6sJIG9vDtbDWJnwyd2iEJNQM yKQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fmIeJk6C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p16si2957688plf.211.2022.02.08.22.45.28; Tue, 08 Feb 2022 22:45:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fmIeJk6C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391111AbiBGL6V (ORCPT + 99 others); Mon, 7 Feb 2022 06:58:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385425AbiBGLbu (ORCPT ); Mon, 7 Feb 2022 06:31:50 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C53EC03FEEE; Mon, 7 Feb 2022 03:30:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 00C14B811B2; Mon, 7 Feb 2022 11:30:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44884C004E1; Mon, 7 Feb 2022 11:30:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233417; bh=DFsm60ujwlq6xrmRluf3V0gZYV+0uKA4KIhEf3z/2VY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fmIeJk6CfoGr0ULvTUvQGKis4dB5JsC8aQeVFX8HRa6hOa5lfQRjKpZdEuEcgjjt1 zwZsZV66GMHZz+mjjNF88RVYMptQfPfpuC0aas/gUUQ54sdC0I713DlO5A2jexCTUS aAQ6m8cSTN/OOUlnVTZgcJkOACwVzNoyAXgkZouM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Riwen Lu , Eric Wong , =?UTF-8?q?Mateusz=20Jo=C5=84czyk?= , Alexandre Belloni Subject: [PATCH 5.15 091/110] rtc: cmos: Evaluate century appropriate Date: Mon, 7 Feb 2022 12:07:04 +0100 Message-Id: <20220207103805.483671403@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Riwen Lu commit ff164ae39b82ee483b24579c8e22a13a8ce5bd04 upstream. There's limiting the year to 2069. When setting the rtc year to 2070, reading it returns 1970. Evaluate century starting from 19 to count the correct year. $ sudo date -s 20700106 Mon 06 Jan 2070 12:00:00 AM CST $ sudo hwclock -w $ sudo hwclock -r 1970-01-06 12:00:49.604968+08:00 Fixes: 2a4daadd4d3e5071 ("rtc: cmos: ignore bogus century byte") Signed-off-by: Riwen Lu Acked-by: Eric Wong Reviewed-by: Mateusz Jończyk Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/20220106084609.1223688-1-luriwen@kylinos.cn Signed-off-by: Mateusz Jończyk # preparation for stable Signed-off-by: Greg Kroah-Hartman --- drivers/rtc/rtc-mc146818-lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/rtc/rtc-mc146818-lib.c +++ b/drivers/rtc/rtc-mc146818-lib.c @@ -104,7 +104,7 @@ again: time->tm_year += real_year - 72; #endif - if (century > 20) + if (century > 19) time->tm_year += (century - 19) * 100; /*