lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20160916201204.9424-11-nicstange@gmail.com>
Date:   Fri, 16 Sep 2016 22:12:03 +0200
From:   Nicolai Stange <nicstange@...il.com>
To:     Thomas Gleixner <tglx@...utronix.de>
Cc:     John Stultz <john.stultz@...aro.org>, linux-kernel@...r.kernel.org,
        Nicolai Stange <nicstange@...il.com>
Subject: [RFC v7 22/23] clockevents: make setting of ->mult and ->mult_adjusted atomic

In order to avoid races between setting a struct clock_event_device's
->mult_adjusted in clockevents_update_freq() and yet to be implemented
updates triggered from the timekeeping core, the setting of ->mult and
->mult_adjusted should be made atomic.

Protect the update in clockevents_update_freq() by locking the
clockevents_lock spinlock. Frequency updates are expected to be done
seldomly and thus, taking this subsystem lock should not have any impact
on performance.

Note that the call to tick_broadcast_update_freq() is also protected
by this clockevents_lock and thus, this patch can take the
tick_broadcast_lock with the clockevents_lock being held. However,
this is supposed to be safe since the sequence
  __clockevents_unbind() -> clockevents_replace() ->
  tick_install_replacement() -> tick_setup_device() ->
  tick_device_uses_broadcast()
already does this, too.

Signed-off-by: Nicolai Stange <nicstange@...il.com>
---
 kernel/time/clockevents.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 67d572e..b121932 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -658,11 +658,11 @@ int clockevents_update_freq(struct clock_event_device *dev, u32 freq)
 	unsigned long flags;
 	int ret;
 
-	local_irq_save(flags);
+	raw_spin_lock_irqsave(&clockevents_lock, flags);
 	ret = tick_broadcast_update_freq(dev, freq);
 	if (ret == -ENODEV)
 		ret = __clockevents_update_freq(dev, freq);
-	local_irq_restore(flags);
+	raw_spin_unlock_irqrestore(&clockevents_lock, flags);
 	return ret;
 }
 
-- 
2.10.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ