af_unix: Only allow recv on connected seqpacket sockets.
authorEric W. Biederman <ebiederm@xmission.com>
Sun, 24 Apr 2011 01:54:57 +0000 (01:54 +0000)
committerSteve Conklin <sconklin@canonical.com>
Thu, 2 Jun 2011 19:23:15 +0000 (14:23 -0500)
commit4ce4a71e7f5bdd1d2bce71f1e798c76d3716630a
tree1694f398be89374de3f197875d8b6de1fcf2bb09
parentc753aa8984e1ebfb27c1bd6bf4202eb74a8c5106
af_unix: Only allow recv on connected seqpacket sockets.

BugLink: http://bugs.launchpad.net/bugs/780546

commit a05d2ad1c1f391c7f514a1d1e09b5417968a7d07 upstream.

This fixes the following oops discovered by Dan Aloni:
> Anyway, the following is the output of the Oops that I got on the
> Ubuntu kernel on which I first detected the problem
> (2.6.37-12-generic). The Oops that followed will be more useful, I
> guess.

>[ 5594.669852] BUG: unable to handle kernel NULL pointer dereference
> at           (null)
> [ 5594.681606] IP: [<ffffffff81550b7b>] unix_dgram_recvmsg+0x1fb/0x420
> [ 5594.687576] PGD 2a05d067 PUD 2b951067 PMD 0
> [ 5594.693720] Oops: 0002 [#1] SMP
> [ 5594.699888] last sysfs file:

The bug was that unix domain sockets use a pseduo packet for
connecting and accept uses that psudo packet to get the socket.
In the buggy seqpacket case we were allowing unconnected
sockets to call recvmsg and try to receive the pseudo packet.

That is always wrong and as of commit 7361c36c5 the pseudo
packet had become enough different from a normal packet
that the kernel started oopsing.

Do for seqpacket_recv what was done for seqpacket_send in 2.5
and only allow it on connected seqpacket sockets.

Tested-by: Dan Aloni <dan@aloni.org>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
net/unix/af_unix.c