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:	Wed, 27 May 2009 14:00:01 +0900
From:	Daisuke Nishimura <nishimura@....nes.nec.co.jp>
To:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Cc:	"linux-mm@...ck.org" <linux-mm@...ck.org>,
	"balbir@...ux.vnet.ibm.com" <balbir@...ux.vnet.ibm.com>,
	"hugh.dickins@...cali.co.uk" <hugh.dickins@...cali.co.uk>,
	"hannes@...xchg.org" <hannes@...xchg.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Daisuke Nishimura <nishimura@....nes.nec.co.jp>
Subject: Re: [RFC][PATCH 2/5] add SWAP_HAS_CACHE flag to swap_map

On Wed, 27 May 2009 13:36:29 +0900, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com> wrote:
> On Wed, 27 May 2009 13:02:46 +0900
> Daisuke Nishimura <nishimura@....nes.nec.co.jp> wrote:
> 
> > > @@ -1067,21 +1113,21 @@ static int try_to_unuse(unsigned int typ
> > >  		}
> > >  
> > >  		/*
> > > -		 * How could swap count reach 0x7fff when the maximum
> > > -		 * pid is 0x7fff, and there's no way to repeat a swap
> > > -		 * page within an mm (except in shmem, where it's the
> > > -		 * shared object which takes the reference count)?
> > > -		 * We believe SWAP_MAP_MAX cannot occur in Linux 2.4.
> > > -		 *
> > > +		 * How could swap count reach 0x7ffe ?
> > > +		 * There's no way to repeat a swap page within an mm
> > > +		 * (except in shmem, where it's the shared object which takes
> > > +		 * the reference count)?
> > > +		 * We believe SWAP_MAP_MAX cannot occur.(if occur, unsigned
> > > +		 * short is too small....)
> > >  		 * If that's wrong, then we should worry more about
> > >  		 * exit_mmap() and do_munmap() cases described above:
> > >  		 * we might be resetting SWAP_MAP_MAX too early here.
> > >  		 * We know "Undead"s can happen, they're okay, so don't
> > >  		 * report them; but do report if we reset SWAP_MAP_MAX.
> > >  		 */
> > > -		if (*swap_map == SWAP_MAP_MAX) {
> > > +		if (swap_count(*swap_map) == SWAP_MAP_MAX) {
> > >  			spin_lock(&swap_lock);
> > > -			*swap_map = 1;
> > > +			*swap_map = make_swap_count(0, 1);
> > Can we assume the entry has SWAP_HAS_CACHE here ?
> > Shouldn't we check PageSwapCache beforehand ?
> > 
> 
> IIUC, in this try_to_unuse code, the page is added to swap cache and locked
> before reaches here. But....ah,ok, unuse_mm() may release lock_page() before
> reach here. Then...
> 
And the owner process might have removed the swap cache before we take the lock,
as the following comments in try_to_unuse() says.

> if (PageSwapCache(page) && swap_count(*swap_map) == SWAP_MAP_MAX)
> 
> is right ? (maybe original code, set to "1" is also buggy.)
> 
Reading the following code in try_to_unuse(), I think

	int valid_swap_cache = !!(PageSwapCache(page) &&
					page_private(page) == entry.val)
	  :
	*swap_map = make_swap_count(0(or 1?), valid_swap_cache);

might be better.

But I can't confirm it anyway. I've never hit SWAP_MAP_MAX.


Thanks,
Daisuke Nishimura.
--
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