linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Dmitry Vyukov <dvyukov@google.com>,
	Johannes Berg <johannes.berg@intel.com>,
	Loic Poulain <loic.poulain@linaro.org>,
	netdev@vger.kernel.org, Sergey Ryazanov <ryazanov.s.a@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>,
	M Chetan Kumar <m.chetan.kumar@intel.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	"David S. Miller" <davem@davemloft.net>,
	Intel Corporation <linuxwwan@intel.com>,
	alsa-devel@alsa-project.org, Takashi Iwai <tiwai@suse.com>,
	Jaroslav Kysela <perex@perex.cz>,
	Oliver Hartkopp <socketcan@hartkopp.net>,
	linux-can@vger.kernel.org, Marc Kleine-Budde <mkl@pengutronix.de>,
	Sebastian Reichel <sre@kernel.org>,
	linux-pm@vger.kernel.org, David Airlie <airlied@linux.ie>,
	intel-gfx@lists.freedesktop.org,
	Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
	Jani Nikula <jani.nikula@linux.intel.com>,
	dri-devel@lists.freedesktop.org, Daniel Vetter <daniel@ffwll.ch>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>
Subject: [patch 00/11] hrtimers: Cleanup hrtimer_forward() [ab]use
Date: Thu, 23 Sep 2021 18:04:18 +0200 (CEST)	[thread overview]
Message-ID: <20210923153311.225307347@linutronix.de> (raw)

A recent syzbot report unearthed abuse of hrtimer_forward() which can cause
runaway timers hogging the CPU in timer expiry context by rearming the
timer in the past over and over.

This happens when the caller uses timer->expiry for the 'now' argument of
hrtimer_forward(). That works as long as the timer expiry is on time, but
can cause a long period of rearm/fire loops which hog the CPU. Expiring
late can have various causes, but obviously virtualization is prone to that
due to VCPU scheduling.

The correct usage of hrtimer_forward() is to hand the current time to the
'now' argument which ensures that the next event on the periodic time line
is past now. This is what hrtimer_forward_now() provides.

The following series addresses this:

    1) Add a debug mechanism to the hrtimer expiry loop

    2) Convert all hrtimer_forward() usage outside of kernel/time/ to
       use hrtimer_forward_now().

    3) Confine hrtimer_forward() to kernel/time/ core code.

The mac80211_hwsim patch has already been picked up by the wireless
maintainer and all other patches which affect usage outside the core code
can be picked up by the relevant subsystems. If a maintainer wants me to
pick a particular patch up, please let me know.

The last patch which confines hrtimer_forward() will be postponed until all
other patches have been merged into Linus tree.

The series is also available from git:

    git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git hrtimer

Thanks,

	tglx
---
 drivers/gpu/drm/i915/i915_pmu.c        |    2 -
 drivers/net/wireless/mac80211_hwsim.c  |    4 +-
 drivers/net/wwan/iosm/iosm_ipc_imem.c  |    4 +-
 drivers/power/reset/ltc2952-poweroff.c |    4 --
 include/linux/hrtimer.h                |   26 -----------------
 include/linux/posix-timers.h           |    3 ++
 kernel/signal.c                        |   14 +--------
 kernel/time/hrtimer.c                  |   48 ++++++++++++++++++++++++++++++++-
 kernel/time/itimer.c                   |   13 ++++++++
 kernel/time/posix-timers.c             |   42 +++++++++++-----------------
 kernel/time/tick-internal.h            |    1 
 net/can/bcm.c                          |    2 -
 sound/drivers/pcsp/pcsp_lib.c          |    2 -
 13 files changed, 92 insertions(+), 73 deletions(-)


             reply	other threads:[~2021-09-23 16:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-23 16:04 Thomas Gleixner [this message]
2021-09-23 16:04 ` [patch 01/11] hrtimer: Add a mechanism to catch runaway timers Thomas Gleixner
2021-09-24  8:16   ` Dmitry Vyukov
2021-09-23 16:04 ` [patch 02/11] mac80211-hwsim: Fix late beacon hrtimer handling Thomas Gleixner
2021-09-23 16:04 ` [patch 03/11] net: iosm: Use hrtimer_forward_now() Thomas Gleixner
2021-09-23 16:04 ` [patch 04/11] ALSA: pcsp: Make hrtimer forwarding more robust Thomas Gleixner
2021-09-28  8:58   ` Takashi Iwai
2021-09-23 16:04 ` [patch 05/11] can: bcm: Use hrtimer_forward_now() Thomas Gleixner
2021-10-13 13:59   ` Marc Kleine-Budde
2021-09-23 16:04 ` [patch 06/11] power: reset: ltc2952: " Thomas Gleixner
2021-09-27 12:34   ` Sebastian Reichel
2021-09-23 16:04 ` [patch 07/11] drm/i915/pmu: " Thomas Gleixner
2021-09-24  9:03   ` [Intel-gfx] " Tvrtko Ursulin
2021-09-23 16:04 ` [patch 08/11] signal: Move itimer rearming into itimer code Thomas Gleixner
2021-09-23 16:04 ` [patch 09/11] posix-timers: Fixup stale commnt and reduce ifdeffery Thomas Gleixner
2021-09-23 16:04 ` [patch 10/11] posix-timers: Use hrtimer_forward_now() Thomas Gleixner
2021-09-23 16:04 ` [patch 11/11] hrtimer: Make hrtimer_forward() private to core timer code Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210923153311.225307347@linutronix.de \
    --to=tglx@linutronix.de \
    --cc=airlied@linux.ie \
    --cc=alsa-devel@alsa-project.org \
    --cc=daniel@ffwll.ch \
    --cc=davem@davemloft.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=dvyukov@google.com \
    --cc=ebiederm@xmission.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=johannes.berg@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linuxwwan@intel.com \
    --cc=loic.poulain@linaro.org \
    --cc=m.chetan.kumar@intel.com \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=peterz@infradead.org \
    --cc=rodrigo.vivi@intel.com \
    --cc=ryazanov.s.a@gmail.com \
    --cc=socketcan@hartkopp.net \
    --cc=sre@kernel.org \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).