From: Yann Droneaud <ydroneaud@opteya.com>
To: Lino Sanfilippo <LinoSanfilippo@gmx.de>
Cc: linux-kernel@vger.kernel.org, Eric Paris <eparis@redhat.com>,
Al Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCHv5 5/7] fanotify: enable close-on-exec on events' fd when requested in fanotify_init()
Date: Mon, 20 Jan 2014 18:15:30 +0100 [thread overview]
Message-ID: <1390238130.3865.20.camel@localhost.localdomain> (raw)
In-Reply-To: <3d9591f81e62a78a726721c8052b3910870db35e.1388952061.git.ydroneaud@opteya.com>
Hi Lino,
I've recently sent this patch which may fix a bug in the way fanotify
creates its file descriptors.
I failed to noticed you've been working recently on fanotify subsystem
and miss the opportunity to add you in the Cc:s.
Please have a look to this patch and help to get it merged.
Le dimanche 05 janvier 2014 à 21:36 +0100, Yann Droneaud a écrit :
> According to commit 80af258867648, file descriptor created as part
> of file access notification events inherit flags from the event_f_flags
> argument passed to syscall fanotify_init(2).
>
> So while it is legal for userspace to call fanotify_init() with O_CLOEXEC
> as part of its second argument, O_CLOEXEC is currently silently ignored.
>
> Indeed event_f_flags are only given to dentry_open(), which only
> seems to care about O_ACCMODE and O_PATH in do_dentry_open(), O_DIRECT
> in open_check_o_direct() and O_LARGEFILE in generic_file_open().
>
> More, there's no effective check on event_f_flags value that would
> catch unknown / unsupported values, unlike the one on f_flags argument
> of the syscall (see FAN_ALL_INIT_FLAGS in include/uapi/linux/fanotify.h).
...
> But it seems logical to set close-on-exec flag on the file descriptor
> if userspace is allowed to request it with O_CLOEXEC.
>
...
> So this patch replaces call to macro get_unused_fd() by a call to
> function get_unused_fd_flags() with event_f_flags value as argument.
> This way O_CLOEXEC flag in the second argument of fanotify_init(2)
> syscall is interpreted so that close-on-exec get enabled.
...
> Cc: Eric Paris <eparis@redhat.com>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: stable@vger.kernel.org
> Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
> Link:
> http://lkml.kernel.org/r/cover.1388952061.git.ydroneaud@opteya.com
>
> ---
> fs/notify/fanotify/fanotify_user.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
> index 57d7c083cb4b..6d0eaabba02e 100644
> --- a/fs/notify/fanotify/fanotify_user.c
> +++ b/fs/notify/fanotify/fanotify_user.c
> @@ -71,7 +71,7 @@ static int create_fd(struct fsnotify_group *group,
>
> pr_debug("%s: group=%p event=%p\n", __func__, group, event);
>
> - client_fd = get_unused_fd();
> + client_fd = get_unused_fd_flags(group->fanotify_data.f_flags);
> if (client_fd < 0)
> return client_fd;
>
Regards.
--
Yann Droneaud
OPTEYA
next prev parent reply other threads:[~2014-01-20 17:15 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-05 20:36 [PATCH v5 0/7] Getting rid of get_unused_fd() / enable close-on-exec Yann Droneaud
2014-01-05 20:36 ` [PATCHv5 1/7] ia64: use get_unused_fd_flags(0) instead of get_unused_fd() Yann Droneaud
2014-01-05 20:36 ` [PATCHv5 2/7] ppc/cell: " Yann Droneaud
2014-01-05 20:36 ` [PATCHv5 3/7] binfmt_misc: " Yann Droneaud
2014-01-05 20:36 ` [PATCHv5 4/7] file: " Yann Droneaud
2014-01-05 20:36 ` [PATCHv5 5/7] fanotify: enable close-on-exec on events' fd when requested in fanotify_init() Yann Droneaud
2014-01-20 17:15 ` Yann Droneaud [this message]
2014-01-05 20:36 ` [PATCHv5 6/7] perf: introduce a flag to enable close-on-exec in perf_event_open() Yann Droneaud
2014-01-06 9:29 ` Peter Zijlstra
2014-01-06 10:51 ` [PATCH] perf tools: enable close-on-exec flag on perf file descriptor Yann Droneaud
2014-01-06 11:24 ` Peter Zijlstra
2014-01-06 14:43 ` Arnaldo Carvalho de Melo
2014-01-06 21:01 ` Yann Droneaud
2014-01-06 21:14 ` Arnaldo Carvalho de Melo
2014-01-06 14:22 ` Jiri Olsa
2014-01-06 15:31 ` Yann Droneaud
2014-01-11 18:07 ` [PATCHv1] " Yann Droneaud
2014-01-13 10:09 ` [PATCHv2] " Yann Droneaud
2014-01-15 18:50 ` Arnaldo Carvalho de Melo
2014-01-26 21:20 ` [PATCHv3] " Yann Droneaud
2014-03-11 8:39 ` [PATCHv4] " Yann Droneaud
2014-06-02 10:56 ` [PATCHv5] " Yann Droneaud
2014-06-02 19:23 ` Jiri Olsa
2014-06-03 8:57 ` Yann Droneaud
2014-06-03 9:23 ` Adrian Hunter
2014-06-03 11:51 ` Jiri Olsa
2014-06-30 20:28 ` [PATCHv6] " Yann Droneaud
2014-07-12 23:28 ` Jiri Olsa
2014-01-06 16:27 ` [PATCH] " Andi Kleen
2014-01-06 16:39 ` Peter Zijlstra
2014-01-06 16:52 ` Andi Kleen
2014-01-06 17:15 ` Yann Droneaud
2014-01-12 18:43 ` [tip:perf/core] perf: Introduce a flag to enable close-on-exec in perf_event_open() tip-bot for Yann Droneaud
2014-01-05 20:36 ` [PATCHv5 7/7] file: remove macro get_unused_fd() Yann Droneaud
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=1390238130.3865.20.camel@localhost.localdomain \
--to=ydroneaud@opteya.com \
--cc=LinoSanfilippo@gmx.de \
--cc=akpm@linux-foundation.org \
--cc=eparis@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®