Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp685603pxb; Tue, 5 Apr 2022 18:44:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAGeEZIeEtiNTFlPOUnTSeBVcfiitm/YCC+B4kranoVKT3keccu0f+i5NSzy3NxomvHWWr X-Received: by 2002:a17:907:1b1f:b0:6e4:b202:db68 with SMTP id mp31-20020a1709071b1f00b006e4b202db68mr6292377ejc.294.1649209384349; Tue, 05 Apr 2022 18:43:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649209384; cv=none; d=google.com; s=arc-20160816; b=YBKHG7TPLsxkD3JVaeFEdl16IoHlqVx4bZLkxxtJrSrEfSiBumotkxcVhMVyNHsEi1 YLDW61OAtqeDRzbE8Zs6Y40ugShv13IYCBP74t8vnwAnY5seZVCQsqM+Rtkitdswh+Kz OVFNpecxUncUfiXsmIxKqRAQfVR4RaFwT0hZyscvoh3pYONWwQyhQjFzjpfwbOlPHkzl o/ia7UtwfP3Cne6i1Z++W1K9MuHdA2rUXll2zD+UkxjZkm/vEiapRpdTzvIBmIywKJ1P Lp80LB6tfoKtq0G8CTBSZgZTvCY7mjycskA5Mh6PE79iSekeVWat/ee1m2ejcGS0Tjsb /ucA== 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=MS41JKQCDbXwxL7e+gy88DIiwJjTXNIfZbnvFaxQp/Y=; b=ZEuuz8kxo6+aYMOxIcIqTTUq3TEaN6rQUWioSjDA8TMQYYqeCjC+NumGxjC6DE74QJ Zd0FSf3KBs/OLJfWtNooZhpDHFddIiR05DH3Wi4meSZN3ASuJELLl3bsHTG9CvpcDebt Ir9Zp57U6A2Mtal0a/8V9e0/1Q2HO4UVomUpPqNx3YyWnx29oCsIfDdeOGB2ruQvfW2f f4OZxSmLYexnSsC0i0kaStYlsW4sPq8/b2OTRtPKNBBNeT7sw4ZDtLgaBiKVH34SQY24 5snYF5LBP/wFcwd1uBnOyCfxneTHMYEK6SgzaVozxAIRnuRI5cFiofAW86ooEvxuUseo T9NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=umdtQ3u1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f21-20020a0564021e9500b00418c2b5bda6si12984215edf.136.2022.04.05.18.42.34; Tue, 05 Apr 2022 18:43:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=umdtQ3u1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1384787AbiDEOSZ (ORCPT + 99 others); Tue, 5 Apr 2022 10:18:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239697AbiDEJeA (ORCPT ); Tue, 5 Apr 2022 05:34:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86AE078911; Tue, 5 Apr 2022 02:22:55 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 243FE6144D; Tue, 5 Apr 2022 09:22:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B37FC385A0; Tue, 5 Apr 2022 09:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150574; bh=9oeaOtDRB/SGVsQXC0FYtjORDubOt8V3HM+oZFsGGz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=umdtQ3u1Hh86WM491LLpt/m9v+/dlHTsMOY7l0D3P3jdS1FIuRAGLocZGNw8Hr6HY jG/CZHWsCfdeRAujP8JzZC08E3ClTAMJ8gkJvKQZU2pZQIQFRoGSv8xhfXkRQTPn5v OBHE48Z71vaUQa0TS/DKc1rLMiz6chlDUqhJnQ00= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Mateusz=20Jo=C5=84czyk?= , Alessandro Zummo , Alexandre Belloni , Thomas Gleixner Subject: [PATCH 5.15 103/913] rtc: mc146818-lib: fix locking in mc146818_set_time Date: Tue, 5 Apr 2022 09:19:25 +0200 Message-Id: <20220405070342.914276063@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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: Mateusz Jończyk commit 811f5559270f25c34c338d6eaa2ece2544c3d3bd upstream. In mc146818_set_time(), CMOS_READ(RTC_CONTROL) was performed without the rtc_lock taken, which is required for CMOS accesses. Fix this. Nothing in kernel modifies RTC_DM_BINARY, so a separate critical section is allowed here. Fixes: dcf257e92622 ("rtc: mc146818: Reduce spinlock section in mc146818_set_time()") Signed-off-by: Mateusz Jończyk Cc: Alessandro Zummo Cc: Alexandre Belloni Cc: Thomas Gleixner Cc: stable@vger.kernel.org Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/20220220090403.153928-1-mat.jonczyk@o2.pl Signed-off-by: Greg Kroah-Hartman --- drivers/rtc/rtc-mc146818-lib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/rtc/rtc-mc146818-lib.c +++ b/drivers/rtc/rtc-mc146818-lib.c @@ -176,8 +176,10 @@ int mc146818_set_time(struct rtc_time *t if (yrs >= 100) yrs -= 100; - if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) - || RTC_ALWAYS_BCD) { + spin_lock_irqsave(&rtc_lock, flags); + save_control = CMOS_READ(RTC_CONTROL); + spin_unlock_irqrestore(&rtc_lock, flags); + if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { sec = bin2bcd(sec); min = bin2bcd(min); hrs = bin2bcd(hrs);