Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1468992

Re: [PATCH 2/2] timekeeping: Cap array access in timekeeping_debug to protect against invalid sleep times

From Chen Yu <yu.c.chen@intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] timekeeping: Cap array access in timekeeping_debug to protect against invalid sleep times
Date 2016-08-24 03:00 +0200
Message-ID <s9uHT-39E-1@gated-at.bofh.it> (permalink)
References <s9sZs-2eX-19@gated-at.bofh.it> <s9sZs-2eX-27@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi John, some small typos below, others should be OK.

On Tue, Aug 23, 2016 at 04:08:22PM -0700, John Stultz wrote:
> It was reported that hibernation could fail on the 2nd attempt,
> where the system hangs at hibernate() -> syscore_resume() ->
> i8237A_resume() -> claim_dma_lock(), because the lock has
> already been taken.
> 
> However there is actually no other process would like to grab
> this lock on that problematic platform.
> 
> Further investigation showed that the problem is triggered by
> setting /sys/power/pm_trace to 1 before the 1st hibernation.
> 
> Since once pm_trace is enabled, the rtc becomes unmeaningful
> after suspend, and meanwhile some BIOSes would like to adjust
> the 'invalid' tsc(e.g, smaller than 1970) to the release date
I checked the previous commit log, and I have made a mistake, it
should be:
s/tsc/RTC
> of that motherboard during POST stage, thus after resumed, it
> may seem that the system had a significant long sleep time might
> due to meaningless tsc or RTC delta.
s/tsc or RTC/RTC
> 
> Then in timekeeping_resume -> tk_debug_account_sleep_time, if
> the bit31 of the sleep time happened to be set to 1, the fls
> returns 32 and then we add 1 to sleep_time_bin[32], which
> caused a memory overwritten.
> 
> As depicted by System.map:
> 0xffffffff81c9d080 b sleep_time_bin
> 0xffffffff81c9d100 B dma_spin_lock
> the dma_spin_lock.val is set to 1, which caused this problem.
> 
> This patch adds a sanity check in tk_debug_account_sleep_time()
> to ensure we don't index past the sleep_time_bin array.
> 
BTW, I've also post a fix to deal with pm_trace which might break
timekeeping at:
https://patchwork.kernel.org/patch/9287347/
could you please hel take a glance? thanks.

Yu

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[GIT PULL][PATCH 0/2] Timekeeping items for 4.8 via tip/timers/urgent John Stultz <john.stultz@linaro.org> - 2016-08-24 01:10 +0200
  [PATCH 2/2] timekeeping: Cap array access in timekeeping_debug to protect against invalid sleep times John Stultz <john.stultz@linaro.org> - 2016-08-24 01:10 +0200
    Re: [PATCH 2/2] timekeeping: Cap array access in timekeeping_debug  to protect against invalid sleep times Chen Yu <yu.c.chen@intel.com> - 2016-08-24 03:00 +0200
      Re: [PATCH 2/2] timekeeping: Cap array access in timekeeping_debug to  protect against invalid sleep times John Stultz <john.stultz@linaro.org> - 2016-08-24 05:00 +0200
    [RFC][PATCH v2] timekeeping: Cap array access in timekeeping_debug to protect against invalid sleep times John Stultz <john.stultz@linaro.org> - 2016-08-24 05:10 +0200
    [tip:timers/urgent] timekeeping: Cap array access in  timekeeping_debug tip-bot for John Stultz <tipbot@zytor.com> - 2016-08-24 09:50 +0200
  [PATCH 1/2] timekeeping: Avoid taking lock in NMI path with CONFIG_DEBUG_TIMEKEEPING John Stultz <john.stultz@linaro.org> - 2016-08-24 01:20 +0200
    [tip:timers/urgent] timekeeping: Avoid taking lock in NMI path with  CONFIG_DEBUG_TIMEKEEPING tip-bot for John Stultz <tipbot@zytor.com> - 2016-08-24 09:50 +0200

csiph-web