From patchwork Tue Jul 7 16:10:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 39945 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 761FD3861000; Tue, 7 Jul 2020 16:11:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 761FD3861000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594138268; bh=ReL6FjjjfsPxuLNrcK4Yux1100y11G/s3qCaHQU6iUM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=IE1dB1t1LFmjCIoj5YR2+3d9/uVehXtlrSTFY2GZwnJHq6/waenJEnl/h2N1IcEGB PNt9GpHt10H2XxEo7H05Fp1rmacohf8/EiKJzbq6bZgmRb6vU6g7W1Z7v5a2uh+Wys itrs2TMaqj90/31c/qRau75UH5817hnfH1ybO3+E= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id EAEC5385E444 for ; Tue, 7 Jul 2020 16:11:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EAEC5385E444 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-285-ssjxmfrFP3C45UDVkzPFKg-1; Tue, 07 Jul 2020 12:11:03 -0400 X-MC-Unique: ssjxmfrFP3C45UDVkzPFKg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4487BA0C00; Tue, 7 Jul 2020 16:11:02 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-112-206.ams2.redhat.com [10.36.112.206]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D6E4100238E; Tue, 7 Jul 2020 16:10:58 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH] sunrpc: Turn bindresvport into a compatibility symbol Date: Tue, 07 Jul 2020 18:10:56 +0200 Message-ID: <87k0zfwbjj.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Cc: Andreas Schwab , Joseph Myers Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" (This is a bit of a controversial change, but I'm not sure what our alternatives are, given the conflict with libtirpc.) bindresvport is mostly used along with Sun RPC functions. libtirpc has its own implementation of it, and this implementation is is used when linking against libtirpc (under a separate symbol version). The libtirpc implementation is superior because it provides a filter for well-known ports, addressing historic bug 456. Exceptions that use bindresvport without linking against libtirpc are torque (the resource manager) and the sign command in OBS (the build service). This change turns bindresvport into a compatibility symbol because it is currently declared in a non-RPC header (), and remvoes it from the public header. In theory, it would be possible to make the declaration conditional on --enable-obsolete-rpc, but that would need quite a bit of shuffling for a declaration that would be removed soon anyway. Despite the declaration of bindresvport6 in a public header file, no implemention was provided by glibc, so this commit removes this declaration without further changes. --- NEWS | 3 +++ include/netinet/in.h | 4 +++- inet/netinet/in.h | 10 ---------- sunrpc/bindrsvprt.c | 9 +++++++-- sunrpc/clnt_tcp.c | 2 +- sunrpc/clnt_udp.c | 2 +- sunrpc/svc_tcp.c | 2 +- sunrpc/svc_udp.c | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/NEWS b/NEWS index 839934d649..a28ce0047b 100644 --- a/NEWS +++ b/NEWS @@ -67,6 +67,9 @@ Deprecated and removed features, and other changes affecting compatibility: * ldconfig now defaults to the new format for ld.so.cache. glibc has already supported this format for almost 20 years. +* The bindresvport function is no longer supported for new programs. + Applications that need this functions should link against libtirpc. + Changes to build and runtime requirements: * powerpc64le requires GCC 7.4 or newer. This is required for supporting diff --git a/include/netinet/in.h b/include/netinet/in.h index 5e377469e7..33e37553a5 100644 --- a/include/netinet/in.h +++ b/include/netinet/in.h @@ -3,7 +3,9 @@ #include #ifndef _ISOMAC -libc_hidden_proto (bindresvport) +int __bindresvport (int __sockfd, struct sockaddr_in *__sock_in) __THROW; +libc_hidden_proto (__bindresvport) + libc_hidden_proto (in6addr_loopback) extern __typeof (in6addr_loopback) __in6addr_loopback; libc_hidden_proto (__in6addr_loopback) diff --git a/inet/netinet/in.h b/inet/netinet/in.h index f6355c7efe..a90e23e9d0 100644 --- a/inet/netinet/in.h +++ b/inet/netinet/in.h @@ -502,16 +502,6 @@ extern uint16_t htons (uint16_t __hostshort) #define IN6_IS_ADDR_MULTICAST(a) (((const uint8_t *) (a))[0] == 0xff) -#ifdef __USE_MISC -/* Bind socket to a privileged IP port. */ -extern int bindresvport (int __sockfd, struct sockaddr_in *__sock_in) __THROW; - -/* The IPv6 version of this function. */ -extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in) - __THROW; -#endif - - #define IN6_IS_ADDR_MC_NODELOCAL(a) \ (IN6_IS_ADDR_MULTICAST(a) \ && ((((const uint8_t *) (a))[1] & 0xf) == 0x1)) diff --git a/sunrpc/bindrsvprt.c b/sunrpc/bindrsvprt.c index da33c05101..357fa94fee 100644 --- a/sunrpc/bindrsvprt.c +++ b/sunrpc/bindrsvprt.c @@ -36,6 +36,7 @@ #include #include #include +#include /* * Locks the static variables in this file. @@ -46,7 +47,7 @@ __libc_lock_define_initialized (static, lock); * Bind a socket to a privileged IP port */ int -bindresvport (int sd, struct sockaddr_in *sin) +__bindresvport (int sd, struct sockaddr_in *sin) { static short port; struct sockaddr_in myaddr; @@ -107,4 +108,8 @@ bindresvport (int sd, struct sockaddr_in *sin) return res; } -libc_hidden_def (bindresvport) +libc_hidden_def (__bindresvport) + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_32) +compat_symbol (libc, __bindresvport, bindresvport, GLIBC_2_0); +#endif diff --git a/sunrpc/clnt_tcp.c b/sunrpc/clnt_tcp.c index 249e9c3584..534a75f2bb 100644 --- a/sunrpc/clnt_tcp.c +++ b/sunrpc/clnt_tcp.c @@ -148,7 +148,7 @@ clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers, if (*sockp < 0) { *sockp = __socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); - (void) bindresvport (*sockp, (struct sockaddr_in *) 0); + (void) __bindresvport (*sockp, (struct sockaddr_in *) 0); if ((*sockp < 0) || (__connect (*sockp, (struct sockaddr *) raddr, sizeof (*raddr)) < 0)) diff --git a/sunrpc/clnt_udp.c b/sunrpc/clnt_udp.c index ee79b09b40..fcc90db434 100644 --- a/sunrpc/clnt_udp.c +++ b/sunrpc/clnt_udp.c @@ -185,7 +185,7 @@ __libc_clntudp_bufcreate (struct sockaddr_in *raddr, u_long program, goto fooy; } /* attempt to bind to prov port */ - (void) bindresvport (*sockp, (struct sockaddr_in *) 0); + (void) __bindresvport (*sockp, (struct sockaddr_in *) 0); #ifdef IP_RECVERR { int on = 1; diff --git a/sunrpc/svc_tcp.c b/sunrpc/svc_tcp.c index efbdd22548..3c16e7a985 100644 --- a/sunrpc/svc_tcp.c +++ b/sunrpc/svc_tcp.c @@ -169,7 +169,7 @@ svctcp_create (int sock, u_int sendsize, u_int recvsize) } memset ((char *) &addr, 0, sizeof (addr)); addr.sin_family = AF_INET; - if (bindresvport (sock, &addr)) + if (__bindresvport (sock, &addr)) { addr.sin_port = 0; (void) __bind (sock, (struct sockaddr *) &addr, len); diff --git a/sunrpc/svc_udp.c b/sunrpc/svc_udp.c index ae67c9b36a..69f75fdc19 100644 --- a/sunrpc/svc_udp.c +++ b/sunrpc/svc_udp.c @@ -140,7 +140,7 @@ svcudp_bufcreate (int sock, u_int sendsz, u_int recvsz) } memset ((char *) &addr, 0, sizeof (addr)); addr.sin_family = AF_INET; - if (bindresvport (sock, &addr)) + if (__bindresvport (sock, &addr)) { addr.sin_port = 0; (void) __bind (sock, (struct sockaddr *) &addr, len);