scm: Only support SCM_RIGHTS on unix domain sockets.
authorEric W. Biederman <ebiederm@xmission.com>
Sun, 28 Feb 2010 01:20:36 +0000 (01:20 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 1 Mar 2010 02:22:02 +0000 (18:22 -0800)
We use scm_send and scm_recv on both unix domain and
netlink sockets, but only unix domain sockets support
everything required for file descriptor passing,
so error if someone attempts to pass file descriptors
over netlink sockets.

Cc: stable@kernel.org
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/scm.c

index b7ba91b074b33995deee5278fb54c30d100d041b..9b264634acfd6233ebfa7369cc4537638377d06d 100644 (file)
@@ -156,6 +156,8 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p)
                switch (cmsg->cmsg_type)
                {
                case SCM_RIGHTS:
+                       if (!sock->ops || sock->ops->family != PF_UNIX)
+                               goto error;
                        err=scm_fp_copy(cmsg, &p->fp);
                        if (err<0)
                                goto error;