Re: [PATCH] linux 2.9.10-rc1: Fix oops in unix_dgram_sendmsg whenusing SELinux and SOCK_SEQPACKET

From: James Morris
Date: Thu Nov 18 2004 - 21:22:35 EST


On Thu, 18 Nov 2004, Alan Cox wrote:

> On Iau, 2004-11-18 at 03:42, James Morris wrote:
> > > Well, my reading of socket(2) suggests that it's _not_ supposed to work.
> >
> > sendto() on a non connected socket should fail with ENOTCONN.
>
> Not entirely true at all. A network protocol can implement lazy binding
> and do implicit binding on the sendto. Other protocols might not
> actually have a receiving component so have no bind() functionality at
> all.

I got this from the Linux man page for sendto():

If sendto is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET)
socket, the parameters to and tolen are ignored (and the error EISCONN
may be returned when they are not NULL and 0), and the error ENOTCONN
is returned when the socket was not actually connected.

And Posix 1003.1 offers the following error code for sendto():


The sendto() function shall fail if:
...

[ENOTCONN]
The socket is connection-mode but is not connected.

(I'm not saying you're wrong).

> POSIX 1003.1g draft 6.4 permits a user to pass a "null" address for
> various things. Indeed some systems implement send() as sendto() with a
> NULL, 0 address component and some user space does likewise. It also has
> a lot to say on the other cases although I don't think it ever fully got
> past draft state.

sendto() with a NULL address will still work fine.


- James
--
James Morris
<jmorris@xxxxxxxxxx>


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/