From patchwork Fri Sep 27 09:35:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 174622 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3245746ill; Fri, 27 Sep 2019 02:37:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxHSRzoiJRwa9+YuDPksk7LMI8wp+y9xi3d1LzvW23GwvtDGz5WDAYiixICAtSO3g6EXTNb X-Received: by 2002:a50:93a4:: with SMTP id o33mr3514769eda.0.1569577045685; Fri, 27 Sep 2019 02:37:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569577045; cv=none; d=google.com; s=arc-20160816; b=huYKi9Mig/lntXtFuPU0mBKHBJ25LfF2/U7AP6kMKB2+fXBnsgUIwm0N8a18JCTtYK jSAMmGGZjuxq4+FAzMbA6D9u3YMQZ07u+OV7g6Bar7+l1YrSTB90Hlh6QLITGi/G/tPL AKv6Q2h5RjQkctiqtTLY8v5aGbt/fI+PimdVb1f20ijN4GOwVqB2S3wezywhYorw3VIe vBRDHaTcp0a04FPdfib0urECeC5DxD5sOFT3I6hfllUyEG3kL8xanAPo8m52pUPrn4gk FvvtEjAZyZx7eOrclxiTFMVlMm9AVYVkoBOs4l2kQfza2Myvbvw8uozCPmcx20EDC8Pi R4PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=vJzF8WlgUqc1RsR95UB9lwwYV0dr5aBFLgK7a4VpJl0=; b=oN19MpCtg/MiGHa/kdmNMjfdUtpTUfQ6sZbT4CEvZoO5BYzZC2fej6EJjMc1aiMfax KvV4/sIErVXAw7qWaScuUUe4YccjDVVObo5xkCadVzs7HY0jQjDqrU40jw8wp1rc5p4m 8DG7+HofUNCdTisFwM96zDvKRfZZWHnNjs2z8Eatb4zhAYo3zM4xsvt03sBhH6LEtHkX QKZ7WB0SQhfM4Cxk5TTO89h3ixn9DNLSeVa4bFqjrbBdytDPKavBhdP1ga9pCAIlTJPN gQD5N1BL8xvVaqaUMmBI6IopFyxfQMiYieMexZzc0pYtMkm0FUFdqQ87E8OQE4koq8fV ubkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b="a/t82mTw"; 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 z7si2386219ejr.99.2019.09.27.02.37.25; Fri, 27 Sep 2019 02:37:25 -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="a/t82mTw"; 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 S1727164AbfI0JhW (ORCPT + 26 others); Fri, 27 Sep 2019 05:37:22 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:33057 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726438AbfI0JhC (ORCPT ); Fri, 27 Sep 2019 05:37:02 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x8R9a5ub001372; Fri, 27 Sep 2019 18:36:07 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x8R9a5ub001372 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1569576967; bh=vJzF8WlgUqc1RsR95UB9lwwYV0dr5aBFLgK7a4VpJl0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a/t82mTwbwWZPr0/tQv9F1qEmfxY+FFesX4KbzmGMTG21vQhlXMBP7rrvpG/Gvk6w EC+o8FZKVJbbAVEZoykh5cD2QqCDz/m+73YH1vmQ2Up3QMvK99h0chvD0XxdoYMafC uOsZH+QvFnmPwiHz1IRaSCJXFXASiKeDWhOTxiFDswTY2pRWlD9V3c//TfIpSFUCwr Rz0S84dpoQubEEROWm9wXT/T9ga6jnFTjaA5V4G6/pBsqw1cEZTCcCRkj3XXFk4KLL 2mhnuT7X3lne5Abip9GRwCQrTuntCf8So9MR7YqWsmfYyqDEW/17TOx+STvRxZF6TM Cy6NJ4OYl1HKw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Jessica Yu Cc: Matthias Maennich , Greg Kroah-Hartman , Joel Fernandes , Martijn Coenen , Will Deacon , Masahiro Yamada , Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] modpost: fix broken sym->namespace for external module builds Date: Fri, 27 Sep 2019 18:35:57 +0900 Message-Id: <20190927093603.9140-2-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190927093603.9140-1-yamada.masahiro@socionext.com> References: <20190927093603.9140-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- scripts/mod/modpost.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.17.1 Reviewed-by: Matthias Maennich diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 3961941e8e7a..5c628a7d80f7 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2195,7 +2195,7 @@ static int check_exports(struct module *mod) else basename = mod->name; - if (exp->namespace) { + if (exp->namespace && exp->namespace[0]) { add_namespace(&mod->required_namespaces, exp->namespace); @@ -2453,7 +2453,7 @@ static void read_dump(const char *fname, unsigned int kernel) mod = new_module(modname); mod->skip = 1; } - s = sym_add_exported(symname, namespace, mod, + s = sym_add_exported(symname, NOFAIL(strdup(namespace)), mod, export_no(export)); s->kernel = kernel; s->preloaded = 1; From patchwork Fri Sep 27 09:35:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 174620 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3245620ill; Fri, 27 Sep 2019 02:37:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzP7LobF/vdm4J7eAfSgF/Qc7N68A9ql4bF+uJWj8v4/vWpZK6rtYRXvLecErME3vkY97hx X-Received: by 2002:aa7:c749:: with SMTP id c9mr3433290eds.232.1569577037290; Fri, 27 Sep 2019 02:37:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569577037; cv=none; d=google.com; s=arc-20160816; b=TBPVdedkFlUM/TSbRE9grgXvQmS7qfV1K+Pu9KVD3zBYN3/AcWd1pgQxmidHK9Sy6i ZRh/jE9b0U9HxFb0y+hzOz+H05HfmhGlHpMZsCMdecbIc5EiJfrg5pDzKtcdZ64jD0+n wRKESioIxKNFGJqg1TmEmWXb2umN1e5a9qyZEo+EoHavxflwfZ9wPy4X44nNPBxsIQ9N a9N/defvdsav1sfUdTIVzWQklRGiqd8mi+5lHsyX/6RAMVjtCwrCWukhPh0hjfMvuQjo 8DSZeCDZ6M/22zLzL1pVTlFe1NylCCt+2ypiHt4TMCA4dOn6k7UQgoXmLWM+kc2QHGqF RxdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=k0hBXKWoJkYYxdDyuOyeX7IT6hvCtlLoJTUWwkZpHoo=; b=bvUJmF+xoYAYqmsjyfVNJDHFFeA5bT/ywQDtstKr039Nek6hcULeBpLPMraMgh7/J0 b3vr5brPHwMX/kxm6bsIYRdMZ6+qEc6JuTh2oCvkqYQbE2qlu351bCLfWc4Okk9m875z BHCeZB68vveoLgbISGYX98KC5IVeLljzDGH3uNjvy8lLXJFPaACX2l00iQRW8f8AgQ3Q GKIww0Lq5HKC/bW8uyceUCttA9nYgHVztaw6YUeRI+gR86UuTMbHIKnNUiZwKt9U5EmB 9vlKU9yay4wy3YVuhy6oNM5ZZ/T9tH/7Yht1ECz13LUNtsApup5AyNWaRE9iFHN4uGGq 1ODw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=2NU1Uj+G; 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 a23si1314162edj.201.2019.09.27.02.37.17; Fri, 27 Sep 2019 02:37:17 -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=2NU1Uj+G; 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 S1727114AbfI0JhP (ORCPT + 26 others); Fri, 27 Sep 2019 05:37:15 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:33064 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726444AbfI0JhC (ORCPT ); Fri, 27 Sep 2019 05:37:02 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x8R9a5uc001372; Fri, 27 Sep 2019 18:36:08 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x8R9a5uc001372 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1569576968; bh=k0hBXKWoJkYYxdDyuOyeX7IT6hvCtlLoJTUWwkZpHoo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2NU1Uj+GZgATSlHQ/wpNiFGS13yTeurDYkQ5oWGWobbFSPBjB+S2L6Fw/LgnWkTAq hWIRQQ41fCSLUNCBf+HYJZpbU959wGqrEA72oxHXEOjKJMSWh0zUo3N/sSGmjzhqzA D32uDOKQCjHot8mwF7RjQ3ysW8A3joNSk4qE8q1zcFV/svc+eMf4VFKUt2JxAYJCKw rysk1hb7vz3OotkLSrzSX5ezVfEFv12Sr9ojoceyMo6VmsPBBWJhLrk4vNps7///3U yEBu+i2JGF6ZOMzg2oRMYSRJkvsMvIqDtV92F3sTt+tEvDeBMXe70++/0/ZmSO0rt4 ozmoh+j5CsHlw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Jessica Yu Cc: Matthias Maennich , Greg Kroah-Hartman , Joel Fernandes , Martijn Coenen , Will Deacon , Masahiro Yamada , Michal Marek , Will Deacon , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] module: swap the order of symbol.namespace Date: Fri, 27 Sep 2019 18:35:58 +0900 Message-Id: <20190927093603.9140-3-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190927093603.9140-1-yamada.masahiro@socionext.com> References: <20190927093603.9140-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, EXPORT_SYMBOL_NS(_GPL) constructs the kernel symbol as follows: __ksymtab_SYMBOL.NAMESPACE The sym_extract_namespace() in modpost allocates memory for the part SYMBOL.NAMESPACE when '.' is contained. One problem is that the pointer returned by strdup() is lost because the symbol name will be copied to malloc'ed memory by alloc_symbol(). No one will keep track of the pointer of strdup'ed memory. sym->namespace still points to the NAMESPACE part. So, if you like, you can free it with complicated code like this: free(sym->namespace - strlen(sym->name) - 1); I would not say it is fatal since we seldom bother to manually free memory in host programs. But, I can fix it in an elegant way. I swapped the order of the symbol and the namespace as follows: __ksymtab_NAMESPACE.SYMBOL then, simplified sym_extract_namespace() so that it allocates memory only for the NAMESPACE part. I prefer this order because it is intuitive and also matches to major languages. For example, NAMESPACE::NAME in C++, MODULE.NAME in Python. Signed-off-by: Masahiro Yamada --- include/linux/export.h | 4 ++-- scripts/mod/modpost.c | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) -- 2.17.1 Reviewed-by: Matthias Maennich diff --git a/include/linux/export.h b/include/linux/export.h index 95f55b7f83a0..0695d4e847d9 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -52,7 +52,7 @@ extern struct module __this_module; __ADDRESSABLE(sym) \ asm(" .section \"___ksymtab" sec "+" #sym "\", \"a\" \n" \ " .balign 4 \n" \ - "__ksymtab_" #sym NS_SEPARATOR #ns ": \n" \ + "__ksymtab_" #ns NS_SEPARATOR #sym ": \n" \ " .long " #sym "- . \n" \ " .long __kstrtab_" #sym "- . \n" \ " .long __kstrtab_ns_" #sym "- . \n" \ @@ -76,7 +76,7 @@ struct kernel_symbol { #else #define __KSYMTAB_ENTRY_NS(sym, sec, ns) \ static const struct kernel_symbol __ksymtab_##sym##__##ns \ - asm("__ksymtab_" #sym NS_SEPARATOR #ns) \ + asm("__ksymtab_" #ns NS_SEPARATOR #sym) \ __attribute__((section("___ksymtab" sec "+" #sym), used)) \ __aligned(sizeof(void *)) \ = { (unsigned long)&sym, __kstrtab_##sym, __kstrtab_ns_##sym } diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 5c628a7d80f7..d171b0cffb05 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -350,18 +350,16 @@ static enum export export_from_sec(struct elf_info *elf, unsigned int sec) static const char *sym_extract_namespace(const char **symname) { - size_t n; - char *dupsymname; + char *namespace = NULL; + char *ns_separator; - n = strcspn(*symname, "."); - if (n < strlen(*symname) - 1) { - dupsymname = NOFAIL(strdup(*symname)); - dupsymname[n] = '\0'; - *symname = dupsymname; - return dupsymname + n + 1; + ns_separator = strchr(*symname, '.'); + if (ns_separator) { + namespace = NOFAIL(strndup(*symname, ns_separator - *symname)); + *symname = ns_separator + 1; } - return NULL; + return namespace; } /** From patchwork Fri Sep 27 09:35:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 174623 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3245769ill; Fri, 27 Sep 2019 02:37:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzEREJtpIfJsmJKgKocF2q+3tgGhijVsr/yXHoe5+BrM3VvHMtimktYNwulLj5VIQGFLymj X-Received: by 2002:a17:906:d97a:: with SMTP id rp26mr7031731ejb.251.1569577047196; Fri, 27 Sep 2019 02:37:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569577047; cv=none; d=google.com; s=arc-20160816; b=CLzlIAsmw5zmWVUARoqYtJCaspa5+wlgmPm85U1+ql6OplVMXtnmw1qK06oTeSZJh/ Hiwlb15CEkddksGzvMSRMRG3HpRnxxUXJo7nerEd0IJ6OX85gcXB0bkb32UXtcVbK5yp jQC44Z79T1TFn7+wHcFsGstM8hc1RtSWRMhXQw9CmsihyrpVLICvkEJlRFEb0z0KOFWa ZTMrKeW0lJNGXDpNTGfytvuR/dRRf8XcJ3INVQwTRfSjI79Nv2Z/i9XB8S8NU2wtNPTd aCwifdEK1/hbyziuUiV2DoRk8zBcn5oGTtmdmTRSrinwRhwFA6ExLS1qOL9LNSiZmkYp JWdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=Fynp0G6evPgfPqhsg7r4WZQkR9spuRzwJdxpkYdeONU=; b=W994lwQf2ERM5bV42OFyxQ+MjKQKQfMw0KU3F/d41uInBObDKvH4LkNxASGfMMs+IZ Lwy7uEmWT4Lwn017phTyz73Y2ukfkAWeBbFVlZvUveibGlw/LYi/sGnlfm4SiVH+Pc43 bQTWklxKfgAI/BFKWXxMncC9mwQwPzLtK3ekMBbfx7MtoHDio7QVeJak/GMavGFQWUYr q0/bR+IVSf/xgKIJRVcgwEn8gBjzsdABZp09FjMjtKSGRSHxnARL+QUkMmJzgg139dDl rgr0OwrcUODKXGU/QmKGZMZACvtkrO7z7NYG1H8owtDH6HbQ3aX/1CGZpVC/lFKLDTaX gcPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=NKUk7uGl; 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 z7si2386219ejr.99.2019.09.27.02.37.27; Fri, 27 Sep 2019 02:37:27 -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=NKUk7uGl; 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 S1727198AbfI0Jh0 (ORCPT + 26 others); Fri, 27 Sep 2019 05:37:26 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:33056 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726339AbfI0JhB (ORCPT ); Fri, 27 Sep 2019 05:37:01 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x8R9a5ud001372; Fri, 27 Sep 2019 18:36:09 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x8R9a5ud001372 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1569576969; bh=Fynp0G6evPgfPqhsg7r4WZQkR9spuRzwJdxpkYdeONU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NKUk7uGll+V8LdUDPB1GVeeJOolszILWQCZ7SBQwkVdpbGuFn/6kDpUjNB0/QnynN 2qtuscgntP19CTgrkmvl5MSiiiCNBM8MTMvqvOQ4ZMK6qxLZECMooRQMg6/8GhwHCg 4qU/g9rGsuM3KtYDnkAKAF8mdbt1DU2+OHsXQWxPZbNlhE1f7JA0E0NXhTwlDXPVww 4avl6+5iYDzdjgiBkx4qQI4Jn3n3WKQrBxF1+7k8g8hxJW9+fKH4EYxiht2YQCla4r xGD/ItNo3FzzIpks94EAkkrKdxQaT80bh4XJSdYX5FJ+9Eyq/pDWRgWKZzoce+x0d1 X55tIS908scnw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Jessica Yu Cc: Matthias Maennich , Greg Kroah-Hartman , Joel Fernandes , Martijn Coenen , Will Deacon , Masahiro Yamada , Will Deacon , linux-kernel@vger.kernel.org Subject: [PATCH 3/7] module: rename __kstrtab_ns_* to __kstrtabns_* to avoid symbol conflict Date: Fri, 27 Sep 2019 18:35:59 +0900 Message-Id: <20190927093603.9140-4-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190927093603.9140-1-yamada.masahiro@socionext.com> References: <20190927093603.9140-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The module namespace produces __strtab_ns_ symbols to store namespace strings, but it does not guarantee the name uniqueness. This is a potential problem because we have exported symbols staring with "ns_". For example, kernel/capability.c exports the following symbols: EXPORT_SYMBOL(ns_capable); EXPORT_SYMBOL(capable); Assume a situation where those are converted as follows: EXPORT_SYMBOL_NS(ns_capable, some_namespace); EXPORT_SYMBOL_NS(capable, some_namespace); The former expands to "__kstrtab_ns_capable" and "__kstrtab_ns_ns_capable", and the latter to "__kstrtab_capable" and "__kstrtab_ns_capable". Then, we have the duplication for "__kstrtab_ns_capable". To ensure the uniqueness, rename "__kstrtab_ns_*" to "__kstrtabns_*". Signed-off-by: Masahiro Yamada --- include/linux/export.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.1 Reviewed-by: Matthias Maennich diff --git a/include/linux/export.h b/include/linux/export.h index 0695d4e847d9..621158ecd2e2 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -55,7 +55,7 @@ extern struct module __this_module; "__ksymtab_" #ns NS_SEPARATOR #sym ": \n" \ " .long " #sym "- . \n" \ " .long __kstrtab_" #sym "- . \n" \ - " .long __kstrtab_ns_" #sym "- . \n" \ + " .long __kstrtabns_" #sym "- . \n" \ " .previous \n") #define __KSYMTAB_ENTRY(sym, sec) \ @@ -79,7 +79,7 @@ struct kernel_symbol { asm("__ksymtab_" #ns NS_SEPARATOR #sym) \ __attribute__((section("___ksymtab" sec "+" #sym), used)) \ __aligned(sizeof(void *)) \ - = { (unsigned long)&sym, __kstrtab_##sym, __kstrtab_ns_##sym } + = { (unsigned long)&sym, __kstrtab_##sym, __kstrtabns_##sym } #define __KSYMTAB_ENTRY(sym, sec) \ static const struct kernel_symbol __ksymtab_##sym \ @@ -112,7 +112,7 @@ struct kernel_symbol { /* For every exported symbol, place a struct in the __ksymtab section */ #define ___EXPORT_SYMBOL_NS(sym, sec, ns) \ ___export_symbol_common(sym, sec); \ - static const char __kstrtab_ns_##sym[] \ + static const char __kstrtabns_##sym[] \ __attribute__((section("__ksymtab_strings"), used, aligned(1))) \ = #ns; \ __KSYMTAB_ENTRY_NS(sym, sec, ns) From patchwork Fri Sep 27 09:36:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 174618 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3245460ill; Fri, 27 Sep 2019 02:37:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2eYsl1fmZBc05Y5U6qYWcT1bzY6k6hJZzSmQF7ZLYQXzjxiyMdIAjnpeOVjH8SQHlrjgn X-Received: by 2002:a17:906:7e06:: with SMTP id e6mr6986362ejr.149.1569577030062; Fri, 27 Sep 2019 02:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569577030; cv=none; d=google.com; s=arc-20160816; b=mn33EBWvlqD69E7YvmI2t7RZjMIkpOo3mc8A8j1RX50GmYnlXyyTf6RZEodDNZ3F3k MOJo29Mo27tbsO1HzCKVqJjJ4rY+HskNDjyjChT7CeasgggXZDsDzo6WMgkL2JK7G3SE KiKUv04zr/nzduQBDJ4XjBY5Hbx4cnYhPKhygyxh/tzj+NjcXA2a6zKXHh2cRxVuE6h6 jOCIYhIsBXJACpzDWOoh7v9ZypR8VlokXtI0Rx+30X09P0RKTBoQOlL9vDdE3Boesp5T tQsOwytWXwWxO/47dQDywfVpMN6oAb7+hXk/WAEeUxa89EbZ281+jz9H37yUu92s3qf/ tVBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=rsB4h06qUtfwfDPTJVMKf592jd7/Pnx6aEXTAIEd2KQ=; b=EJtH6myuVJAIspaW52EzPc0EoBlIglkmarSNkwDGMFtT/hR9F9JkIZmglSaHiZjrt2 kW5+dCGZfB54GXuq3iwhRgP8MsJuItrvKWS4SMYSBD2uxu+XrsEBQh/HnrXm43ZsiDc1 pW6lKwwBq6B/6BU1pY5Pxrt7QN6Zv+WN6KaiFUwoXa1bF+ECHNoXlJY2Ios0w+rXsv9U /oh4dF37HmZQxK9bzRw8NnEGEGkVvBTMtZlSRVz8exKEmIPkEr1HYotErP9BUZMgWRBA xKtVmSZQ+mcrYs3G1/hRfDuZL0Xov7iCGpbd6rESnKxY7BXo1VmzkzyTiiztTKh+h7AV IIkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=B0R09e0l; 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 v5si1282078ede.126.2019.09.27.02.37.09; Fri, 27 Sep 2019 02:37:10 -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=B0R09e0l; 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 S1726978AbfI0JhE (ORCPT + 26 others); Fri, 27 Sep 2019 05:37:04 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:33058 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbfI0JhC (ORCPT ); Fri, 27 Sep 2019 05:37:02 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x8R9a5ue001372; Fri, 27 Sep 2019 18:36:09 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x8R9a5ue001372 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1569576970; bh=rsB4h06qUtfwfDPTJVMKf592jd7/Pnx6aEXTAIEd2KQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B0R09e0lhFhBsdHnZKZbSPkPCeaxl+CutXvTjvjYBVKQU6KfUokdgT6QnYPVYx9wb xAd/Fv3g/mfSwGtaTAxLBxI0MBNqFfbWzXBvBHZDBuDAX7qag5oUXZFIPClKjPjlxp ly8cVPCH0Cp5U086RNQcP6jOioiNfOR4p99a8FEL2hN3iy5qKWy0Zgbyim33YVDDrQ /qGdifZtVgss0BFFcDYhsC2Blr+ZrYDH7zXPihfT1eeOpJZSHsKxTVwgG8wtRfAHoS Ij28vs2WB3r/nyt+Fisu8vTIOE6fD1AMQ4wsotlJs1AhLopuFrNqG8FbluLbYQWEJ+ uT96h2QAFsYNg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Jessica Yu Cc: Matthias Maennich , Greg Kroah-Hartman , Joel Fernandes , Martijn Coenen , Will Deacon , Masahiro Yamada , Will Deacon , linux-kernel@vger.kernel.org Subject: [PATCH 4/7] module: avoid code duplication in include/linux/export.h Date: Fri, 27 Sep 2019 18:36:00 +0900 Message-Id: <20190927093603.9140-5-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190927093603.9140-1-yamada.masahiro@socionext.com> References: <20190927093603.9140-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org include/linux/export.h has lots of code duplication between EXPORT_SYMBOL and EXPORT_SYMBOL_NS. To improve the maintainability and readability, unify the implementation. When the symbol has no namespace, pass the empty string "" to the 'ns' parameter. The drawback of this change is, it grows the code size. When the symbol has no namespace, sym->namespace was previously NULL, but it is now am empty string "". So, it increases 1 byte for every no namespace EXPORT_SYMBOL. A typical kernel configuration has 10K exported symbols, so it increases 10KB in rough estimation. I did not come up with a good idea to refactor it without increasing the code size. I am not sure how big a deal it is, but at least include/linux/export.h looks nicer. Signed-off-by: Masahiro Yamada --- include/linux/export.h | 100 +++++++++++++---------------------------- kernel/module.c | 2 +- 2 files changed, 33 insertions(+), 69 deletions(-) -- 2.17.1 diff --git a/include/linux/export.h b/include/linux/export.h index 621158ecd2e2..55245a405a2f 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -48,45 +48,28 @@ extern struct module __this_module; * absolute relocations that require runtime processing on relocatable * kernels. */ -#define __KSYMTAB_ENTRY_NS(sym, sec, ns) \ +#define __KSYMTAB_ENTRY(sym, sec, ns) \ __ADDRESSABLE(sym) \ asm(" .section \"___ksymtab" sec "+" #sym "\", \"a\" \n" \ " .balign 4 \n" \ - "__ksymtab_" #ns NS_SEPARATOR #sym ": \n" \ + "__ksymtab_" ns NS_SEPARATOR #sym ": \n" \ " .long " #sym "- . \n" \ " .long __kstrtab_" #sym "- . \n" \ " .long __kstrtabns_" #sym "- . \n" \ " .previous \n") -#define __KSYMTAB_ENTRY(sym, sec) \ - __ADDRESSABLE(sym) \ - asm(" .section \"___ksymtab" sec "+" #sym "\", \"a\" \n" \ - " .balign 4 \n" \ - "__ksymtab_" #sym ": \n" \ - " .long " #sym "- . \n" \ - " .long __kstrtab_" #sym "- . \n" \ - " .long 0 \n" \ - " .previous \n") - struct kernel_symbol { int value_offset; int name_offset; int namespace_offset; }; #else -#define __KSYMTAB_ENTRY_NS(sym, sec, ns) \ - static const struct kernel_symbol __ksymtab_##sym##__##ns \ - asm("__ksymtab_" #ns NS_SEPARATOR #sym) \ - __attribute__((section("___ksymtab" sec "+" #sym), used)) \ - __aligned(sizeof(void *)) \ - = { (unsigned long)&sym, __kstrtab_##sym, __kstrtabns_##sym } - -#define __KSYMTAB_ENTRY(sym, sec) \ +#define __KSYMTAB_ENTRY(sym, sec, ns) \ static const struct kernel_symbol __ksymtab_##sym \ - asm("__ksymtab_" #sym) \ + asm("__ksymtab_" ns NS_SEPARATOR #sym) \ __attribute__((section("___ksymtab" sec "+" #sym), used)) \ __aligned(sizeof(void *)) \ - = { (unsigned long)&sym, __kstrtab_##sym, NULL } + = { (unsigned long)&sym, __kstrtab_##sym, __kstrtabns_##sym } struct kernel_symbol { unsigned long value; @@ -97,29 +80,21 @@ struct kernel_symbol { #ifdef __GENKSYMS__ -#define ___EXPORT_SYMBOL(sym,sec) __GENKSYMS_EXPORT_SYMBOL(sym) -#define ___EXPORT_SYMBOL_NS(sym,sec,ns) __GENKSYMS_EXPORT_SYMBOL(sym) +#define ___EXPORT_SYMBOL(sym, sec, ns) __GENKSYMS_EXPORT_SYMBOL(sym) #else -#define ___export_symbol_common(sym, sec) \ +/* For every exported symbol, place a struct in the __ksymtab section */ +#define ___EXPORT_SYMBOL(sym, sec, ns) \ extern typeof(sym) sym; \ __CRC_SYMBOL(sym, sec); \ static const char __kstrtab_##sym[] \ __attribute__((section("__ksymtab_strings"), used, aligned(1))) \ - = #sym \ - -/* For every exported symbol, place a struct in the __ksymtab section */ -#define ___EXPORT_SYMBOL_NS(sym, sec, ns) \ - ___export_symbol_common(sym, sec); \ + = #sym; \ static const char __kstrtabns_##sym[] \ __attribute__((section("__ksymtab_strings"), used, aligned(1))) \ - = #ns; \ - __KSYMTAB_ENTRY_NS(sym, sec, ns) - -#define ___EXPORT_SYMBOL(sym, sec) \ - ___export_symbol_common(sym, sec); \ - __KSYMTAB_ENTRY(sym, sec) + = ns; \ + __KSYMTAB_ENTRY(sym, sec, ns) #endif @@ -130,8 +105,7 @@ struct kernel_symbol { * be reused in other execution contexts such as the UEFI stub or the * decompressor. */ -#define __EXPORT_SYMBOL_NS(sym, sec, ns) -#define __EXPORT_SYMBOL(sym, sec) +#define __EXPORT_SYMBOL(sym, sec, ns) #elif defined(CONFIG_TRIM_UNUSED_KSYMS) @@ -147,48 +121,38 @@ struct kernel_symbol { #define __ksym_marker(sym) \ static int __ksym_marker_##sym[0] __section(".discard.ksym") __used -#define __EXPORT_SYMBOL(sym, sec) \ +#define __EXPORT_SYMBOL(sym, sec, ns) \ __ksym_marker(sym); \ - __cond_export_sym(sym, sec, __is_defined(__KSYM_##sym)) -#define __cond_export_sym(sym, sec, conf) \ - ___cond_export_sym(sym, sec, conf) -#define ___cond_export_sym(sym, sec, enabled) \ - __cond_export_sym_##enabled(sym, sec) -#define __cond_export_sym_1(sym, sec) ___EXPORT_SYMBOL(sym, sec) -#define __cond_export_sym_0(sym, sec) /* nothing */ - -#define __EXPORT_SYMBOL_NS(sym, sec, ns) \ - __ksym_marker(sym); \ - __cond_export_ns_sym(sym, sec, ns, __is_defined(__KSYM_##sym)) -#define __cond_export_ns_sym(sym, sec, ns, conf) \ - ___cond_export_ns_sym(sym, sec, ns, conf) -#define ___cond_export_ns_sym(sym, sec, ns, enabled) \ - __cond_export_ns_sym_##enabled(sym, sec, ns) -#define __cond_export_ns_sym_1(sym, sec, ns) ___EXPORT_SYMBOL_NS(sym, sec, ns) -#define __cond_export_ns_sym_0(sym, sec, ns) /* nothing */ + __cond_export_sym(sym, sec, ns, __is_defined(__KSYM_##sym)) +#define __cond_export_sym(sym, sec, ns, conf) \ + ___cond_export_sym(sym, sec, ns, conf) +#define ___cond_export_sym(sym, sec, ns, enabled) \ + __cond_export_sym_##enabled(sym, sec, ns) +#define __cond_export_sym_1(sym, sec, ns) ___EXPORT_SYMBOL(sym, sec, ns) +#define __cond_export_sym_0(sym, sec, ns) /* nothing */ #else -#define __EXPORT_SYMBOL_NS(sym,sec,ns) ___EXPORT_SYMBOL_NS(sym,sec,ns) -#define __EXPORT_SYMBOL(sym,sec) ___EXPORT_SYMBOL(sym,sec) +#define __EXPORT_SYMBOL(sym, sec, ns) ___EXPORT_SYMBOL(sym, sec, ns) #endif /* CONFIG_MODULES */ #ifdef DEFAULT_SYMBOL_NAMESPACE -#undef __EXPORT_SYMBOL -#define __EXPORT_SYMBOL(sym, sec) \ - __EXPORT_SYMBOL_NS(sym, sec, DEFAULT_SYMBOL_NAMESPACE) +#include +#define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, __stringify(DEFAULT_SYMBOL_NAMESPACE)) +#else +#define _EXPORT_SYMBOL(sym, sec) __EXPORT_SYMBOL(sym, sec, "") #endif -#define EXPORT_SYMBOL(sym) __EXPORT_SYMBOL(sym, "") -#define EXPORT_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_gpl") -#define EXPORT_SYMBOL_GPL_FUTURE(sym) __EXPORT_SYMBOL(sym, "_gpl_future") -#define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL_NS(sym, "", ns) -#define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL_NS(sym, "_gpl", ns) +#define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "") +#define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "_gpl") +#define EXPORT_SYMBOL_GPL_FUTURE(sym) _EXPORT_SYMBOL(sym, "_gpl_future") +#define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL(sym, "", #ns) +#define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "_gpl", #ns) #ifdef CONFIG_UNUSED_SYMBOLS -#define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused") -#define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl") +#define EXPORT_UNUSED_SYMBOL(sym) _EXPORT_SYMBOL(sym, "_unused") +#define EXPORT_UNUSED_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "_unused_gpl") #else #define EXPORT_UNUSED_SYMBOL(sym) #define EXPORT_UNUSED_SYMBOL_GPL(sym) diff --git a/kernel/module.c b/kernel/module.c index 32873bcce738..73f69ff86db5 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1399,7 +1399,7 @@ static int verify_namespace_is_imported(const struct load_info *info, char *imported_namespace; namespace = kernel_symbol_namespace(sym); - if (namespace) { + if (namespace && namespace[0]) { imported_namespace = get_modinfo(info, "import_ns"); while (imported_namespace) { if (strcmp(namespace, imported_namespace) == 0) From patchwork Fri Sep 27 09:36:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 174619 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3245490ill; Fri, 27 Sep 2019 02:37:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwhC30RsVaxgsShokkCbfyC31uFBHRWrSWbjTnyFQmDWD9rjJHnZjiOoXb5atR6p3RZoW9w X-Received: by 2002:a17:906:6bca:: with SMTP id t10mr7047445ejs.64.1569577031518; Fri, 27 Sep 2019 02:37:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569577031; cv=none; d=google.com; s=arc-20160816; b=uHo9QI/+YidYm6jb9fy8zWa8GASEbnv+SDou6uwrGh6QMmerAns0ssiaTnpIOb21S/ K0vWlBPQcBickAqeAuFX+Lr2vYIIeVNN1kI4ROUfe9rNS6EYl9t1jijthq63SCbxOF7W ZBGCpLEkfcW6SvgdDOgaBYd7gAnOD2xwu3KH0cxEndBllPhO5IydgLlXSwYo+8oYlhQx usGlm8YonxceMTAvz1PbB0UG7IGsLFaQhq9fWuE2/5aDWzb8oFDKUATSODb5NUpyIJND 4h6ZNofwbVyyDpwGFSeDgCsd4e5g/bVrI1mZ/oc2CTTVe0MgPoLRa30HfwePfgFPrwhh vUEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=PdteufK64PUrtistqDZxQfPkOhODuQM4/dZUBLfPgTA=; b=nEskuy8KOD6Y5RP4RAROCm1GjK5G6zrSVj6427AY2BoKa5XXKUADY7gNKDEabmemmd DOzAhhxDqjWlFdVQVIz3AcayHvCj7inmZ36SluGbQJi3YxRFK1MI9xhbTPWh7Ad+e6Oo wjL56M35iAg4SEtLwZq5rtz+oVEUKzqFvkQTJ+VISjzVMIJEF9SnYkuzxI39V7UdR3nd K0a5XDwqS5DlIf2XOVmOZ45zpsDZW0nmcNc0LOVINXyoASfwVUzHrkGV9g11Om7JRYD0 I0EMqvpKPS2Ui+WwkXL6iCHzGDnBG8SrRF871L65aRbcDCC2oHMn/qCv6WGJ6wJmYMoP PpUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=EM8WpQlH; 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 v5si1282078ede.126.2019.09.27.02.37.11; Fri, 27 Sep 2019 02:37:11 -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=EM8WpQlH; 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 S1726896AbfI0JhD (ORCPT + 26 others); Fri, 27 Sep 2019 05:37:03 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:33065 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbfI0JhC (ORCPT ); Fri, 27 Sep 2019 05:37:02 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x8R9a5uf001372; Fri, 27 Sep 2019 18:36:10 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x8R9a5uf001372 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1569576971; bh=PdteufK64PUrtistqDZxQfPkOhODuQM4/dZUBLfPgTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EM8WpQlHl/RRg5lRspAhRnXuVP7NMRwN3vND8I4as8aaLPekCtI2sURqIXOQUzDqJ TJHa0dr1aSxHTVohjmVKh7oax8Y6aHX6vl0frGNzHY2Kajqt1EupmVDFm5uVTT36nI WTqmMnV47W4d6qBAKQZwm29A4ypO1YqbCZQRbrrvANW8PLu1Z4gsMkTGzAkFJ/v6aw HY/TlIH66PvW6R/IEv69y/UWP17UXOHEpE7VWJKN4aqBCdnNEQwkFNCXzd0B4zz7VG d5miMuXHwDAUjJBe6WWgZaWnkP07YEIXzgMDUvwQxkliu+OIVfQBRM26Bg370XpJOe 0pyYPUk423uwg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Jessica Yu Cc: Matthias Maennich , Greg Kroah-Hartman , Joel Fernandes , Martijn Coenen , Will Deacon , Masahiro Yamada , Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] kbuild: fix build error of 'make nsdeps' in clean tree Date: Fri, 27 Sep 2019 18:36:01 +0900 Message-Id: <20190927093603.9140-6-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190927093603.9140-1-yamada.masahiro@socionext.com> References: <20190927093603.9140-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Running 'make nsdeps' in a clean source tree fails as follows: $ make -s clean; make -s defconfig; make nsdeps [ snip ] awk: fatal: cannot open file `init/modules.order' for reading (No such file or directory) make: *** [Makefile;1307: modules.order] Error 2 make: *** Deleting file 'modules.order' make: *** Waiting for unfinished jobs.... The cause of the error is 'make nsdeps' does not build modules at all. Set KBUILD_MODULES to fix it. Signed-off-by: Masahiro Yamada --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Matthias Maennich diff --git a/Makefile b/Makefile index d456746da347..80ba8efd56bb 100644 --- a/Makefile +++ b/Makefile @@ -616,7 +616,7 @@ endif # in addition to whatever we do anyway. # Just "make" or "make all" shall build modules as well -ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) +ifneq ($(filter all _all modules nsdeps,$(MAKECMDGOALS)),) KBUILD_MODULES := 1 endif From patchwork Fri Sep 27 09:36:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 174616 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3245445ill; Fri, 27 Sep 2019 02:37:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHKGzFILIRAkn1m0WREa7ZnxjE9AObMIJWUf9AuQNfoFmdKOILVVPiqvyur784Sr8MsUwR X-Received: by 2002:a17:907:20c1:: with SMTP id qq1mr6716622ejb.87.1569577029234; Fri, 27 Sep 2019 02:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569577029; cv=none; d=google.com; s=arc-20160816; b=DMBjJ3ibjTY9s5MI+y3RjW7v8FDmf+6QMmC0x+63gpetTFIdxK5YSyk7hS7RmqczGC 85MlDWLECk1bdhLaDrg7gsBQtKb/8Hhga/+wPJJ2NZTcRLQLaNxXCddaxCR30BA0T3qJ 9CAxnvuZGc1fa1EN+TNEG5qz1czHjOcrwTweT7jY6Hl8lPhHbuzA+uW5osRhbyAdUCo2 A0LcmfIvdrvNCWCRq3m/ujh1XAPEzbwOcud8lLLJp8ytXwB5HQvABzbpbCrbszgYD7kM Bzvt1ONmDMEnnEzeec2rrs3BDsh+c10xTxueS4trUequisCCsgw0y1b6g9CJxNI/NC/6 RD3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=UQ6bH4/qZBZ6u3bYLv57zfd3f4RxEgvS4K1+jdI01bE=; b=j/R1HzZ4oZ5tIHZk6z/8xtQOnYcEEoYXb3bYk1+28+OKF3ac2bbJuIUNKDrPzXjHcR oi0RCZFjF89Sv63jvD5tv424AMiJ6f5vOfwgQqTy+kyAHkCCu6XVhhOLXoUiHnnZm87U u1/yV7T6CuvSTOb/cnj3NdFvwyPRCHpQUqCQwBo8pi8pnM6t4woQ6vxzxcVJo2TXOVOV T5CdjjKfGQgMUG1UYHAyfysAY6790CqL9P5JoN5fTnoOpfGHrbIOfIZlBRA/X5mYnhzo c3+yGji6pOszuUStW1obitkzzYHVtPKtUUtCkSkJPJA3qnc7PkqTPI1/wUXixEfj6iAY pQkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=frbgdxeG; 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 v5si1282078ede.126.2019.09.27.02.37.09; Fri, 27 Sep 2019 02:37:09 -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=frbgdxeG; 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 S1726730AbfI0JhC (ORCPT + 26 others); Fri, 27 Sep 2019 05:37:02 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:33054 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726385AbfI0JhB (ORCPT ); Fri, 27 Sep 2019 05:37:01 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x8R9a5ug001372; Fri, 27 Sep 2019 18:36:12 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x8R9a5ug001372 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1569576972; bh=UQ6bH4/qZBZ6u3bYLv57zfd3f4RxEgvS4K1+jdI01bE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=frbgdxeGGQj1AAOjEhqLFlCDcjeLt7cStOzPH2l82NztyjA71sxo14Zi/bXCzvh4P 9kwGdlzThgqbZ5CzsQdWDHGtrdB9yVtVpy5U1E7UswRYGVcjPc0tI+RKVhIb6drVlP ytCFvoZbIb64pCdDTruU+ag/LDUV+50pjhDetlTWyp8DFje/JNuoquAbcFNwlWw2GC wiGq7O8KYRo0/d/OJBomxqPpMxuswzr450Tbaau6QB7nrV6HzL4rkxGg0xrB/NddBz +gXUFIRw3MPzkk2lypyO98bt6neq0ofHuGCZqKUpFvH9K9bOSqQF+kDIgy6RdYXUfy ELHedr+p7EVNQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Jessica Yu Cc: Matthias Maennich , Greg Kroah-Hartman , Joel Fernandes , Martijn Coenen , Will Deacon , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 6/7] nsdeps: fix hashbang of scripts/nsdeps Date: Fri, 27 Sep 2019 18:36:02 +0900 Message-Id: <20190927093603.9140-7-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190927093603.9140-1-yamada.masahiro@socionext.com> References: <20190927093603.9140-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This script does not use bash-extension. I am guessing this hashbang was copied from scripts/coccicheck, which really uses bash-extension. /bin/sh is enough for this script. Signed-off-by: Masahiro Yamada --- scripts/nsdeps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Matthias Maennich diff --git a/scripts/nsdeps b/scripts/nsdeps index ac2b6031dd13..964b7fb8c546 100644 --- a/scripts/nsdeps +++ b/scripts/nsdeps @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # SPDX-License-Identifier: GPL-2.0 # Linux kernel symbol namespace import generator # From patchwork Fri Sep 27 09:36:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 174621 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3245668ill; Fri, 27 Sep 2019 02:37:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrbs5sYBMbUNthiVVZYnhy9wVhStR+yoT2kGqZ9RGdrrbb9Ra8A8DHVb5W6xEWF7Umu43I X-Received: by 2002:a17:906:7e56:: with SMTP id z22mr6615273ejr.294.1569577040018; Fri, 27 Sep 2019 02:37:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569577040; cv=none; d=google.com; s=arc-20160816; b=GR7o7X43zTdwW+W6/QrrD/ZTyH0cfaqRi8Z/K1FHz0wedOpeTaQx28Bq6mkz/EWDtD eu3DD+bedEV6VaF6+0cWhN6o5LMfUP88BRhlasZ+YcDrvDTB/2EI1sIiuuL08p8Sayyr z7a25SFLzJFAAtBBkkQeyengTfZ5xA3G4ocgfCtuB32vJvQ0kvIKsWKs2Bn2n8X3W4X7 K7NOVj+EH/1ePqv9qImZERbVv8elruyY9a6u/gUnIM6jeqIXg/AYpjjXdgUH/6f3up7j 6+sg6tNdsYcrm3J4AvsTjFpnCroPoW6Eb6NeQtNdUG4jJEY5hCbhr12q5E/0ebL42Hdk 2lRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=8Z1yZcx7lt82yK82hKDWaRuslS2lyBCS5/OQGziEcvs=; b=DKEaf16ssPQ8f/vjpNelPf1A05oxnFcrwrZliNJbpPtuHlMKA75vzjFXJkKW4rHL01 9BYr3qibdOfVKEPM1O11MgiI8/rS+RGoXuNmQpsIE4m1eh8p0yvpl+rRBIONuXr7hGV0 PU5uRB8Sn/VRC5HZl/8Neidr0bAdNtM6ryLeaU4WzVSmZXourUBvegsaAkg62JAwuXSt wx7TNLhCPZTKujXtID7chYpvj1RgPfKanwTWC9aKm4eBBiW2mksqUVwNXyZWLNOR5Py0 ywSOM/pZJZfSq5DGZXVbcd1/seM/NR5esGWxEOGgBNattm5OxxBrA3JMcvB4FKculylD TVKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=uoWzyLR7; 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 a23si1314162edj.201.2019.09.27.02.37.19; Fri, 27 Sep 2019 02:37:20 -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=uoWzyLR7; 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 S1727135AbfI0JhT (ORCPT + 26 others); Fri, 27 Sep 2019 05:37:19 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:33055 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726423AbfI0JhC (ORCPT ); Fri, 27 Sep 2019 05:37:02 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id x8R9a5uh001372; Fri, 27 Sep 2019 18:36:13 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x8R9a5uh001372 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1569576973; bh=8Z1yZcx7lt82yK82hKDWaRuslS2lyBCS5/OQGziEcvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uoWzyLR7WPO97Yw+7t2zQ6Bn+mWJ4wLoAivcRWkOp71OIQ4a7nclOHfnfEZcMfLq2 gsfADMWqfz6bC+Epby+QMFO9UMLLAPmaOoQiOYb4pN843ldf5QrkWkPYAZ6B4KFLrT EHjvPttNsdP+0/CAKOdTvY3Xf4STusL1CBVtA2fcq1OK8Cg9yfWAdPAWeW/HbjcZ5n OtN0uNov4PROdyIluCGO1s+S4YLwJN+stI+hpC18A8xDmwkxfwzvczxj5ajXXyzHRu AYi7QmobHJr+rFXav0f1osZ59d0aD+l8SF0fF46Q3Cp3f7aXef+eMDSH6iHp7z5uGT ekA/bWw/6OMew== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Jessica Yu Cc: Matthias Maennich , Greg Kroah-Hartman , Joel Fernandes , Martijn Coenen , Will Deacon , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 7/7] nsdeps: make generated patches independent of locale Date: Fri, 27 Sep 2019 18:36:03 +0900 Message-Id: <20190927093603.9140-8-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190927093603.9140-1-yamada.masahiro@socionext.com> References: <20190927093603.9140-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org scripts/nsdeps automatically generates a patch to add MODULE_IMPORT_NS tags, and what is nicer, it sorts the lines alphabetically with the "sort" command. However, the output from the "sort" command depends on locale. Especially when namespaces contain underscores, the result is different depending on the locale. For example, I got this: $ { echo usbcommon; echo usb_common; } | LANG=en_US.UTF-8 sort usbcommon usb_common $ { echo usbcommon; echo usb_common; } | LANG=C sort usb_common usbcommon So, this means people might potentially send different patches. This kind of issue was reported in the past, for example, commit f55f2328bb28 ("kbuild: make sorting initramfs contents independent of locale"). Adding "LANG=C" is a conventional way of fixing when a deterministic result is desirable. Signed-off-by: Masahiro Yamada --- scripts/nsdeps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Matthias Maennich diff --git a/scripts/nsdeps b/scripts/nsdeps index 964b7fb8c546..3754dac13b31 100644 --- a/scripts/nsdeps +++ b/scripts/nsdeps @@ -41,7 +41,7 @@ generate_deps() { for source_file in $mod_source_files; do sed '/MODULE_IMPORT_NS/Q' $source_file > ${source_file}.tmp offset=$(wc -l ${source_file}.tmp | awk '{print $1;}') - cat $source_file | grep MODULE_IMPORT_NS | sort -u >> ${source_file}.tmp + cat $source_file | grep MODULE_IMPORT_NS | LANG=C sort -u >> ${source_file}.tmp tail -n +$((offset +1)) ${source_file} | grep -v MODULE_IMPORT_NS >> ${source_file}.tmp if ! diff -q ${source_file} ${source_file}.tmp; then mv ${source_file}.tmp ${source_file}