Patch "cgroup/pids: Avoid spurious event notification" has been added to the 6.11-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    cgroup/pids: Avoid spurious event notification

to the 6.11-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     cgroup-pids-avoid-spurious-event-notification.patch
and it can be found in the queue-6.11 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 424ed6c4548fff74a1533e6f602bf0b2ed037501
Author: Xiu Jianfeng <xiujianfeng@xxxxxxxxxx>
Date:   Tue Jul 30 03:29:20 2024 +0000

    cgroup/pids: Avoid spurious event notification
    
    [ Upstream commit d72a00a8485d1cb11ac1a57bf89b02cbd3a405bf ]
    
    Currently when a process in a group forks and fails due to it's
    parent's max restriction, all the cgroups from 'pids_forking' to root
    will generate event notifications but only the cgroups from
    'pids_over_limit' to root will increase the counter of PIDCG_MAX.
    
    Consider this scenario: there are 4 groups A, B, C,and D, the
    relationships are as follows, and user is watching on C.pids.events.
    
    root->A->B->C->D
    
    When a process in D forks and fails due to B.max restriction, the
    user will get a spurious event notification because when he wakes up
    and reads C.pids.events, he will find that the content has not changed.
    
    To address this issue, only the cgroups from 'pids_over_limit' to root
    will have their PIDCG_MAX counters increased and event notifications
    generated.
    
    Fixes: 385a635cacfe ("cgroup/pids: Make event counters hierarchical")
    Signed-off-by: Xiu Jianfeng <xiujianfeng@xxxxxxxxxx>
    Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/cgroup/pids.c b/kernel/cgroup/pids.c
index f5cb0ec45b9dd..34aa63d7c9c65 100644
--- a/kernel/cgroup/pids.c
+++ b/kernel/cgroup/pids.c
@@ -244,7 +244,6 @@ static void pids_event(struct pids_cgroup *pids_forking,
 		       struct pids_cgroup *pids_over_limit)
 {
 	struct pids_cgroup *p = pids_forking;
-	bool limit = false;
 
 	/* Only log the first time limit is hit. */
 	if (atomic64_inc_return(&p->events_local[PIDCG_FORKFAIL]) == 1) {
@@ -252,20 +251,17 @@ static void pids_event(struct pids_cgroup *pids_forking,
 		pr_cont_cgroup_path(p->css.cgroup);
 		pr_cont("\n");
 	}
-	cgroup_file_notify(&p->events_local_file);
 	if (!cgroup_subsys_on_dfl(pids_cgrp_subsys) ||
-	    cgrp_dfl_root.flags & CGRP_ROOT_PIDS_LOCAL_EVENTS)
+	    cgrp_dfl_root.flags & CGRP_ROOT_PIDS_LOCAL_EVENTS) {
+		cgroup_file_notify(&p->events_local_file);
 		return;
+	}
 
-	for (; parent_pids(p); p = parent_pids(p)) {
-		if (p == pids_over_limit) {
-			limit = true;
-			atomic64_inc(&p->events_local[PIDCG_MAX]);
-			cgroup_file_notify(&p->events_local_file);
-		}
-		if (limit)
-			atomic64_inc(&p->events[PIDCG_MAX]);
+	atomic64_inc(&pids_over_limit->events_local[PIDCG_MAX]);
+	cgroup_file_notify(&pids_over_limit->events_local_file);
 
+	for (p = pids_over_limit; parent_pids(p); p = parent_pids(p)) {
+		atomic64_inc(&p->events[PIDCG_MAX]);
 		cgroup_file_notify(&p->events_file);
 	}
 }




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux