All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Neil Horman <nhorman@tuxdriver.com>
Cc: netdev@vger.kernel.org, Thomas Graf <tgraf@infradead.org>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH 3/4] net: use cgroup_attach method to migrate socket priotiy and classid
Date: Wed, 21 Dec 2011 15:40:57 +0000	[thread overview]
Message-ID: <20111221154057.GI23916@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1324478390-22036-4-git-send-email-nhorman@tuxdriver.com>

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?

  reply	other threads:[~2011-12-21 15:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-21 14:39 [PATCH 0/4] net: Improve socket sharing between multiple cgroups Neil Horman
2011-12-21 14:39 ` [PATCH 1/4] net_prio/classid: add cgroup process ownership filter Neil Horman
2011-12-21 14:39 ` [PATCH 2/4] vfs: Export some file manipulation functions Neil Horman
2011-12-21 15:30   ` Christoph Hellwig
2011-12-21 16:42     ` Neil Horman
2011-12-21 14:39 ` [PATCH 3/4] net: use cgroup_attach method to migrate socket priotiy and classid Neil Horman
2011-12-21 15:40   ` Al Viro [this message]
2011-12-21 14:39 ` [PATCH 4/4] net: remove no-longer needed calls to sock_update_[classid|netprioix] Neil Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111221154057.GI23916@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=tgraf@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.