Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp3214204ybn; Fri, 27 Sep 2019 02:58:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9Mmni9iTWiaEfYavRMpT34ihZP9tpZBceApJIYP4fPAQB3AbUiPnfSoBztHkY95oOuQmQ X-Received: by 2002:a05:6402:65a:: with SMTP id u26mr3501426edx.86.1569578336568; Fri, 27 Sep 2019 02:58:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569578336; cv=none; d=google.com; s=arc-20160816; b=i5PEDs71rr6zdGhKtqx7IUk4KIKVnnVvZ9Fj1CSvbaW19ApS2UruycNpcaSznDCJO2 GxoyoD0FQGAsXTAaKnGMvNlwuOxI5Wwv8ghCBE7c4bOADpC6dEbgBt0IFfVSPYwqGzsX Jw0eIErvLI5PgSMNAA5sOR6SBL5MkBzxR03rI6AqoSFhAXYmo24G4rMnZvGoBtxklixW pKw2N2ZiKj1Gb4ADvm1ZPiouY1NNKW5aNlVEPm5CFLjqkVyRCFrxvc0Dse+ZkE85xA1N 1cGD1Epfi0wjhGys44A8qE6K8JHCzpxOLCDVTAWd2JNZPLd7Inc9+0JttCOKWZzu1a/t hy4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature:dkim-filter; bh=4qDVNhnCcZvGDKMTTIvOCeP5JH/7NpDusdsDsAqAwwE=; b=X3Uc63uyDemCJp5DQwNfdFY/rO8s4wbYxsn0PE3ZdUG4aXg9ibrk018nFOPWvn9q6d yn82G17CTWvwrjAJmkqmVnKcNZh7tLePV7EZpQCtb3RjwX6i42jJ5vBvTO4zzB/CkfeR BvR8glwvjH6TjdZU8BJdN5n6atkb3xslPWdUV8uO2kUhYVnGai7npjtz7mTqla9MAhxe S/MeUNM099pAdvckZcUMr1JUjlnI0j4yG8542+pK5nnXIBHFIBF2N85gFEaQryHW4Pn4 F9EBysofrruPJ7eOEEcZWN5gKNDmZjdwORHHb9M0jrQxaUrRtpQdrcCsi/HBPPImcpcu nzww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=XKYBcXnL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b16si1179788edb.341.2019.09.27.02.58.31; Fri, 27 Sep 2019 02:58:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=XKYBcXnL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726295AbfI0J57 (ORCPT + 99 others); Fri, 27 Sep 2019 05:57:59 -0400 Received: from conssluserg-02.nifty.com ([210.131.2.81]:25430 "EHLO conssluserg-02.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbfI0J56 (ORCPT ); Fri, 27 Sep 2019 05:57:58 -0400 Received: from mail-vs1-f46.google.com (mail-vs1-f46.google.com [209.85.217.46]) (authenticated) by conssluserg-02.nifty.com with ESMTP id x8R9vWf1002432; Fri, 27 Sep 2019 18:57:32 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com x8R9vWf1002432 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1569578253; bh=4qDVNhnCcZvGDKMTTIvOCeP5JH/7NpDusdsDsAqAwwE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=XKYBcXnLL3ZwLskkyYgV3ToDdaoh4S6dXjI6i7nfRhPYljatB45u87bsSnkufj3LD vhLUDHE4hPxHEjHJPUhWFRRCy3NyyJDy6VBkWEP7hFeMwS03zu/FOfWkRcjqeyq+yQ xhVLn1kH2IDmWNAB4k4JZfoo08PbjP8vupONrmOvdLGoiCeAF9XNS7qy8W8X/tion1 1Ar/Fq/riIcDGBaN72hUdjC7suttWC/SI/ugjbbGWdWkCcVHDoXjNpVb4zDmLyK0zM 4eYjr9h42tsauJ5eK6lE/T5WBVfdtBU3APHwzUdImWW2keoHT6NnUKrkoEyd+2itFa mAUufZSL/FHrw== X-Nifty-SrcIP: [209.85.217.46] Received: by mail-vs1-f46.google.com with SMTP id p13so1481496vso.0; Fri, 27 Sep 2019 02:57:32 -0700 (PDT) X-Gm-Message-State: APjAAAWOawkst2/O+ZJg1Zh23WM7OZ7yZ4dZwAqMElKOsC6mHPTP1DPm VTmbqlXrGfauZ9+fLGXDFO5ed0XVWDv2pTLa4sI= X-Received: by 2002:a67:88c9:: with SMTP id k192mr1864063vsd.181.1569578251420; Fri, 27 Sep 2019 02:57:31 -0700 (PDT) MIME-Version: 1.0 References: <20190927093603.9140-1-yamada.masahiro@socionext.com> <20190927093603.9140-2-yamada.masahiro@socionext.com> In-Reply-To: <20190927093603.9140-2-yamada.masahiro@socionext.com> From: Masahiro Yamada Date: Fri, 27 Sep 2019 18:56:55 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/7] modpost: fix broken sym->namespace for external module builds To: Jessica Yu Cc: Matthias Maennich , Greg Kroah-Hartman , Joel Fernandes , Martijn Coenen , Will Deacon , Michal Marek , Linux Kbuild mailing list , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 27, 2019 at 6:37 PM Masahiro Yamada wrote: > > Currently, external module builds produce tons of false-positives: > > WARNING: module uses symbol from namespace , but does not import it. > > Here, the part shows a random string. > > When you build external modules, the symbol info of vmlinux and > in-kernel modules are read from $(objtree)/Module.symvers, but > read_dump() is buggy in multiple ways: > > [1] When the modpost is run for vmlinux and in-kernel modules, > sym_extract_namespace() correctly allocates memory for the namespace. > On the other hand, read_dump() does not, then sym->namespace will > point to somewhere in the line buffer of get_next_line(). The data > in the buffer will be replaced soon, and sym->namespace will end up > with pointing to unrelated data. As a result, check_exports() will > show random strings in the warning messages. > > [2] When there is no namespace, sym_extract_namespace() returns NULL. > On the other hand, read_dump() sets namespace to an empty string "". > (but, it will be later replaced with unrelated data due to bug [1].) > The check_exports() shows a warning unless exp->namespace is NULL, > so every symbol read from read_dump() emits the warning, which is > mostly false positive. > > To address [1], I added NOFAIL(strdup(...)) to allocate memory. > For [2], I changed the if-conditional in check_exports(). > > Signed-off-by: Masahiro Yamada > --- > Fixes: cb9b55d21fe0 ("modpost: add support for symbol namespaces") -- Best Regards Masahiro Yamada