Skip to contentSkip to conversation

SELinux: use do_each_thread as a proper do/while block

PATCH In review James Morris 2 participants 2 messages Jun 11, 2008 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SELinux: use do_each_thread as a proper do/while block

Please review.

----
Use do_each_thread as a proper do/while block. Sparse complained.

---
 security/selinux/hooks.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
security/selinux/hooks.c +2 -2
index 6e8d0e9..4130d64 100644
@@ -5196,12 +5196,12 @@ static int selinux_setprocattr(struct task_struct *p,
 			struct task_struct *g, *t;
 			struct mm_struct *mm = p->mm;
 			read_lock(&tasklist_lock);
-			do_each_thread(g, t)
+			do_each_thread(g, t) {
 				if (t->mm == mm && t != p) {
 					read_unlock(&tasklist_lock);
 					return -EPERM;
 				}
-			while_each_thread(g, t);
+			} while_each_thread(g, t);
 			read_unlock(&tasklist_lock);
 		}
 
Signature · 7 lines
1.5.5.1


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · James Morris

Please review.

----
Use do_each_thread as a proper do/while block. Sparse complained.

We may wish to consider removing this restriction altogether, and/or making it subject to a permission check. Per-thread context can be useful for multi-threaded server effectively acting as a userspace object manager but wanting to set kernel context to avoid race conditions on file accesses, ala the samba file server case.

Quoted 23 lines
---
 security/selinux/hooks.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
security/selinux/hooks.c +2 -2
index 6e8d0e9..4130d64 100644
@@ -5196,12 +5196,12 @@ static int selinux_setprocattr(struct task_struct *p,
 			struct task_struct *g, *t;
 			struct mm_struct *mm = p->mm;
 			read_lock(&tasklist_lock);
-			do_each_thread(g, t)
+			do_each_thread(g, t) {
 				if (t->mm == mm && t != p) {
 					read_unlock(&tasklist_lock);
 					return -EPERM;
 				}
-			while_each_thread(g, t);
+			} while_each_thread(g, t);
 			read_unlock(&tasklist_lock);
 		}
 
Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.