+ fanotify-use-fanotify-event-structure-for-permission-response-processing.patch added to -mm tree
Subsystems (2)
Subject: + fanotify-use-fanotify-event-structure-for-permission-response-processing.patch added to -mm tree
To: [email protected],[email protected]
From: [email protected]
Date: Thu, 30 Jan 2014 14:01:31 -0800
The patch titled
Subject: fanotify: use fanotify event structure for permission response processing
has been added to the -mm tree. Its filename is
fanotify-use-fanotify-event-structure-for-permission-response-processing.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/fanotify-use-fanotify-event-structure-for-permission-response-processing.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/fanotify-use-fanotify-event-structure-for-permission-response-processing.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Jan Kara <[email protected]>
Subject: fanotify: use fanotify event structure for permission response processing
Currently, fanotify creates new structure to track the fact that permission event has been reported to userspace and someone is waiting for a response to it. As event structures are now completely in the hands of each notification framework, we can use the event structure for this tracking instead of allocating a new structure.
Since this makes the event structures for normal events and permission events even more different and the structures have different lifetime rules, we split them into two separate structures (where permission event structure contains the structure for a normal event). This makes normal events 8 bytes smaller and the code a tad bit cleaner.
---
fs/notify/fanotify/fanotify.c | 63 ++++++++++----- fs/notify/fanotify/fanotify.h | 31 +++++-- fs/notify/fanotify/fanotify_user.c | 113 +++++++++------------------ 3 files changed, 109 insertions(+), 98 deletions(-)
fs/notify/fanotify/fanotify.c renamed from fs/notify/fanotify/fanotify.c~fanotify-use-fanotify-event-structure-for-permission-response-processing +45 -18
@@ -60,8 +60,8 @@ static int fanotify_merge(struct list_he }#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS -static int fanotify_get_response_from_access (struct fsnotify_group *group, -struct fanotify_event_info *event) +static int fanotify_get_response (struct fsnotify_group *group, +struct fanotify_perm_event_info *event) {int ret;
@@ -142,6 +142,40 @@ static bool fanotify_should_send_event(sreturn false; } +static struct fanotify_event_info *alloc_event (struct inode *inode,u32 mask, +struct path *path) +{ +struct fanotify_event_info *event; + +#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS +if (mask &FAN_ALL_PERM_EVENTS ) { +struct fanotify_perm_event_info *pevent; + + pevent =kmem_cache_alloc (fanotify_perm_event_cachep, +GFP_KERNEL ); +if (!pevent) +return NULL ; + event = &pevent->fae; + pevent->response =0 ; + goto init; + } +#endif + event =kmem_cache_alloc (fanotify_event_cachep,GFP_KERNEL ); +if (!event) +return NULL ; +init:__maybe_unused +fsnotify_init_event (&event->fse, inode, mask); + event->tgid =get_pid (task_tgid (current)); +if (data_type ==FSNOTIFY_EVENT_PATH ) { + event->path = *path; +path_get (&event->path); + }else { + event->path.mnt =NULL ; + event->path.dentry =NULL ; + } +return event; +} + static int fanotify_handle_event(struct fsnotify_group *group, struct inode *inode, struct fsnotify_mark *inode_mark,
@@ -171,25 +205,11 @@ static int fanotify_handle_event(structpr_debug ("%s: group=%p inode=%p mask=%x\n" , __func__, group, inode, mask); - event =kmem_cache_alloc (fanotify_event_cachep,GFP_KERNEL ); + event =alloc_event (inode, mask, data);if (unlikely (!event))return -ENOMEM ; fsn_event = &event->fse; -fsnotify_init_event (fsn_event, inode, mask); - event->tgid =get_pid (task_tgid (current)); -if (data_type ==FSNOTIFY_EVENT_PATH ) { -struct path *path = data; - event->path = *path; -path_get (&event->path); - }else { - event->path.mnt =NULL ; - event->path.dentry =NULL ; - } -#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS - event->response =0 ; -#endif - ret =fsnotify_add_notify_event (group, fsn_event, fanotify_merge);if (ret) {BUG_ON (mask &FAN_ALL_PERM_EVENTS );
@@ -200,7 +220,7 @@ static int fanotify_handle_event(struct#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS if (mask &FAN_ALL_PERM_EVENTS ) { - ret =fanotify_get_response_from_access (group, event); + ret =fanotify_get_response (group,FANOTIFY_PE (fsn_event));fsnotify_destroy_event (group, fsn_event); }#endif
@@ -223,6 +243,13 @@ static void fanotify_free_event(struct f event =FANOTIFY_E (fsn_event);path_put (&event->path);put_pid (event->tgid); +#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS +if (fsn_event->mask &FAN_ALL_PERM_EVENTS ) { +kmem_cache_free (fanotify_perm_event_cachep, +FANOTIFY_PE (fsn_event)); +return ; + } +#endif kmem_cache_free (fanotify_event_cachep, event); }
fs/notify/fanotify/fanotify.h renamed from fs/notify/fanotify/fanotify.h~fanotify-use-fanotify-event-structure-for-permission-response-processing +24 -7
@@ -3,13 +3,12 @@#include <linux/slab.h> extern struct kmem_cache *fanotify_event_cachep; +extern struct kmem_cache *fanotify_perm_event_cachep;/* -* Lifetime of the structure differs for normal and permission events. In both -* cases the structure is allocated in fanotify_handle_event(). For normal -* events the structure is freed immediately after reporting it to userspace. -* For permission events we free it only after we receive response from -* userspace. +* Structure for normal fanotify events. It gets allocated in +* fanotify_handle_event() and freed when the information is retrieved by +* userspace */ struct fanotify_event_info {struct fsnotify_event fse;
@@ -19,11 +18,29 @@ struct fanotify_event_info {*/ struct path path;struct pid *tgid; +}; +#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS -u32 response;/* userspace answer to question */ -#endif +/* +* Structure for permission fanotify events. It gets allocated and freed in +* fanotify_handle_event() since we wait there for user response. When the +* information is retrieved by userspace the structure is moved from +* group->notification_list to group->fanotify_data.access_list to wait for +* user response. +*/ +struct fanotify_perm_event_info { +struct fanotify_event_info fae; +int response;/* userspace answer to question */ +int fd;/* fd we passed to userspace for this event */ }; +static inline struct fanotify_perm_event_info * +FANOTIFY_PE (struct fsnotify_event *fse) +{ + return container_of(fse, struct fanotify_perm_event_info, fae.fse); +} +#endif +static inline struct fanotify_event_info *FANOTIFY_E (struct fsnotify_event *fse) { return container_of(fse, struct fanotify_event_info, fse);
fs/notify/fanotify/fanotify_user.c renamed from fs/notify/fanotify/fanotify_user.c~fanotify-use-fanotify-event-structure-for-permission-response-processing +40 -73
190 lines not on this page · raw message
_
Patches currently in -mm which might be from [email protected] are
origin.patch
fanotify-remove-useless-bypass_perm-check.patch fanotify-use-fanotify-event-structure-for-permission-response-processing.patch fanotify-remove-useless-test-from-event-initialization.patch fanotify-convert-access_mutex-to-spinlock.patch fanotify-reorganize-loop-in-fanotify_read.patch fanotify-move-unrelated-handling-from-copy_event_to_user.patch linux-next.patch kernel-use-lockless-list-for-smp_call_function_single.patch mm-add-strictlimit-knob-v2.patch