diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-08-31 07:17:17 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-08-31 07:17:17 +0200 |
| commit | dd5597245d35cfbb0890b8a868028aa1d2018701 (patch) | |
| tree | 865b93bf83987840fd763bf8a3d1c615ccda2f7b /kernel/watch_queue.c | |
| parent | 551b6729578a8981c46af964c10bf7d5d9ddca83 (diff) | |
| parent | f75aef392f869018f78cfedf3c320a6b3fcfda6b (diff) | |
Merge 5.9-rc3 into char-misc-next
We need the fixes in here as well.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel/watch_queue.c')
| -rw-r--r-- | kernel/watch_queue.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c index f74020f6bd9d..0ef8f65bd2d7 100644 --- a/kernel/watch_queue.c +++ b/kernel/watch_queue.c @@ -393,6 +393,7 @@ static void free_watch(struct rcu_head *rcu) struct watch *watch = container_of(rcu, struct watch, rcu); put_watch_queue(rcu_access_pointer(watch->queue)); + atomic_dec(&watch->cred->user->nr_watches); put_cred(watch->cred); } @@ -452,6 +453,13 @@ int add_watch_to_object(struct watch *watch, struct watch_list *wlist) watch->cred = get_current_cred(); rcu_assign_pointer(watch->watch_list, wlist); + if (atomic_inc_return(&watch->cred->user->nr_watches) > + task_rlimit(current, RLIMIT_NOFILE)) { + atomic_dec(&watch->cred->user->nr_watches); + put_cred(watch->cred); + return -EAGAIN; + } + spin_lock_bh(&wqueue->lock); kref_get(&wqueue->usage); kref_get(&watch->usage); |
