Re: fanotify permission events on virtual filesystem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed 20-03-19 15:46:20, Amir Goldstein wrote:
> On Wed, Mar 20, 2019 at 3:16 PM Jan Kara <jack@xxxxxxx> wrote:
> > recently, one of our customers has reported a deadlock with fanotify. The
> > analysis has shown that a process has put (likely by mistake) FAN_OPEN_PERM
> > mark on /proc and / filesystem. That resulted in a deadlock like follows:
> >
> > process 1:                      process 2:              process 3:
> > open("/proc/process 2/maps")
> >   - blocks waiting for response to
> >     FAN_OPEN_PERM event
> >
> >                                 exec(2)
> >                                   __do_execve_file()
> >                                     - grabs current->signal->cred_guard_mutex
> >                                     do_open_execat()
> >                                       - blocks waiting for response to
> >                                         FAN_OPEN_PERM event
> >
> >                                                         reads fanotify event
> >                                                         generated by process 1
> >                                                           create_fd()
> >                                                             dentry_open()
> >                                                               proc_maps_open()
> >                                                                 blocks on
> >                                                 cred_guard_mutex of process 2.
> >
> > Now this is not the only case where you can setup fanotify permissions
> > events so that your listener deadlocks but I'd argue that this case is
> > especially nasty and it is unrealistic to expect from userspace that it
> > would be able to implement fanotify listener in such a way that is
> > deadlock-free for proc filesystem since the lock dependencies there are
> > very different. So how about we just forbid placing marks with fanotify
> > permission events on proc? Any other virtual filesystem we should exclude?
> >
> 
> I bet if we forbid placing marks on /proc, some apps would break.

Well, I didn't mean all marks, just the permission ones. I'm not sure there
are apps that place permission events on /proc...

> I always though that allowing O_PATH in event_f_flags can make
> sense for some apps.
> 
> What if instead of forbiding marks of /proc, we would force those
> marks to use O_PATH for fd creation. Some of the functionality
> will remain. Apps are less likely to break. Deadlocks will be less
> likely, although maybe still possible.

Yes, that's another option. But if this is automatic, it is going to be
confusing to potential users - report O_PATH fd if getting normal fd is
dangerous isn't great. And also the deadlocks are there only for permission
events so there's no strong reason to restrict normal ones.

> Note that the new FAN_REPORT_FID listener already excludes
> marking most virtual filesystems for lack of s_export_op.

Yes, I know.

								Honza
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux