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]
Date:	Thu, 2 Dec 2010 01:00:39 +0100
From:	"Rafael J. Wysocki" <rjw@...k.pl>
To:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Cc:	Hugh Dickins <hughd@...gle.com>,
	Ondrej Zary <linux@...nbow-software.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
	Kernel development list <linux-kernel@...r.kernel.org>,
	Balbir Singh <balbir@...ibm.com>
Subject: Re: 2.6.35.5: hibernation broken... AGAIN

On Thursday, December 02, 2010, KAMEZAWA Hiroyuki wrote:
> On Wed, 1 Dec 2010 23:23:31 +0100
> "Rafael J. Wysocki" <rjw@...k.pl> wrote:
> 
> > On Wednesday, December 01, 2010, Rafael J. Wysocki wrote:
> > > On Wednesday, December 01, 2010, KAMEZAWA Hiroyuki wrote:
> > > > On Wed, 1 Dec 2010 01:38:53 +0100
> > > > "Rafael J. Wysocki" <rjw@...k.pl> wrote:
> > > > 
> > > > > On Wednesday, December 01, 2010, Rafael J. Wysocki wrote:
> > > > > > On Tuesday, November 30, 2010, Hugh Dickins wrote:
> > > > > > > On Sat, 27 Nov 2010, Rafael J. Wysocki wrote:
> > > > > > > > On Saturday, November 27, 2010, Ondrej Zary wrote:
> > > > > ...
> > > > > > > 
> > > > > > > Trivial point, I suppose, but it bothers me that PM is accumulating
> > > > > > > wrappers around wrappers around gfp_allowed_mask.  Looks like
> > > > > > > clear_gfp_allowed_mask and set_gfp_allowed_mask (oddly asymmetrical)
> > > > > > > were not really what we need.  How about scrapping them, and putting
> > > > > > > pm_restrict_gfp_mask() and pm_restore_gfp_mask() into page_alloc.c?
> > > > > > 
> > > > > > Sure, that sounds like a good idea indeed.
> > > > > 
> > > > > Below is an updated patch in which I tried to address your comments.
> > > > > 
> > > > > I didn't find it very useful to couple pm_restore_gfp_mask() with the thawing
> > > > > of tasks, but nevertheless I think all of the spots where it's needed are
> > > > > covered now.
> > > > > 
> > > > > The patch has only been compile-tested for now, so caveat emptor.
> > > > > 
> > > > 
> > > > Hmm, can't we have some error check as 
> > > > 
> > > > > +static gfp_t saved_gfp_mask;
> > > > 
> > > > atomic_t gfp_mask_save_mode_counter;
> > > > 
> > > > > +
> > > > > +void pm_restore_gfp_mask(void)
> > > > >  {
> > > > >  	WARN_ON(!mutex_is_locked(&pm_mutex));
> > > > > -	gfp_allowed_mask = mask;
> > > > 
> > > > 	if (atomic_dec_return(&gfp_mask_save_mode_counter))
> > > > 		WARN_ONCE()
> > > > 
> > > > > +	if (saved_gfp_mask) {
> > > > > +		gfp_allowed_mask = saved_gfp_mask;
> > > > > +		saved_gfp_mask = 0;
> > > > > +	}
> > > > >  }
> > > > 
> > > > > +void pm_restrict_gfp_mask(void)
> > > > >  {
> > > > > -	gfp_t ret = gfp_allowed_mask;
> > > > > -
> > > > >  	WARN_ON(!mutex_is_locked(&pm_mutex));
> > > > > -	gfp_allowed_mask &= ~mask;
> > > > > -	return ret;
> > > > > +	saved_gfp_mask = gfp_allowed_mask;
> > > > > +	gfp_allowed_mask &= ~GFP_IOFS;
> > > > 
> > > > 	if (atomic_inc_return(&gfp_mask_save_mode_counter) > 1)
> > > > 		WARN_ONCE()
> > > > 
> > > > or some ?
> > > 
> > > What exactly would that be useful for?
> > 
> > Please note that pm_restore_gfp_mask() can be legitimately called before
> > pm_restrict_gfp_mask() via the SNAPSHOT_CREATE_IMAGE hibernate ioctl, so the
> > test you're suggesting wouldn't really work.
> > 
> 
> Hm, I just wonder some tests not for breaking gfp_allowed_mask by
>  - double call

That's easy.  It's sufficient to do WARN_ON(saved_gfp_mask) at the beginning
of pm_restrict_gfp_mask().  This also takes care of the "forget to restore"
case to some extent, because pm_restrict_gfp_mask() will generally be only
called twice in a row if there's a missing pm_restore_gfp_mask() in between.

>  - forget to restore

This is kind of difficult in general.  You can't detect a missing
pm_restore_gfp_mask() other than by checking if pm_restrict_gfp_mask() is not
called twice in a row IMHO.

> That will be fatal.

Yes, it will.

> I'm not very interested in implementation detail

Well ...

Thanks,
Rafael
--
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