mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-28 07:04:00 +08:00
23281c8034
Pull fsnotify updates from Jan Kara: - fixes of use-after-tree issues when handling fanotify permission events from Miklos - refcount_t conversions from Elena - fixes of ENOMEM handling in dnotify and fsnotify from me * 'fsnotify' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: fsnotify: convert fsnotify_mark.refcnt from atomic_t to refcount_t fanotify: clean up CONFIG_FANOTIFY_ACCESS_PERMISSIONS ifdefs fsnotify: clean up fsnotify() fanotify: fix fsnotify_prepare_user_wait() failure fsnotify: fix pinning group in fsnotify_prepare_user_wait() fsnotify: pin both inode and vfsmount mark fsnotify: clean up fsnotify_prepare/finish_user_wait() fsnotify: convert fsnotify_group.refcnt from atomic_t to refcount_t fsnotify: Protect bail out path of fsnotify_add_mark_locked() properly dnotify: Handle errors from fsnotify_add_mark_locked() in fcntl_dirnotify()
57 lines
1.7 KiB
C
57 lines
1.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#include <linux/fsnotify_backend.h>
|
|
#include <linux/path.h>
|
|
#include <linux/slab.h>
|
|
|
|
extern struct kmem_cache *fanotify_mark_cache;
|
|
extern struct kmem_cache *fanotify_event_cachep;
|
|
extern struct kmem_cache *fanotify_perm_event_cachep;
|
|
|
|
/*
|
|
* 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;
|
|
/*
|
|
* We hold ref to this path so it may be dereferenced at any point
|
|
* during this object's lifetime
|
|
*/
|
|
struct path path;
|
|
struct pid *tgid;
|
|
};
|
|
|
|
/*
|
|
* 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);
|
|
}
|
|
|
|
static inline bool fanotify_is_perm_event(u32 mask)
|
|
{
|
|
return IS_ENABLED(CONFIG_FANOTIFY_ACCESS_PERMISSIONS) &&
|
|
mask & FAN_ALL_PERM_EVENTS;
|
|
}
|
|
|
|
static inline struct fanotify_event_info *FANOTIFY_E(struct fsnotify_event *fse)
|
|
{
|
|
return container_of(fse, struct fanotify_event_info, fse);
|
|
}
|
|
|
|
struct fanotify_event_info *fanotify_alloc_event(struct inode *inode, u32 mask,
|
|
const struct path *path);
|