Thread (36 messages) 36 messages, 4 authors, 16d ago

Re: [PATCH v4 13/15] fs: convert process/thread iterators to for_each_*_rculock

flat view

From: sashiko-bot@kernel.org
Date: 2026-09-21 10:39:16
Also in: linux-security-module

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] fs: mixing goto and scoped_guard in __set_oom_adj violates cleanup rules
--

commit da2e9c3ae4d6602d37bc777bfafc43d2f081d385
Author: Ye Liu [off-list ref]

fs: convert process/thread iterators to for_each_*_rculock
    
Replace the manual rcu_read_lock()/rcu_read_unlock() pairs combined
with for_each_process() and for_each_process_thread() loops in fs/
with the for_each_*_rculock() macros, which scope the RCU read lock
to the loop body via scoped_guard(rcu).
quoted hunk ↗ jump to hunk
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 58be389424605..2c47d838a1c76 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1161,8 +1161,7 @@ static int __set_oom_adj(struct file *file, int oom_adj, bool legacy)
 	if (mm) {
 		struct task_struct *p;
 
-		rcu_read_lock();
-		for_each_process(p) {
+		for_each_process_rculock(p) {
[Severity: Low]
Does introducing for_each_process_rculock() here violate the rule against
mixing scope-based cleanup and goto error handling in the same function?

This macro expands to scoped_guard(rcu), introducing scope-based cleanup into
__set_oom_adj(). However, this function already uses manual goto-based error
handling:

fs/proc/base.c:__set_oom_adj() {
    ...
		if (oom_adj < task->signal->oom_score_adj &&
				!capable(CAP_SYS_RESOURCE)) {
			err = -EACCES;
			goto err_unlock;
		}
    ...
err_unlock:
	mutex_unlock(&oom_adj_mutex);
	put_task_struct(task);
	return err;
}

The subsystem guidelines require converting all resources in a function to
scope-based cleanup, or none at all, explicitly prohibiting mixing both in the
same function.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260921092101.89285-1-ye.liu@linux.dev?part=13
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help