Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp241538pxj; Thu, 20 May 2021 08:24:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlgSkLKskVax6Bgv/xwcKsv/1i/CP/DMHoNRmW1yBGjAUbejKIVl2R5nj5hLUlXIVuW2F0 X-Received: by 2002:a05:6e02:1b05:: with SMTP id i5mr6574262ilv.204.1621524265324; Thu, 20 May 2021 08:24:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621524265; cv=none; d=google.com; s=arc-20160816; b=RWrN118SnYyFHLi12eWxrd9P7SmjiE0M4q+yPUM7MKHIu8CuF/y3lotVl6ZdLafx8/ nI6i/ueiyx9k3LnIn3KyITTHULnWbT59qVz3+2wwE8S2L+i+RKAZaE93Phlu7UT5W+QY YNYZEns5Ncx6Bswi+GZgt5E5EofdHWpwyQoLWqUXI+3oYT36GQNfVOzAda1tt3xToi0b BD87mKISB4KX+60rINSIl/WxtvnlzZcG2SME2KLDlzJ7GwJOX70v/VKE6pSlZY0ckjU7 2/ebgU2eSGGcxOeXAx9nfvJ704/kT9bCvBU/I12VnHKxQUNyKiReTt2483HQaCkc+2FI /kbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UxbI7i6zRBA4T7aHfdiIlgRiCb30hgqjuzJby7zmSFk=; b=BQuk9NU40XxDcjEVK9C53ETC0rlYLHQGU4CLExJ2FKa/guav99ldtUQ/ZkylnIlvcp p9KRKvHwwQFYV4J1ynnaletxzzZ05wWky3nWPuq5eyIYUvyloL9P3gaw+0ix/DAF18G4 FZ3ETKL2SOkRizQfLH5azhOiOYdjMxFZxrtFsRiarAtb4zfXmzWrxgDmg8rG4+/YVRkU 9sp6C2AujeIXqsTNaLUW07pLNeTp9E+wYeEeNJqMUpJNsOudepAQw6I5CiJK1WpGLImi /LzYh4wDWKFptER+HObFnWNUHF25DzLRsgnQCXuLkMnXgwYWhWpASOqU5guKx/qF0Ysd CDsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T17uZxTP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k7si2431066iok.65.2021.05.20.08.24.12; Thu, 20 May 2021 08:24:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T17uZxTP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232437AbhETJfZ (ORCPT + 99 others); Thu, 20 May 2021 05:35:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:34686 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231985AbhETJdA (ORCPT ); Thu, 20 May 2021 05:33:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C4D1A613DA; Thu, 20 May 2021 09:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621502916; bh=ouPUubX0podFZljV6MH3eWHq7jZEaHhpp8WTmiD8ZY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T17uZxTPJPxbWAZ+/5xQb7YTegaUyLn+0aFogut6IvJWKeS2J7fHv1ic9GNa0WlR1 pbmbIIusq5HVXWW+rHWlXDdK2bAMRBWlBFgeaP8Mr3s/IFFpj/XvnrZxZyiqtu432h HfIqH0qLAt5HP5Nk08EBTmn5RVX2oLM9OZ4Mj8lI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ritesh Raj Sarraf , Johannes Berg , Anton Ivanov , Richard Weinberger , Sasha Levin Subject: [PATCH 5.4 16/37] um: Mark all kernel symbols as local Date: Thu, 20 May 2021 11:22:37 +0200 Message-Id: <20210520092052.811814581@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092052.265851579@linuxfoundation.org> References: <20210520092052.265851579@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg [ Upstream commit d5027ca63e0e778b641cf23e3f5c6d6212cf412b ] Ritesh reported a bug [1] against UML, noting that it crashed on startup. The backtrace shows the following (heavily redacted): (gdb) bt ... #26 0x0000000060015b5d in sem_init () at ipc/sem.c:268 #27 0x00007f89906d92f7 in ?? () from /lib/x86_64-linux-gnu/libcom_err.so.2 #28 0x00007f8990ab8fb2 in call_init (...) at dl-init.c:72 ... #40 0x00007f89909bf3a6 in nss_load_library (...) at nsswitch.c:359 ... #44 0x00007f8990895e35 in _nss_compat_getgrnam_r (...) at nss_compat/compat-grp.c:486 #45 0x00007f8990968b85 in __getgrnam_r [...] #46 0x00007f89909d6b77 in grantpt [...] #47 0x00007f8990a9394e in __GI_openpty [...] #48 0x00000000604a1f65 in openpty_cb (...) at arch/um/os-Linux/sigio.c:407 #49 0x00000000604a58d0 in start_idle_thread (...) at arch/um/os-Linux/skas/process.c:598 #50 0x0000000060004a3d in start_uml () at arch/um/kernel/skas/process.c:45 #51 0x00000000600047b2 in linux_main (...) at arch/um/kernel/um_arch.c:334 #52 0x000000006000574f in main (...) at arch/um/os-Linux/main.c:144 indicating that the UML function openpty_cb() calls openpty(), which internally calls __getgrnam_r(), which causes the nsswitch machinery to get started. This loads, through lots of indirection that I snipped, the libcom_err.so.2 library, which (in an unknown function, "??") calls sem_init(). Now, of course it wants to get libpthread's sem_init(), since it's linked against libpthread. However, the dynamic linker looks up that symbol against the binary first, and gets the kernel's sem_init(). Hajime Tazaki noted that "objcopy -L" can localize a symbol, so the dynamic linker wouldn't do the lookup this way. I tried, but for some reason that didn't seem to work. Doing the same thing in the linker script instead does seem to work, though I cannot entirely explain - it *also* works if I just add "VERSION { { global: *; }; }" instead, indicating that something else is happening that I don't really understand. It may be that explicitly doing that marks them with some kind of empty version, and that's different from the default. Explicitly marking them with a version breaks kallsyms, so that doesn't seem to be possible. Marking all the symbols as local seems correct, and does seem to address the issue, so do that. Also do it for static link, nsswitch libraries could still be loaded there. [1] https://bugs.debian.org/983379 Reported-by: Ritesh Raj Sarraf Signed-off-by: Johannes Berg Acked-By: Anton Ivanov Tested-By: Ritesh Raj Sarraf Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- arch/um/kernel/dyn.lds.S | 6 ++++++ arch/um/kernel/uml.lds.S | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S index f5001481010c..a82ec0113321 100644 --- a/arch/um/kernel/dyn.lds.S +++ b/arch/um/kernel/dyn.lds.S @@ -6,6 +6,12 @@ OUTPUT_ARCH(ELF_ARCH) ENTRY(_start) jiffies = jiffies_64; +VERSION { + { + local: *; + }; +} + SECTIONS { PROVIDE (__executable_start = START); diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S index 9f21443be2c9..85b404d068f4 100644 --- a/arch/um/kernel/uml.lds.S +++ b/arch/um/kernel/uml.lds.S @@ -7,6 +7,12 @@ OUTPUT_ARCH(ELF_ARCH) ENTRY(_start) jiffies = jiffies_64; +VERSION { + { + local: *; + }; +} + SECTIONS { /* This must contain the right address - not quite the default ELF one.*/ -- 2.30.2