netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Wagner <wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
To: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Daniel Wagner
	<daniel.wagner-98C5kh4wR6ohFhg+JK9F0w@public.gmane.org>,
	"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
	Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
	David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Eric Dumazet
	<eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	John Fastabend
	<john.r.fastabend-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>,
	Tim Chen <tim.c.chen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Subject: [PATCH v3 3/6] cgroup: Update classid for fd pass in SCM_RIGHTS datagramm
Date: Tue, 14 Aug 2012 15:02:20 +0200	[thread overview]
Message-ID: <1344949343-26090-5-git-send-email-wagi@monom.org> (raw)
In-Reply-To: <1344949343-26090-1-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>

From: Daniel Wagner <daniel.wagner-98C5kh4wR6ohFhg+JK9F0w@public.gmane.org>

A socket fd passed in a SCM_RIGHTS datagram was not getting
updated with the new tasks cgrp classid. This leaves IO on
the socket tagged with the old tasks classid.

To fix this add a check in the scm recvmsg path to update the
sock cgrp classid with the new tasks value.

Signed-off-by: Daniel Wagner <daniel.wagner-98C5kh4wR6ohFhg+JK9F0w@public.gmane.org>
Cc: "David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Cc: Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
Cc: David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Eric Dumazet <eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: John Fastabend <john.r.fastabend-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
Cc: Tim Chen <tim.c.chen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
 net/core/scm.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/core/scm.c b/net/core/scm.c
index 8f6ccfd..221080f 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -35,7 +35,7 @@
 #include <net/sock.h>
 #include <net/compat.h>
 #include <net/scm.h>
-
+#include <net/cls_cgroup.h>
 
 /*
  *	Only allow a user to send credentials, that they could set with
@@ -249,6 +249,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
 	struct file **fp = scm->fp->fp;
 	int __user *cmfptr;
 	int err = 0, i;
+	__u32 classid = task_cls_classid(current);
 
 	if (MSG_CMSG_COMPAT & msg->msg_flags) {
 		scm_detach_fds_compat(msg, scm);
@@ -265,6 +266,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
 	for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
 	     i++, cmfptr++)
 	{
+		struct socket *sock;
 		int new_fd;
 		err = security_file_receive(fp[i]);
 		if (err)
@@ -282,6 +284,9 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
 		/* Bump the usage count and install the file. */
 		get_file(fp[i]);
 		fd_install(new_fd, fp[i]);
+		sock = sock_from_file(fp[i], &err);
+		if (sock)
+			sock->sk->sk_classid = classid;
 	}
 
 	if (i > 0)
-- 
1.7.12.rc1.16.g05a20c8

  parent reply	other threads:[~2012-08-14 13:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-14 13:02 [PATCH v3 0/6] cgroup cls & netprio 'cleanups' Daniel Wagner
2012-08-14 13:02 ` [PATCH v3 1/6] cgroup: Move cls function definition to cls_cgroup.h Daniel Wagner
     [not found] ` <1344949343-26090-1-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-14 13:02   ` [PATCH v3 2/6] cgroup: net_cls rework update socket logic Daniel Wagner
2012-08-14 13:02   ` [PATCH v3 2/5] cgroup: " Daniel Wagner
2012-08-14 13:02   ` Daniel Wagner [this message]
2012-08-14 13:10   ` [PATCH v3 0/6] cgroup cls & netprio 'cleanups' Neil Horman
     [not found]     ` <20120814131035.GC18731-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2012-08-14 13:25       ` Daniel Wagner
     [not found]         ` <502A51DE.7040809-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-14 13:30           ` Neil Horman
     [not found]             ` <20120814133053.GD18731-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2012-08-14 13:46               ` Daniel Wagner
     [not found]                 ` <502A56C9.8070701-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-14 15:37                   ` Neil Horman
2012-08-14 13:02 ` [PATCH v3 4/6] cgroup: Use IS_MODULE/BUITLIN for net_cls Daniel Wagner
2012-08-14 13:02 ` [PATCH v3 5/6] cgroup: Use IS_MODULE/BUITLIN for net_prio Daniel Wagner
2012-08-14 13:02 ` [PATCH v3 6/6] cgroup: Assign subsystem IDs during compile time Daniel Wagner
     [not found]   ` <1344949343-26090-8-git-send-email-wagi-kQCPcA+X3s7YtjvyW6yDsg@public.gmane.org>
2012-08-14 17:27     ` Tejun Heo
     [not found]       ` <20120814172749.GL25632-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-08-14 21:01         ` Daniel Wagner

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=1344949343-26090-5-git-send-email-wagi@monom.org \
    --to=wagi-kqcpca+x3s7ytjvyw6ydsg@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=daniel.wagner-98C5kh4wR6ohFhg+JK9F0w@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=john.r.fastabend-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org \
    --cc=tim.c.chen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).