Re: [PATCH] mm/swap: fix race on swap_info reuse between swapoff and swapon

2014-01-31 Thread Hugh Dickins
On Mon, 13 Jan 2014, Weijie Yang wrote: > On Mon, Jan 13, 2014 at 2:27 PM, Mateusz Guzik wrote: > > > > Newly introduced window: > > > > p->swap_map == NULL && (p->flags & SWP_USED) > > > > breaks swap_info_get: > > if (!(p->flags & SWP_USED)) > > goto bad_device; > >

Re: [PATCH] mm/swap: fix race on swap_info reuse between swapoff and swapon

2014-01-31 Thread Hugh Dickins
On Thu, 9 Jan 2014, Weijie Yang wrote: > swapoff clear swap_info's SWP_USED flag prematurely and free its resources > after that. A concurrent swapon will reuse this swap_info while its previous > resources are not cleared completely. > > These late freed resources are: > - p->percpu_cluster > -

Re: [PATCH] mm/swap: fix race on swap_info reuse between swapoff and swapon

2014-01-12 Thread Weijie Yang
On Mon, Jan 13, 2014 at 2:27 PM, Mateusz Guzik wrote: > On Mon, Jan 13, 2014 at 11:51:42AM +0800, Weijie Yang wrote: >> On Mon, Jan 13, 2014 at 11:27 AM, Andrew Morton >> wrote: >> > On Mon, 13 Jan 2014 11:08:58 +0800 Weijie Yang >> > wrote: >> > >> >> >> --- a/mm/swapfile.c >> >> >> +++ b/mm/s

Re: [PATCH] mm/swap: fix race on swap_info reuse between swapoff and swapon

2014-01-12 Thread Mateusz Guzik
On Mon, Jan 13, 2014 at 11:51:42AM +0800, Weijie Yang wrote: > On Mon, Jan 13, 2014 at 11:27 AM, Andrew Morton > wrote: > > On Mon, 13 Jan 2014 11:08:58 +0800 Weijie Yang > > wrote: > > > >> >> --- a/mm/swapfile.c > >> >> +++ b/mm/swapfile.c > >> >> @@ -1922,7 +1922,6 @@ SYSCALL_DEFINE1(swapoff,

Re: [PATCH] mm/swap: fix race on swap_info reuse between swapoff and swapon

2014-01-12 Thread Weijie Yang
On Mon, Jan 13, 2014 at 11:27 AM, Andrew Morton wrote: > On Mon, 13 Jan 2014 11:08:58 +0800 Weijie Yang > wrote: > >> >> --- a/mm/swapfile.c >> >> +++ b/mm/swapfile.c >> >> @@ -1922,7 +1922,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, >> >> specialfile) >> >> p->swap_map = NULL; >>

Re: [PATCH] mm/swap: fix race on swap_info reuse between swapoff and swapon

2014-01-12 Thread Andrew Morton
On Mon, 13 Jan 2014 11:08:58 +0800 Weijie Yang wrote: > >> --- a/mm/swapfile.c > >> +++ b/mm/swapfile.c > >> @@ -1922,7 +1922,6 @@ SYSCALL_DEFINE1(swapoff, const char __user *, > >> specialfile) > >> p->swap_map = NULL; > >> cluster_info = p->cluster_info; > >> p->cluster_info

Re: [PATCH] mm/swap: fix race on swap_info reuse between swapoff and swapon

2014-01-12 Thread Weijie Yang
On Sat, Jan 11, 2014 at 9:11 AM, Andrew Morton wrote: > On Thu, 09 Jan 2014 13:39:55 +0800 Weijie Yang > wrote: > >> swapoff clear swap_info's SWP_USED flag prematurely and free its resources >> after that. A concurrent swapon will reuse this swap_info while its previous >> resources are not cle

Re: [PATCH] mm/swap: fix race on swap_info reuse between swapoff and swapon

2014-01-10 Thread Andrew Morton
On Thu, 09 Jan 2014 13:39:55 +0800 Weijie Yang wrote: > swapoff clear swap_info's SWP_USED flag prematurely and free its resources > after that. A concurrent swapon will reuse this swap_info while its previous > resources are not cleared completely. > > These late freed resources are: > - p->per

Re: [PATCH] mm/swap: fix race on swap_info reuse between swapoff and swapon

2014-01-10 Thread Andrew Morton
On Thu, 09 Jan 2014 13:39:55 +0800 Weijie Yang wrote: > swapoff clear swap_info's SWP_USED flag prematurely and free its resources > after that. A concurrent swapon will reuse this swap_info while its previous > resources are not cleared completely. > > These late freed resources are: > - p->per

[PATCH] mm/swap: fix race on swap_info reuse between swapoff and swapon

2014-01-08 Thread Weijie Yang
swapoff clear swap_info's SWP_USED flag prematurely and free its resources after that. A concurrent swapon will reuse this swap_info while its previous resources are not cleared completely. These late freed resources are: - p->percpu_cluster - swap_cgroup_ctrl[type] - block_device setting - inode-