On Thu, 18 Nov 2004, Ross Kendall Axe wrote:
Ross Kendall Axe wrote:
A possibility that hadn't occurred to me was using sendto to send packets
without connecting. Is this supposed to work? If so, then my patch is
indeed inappropriate. If not, then that needs fixing also.
Well, my reading of socket(2) suggests that it's _not_ supposed to work.
sendto() on a non connected socket should fail with ENOTCONN.
This patch causes sendmsg on SOCK_SEQPACKET unix domain sockets to return
EISCONN or ENOTSUPP as appropriate if the 'to' address is specified.
For sendto():
The address must be ignored on a connected mode socket (i.e. in this case).
According to the send(2) man page, we may return EISCONN if the address
and addr length are not NULL and zero. I think that the man page is
incorrect. Posix says that EISCONN means "A destination address was
specified and the socket is already connected", not "A destination address
was specified and the socket is connected mode". i.e. we should only return EISCONN if the socket is in a connected state.
I'm not sure if we should return any error at all if an address is supplied to sendto() on SOCK_SEQPACKET. We're only required to ignore it.
I would say that we should return an error as it is likely a progamming mistake in the application and we should let them know.
However, as mentioned above, I don't think EISCONN is appropriate in this case. EINVAL might be better.
It also causes recvmsg to return EINVAL on unconnected sockets. This
behaviour is consistent with SOCK_STREAM sockets.
This seems incorrect too, Posix says to use ENOTCONN.
There is a non SELinux-related bug lurking in this code.
I got this oops
when trying to kill a modified version of seqpacket-crash which keeps
sending in a loop and uses sendto() and an address with SOCK_SEQPACKET.
- James
Attachment:
signature.asc
Description: OpenPGP digital signature