diff --git a/sys/kern/kern_sendfile.c b/sys/kern/kern_sendfile.c index 071c2fbbd436..323e7fcde07b 100644 --- a/sys/kern/kern_sendfile.c +++ b/sys/kern/kern_sendfile.c @@ -649,16 +649,20 @@ sendfile_getsock(struct thread *td, int s, struct file **sock_fp, *sock_fp = NULL; *so = NULL; + /* + * The socket must be a stream socket and connected. + */ error = getsock(td, s, &cap_send_rights, sock_fp); if (error != 0) return (error); *so = (*sock_fp)->f_data; + if ((*so)->so_type != SOCK_STREAM) + return (EINVAL); /* - * sendfile(2) should be supported for every SOCK_STREAM socket. - * However, the support of PF_UNIX/SOCK_STREAM is temporarily degraded - * and IPPROTO_SCTP isn't supported, yet. + * SCTP one-to-one style sockets currently don't work with + * sendfile(). So indicate EINVAL for now. */ - if ((*so)->so_proto->pr_protocol != IPPROTO_TCP) + if ((*so)->so_proto->pr_protocol == IPPROTO_SCTP) return (EINVAL); return (0); }