From: Marko Rauhamaa <marko.rauhamaa@f-secure.com>
To: <linux-fsdevel@vger.kernel.org>
Cc: <marko.rauhamaa@f-secure.com>, Amir Goldstein <amir73il@gmail.com>
Subject: Reproducible, long-standing fanotify+autofs problem
Date: Wed, 25 Jan 2017 13:48:16 +0200 [thread overview]
Message-ID: <878tpztl6n.fsf@drapion.f-secure.com> (raw)
We have run into an easily reproducible fanotify hang that affects
several distros as well as the latest development kernel. (It isn't
fixed by Amir Goldstein's recent fanotify patch, BTW.)
Here is a simple reproduction:
1. Compile and build the tiny test program below, which has been
adapted from the example in "man fanotify":
cc -o fantest3 fantest.c
2. Install autofs.
3. Run these commands as root:
mkdir -p foo/home/test foo/user/test
echo /sshome /etc/auto.sshome >/etc/auto.master
echo "test / :/root/foo/home/test /user :/root/foo/user/test" \
>/etc/auto.sshome
systemctl start autofs
ls -l /sshome/test
./fantest3 / /sshome/test /sshome/test/user/
# NB! The final slash in the fantest3 command can be significant!
4. Observe the last command hang. While it is hung, other file system
operations from other processes are blocked.
5. Press Ctrl-C to force fantest3 to exit. The file system becomes
alive. Rerunning the fantest3 command no longer hangs.
6. To get back into the problem state, execute (as root):
systemctl restart autofs
ls -l /sshome/test
./fantest3 / /sshome/test /sshome/test/user/
===Begin fantest.c======================================================
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/fanotify.h>
int main(int argc, char *argv[])
{
int fd, i;
if (argc < 2) {
fprintf(stderr, "Usage: %s MOUNT ...\n", argv[0]);
exit(EXIT_FAILURE);
}
fd = fanotify_init(FAN_CLOEXEC | FAN_CLASS_CONTENT | FAN_NONBLOCK,
O_RDONLY);
if (fd == -1) {
perror("fanotify_init");
exit(EXIT_FAILURE);
}
for (i = 1; i < argc; i++)
if (fanotify_mark(fd, FAN_MARK_ADD | FAN_MARK_MOUNT,
FAN_OPEN_PERM | FAN_CLOSE_WRITE, AT_FDCWD,
argv[i]) == -1) {
perror("fanotify_mark");
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
}
===End fantest.c========================================================
Marko
next reply other threads:[~2017-01-25 11:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-25 11:48 Marko Rauhamaa [this message]
2017-01-25 12:03 ` Reproducible, long-standing fanotify+autofs problem Amir Goldstein
2017-01-25 14:06 ` Marko Rauhamaa
2017-01-25 14:11 ` Amir Goldstein
2017-01-25 14:42 ` Marko Rauhamaa
2017-01-25 14:54 ` Amir Goldstein
2017-01-25 15:15 ` Jan Kara
[not found] ` <87efzrrwec.fsf@drapion.f-secure.com>
[not found] ` <20170127134620.GA16757@quack2.suse.cz>
2017-01-27 14:21 ` Marko Rauhamaa
2017-01-25 15:20 ` Marko Rauhamaa
2017-01-26 17:47 ` Marko Rauhamaa
2017-01-26 18:05 ` Marko Rauhamaa
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=878tpztl6n.fsf@drapion.f-secure.com \
--to=marko.rauhamaa@f-secure.com \
--cc=amir73il@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.