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: <1518372105.2617.22.camel@decadent.org.uk>
Date:   Sun, 11 Feb 2018 18:01:45 +0000
From:   Ben Hutchings <ben@...adent.org.uk>
To:     alex chen <alex.chen@...wei.com>
Cc:     linux-kernel@...r.kernel.org, stable@...r.kernel.org,
        akpm@...ux-foundation.org, Joel Becker <jlbec@...lplan.org>,
        Joseph Qi <jiangqi903@...il.com>,
        Jun Piao <piaojun@...wei.com>,
        Mark Fasheh <mfasheh@...sity.com>,
        Changwei Ge <ge.changwei@....com>,
        Junxiao Bi <junxiao.bi@...cle.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH 3.2 39/79] ocfs2: should wait dio before inode lock in
 ocfs2_setattr()

On Sun, 2018-02-11 at 15:39 +0800, alex chen wrote:
> Hi Ben,
> 
> ocfs2_dio_end_io_write() was introduced in 4.6 and the problem this patch
> fixes is only exist in the kernel 4.6 and above 4.6.

Thanks for the reminder.  I'll drop this from the 3.2 and 3.16 patch
queues.

Ben.

> Thanks,
> Alex
> 
> On 2018/2/11 12:20, Ben Hutchings wrote:
> > 3.2.99-rc1 review patch.  If anyone has any objections, please let me know.
> > 
> > ------------------
> > 
> > From: alex chen <alex.chen@...wei.com>
> > 
> > commit 28f5a8a7c033cbf3e32277f4cc9c6afd74f05300 upstream.
> > 
> > we should wait dio requests to finish before inode lock in
> > ocfs2_setattr(), otherwise the following deadlock will happen:
> > 
> > process 1                  process 2                    process 3
> > truncate file 'A'          end_io of writing file 'A'   receiving the bast messages
> > ocfs2_setattr
> >  ocfs2_inode_lock_tracker
> >   ocfs2_inode_lock_full
> >  inode_dio_wait
> >   __inode_dio_wait
> >   -->waiting for all dio
> >   requests finish
> >                                                         dlm_proxy_ast_handler
> >                                                          dlm_do_local_bast
> >                                                           ocfs2_blocking_ast
> >                                                            ocfs2_generic_handle_bast
> >                                                             set OCFS2_LOCK_BLOCKED flag
> >                         dio_end_io
> >                          dio_bio_end_aio
> >                           dio_complete
> >                            ocfs2_dio_end_io
> >                             ocfs2_dio_end_io_write
> >                              ocfs2_inode_lock
> >                               __ocfs2_cluster_lock
> >                                ocfs2_wait_for_mask
> >                                -->waiting for OCFS2_LOCK_BLOCKED
> >                                flag to be cleared, that is waiting
> >                                for 'process 1' unlocking the inode lock
> >                            inode_dio_end
> >                            -->here dec the i_dio_count, but will never
> >                            be called, so a deadlock happened.
> > 
> > Link: http://lkml.kernel.org/r/59F81636.70508@huawei.com
> > Signed-off-by: Alex Chen <alex.chen@...wei.com>
> > Reviewed-by: Jun Piao <piaojun@...wei.com>
> > Reviewed-by: Joseph Qi <jiangqi903@...il.com>
> > Acked-by: Changwei Ge <ge.changwei@....com>
> > Cc: Mark Fasheh <mfasheh@...sity.com>
> > Cc: Joel Becker <jlbec@...lplan.org>
> > Cc: Junxiao Bi <junxiao.bi@...cle.com>
> > Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
> > Signed-off-by: Linus Torvalds <torvalds@...ux-foundation.org>
> > Signed-off-by: Ben Hutchings <ben@...adent.org.uk>
> > ---
> >  fs/ocfs2/file.c | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > --- a/fs/ocfs2/file.c
> > +++ b/fs/ocfs2/file.c
> > @@ -1130,6 +1130,13 @@ int ocfs2_setattr(struct dentry *dentry,
> >  		dquot_initialize(inode);
> >  	size_change = S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_SIZE;
> >  	if (size_change) {
> > +		/*
> > +		 * Here we should wait dio to finish before inode lock
> > +		 * to avoid a deadlock between ocfs2_setattr() and
> > +		 * ocfs2_dio_end_io_write()
> > +		 */
> > +		inode_dio_wait(inode);
> > +
> >  		status = ocfs2_rw_lock(inode, 1);
> >  		if (status < 0) {
> >  			mlog_errno(status);
> > @@ -1149,8 +1156,6 @@ int ocfs2_setattr(struct dentry *dentry,
> >  		if (status)
> >  			goto bail_unlock;
> >  
> > -		inode_dio_wait(inode);
> > -
> >  		if (i_size_read(inode) >= attr->ia_size) {
> >  			if (ocfs2_should_order_data(inode)) {
> >  				status = ocfs2_begin_ordered_truncate(inode,
> > 
> > 
> > .
> > 
> 
> 
-- 
Ben Hutchings
Sturgeon's Law: Ninety percent of everything is crap.


Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ