net/tipc: initialize security state for new connection socket
authorStephen Smalley <sds@tycho.nsa.gov>
Tue, 7 Jul 2015 13:43:45 +0000 (09:43 -0400)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 13 Oct 2015 02:46:12 +0000 (03:46 +0100)
[ Upstream commit fdd75ea8df370f206a8163786e7470c1277a5064 ]

Calling connect() with an AF_TIPC socket would trigger a series
of error messages from SELinux along the lines of:
SELinux: Invalid class 0
type=AVC msg=audit(1434126658.487:34500): avc:  denied  { <unprintable> }
  for pid=292 comm="kworker/u16:5" scontext=system_u:system_r:kernel_t:s0
  tcontext=system_u:object_r:unlabeled_t:s0 tclass=<unprintable>
  permissive=0

This was due to a failure to initialize the security state of the new
connection sock by the tipc code, leaving it with junk in the security
class field and an unlabeled secid.  Add a call to security_sk_clone()
to inherit the security state from the parent socket.

Reported-by: Tim Shearer <tim.shearer@overturenetworks.com>
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Acked-by: Paul Moore <paul@paul-moore.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 3.2: adjust context, indentation]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/tipc/socket.c

index 058941e..580ecf2 100644 (file)
@@ -1541,6 +1541,8 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags)
                u32 new_ref = new_tport->ref;
                struct tipc_msg *msg = buf_msg(buf);
 
+               security_sk_clone(sock->sk, new_sock->sk);
+
                lock_sock(new_sk);
 
                /*