Thread (8 messages) 8 messages, 3 authors, 2011-12-21

Re: [PATCH 3/4] net: use cgroup_attach method to migrate socket priotiy and classid

From: Al Viro <viro@ZenIV.linux.org.uk>
Date: 2011-12-21 15:41:00

On Wed, Dec 21, 2011 at 09:39:49AM -0500, Neil Horman wrote:
+static void cgrp_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
+			struct cgroup *old_cgrp, struct task_struct *tsk)
+{
+	int fd, err;
+	struct files_struct *files;
+	struct file *file;
+	struct socket *sock;
+	struct cgroup_netprio_state *old, *new;
+	pid_t task_pid;
+ 
+	files = get_files_struct(tsk);
+	task_pid = task_pid_nr(tsk);
+ 
+	old = cgrp_netprio_state(old_cgrp);
+	new = cgrp_netprio_state(cgrp);
+ 
+	spin_lock(&files->file_lock);
+	for (fd=0; fd < files_fdtable(files)->max_fds; fd++) {
+		file = fcheck_files(files, fd);
+		if (!file)
+			continue;
+		sock = sock_from_file(file, &err);
+		if (!sock)
+			continue;
+		if (!sock->sk)
+			continue;
+		if (sock->sk->sk_cgrp_owner == task_pid)
+			sock->sk->sk_cgrp_prioidx = new->prioidx;
This looks bogus *and* racy; what about e.g. files currently in SCM_RIGHTS
datagrams?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help