summaryrefslogtreecommitdiff
path: root/kernel/watch_queue.c
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2020-08-25 11:01:24 +0100
committerMark Brown <broonie@kernel.org>2020-08-25 11:01:24 +0100
commitafa86a047edef28004fb3d2a47d3d90309a830a5 (patch)
tree3c8c4df30900289e41de18db69e732535d1122e4 /kernel/watch_queue.c
parentaafdeba5cbc14cecee3797e669473b70a2b3e81e (diff)
parentd012a7190fc1fd72ed48911e77ca97ba4521bccd (diff)
Merge tag 'v5.9-rc2' into asoc-5.10
Linux 5.9-rc2
Diffstat (limited to 'kernel/watch_queue.c')
-rw-r--r--kernel/watch_queue.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c
index f74020f6bd9d5..0ef8f65bd2d71 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);