summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Zeller <mike@mikezeller.net>2020-04-07 14:02:21 -0400
committerGitHub <noreply@github.com>2020-04-07 14:02:21 -0400
commitcb1f21263e5283c3502e718042f50eeef6ced5bb (patch)
tree7f4b2f3c4eee760b6a7e5f94bc41379e0c4b1a95
parentcb12c768f1182b2a1e68bae192cbb1dd6a6cd2fa (diff)
downloadillumos-joyent-cb1f21263e5283c3502e718042f50eeef6ced5bb.tar.gz
OS-8152 lx should return EACCES when SOCK_DGRAM is used with IPPROTO_ICMP
Reviewed by: Dan McDonald <danmcd@kebe.com> Reviewed by: Mike Gerdts <mike.gerdts@joyent.com> Approved by: Dan McDonald <danmcd@kebe.com>
-rw-r--r--usr/src/uts/common/brand/lx/syscall/lx_socket.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/usr/src/uts/common/brand/lx/syscall/lx_socket.c b/usr/src/uts/common/brand/lx/syscall/lx_socket.c
index 694549a4cb..628b3490db 100644
--- a/usr/src/uts/common/brand/lx/syscall/lx_socket.c
+++ b/usr/src/uts/common/brand/lx/syscall/lx_socket.c
@@ -22,7 +22,7 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
- * Copyright 2019 Joyent, Inc.
+ * Copyright 2020 Joyent, Inc.
* Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
*/
@@ -1402,6 +1402,18 @@ lx_socket_create(int domain, int type, int protocol, int options, file_t **fpp,
file_t *fp;
int err, fd;
+ /*
+ * EACCES is returned in Linux when the user isn't allowed to use a
+ * "ping socket". EACCES is also used by the iputils-ping userland
+ * application to determine if fallback to SOCK_RAW is necessary.
+ *
+ * This can be removed if we ever implement SOCK_DGRAM + IPPROTO_ICMP.
+ */
+ if ((domain == AF_INET && type == SOCK_DGRAM && protocol ==
+ IPPROTO_ICMP) || (domain == AF_INET6 && type == SOCK_DGRAM &&
+ protocol == IPPROTO_ICMPV6))
+ return (EACCES);
+
/* logic cloned from so_socket */
so = socket_create(domain, type, protocol, NULL, NULL, SOCKET_SLEEP,
SOV_DEFAULT, CRED(), &err);