This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Fix mq_notify socket, recv namespace (bug 18546)
- From: Joseph Myers <joseph at codesourcery dot com>
- To: <libc-alpha at sourceware dot org>
- Date: Tue, 16 Jun 2015 17:43:37 +0000
- Subject: Fix mq_notify socket, recv namespace (bug 18546)
- Authentication-results: sourceware.org; auth=none
mq_notify (in the 1996 edition of POSIX) brings in references to recv
and socket (not in POSIX until the 2001 edition). This patch fixes
this by using __recv and __socket, exporting them from libc at version
GLIBC_PRIVATE.
Tested for x86_64 and x86 (testsuite and comparison of installed
stripped shared libraries; PLT / dynamic symbol table changes render
the comparison not particularly useful for libc).
2015-06-16 Joseph Myers <joseph@codesourcery.com>
[BZ #18546]
* socket/recv.c (__recv): Use libc_hidden_def.
* socket/socket.c (__socket): Likewise.
* sysdeps/mach/hurd/recv.c (__recv): Likewise.
* sysdeps/mach/hurd/socket.c (__socket): Likewise.
* sysdeps/unix/sysv/linux/generic/recv.c (__recv): Likewise.
* sysdeps/unix/sysv/linux/recv.c (__recv): Use libc_hidden_weak.
* sysdeps/unix/sysv/linux/socket.c (__socket): Use
libc_hidden_def.
* sysdeps/unix/sysv/linux/x86_64/recv.c (__recv): Use
libc_hidden_weak.
* include/sys/socket.h (__socket): Do not use attribute_hidden.
Use libc_hidden_proto.
(__recv): Likewise.
* socket/Versions (libc): Export __recv and __socket at version
GLIBC_PRIVATE.
* sysdeps/unix/sysv/linux/mq_notify.c (helper_thread): Call __recv
instead of recv.
(init_mq_netlink): Call __socket instead of socket.
* conform/Makefile (test-xfail-POSIX/mqueue.h/linknamespace):
Remove variable.
diff --git a/conform/Makefile b/conform/Makefile
index fa25aa8..52df51e 100644
--- a/conform/Makefile
+++ b/conform/Makefile
@@ -346,4 +346,3 @@ test-xfail-XOPEN2K8/ndbm.h/linknamespace = yes
# Unsorted expected failures.
test-xfail-XPG3/unistd.h/linknamespace = yes
test-xfail-XPG4/unistd.h/linknamespace = yes
-test-xfail-POSIX/mqueue.h/linknamespace = yes
diff --git a/include/sys/socket.h b/include/sys/socket.h
index 99f6036..2f4bfd3 100644
--- a/include/sys/socket.h
+++ b/include/sys/socket.h
@@ -8,7 +8,8 @@
protocol PROTOCOL. If PROTOCOL is zero, one is chosen automatically.
Returns a file descriptor for the new socket, or -1 for errors. */
extern int __socket (int __domain, int __type,
- int __protocol) attribute_hidden;
+ int __protocol);
+libc_hidden_proto (__socket)
/* Create two new sockets, of type TYPE in domain DOMAIN and using
protocol PROTOCOL, which are connected to each other, and put file
@@ -64,8 +65,8 @@ libc_hidden_proto (__connect)
This function is a cancellation point and therefore not marked with
__THROW. */
-extern ssize_t __recv (int __fd, void *__buf, size_t __n, int __flags)
- attribute_hidden;
+extern ssize_t __recv (int __fd, void *__buf, size_t __n, int __flags);
+libc_hidden_proto (__recv)
/* Send N bytes of BUF on socket FD to peer at address ADDR (which is
ADDR_LEN bytes long). Returns the number sent, or -1 for errors. */
diff --git a/socket/Versions b/socket/Versions
index dcad329..7ce6f43 100644
--- a/socket/Versions
+++ b/socket/Versions
@@ -39,5 +39,6 @@ libc {
}
GLIBC_PRIVATE {
__sendmmsg;
+ __recv; __socket;
}
}
diff --git a/socket/recv.c b/socket/recv.c
index b1dc1f4..63a9fcb 100644
--- a/socket/recv.c
+++ b/socket/recv.c
@@ -30,6 +30,7 @@ __recv (fd, buf, n, flags)
__set_errno (ENOSYS);
return -1;
}
+libc_hidden_def (__recv)
weak_alias (__recv, recv)
stub_warning (recv)
diff --git a/socket/socket.c b/socket/socket.c
index b7d4e3b..9fe8fd9 100644
--- a/socket/socket.c
+++ b/socket/socket.c
@@ -32,5 +32,6 @@ __socket (domain, type, protocol)
}
+libc_hidden_def (__socket)
weak_alias (__socket, socket)
stub_warning (socket)
diff --git a/sysdeps/mach/hurd/recv.c b/sysdeps/mach/hurd/recv.c
index 4d10106..358380e 100644
--- a/sysdeps/mach/hurd/recv.c
+++ b/sysdeps/mach/hurd/recv.c
@@ -60,4 +60,5 @@ __recv (fd, buf, n, flags)
return nread;
}
+libc_hidden_def (__recv)
weak_alias (__recv, recv)
diff --git a/sysdeps/mach/hurd/socket.c b/sysdeps/mach/hurd/socket.c
index f1f33db..bb7dadd 100644
--- a/sysdeps/mach/hurd/socket.c
+++ b/sysdeps/mach/hurd/socket.c
@@ -64,4 +64,5 @@ __socket (domain, type, protocol)
return _hurd_intern_fd (sock, O_IGNORE_CTTY, 1);
}
+libc_hidden_def (__socket)
weak_alias (__socket, socket)
diff --git a/sysdeps/unix/sysv/linux/generic/recv.c b/sysdeps/unix/sysv/linux/generic/recv.c
index 3786172..324cca6 100644
--- a/sysdeps/unix/sysv/linux/generic/recv.c
+++ b/sysdeps/unix/sysv/linux/generic/recv.c
@@ -28,4 +28,5 @@ __libc_recv (int sockfd, void *buffer, size_t len, int flags)
NULL, NULL);
}
strong_alias (__libc_recv, __recv)
+libc_hidden_def (__recv)
weak_alias (__libc_recv, recv)
diff --git a/sysdeps/unix/sysv/linux/mq_notify.c b/sysdeps/unix/sysv/linux/mq_notify.c
index 5a27274..84b9cfa 100644
--- a/sysdeps/unix/sysv/linux/mq_notify.c
+++ b/sysdeps/unix/sysv/linux/mq_notify.c
@@ -117,8 +117,8 @@ helper_thread (void *arg)
{
union notify_data data;
- ssize_t n = recv (netlink_socket, &data, sizeof (data),
- MSG_NOSIGNAL | MSG_WAITALL);
+ ssize_t n = __recv (netlink_socket, &data, sizeof (data),
+ MSG_NOSIGNAL | MSG_WAITALL);
if (n < NOTIFY_COOKIE_LEN)
continue;
@@ -157,7 +157,7 @@ init_mq_netlink (void)
if (netlink_socket == -1)
{
/* Just a normal netlink socket, not bound. */
- netlink_socket = socket (AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, 0);
+ netlink_socket = __socket (AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, 0);
/* No need to do more if we have no socket. */
if (netlink_socket == -1)
return;
diff --git a/sysdeps/unix/sysv/linux/recv.c b/sysdeps/unix/sysv/linux/recv.c
index d2e80d5..cd2bc1e 100644
--- a/sysdeps/unix/sysv/linux/recv.c
+++ b/sysdeps/unix/sysv/linux/recv.c
@@ -29,3 +29,4 @@ __libc_recv (int fd, void *buf, size_t len, int flags)
}
weak_alias (__libc_recv, recv)
weak_alias (__libc_recv, __recv)
+libc_hidden_weak (__recv)
diff --git a/sysdeps/unix/sysv/linux/socket.c b/sysdeps/unix/sysv/linux/socket.c
index fcb4775..3b2c7fe 100644
--- a/sysdeps/unix/sysv/linux/socket.c
+++ b/sysdeps/unix/sysv/linux/socket.c
@@ -26,4 +26,5 @@ __socket (int fd, int type, int domain)
{
return SOCKETCALL (socket, fd, type, domain);
}
+libc_hidden_def (__socket)
weak_alias (__socket, socket)
diff --git a/sysdeps/unix/sysv/linux/x86_64/recv.c b/sysdeps/unix/sysv/linux/x86_64/recv.c
index 995d11d..06fdb7a 100644
--- a/sysdeps/unix/sysv/linux/x86_64/recv.c
+++ b/sysdeps/unix/sysv/linux/x86_64/recv.c
@@ -29,4 +29,5 @@ __libc_recv (int fd, void *buf, size_t n, int flags)
}
weak_alias (__libc_recv, __recv)
+libc_hidden_weak (__recv)
weak_alias (__recv, recv)
--
Joseph S. Myers
joseph@codesourcery.com