Re: c/r: broken locking when executing map_files
From: Cyrill Gorcunov
Date: Sat May 05 2012 - 15:32:04 EST
On Sat, May 05, 2012 at 10:53:06PM +0400, Cyrill Gorcunov wrote:
> On Sat, May 05, 2012 at 10:20:51PM +0400, Vasiliy Kulikov wrote:
> ...
> > > ---
> > > fs/proc/base.c | 8 +++-----
> > > 1 file changed, 3 insertions(+), 5 deletions(-)
> > >
> > > Index: linux-2.6.git/fs/proc/base.c
> > > ===================================================================
> > > --- linux-2.6.git.orig/fs/proc/base.c
> > > +++ linux-2.6.git/fs/proc/base.c
> > > @@ -2226,16 +2226,16 @@ static struct dentry *proc_map_files_loo
> > > goto out;
> > >
> > > result = ERR_PTR(-EACCES);
> > > - if (lock_trace(task))
> > > + if (!ptrace_may_access(task, PTRACE_MODE_READ))
> >
> > Probably it will be better to change mutex_lock_killable() to
> > mutex_lock_killable_nested() inside of lock_trace() instead of this change?
> > It would keep the race-free check.
>
> Yup, if I'm not missing something SINGLE_DEPTH_NESTING should do the trick
> for us. I'll test and report.
Hmm, this doesn't work well, the mutex remanins killable so when one does
| [root@neptune ~]# /proc/self/map_files/400000-419000
it sleeps forever until killed, which is not good I think. Vasiliy, could
you remind me what exactly is problem if we use unlocked ptrace_may_access
here?
Cyrill
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/