Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 May 2019 14:21:51 +0000 (UTC)
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r348418 - head/sys/compat/linux
Message-ID:  <201905301421.x4UELpD3095406@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Thu May 30 14:21:51 2019
New Revision: 348418
URL: https://svnweb.freebsd.org/changeset/base/348418

Log:
  Linux does not support MSG_OOB for unix(4) or non-stream oriented socket,
  return EOPNOTSUPP as a Linux does.
  
  Reviewed by:	tijl
  MFC after:	1 week
  Differential Revision:	https://reviews.freebsd.org/D20409

Modified:
  head/sys/compat/linux/linux_socket.c

Modified: head/sys/compat/linux/linux_socket.c
==============================================================================
--- head/sys/compat/linux/linux_socket.c	Thu May 30 14:13:09 2019	(r348417)
+++ head/sys/compat/linux/linux_socket.c	Thu May 30 14:21:51 2019	(r348418)
@@ -939,11 +939,13 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
 	struct iovec *iov;
 	socklen_t datalen;
 	struct sockaddr *sa;
+	struct socket *so;
 	sa_family_t sa_family;
+	struct file *fp;
 	void *data;
 	l_size_t len;
 	l_size_t clen;
-	int error;
+	int error, fflag;
 
 	error = copyin(msghdr, &linux_msg, sizeof(linux_msg));
 	if (error != 0)
@@ -974,12 +976,30 @@ linux_sendmsg_common(struct thread *td, l_int s, struc
 
 	control = NULL;
 
-	if (linux_msg.msg_controllen >= sizeof(struct l_cmsghdr)) {
-		error = kern_getsockname(td, s, &sa, &datalen);
+	error = kern_getsockname(td, s, &sa, &datalen);
+	if (error != 0)
+		goto bad;
+	sa_family = sa->sa_family;
+	free(sa, M_SONAME);
+
+	if (flags & LINUX_MSG_OOB) {
+		error = EOPNOTSUPP;
+		if (sa_family == AF_UNIX)
+			goto bad;
+
+		error = getsock_cap(td, s, &cap_send_rights, &fp,
+		    &fflag, NULL);
 		if (error != 0)
 			goto bad;
-		sa_family = sa->sa_family;
-		free(sa, M_SONAME);
+		so = fp->f_data;
+		if (so->so_type != SOCK_STREAM)
+			error = EOPNOTSUPP;
+		fdrop(fp, td);
+		if (error != 0)
+			goto bad;
+	}
+
+	if (linux_msg.msg_controllen >= sizeof(struct l_cmsghdr)) {
 
 		error = ENOBUFS;
 		control = m_get(M_WAITOK, MT_CONTROL);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905301421.x4UELpD3095406>