Skip to content

Commit

Permalink
fanotify: deny permissions when no event was sent
Browse files Browse the repository at this point in the history
If no event was sent to userspace we cannot expect userspace to respond to
permissions requests.  Today such requests just hang forever. This patch will
deny any permissions event which was unable to be sent to userspace.

Reported-by: Tvrtko Ursulin <tvrtko.ursulin@sophos.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
  • Loading branch information
Eric Paris committed Dec 7, 2010
1 parent e8a7e48 commit ecf6f5e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions fs/notify/fanotify/fanotify_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static int create_fd(struct fsnotify_group *group, struct fsnotify_event *event)
return client_fd;
}

static ssize_t fill_event_metadata(struct fsnotify_group *group,
static int fill_event_metadata(struct fsnotify_group *group,
struct fanotify_event_metadata *metadata,
struct fsnotify_event *event)
{
Expand Down Expand Up @@ -257,10 +257,11 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,

pr_debug("%s: group=%p event=%p\n", __func__, group, event);

fd = fill_event_metadata(group, &fanotify_event_metadata, event);
if (fd < 0)
return fd;
ret = fill_event_metadata(group, &fanotify_event_metadata, event);
if (ret < 0)
goto out;

fd = ret;
ret = prepare_for_access_response(group, event, fd);
if (ret)
goto out_close_fd;
Expand All @@ -275,6 +276,13 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
remove_access_response(group, event, fd);
out_close_fd:
sys_close(fd);
out:
#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
if (event->mask & FAN_ALL_PERM_EVENTS) {
event->response = FAN_DENY;
wake_up(&group->fanotify_data.access_waitq);
}
#endif
return ret;
}

Expand Down

0 comments on commit ecf6f5e

Please sign in to comment.