linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: linux-fsdevel@vger.kernel.org
Cc: Amir Goldstein <amir73il@gmail.com>,
	mhocko@suse.cz, Al Viro <viro@zeniv.linux.org.uk>
Subject: fanotify permission events on virtual filesystem
Date: Wed, 20 Mar 2019 14:16:42 +0100	[thread overview]
Message-ID: <20190320131642.GE9485@quack2.suse.cz> (raw)

Hello,

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?

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

             reply	other threads:[~2019-03-20 13:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 13:16 Jan Kara [this message]
2019-03-20 13:46 ` fanotify permission events on virtual filesystem Amir Goldstein
2019-03-20 14:30   ` Jan Kara
2019-03-20 15:02     ` Amir Goldstein
2019-03-21  8:36       ` Marko Rauhamaa
2019-04-01 17:26       ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190320131642.GE9485@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=amir73il@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mhocko@suse.cz \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).