From: Florian Weimer <fweimer@redhat.com>
To: Carlos O'Donell <carlos@redhat.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>, libc-stable@sourceware.org
Subject: Re: Backporting CVE-2016-10739
Date: Tue, 01 Jan 2019 00:00:00 -0000 [thread overview]
Message-ID: <87y36vmsr9.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <47ca567f-7120-19c5-7ed6-c67c9f6306ca@redhat.com> (Carlos O'Donell's message of "Mon, 4 Feb 2019 10:46:49 -0500")
* Carlos O'Donell:
> On 2/4/19 10:44 AM, Florian Weimer wrote:
>> * Carlos O'Donell:
>>
>>>> +#include <arpa/inet.h>
>>>> +
>>>
>>> Please add a comment explaining why this is here.
>>
>> You mean like this?
>>
>> /* Obtain the prototype for __inet_aton_exact. */
>
> It should reference the bug or CVE to document the intent
> of the changes.
>
> Post v3 and I'll sign off?
This approach does not actually work because copying a prototype this
way and adding a hidden visibility attribute does not actually make the
symbol hidden. The patch below however has the desired effect, mainly
because interposition no longer happens and the __inet_aton_exact_hidden
function is not added to the dynamic symbol table of the nscd
executable.
I suspect I would have had to use __attribute__ ((visibility
("hidden"))) directly because we define attribute_hidden thusly:
#if defined SHARED || defined LIBC_NONSHARED \
|| (BUILD_PIE_DEFAULT && IS_IN (libc))
# define attribute_hidden __attribute__ ((visibility ("hidden")))
#else
# define attribute_hidden
#endif
I can post yet another patch which uses real hidden visibility and
avoids the symbol redirect.
Thanks,
Florian
This commit avoids referencing the __inet_aton_exact@GLIBC_PRIVATE
symbol from nscd. In master, the separately-compiled getaddrinfo
implementation in nscd needs it, however such an internal ABI change
is not desirable on a release branch if it can be avoided.
2019-02-04 Florian Weimer <fweimer@redhat.com>
[BZ #20018]
nscd: Do not rely on new GLIBC_PRIVATE ABI after CVE-2016-10739 fix.
* nscd/nscd-inet_addr.c: New file. Build resolv/inet_addr.c for
nscd, without public symbols.
* nscd/Makefile (nscd-modules): Add it.
* nscd/gai.c: Include <arpa/inet.h> and redirect __inet_aton_exact
to __inet_aton_exact_hidden.
diff --git a/nscd/Makefile b/nscd/Makefile
index b713a84c49..eb23c01a39 100644
--- a/nscd/Makefile
+++ b/nscd/Makefile
@@ -36,7 +36,7 @@ nscd-modules := nscd connections pwdcache getpwnam_r getpwuid_r grpcache \
getsrvbynm_r getsrvbypt_r servicescache \
dbg_log nscd_conf nscd_stat cache mem nscd_setup_thread \
xmalloc xstrdup aicache initgrcache gai res_hconf \
- netgroupcache
+ netgroupcache nscd-inet_addr
ifeq ($(build-nscd)$(have-thread-library),yesyes)
diff --git a/nscd/gai.c b/nscd/gai.c
index f57f396f57..36cc6ce4c3 100644
--- a/nscd/gai.c
+++ b/nscd/gai.c
@@ -33,6 +33,13 @@
#define __getifaddrs getifaddrs
#define __freeifaddrs freeifaddrs
+/* We do not want to export __inet_aton_exact. Get the prototype and
+ change it to hidden visibility, and redirect to the hidden
+ definition. */
+#include <arpa/inet.h>
+__typeof__ (__inet_aton_exact) __inet_aton_exact_hidden attribute_hidden;
+#define __inet_aton_exact __inet_aton_exact_hidden
+
/* We are nscd, so we don't want to be talking to ourselves. */
#undef USE_NSCD
diff --git a/nscd/nscd-inet_addr.c b/nscd/nscd-inet_addr.c
new file mode 100644
index 0000000000..901fc620b3
--- /dev/null
+++ b/nscd/nscd-inet_addr.c
@@ -0,0 +1,33 @@
+/* Legacy IPv4 text-to-address functions. Version for nscd.
+ Copyright (C) 2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <arpa/inet.h>
+
+/* We do not want to export __inet_aton_exact. Get the prototype and
+ change it to hidden visibility, and arrange for a definition under
+ a different name. */
+#include <arpa/inet.h>
+__typeof__ (__inet_aton_exact) __inet_aton_exact_hidden attribute_hidden;
+#define __inet_aton_exact __inet_aton_exact_hidden
+
+/* Do not provide definitions of the public symbols exported from
+ libc. */
+#undef weak_alias
+#define weak_alias(from, to)
+
+#include <resolv/inet_addr.c>
next prev parent reply other threads:[~2019-02-04 16:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-01 0:00 Aurelien Jarno
2019-01-01 0:00 ` Florian Weimer
2019-01-01 0:00 ` Florian Weimer
2019-01-01 0:00 ` Carlos O'Donell
2019-01-01 0:00 ` Florian Weimer
2019-01-01 0:00 ` Carlos O'Donell
2019-01-01 0:00 ` Florian Weimer [this message]
2019-01-01 0:00 ` Carlos O'Donell
2019-01-01 0:00 ` Florian Weimer
2019-01-01 0:00 ` Carlos O'Donell
2019-01-01 0:00 ` Florian Weimer
2019-01-01 0:00 ` Aurelien Jarno
2019-01-01 0:00 ` Carlos O'Donell
2019-01-01 0:00 ` Carlos O'Donell
2019-01-01 0:00 ` Florian Weimer
2019-01-01 0:00 ` Aurelien Jarno
2019-01-01 0:00 ` Florian Weimer
2019-01-01 0:00 ` Aurelien Jarno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y36vmsr9.fsf@oldenburg2.str.redhat.com \
--to=fweimer@redhat.com \
--cc=aurelien@aurel32.net \
--cc=carlos@redhat.com \
--cc=libc-stable@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).