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: <20150425201034.GA3008@amd>
Date:	Sat, 25 Apr 2015 22:10:34 +0200
From:	Pavel Machek <pavel@....cz>
To:	Jin Qian <jinqian@...roid.com>
Cc:	"Rafael J. Wysocki" <rjw@...ysocki.net>,
	Len Brown <len.brown@...el.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] power: increment wakeup_count when save_wakeup_count
 failed.

On Wed 2015-04-22 17:50:11, Jin Qian wrote:
> user-space aborts suspend attempt if writing wakeup_count failed.
> Count the write failure towards wakeup_count.

Why should writing wakeup_count fail? Can you make sure it does not
happen, instead?
								Pavel

> Signed-off-by: Jin Qian <jinqian@...roid.com>
> ---
>  drivers/base/power/wakeup.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
> index f24c622..bdb45f3 100644
> --- a/drivers/base/power/wakeup.c
> +++ b/drivers/base/power/wakeup.c
> @@ -57,6 +57,8 @@ static LIST_HEAD(wakeup_sources);
>  
>  static DECLARE_WAIT_QUEUE_HEAD(wakeup_count_wait_queue);
>  
> +static ktime_t last_read_time;
> +
>  /**
>   * wakeup_source_prepare - Prepare a new wakeup source for initialization.
>   * @ws: Wakeup source to prepare.
> @@ -771,10 +773,15 @@ void pm_wakeup_clear(void)
>  bool pm_get_wakeup_count(unsigned int *count, bool block)
>  {
>  	unsigned int cnt, inpr;
> +	unsigned long flags;
>  
>  	if (block) {
>  		DEFINE_WAIT(wait);
>  
> +		spin_lock_irqsave(&events_lock, flags);
> +		last_read_time = ktime_get();
> +		spin_unlock_irqrestore(&events_lock, flags);
> +
>  		for (;;) {
>  			prepare_to_wait(&wakeup_count_wait_queue, &wait,
>  					TASK_INTERRUPTIBLE);
> @@ -806,6 +813,7 @@ bool pm_save_wakeup_count(unsigned int count)
>  {
>  	unsigned int cnt, inpr;
>  	unsigned long flags;
> +	struct wakeup_source *ws;
>  
>  	events_check_enabled = false;
>  	spin_lock_irqsave(&events_lock, flags);
> @@ -813,6 +821,15 @@ bool pm_save_wakeup_count(unsigned int count)
>  	if (cnt == count && inpr == 0) {
>  		saved_count = count;
>  		events_check_enabled = true;
> +	} else {
> +		rcu_read_lock();
> +		list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
> +			if (ws->active ||
> +			    ktime_compare(ws->last_time, last_read_time) > 0) {
> +				ws->wakeup_count++;
> +			}
> +		}
> +		rcu_read_unlock();
>  	}
>  	spin_unlock_irqrestore(&events_lock, flags);
>  	return events_check_enabled;

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ