diff mbox

net: net_cls: fd passed in SCM_RIGHTS datagram not set correctly

Message ID 1358761102-7765-1-git-send-email-wagi@monom.org
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Daniel Wagner Jan. 21, 2013, 9:38 a.m. UTC
From: Daniel Wagner <daniel.wagner@bmw-carit.de>

Commit 6a328d8c6f03501657ad580f6f98bf9a42583ff7 changed the update
logic for the socket but it does not update the SCM_RIGHTS update
as well. This patch is based on the net_prio fix commit

48a87cc26c13b68f6cce4e9d769fcb17a6b3e4b8

    net: netprio: fd passed in SCM_RIGHTS datagram not set correctly

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

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

Let's apply the same fix for net_cls.

Reported-by: Li Zefan <lizefan@huawei.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: John Fastabend <john.r.fastabend@intel.com>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: netdev@vger.kernel.org
Cc: cgroups@vger.kernel.org
---
 net/core/scm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Zefan Li Jan. 21, 2013, 9:54 a.m. UTC | #1
On 2013/1/21 17:38, Daniel Wagner wrote:
> From: Daniel Wagner <daniel.wagner@bmw-carit.de>
> 
> Commit 6a328d8c6f03501657ad580f6f98bf9a42583ff7 changed the update
> logic for the socket but it does not update the SCM_RIGHTS update
> as well. This patch is based on the net_prio fix commit
> 
> 48a87cc26c13b68f6cce4e9d769fcb17a6b3e4b8
> 
>     net: netprio: fd passed in SCM_RIGHTS datagram not set correctly
> 
>     A socket fd passed in a SCM_RIGHTS datagram was not getting
>     updated with the new tasks cgrp prioidx. This leaves IO on
>     the socket tagged with the old tasks priority.
> 
>     To fix this add a check in the scm recvmsg path to update the
>     sock cgrp prioidx with the new tasks value.
> 
> Let's apply the same fix for net_cls.
> 
> Reported-by: Li Zefan <lizefan@huawei.com>

Acutally I didn't report this. I was about to send exactly the same
patch and then I noticed the shared socket issue. ;)

> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: "Eric W. Biederman" <ebiederm@xmission.com>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: John Fastabend <john.r.fastabend@intel.com>
> Cc: Neil Horman <nhorman@tuxdriver.com>
> Cc: netdev@vger.kernel.org
> Cc: cgroups@vger.kernel.org
> ---
>  net/core/scm.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Daniel Wagner Jan. 21, 2013, 10:16 a.m. UTC | #2
On 21.01.2013 10:54, Li Zefan wrote:
> On 2013/1/21 17:38, Daniel Wagner wrote:
>> From: Daniel Wagner <daniel.wagner@bmw-carit.de>
>>
>> Commit 6a328d8c6f03501657ad580f6f98bf9a42583ff7 changed the update
>> logic for the socket but it does not update the SCM_RIGHTS update
>> as well. This patch is based on the net_prio fix commit
>>
>> 48a87cc26c13b68f6cce4e9d769fcb17a6b3e4b8
>>
>>      net: netprio: fd passed in SCM_RIGHTS datagram not set correctly
>>
>>      A socket fd passed in a SCM_RIGHTS datagram was not getting
>>      updated with the new tasks cgrp prioidx. This leaves IO on
>>      the socket tagged with the old tasks priority.
>>
>>      To fix this add a check in the scm recvmsg path to update the
>>      sock cgrp prioidx with the new tasks value.
>>
>> Let's apply the same fix for net_cls.
>>
>> Reported-by: Li Zefan <lizefan@huawei.com>
> 
> Acutally I didn't report this. 

You made me look into this, so you reported it at least in my eyes :)

> I was about to send exactly the same
> patch and then I noticed the shared socket issue. ;)

I don't mind if you want your patch to be applied. I just felt
responsible for the changes I did.

thanks,
daniel

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Jan. 21, 2013, 7:17 p.m. UTC | #3
From: Daniel Wagner <wagi@monom.org>
Date: Mon, 21 Jan 2013 10:38:22 +0100

> From: Daniel Wagner <daniel.wagner@bmw-carit.de>
> 
> Commit 6a328d8c6f03501657ad580f6f98bf9a42583ff7 changed the update
> logic for the socket but it does not update the SCM_RIGHTS update
> as well. This patch is based on the net_prio fix commit
> 
> 48a87cc26c13b68f6cce4e9d769fcb17a6b3e4b8
> 
>     net: netprio: fd passed in SCM_RIGHTS datagram not set correctly
> 
>     A socket fd passed in a SCM_RIGHTS datagram was not getting
>     updated with the new tasks cgrp prioidx. This leaves IO on
>     the socket tagged with the old tasks priority.
> 
>     To fix this add a check in the scm recvmsg path to update the
>     sock cgrp prioidx with the new tasks value.
> 
> Let's apply the same fix for net_cls.
> 
> Reported-by: Li Zefan <lizefan@huawei.com>

You need to resubmit this, and proprly add a "Signed-off-by: " tag
for yourself.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/core/scm.c b/net/core/scm.c
index 57fb1ee..905dcc6 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -35,6 +35,7 @@ 
 #include <net/sock.h>
 #include <net/compat.h>
 #include <net/scm.h>
+#include <net/cls_cgroup.h>
 
 
 /*
@@ -302,8 +303,10 @@  void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
 		}
 		/* Bump the usage count and install the file. */
 		sock = sock_from_file(fp[i], &err);
-		if (sock)
+		if (sock) {
 			sock_update_netprioidx(sock->sk, current);
+			sock_update_classid(sock->sk, current);
+		}
 		fd_install(new_fd, get_file(fp[i]));
 	}