diff options
| -rw-r--r-- | fs/notify/fanotify/fanotify_user.c | 9 | ||||
| -rw-r--r-- | include/linux/fsnotify_backend.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 43d66d9b2eff..1d33d7db277a 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <asm/ioctls.h> | 17 | #include <asm/ioctls.h> |
| 18 | 18 | ||
| 19 | #define FANOTIFY_DEFAULT_MAX_EVENTS 16384 | 19 | #define FANOTIFY_DEFAULT_MAX_EVENTS 16384 |
| 20 | #define FANOTIFY_DEFAULT_MAX_MARKS 8192 | ||
| 20 | 21 | ||
| 21 | extern const struct fsnotify_ops fanotify_fsnotify_ops; | 22 | extern const struct fsnotify_ops fanotify_fsnotify_ops; |
| 22 | 23 | ||
| @@ -584,6 +585,9 @@ static int fanotify_add_vfsmount_mark(struct fsnotify_group *group, | |||
| 584 | if (!fsn_mark) { | 585 | if (!fsn_mark) { |
| 585 | int ret; | 586 | int ret; |
| 586 | 587 | ||
| 588 | if (atomic_read(&group->num_marks) > group->fanotify_data.max_marks) | ||
| 589 | return -ENOSPC; | ||
| 590 | |||
| 587 | fsn_mark = kmem_cache_alloc(fanotify_mark_cache, GFP_KERNEL); | 591 | fsn_mark = kmem_cache_alloc(fanotify_mark_cache, GFP_KERNEL); |
| 588 | if (!fsn_mark) | 592 | if (!fsn_mark) |
| 589 | return -ENOMEM; | 593 | return -ENOMEM; |
| @@ -626,6 +630,9 @@ static int fanotify_add_inode_mark(struct fsnotify_group *group, | |||
| 626 | if (!fsn_mark) { | 630 | if (!fsn_mark) { |
| 627 | int ret; | 631 | int ret; |
| 628 | 632 | ||
| 633 | if (atomic_read(&group->num_marks) > group->fanotify_data.max_marks) | ||
| 634 | return -ENOSPC; | ||
| 635 | |||
| 629 | fsn_mark = kmem_cache_alloc(fanotify_mark_cache, GFP_KERNEL); | 636 | fsn_mark = kmem_cache_alloc(fanotify_mark_cache, GFP_KERNEL); |
| 630 | if (!fsn_mark) | 637 | if (!fsn_mark) |
| 631 | return -ENOMEM; | 638 | return -ENOMEM; |
| @@ -700,6 +707,8 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags) | |||
| 700 | group->max_events = FANOTIFY_DEFAULT_MAX_EVENTS; | 707 | group->max_events = FANOTIFY_DEFAULT_MAX_EVENTS; |
| 701 | } | 708 | } |
| 702 | 709 | ||
| 710 | group->fanotify_data.max_marks = FANOTIFY_DEFAULT_MAX_MARKS; | ||
| 711 | |||
| 703 | fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags); | 712 | fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags); |
| 704 | if (fd < 0) | 713 | if (fd < 0) |
| 705 | goto out_put_group; | 714 | goto out_put_group; |
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index b37f3a71a9dc..49ceed6e92b1 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h | |||
| @@ -169,6 +169,7 @@ struct fsnotify_group { | |||
| 169 | bool bypass_perm; /* protected by access_mutex */ | 169 | bool bypass_perm; /* protected by access_mutex */ |
| 170 | #endif /* CONFIG_FANOTIFY_ACCESS_PERMISSIONS */ | 170 | #endif /* CONFIG_FANOTIFY_ACCESS_PERMISSIONS */ |
| 171 | int f_flags; | 171 | int f_flags; |
| 172 | unsigned int max_marks; | ||
| 172 | } fanotify_data; | 173 | } fanotify_data; |
| 173 | #endif /* CONFIG_FANOTIFY */ | 174 | #endif /* CONFIG_FANOTIFY */ |
| 174 | }; | 175 | }; |
