From: Jan Kara <jack@suse.cz>
To: Miklos Szeredi <mszeredi@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, Jan Kara <jack@suse.cz>,
Amir Goldstein <amir73il@gmail.com>,
Xiong Zhou <xzhou@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 7/7] fanotify: clean up CONFIG_FANOTIFY_ACCESS_PERMISSIONS ifdefs
Date: Mon, 30 Oct 2017 18:20:34 +0100 [thread overview]
Message-ID: <20171030172034.GN23278@quack2.suse.cz> (raw)
In-Reply-To: <1508920899-8115-8-git-send-email-mszeredi@redhat.com>
On Wed 25-10-17 10:41:39, Miklos Szeredi wrote:
> The only negative from this patch should be an addition of 32bytes to
> 'struct fsnotify_group' if CONFIG_FANOTIFY_ACCESS_PERMISSIONS is not
> defined.
>
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
I like this but some comments below.
> @@ -338,11 +332,14 @@ static ssize_t fanotify_read(struct file *file, char __user *buf,
>
> static ssize_t fanotify_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
> {
> -#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
> struct fanotify_response response = { .fd = -1, .response = -1 };
> struct fsnotify_group *group;
> int ret;
>
> + if (!IS_ENABLED(CONFIG_FANOTIFY_ACCESS_PERMISSIONS))
> + return -EINVAL;
> +
> +
Two empty lines here look superfluous.
> @@ -358,59 +355,57 @@ static ssize_t fanotify_write(struct file *file, const char __user *buf, size_t
> count = ret;
>
> return count;
> -#else
> - return -EINVAL;
> -#endif
> }
>
> static int fanotify_release(struct inode *ignored, struct file *file)
> {
> struct fsnotify_group *group = file->private_data;
>
> -#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
> - struct fanotify_perm_event_info *event, *next;
> - struct fsnotify_event *fsn_event;
> + if (IS_ENABLED(CONFIG_FANOTIFY_ACCESS_PERMISSIONS)) {
> + struct fanotify_perm_event_info *event, *next;
> + struct fsnotify_event *fsn_event;
Rather than doing this, I'd just let fanotify_release() go through the same
path for both CONFIG_FANOTIFY_ACCESS_PERMISSIONS enabled and disabled.
Enabled path won't be much more expensive since access_list will be empty
and we have to walk & destroy events anyway. That way you also don't have
to reindent everything.
> @@ -768,10 +763,10 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
> if (force_o_largefile())
> event_f_flags |= O_LARGEFILE;
> group->fanotify_data.f_flags = event_f_flags;
> -#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
> - init_waitqueue_head(&group->fanotify_data.access_waitq);
> - INIT_LIST_HEAD(&group->fanotify_data.access_list);
> -#endif
> + if (IS_ENABLED(CONFIG_FANOTIFY_ACCESS_PERMISSIONS)) {
> + init_waitqueue_head(&group->fanotify_data.access_waitq);
> + INIT_LIST_HEAD(&group->fanotify_data.access_list);
> + }
When having space for these allocated, just initialize them properly.
Otherwise it's asking for trouble.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2017-10-30 17:20 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-25 8:41 [PATCH v2 0/7] fix fanotify issues with the series in v4.12 Miklos Szeredi
2017-10-25 8:41 ` [PATCH v2 1/7] fsnotify: clean up fsnotify_prepare/finish_user_wait() Miklos Szeredi
2017-10-25 12:06 ` Amir Goldstein
2017-10-25 12:07 ` Amir Goldstein
2017-10-25 14:15 ` Miklos Szeredi
2017-10-25 8:41 ` [PATCH v2 2/7] fsnotify: pin both inode and vfsmount mark Miklos Szeredi
2017-10-30 13:34 ` Jan Kara
2017-10-30 13:42 ` Miklos Szeredi
2017-10-30 14:05 ` Jan Kara
2017-10-25 8:41 ` [PATCH v2 3/7] fsnotify: fix pinning group in fsnotify_prepare_user_wait() Miklos Szeredi
2017-10-25 8:41 ` [PATCH v2 4/7] fsnotify: skip unattached marks Miklos Szeredi
2017-10-30 14:00 ` Jan Kara
2017-10-30 14:27 ` Miklos Szeredi
2017-10-25 8:41 ` [PATCH v2 5/7] fanotify: fix fsnotify_prepare_user_wait() failure Miklos Szeredi
2017-10-25 8:41 ` [PATCH v2 6/7] fsnotify: clean up fsnotify() Miklos Szeredi
2017-10-25 11:46 ` Amir Goldstein
2017-10-25 8:41 ` [PATCH v2 7/7] fanotify: clean up CONFIG_FANOTIFY_ACCESS_PERMISSIONS ifdefs Miklos Szeredi
2017-10-25 11:44 ` Amir Goldstein
2017-10-25 14:19 ` Miklos Szeredi
2017-10-30 17:20 ` Jan Kara [this message]
2017-10-25 14:31 ` [PATCH v2 0/7] fix fanotify issues with the series in v4.12 Miklos Szeredi
2017-10-25 15:13 ` Amir Goldstein
2017-10-27 11:53 ` Jan Kara
2017-10-30 15:56 ` Miklos Szeredi
2017-10-30 17:27 ` Jan Kara
2017-10-30 20:18 ` Miklos Szeredi
2017-10-31 9:54 ` Jan Kara
2017-10-31 11:02 ` Amir Goldstein
2017-10-31 16:27 ` 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=20171030172034.GN23278@quack2.suse.cz \
--to=jack@suse.cz \
--cc=amir73il@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mszeredi@redhat.com \
--cc=xzhou@redhat.com \
/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).