From patchwork Thu Oct 3 07:58:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 175058 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1855245ill; Thu, 3 Oct 2019 00:59:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/eqS85SXlu+RSSKUYHBY9iRW/Y87m3ZHhikKnMyyXp9JKpyCOYgT9dfxjMDXcqoVSIR5Z X-Received: by 2002:a50:d51b:: with SMTP id u27mr8062340edi.249.1570089573903; Thu, 03 Oct 2019 00:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570089573; cv=none; d=google.com; s=arc-20160816; b=JGp+WrneeAuz7BWHvrmKa0emlB6kGh14ypyfzPVxLyfCIkuyPyQRvdwAB8rVn+3URJ UJmDYRr29PIN4Cq5GgN3QWLzvIBE5qTFcLQati8n52UKapVgeMGFd//0XBIVqGMGACXN rslyg+EC/+3Np6vRKoJC5txOhObALENZQdInzmUjqfO7WGhvbD+4OHv5/kg2xLqtMXgF 7HLEM9JN2fDXSVju3Um9yDNEiXfdYqb23JRXezF5FRlepJzjM7bcKeoIrU3brudfc93a 9a5W2XLHC0TbnuLofGIn81WEjBSzQM0tpzp98lVECbH9mM1ly9xjdqmFT8BgaPGh8lrX sBDg== 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=Ne5AozHKQBV/eN5L7U5RW8n+qn4kZ0PpPgZtYlmXwqs=; b=X5TTqGWfl0YuTvVTTbBO8Ow/eKJrQh6UFeN/Hx3YPOCyGIZKCNjFEydUkc1+KoZY5s 3xaAGoi/VSr/Z//QmRngUK6vxUmD1hSR1COEcri7DiNJIMMUtqYZaOTWeh/3gTkBQyax LTo7mIo4tSD+6B0zbFd3ItIpPK2KbCJXWDyqXuHKB+FdadUsJVEC1IPapoAh72zdSaNS sXQJVe3g62sXOKvLdwuIbazns2sydseXr//sXymp+YAGw8WFvvZeViHJ3M0WgthfUTAf fj+h/R4ssecICEzjjHKu7NfWs+MkgASPCG6b4CWSoYJ4wa+ePRTMai0qblLRHK+V/0G7 p6Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=SzfFwVTm; 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 o17si790856ejm.261.2019.10.03.00.59.33; Thu, 03 Oct 2019 00:59:33 -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=SzfFwVTm; 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 S1728729AbfJCH7a (ORCPT + 27 others); Thu, 3 Oct 2019 03:59:30 -0400 Received: from conuserg-11.nifty.com ([210.131.2.78]:59227 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726523AbfJCH7R (ORCPT ); Thu, 3 Oct 2019 03:59:17 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id x937wTkT007720; Thu, 3 Oct 2019 16:58:30 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com x937wTkT007720 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1570089510; bh=Ne5AozHKQBV/eN5L7U5RW8n+qn4kZ0PpPgZtYlmXwqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SzfFwVTmehv9gNGgR1TE+D93JWeJI0/ZGZ0C2AeH6e2XkAyF3tUnI1aDCk3wVcaCA EOcO4fYSej8XhnLNgrg90VBGe7z/Zv+ki/Wia+TcRSOgKSpCl6oG+iuNPpzeWggyTk b8EBuTJEE+jY/i3bKdZnET9RDYhA9zDM3o/bjepQsYJScchVY3owxI2mB87R+8qDPx 0t+Y9LXZdnzB7oxd9traZRR4sqyWx3vblOAAyk5OffgU6tjhWFrocsPE/LSJGhdnwm zF2HLmhZHBZW+aIdcALgxtBxl4cXrPhurmfcvHvm6R7GkdZwQxWVSX4E8KmuS6mpi/ 12l3jabmBktsQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Jessica Yu Cc: Matthias Maennich , Greg Kroah-Hartman , Shaun Ruffell , linux-kbuild@vger.kernel.org, Masahiro Yamada , Martijn Coenen , Michal Marek , Will Deacon , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/6] module: swap the order of symbol.namespace Date: Thu, 3 Oct 2019 16:58:21 +0900 Message-Id: <20191003075826.7478-2-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191003075826.7478-1-yamada.masahiro@socionext.com> References: <20191003075826.7478-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, you can free it with complicated code like this: free(sym->namespace - strlen(sym->name) - 1); It complicates memory free. To fix it elegantly, 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 Reviewed-by: Matthias Maennich --- Changes in v2: None include/linux/export.h | 4 ++-- scripts/mod/modpost.c | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) -- 2.17.1 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 442d5e2ad688..2c644086c412 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 Thu Oct 3 07:58:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 175056 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1855127ill; Thu, 3 Oct 2019 00:59:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqyld23dMuETAkqRviwcb4/joMPnGrY+WYpcpTbIRgFw4QW/cpxUWQ68RV4ITI4wHerGVc6N X-Received: by 2002:a17:907:205b:: with SMTP id pg27mr6545864ejb.135.1570089565361; Thu, 03 Oct 2019 00:59:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570089565; cv=none; d=google.com; s=arc-20160816; b=mUm/x9fLu31v2nmVfknJsTVvUGbp6IqhfoczhkEhlpDSH2uDnMhq0UggKwqanhLFw7 ABtHJ5VpJ44V+fa8OU4jAN1y+bq7AMIAfCzYOATqeVD8567NFATAoXheLvl5TVEJyhwA lzTBRlz/ubeO5O6ObUI/TlimLvTgp7+1thNdCfnU2JO1+TwdnxQsG22AJEwL48lsqih9 gTB9XJglOgNv6wwPaVEAPfV55NitkkTkzQQUtGsaU2PzZP9u30lkIB/nNIOysbyciDxL /JW8Fe1UE9VeH69gBuklIxQl6FzQ/wfPyWQhiFJjl+gnskDVJvoZMnETib7hkfOe/TyF gOzg== 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=2WkGrobjA1U1dn5ejZfaJgOsN0toyJldJb1G+H1ogM0=; b=R0WWIemxEQOKo36Io/6aUofkUjhGychavssMo1/ZGJXz+kzdEYw9qWU/3/pEthq94Q 7/W4J3TXr9TASwlp4p+30MqpDLCTAmFhyTFsHVbyhRK3Hb4vt603MGStofcXzUNFWpIk v3sq/hiKErkleG2wqcjNCHE6kwL5coLPP2J5GKcQJDxNRLHi/dilGkk4E0RN/BagR3tK aalW79h9rTfiab7VN6oa7x4yM1HIIA9G2LW6JmEHX2Yz8+EJEd9Pm+lwukS12k0b03Wi lZ+t6B8TWh1/nV82/d3h0iwixTSneOjVXbPkxTz3wZVCAdffhO88iimVivFp6iVFtyHL mizQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=l10tqUHY; 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 j21si920670edr.376.2019.10.03.00.59.25; Thu, 03 Oct 2019 00:59: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=l10tqUHY; 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 S1728570AbfJCH7X (ORCPT + 27 others); Thu, 3 Oct 2019 03:59:23 -0400 Received: from conuserg-11.nifty.com ([210.131.2.78]:59228 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728119AbfJCH7R (ORCPT ); Thu, 3 Oct 2019 03:59:17 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id x937wTkU007720; Thu, 3 Oct 2019 16:58:31 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com x937wTkU007720 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1570089511; bh=2WkGrobjA1U1dn5ejZfaJgOsN0toyJldJb1G+H1ogM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l10tqUHYyIrYc2z8CdUvQAEG+svgnd1dFQ0zv1xeEnjonanZ1TvjAwwVrxl/n3Sw8 5+fGNijQgu7Pu2eIW6tq52e7E+qs1dAZRxWNaYZD6AsYhwL0PB0d/tpXQ3BchFJhMI Snrpr7INlZSTiiBZQZi8JjM0620QSqpsYUi7d7SslcERl5MALc7JwOJ0JDDhZZsx0O 2Uz4uk6GB5SgOAjtEPXxehTKa4uBxMHf52qM2i04OfxMpBjpdzKD8CsG0YeDsum48X UpKnEWtSmAY+nxiZyeLBaGGAgqcVEYs31SRi9CfhBIRY1NzRtq959EQty+n7HP/ZOv 10uEwBTDMyFpQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Jessica Yu Cc: Matthias Maennich , Greg Kroah-Hartman , Shaun Ruffell , linux-kbuild@vger.kernel.org, Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] modpost: fix broken sym->namespace for external module builds Date: Thu, 3 Oct 2019 16:58:22 +0900 Message-Id: <20191003075826.7478-3-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191003075826.7478-1-yamada.masahiro@socionext.com> References: <20191003075826.7478-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() 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], sym_add_exported() calls strdup() for s->namespace. The namespace from sym_extract_namespace() must be freed to avoid memory leak. For [2], I changed the if-conditional in check_exports(). This commit also fixes sym_add_exported() to set s->namespace correctly when the symbol is preloaded. Signed-off-by: Masahiro Yamada Reviewed-by: Matthias Maennich --- Changes in v2: - Change the approach to deal with ->preloaded scripts/mod/modpost.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) -- 2.17.1 Reviewed-by: Shaun Ruffell Tested-by: Shaun Ruffell diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 2c644086c412..936d3ad23c83 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -166,7 +166,7 @@ struct symbol { struct module *module; unsigned int crc; int crc_valid; - const char *namespace; + char *namespace; unsigned int weak:1; unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */ unsigned int kernel:1; /* 1 if symbol is from kernel @@ -348,7 +348,7 @@ static enum export export_from_sec(struct elf_info *elf, unsigned int sec) return export_unknown; } -static const char *sym_extract_namespace(const char **symname) +static char *sym_extract_namespace(const char **symname) { char *namespace = NULL; char *ns_separator; @@ -373,7 +373,6 @@ static struct symbol *sym_add_exported(const char *name, const char *namespace, if (!s) { s = new_symbol(name, mod, export); - s->namespace = namespace; } else { if (!s->preloaded) { warn("%s: '%s' exported twice. Previous export was in %s%s\n", @@ -384,6 +383,8 @@ static struct symbol *sym_add_exported(const char *name, const char *namespace, s->module = mod; } } + free(s->namespace); + s->namespace = namespace ? strdup(namespace) : NULL; s->preloaded = 0; s->vmlinux = is_vmlinux(mod->name); s->kernel = 0; @@ -670,7 +671,8 @@ static void handle_modversions(struct module *mod, struct elf_info *info, unsigned int crc; enum export export; bool is_crc = false; - const char *name, *namespace; + const char *name; + char *namespace; if ((!is_vmlinux(mod->name) || mod->is_dot_o) && strstarts(symname, "__ksymtab")) @@ -745,6 +747,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, name = symname + strlen("__ksymtab_"); namespace = sym_extract_namespace(&name); sym_add_exported(name, namespace, mod, export); + free(namespace); } if (strcmp(symname, "init_module") == 0) mod->has_init = 1; @@ -2193,7 +2196,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); From patchwork Thu Oct 3 07:58:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 175057 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1855224ill; Thu, 3 Oct 2019 00:59:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNRJniRMe3iKwowGM/s9hKxNTZ7UpShqHu1E7URXxuOAxAw+OFLsz4P50iKVwjmsKialoS X-Received: by 2002:a50:eb44:: with SMTP id z4mr7905488edp.207.1570089572430; Thu, 03 Oct 2019 00:59:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570089572; cv=none; d=google.com; s=arc-20160816; b=m9dD98gWDhb3DjP4FMIyK9577zsyVoJvpADcc0Wki7HPsoILIRmAoowsN4cWY3zykU ZM+96d9d6aHfB+dSkpDbUN+gE7Zzp2M2Rq0sTCf8pJOGDq0EaNmrwz0Ot3jZ2y8VPuJK TNOYj24HsYeqxQn3I1bo/HZ5Fzd5KLdal6W5OdJSn8jD+8ItWEiOyEM5ZmSUyUjg3Mxd +Vni0S/m45o048lZUqJJnk8NH8jKr6GMtG7YRnOfrEDh/kjbWW3wG2GTpG6jorN1DqKe 2RmrK2hkpeqm5jQyXdct0bQbnrDk1mOsEsU0/6xtCNRh5hJ7pZXPXsK1CVp5MwEK6CxN jeDQ== 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=120bNVWb/cAQsirkPrw5wuUPD0J6O7LG/eInWnc0GXM=; b=wDRgVDTMBm9QM3Rf9JQnJXDby1a5NbdUchqi53oVYD/tmCv/qUogiaTBurGarxPKUH ZZnBRI/QfExP4TJ9qEMj5hBVlMiPcKut81jiBKeBYnguMxJJX75HVJdftlBnYA9VoWz0 +Rlw9PZjusEuP9sEuqNoLwdlZIc/H3R6UwMpNTsoBGyYmVxY6duTq6I6sHyW501FZG7m pETlxQTd2XsbpgCKmfZ/WZik3igRNjAr1dh/ijxF2icCUImuA6Vpco0/xxnKnbH6JzCB FvsvuEhowz5XI9nGXVYtUF/4IYU5ot3n6Hmr48cYz5rk3meiCccljle9aIu7HNFTN/zp WlOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=sOufCbPQ; 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 o17si790856ejm.261.2019.10.03.00.59.32; Thu, 03 Oct 2019 00:59:32 -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=sOufCbPQ; 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 S1728682AbfJCH71 (ORCPT + 27 others); Thu, 3 Oct 2019 03:59:27 -0400 Received: from conuserg-11.nifty.com ([210.131.2.78]:59223 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728061AbfJCH7R (ORCPT ); Thu, 3 Oct 2019 03:59:17 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id x937wTkV007720; Thu, 3 Oct 2019 16:58:32 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com x937wTkV007720 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1570089512; bh=120bNVWb/cAQsirkPrw5wuUPD0J6O7LG/eInWnc0GXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sOufCbPQwtH53jrQ4+SKNS8BTK/E+XQVV/fnQjxwjvk5EUSt/oSWZrt5XQgHu04Yz +dXnPmpBjOZeJgRpfqmsR4OdoiEUmMIzSq/kOO5SoiB1EdqX2XKB3WZxUMamBpaN9v xElB92NZS0pxrpkwlK0EEvIjRMlfaVrXOmATpd+ubKqJUVvc7QEp57uLYEJxzkOqt6 joTmKXLL6IL42K5T511rqnUtMhHiF/HUw/py6SqPqF6uLBzopMEzEEvq4EeKgrHLLn Lf6+lwHVFdpajOGOSHJmWcH+F6yYt5HZK41Ij7ZpZlJJaBSe7jMTKCXvBd9QjsNGU9 N9ehQ6o3sz3FA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Jessica Yu Cc: Matthias Maennich , Greg Kroah-Hartman , Shaun Ruffell , linux-kbuild@vger.kernel.org, Masahiro Yamada , Martijn Coenen , Will Deacon , linux-kernel@vger.kernel.org Subject: [PATCH v2 3/6] module: rename __kstrtab_ns_* to __kstrtabns_* to avoid symbol conflict Date: Thu, 3 Oct 2019 16:58:23 +0900 Message-Id: <20191003075826.7478-4-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191003075826.7478-1-yamada.masahiro@socionext.com> References: <20191003075826.7478-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 starting 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 duplicated "__kstrtab_ns_capable". To ensure the uniqueness, rename "__kstrtab_ns_*" to "__kstrtabns_*". Signed-off-by: Masahiro Yamada Reviewed-by: Matthias Maennich --- Changes in v2: None include/linux/export.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.1 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 Thu Oct 3 07:58:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 175059 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1855288ill; Thu, 3 Oct 2019 00:59:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtf9bkFFOjviLQkYY4DLSFooVkZOvB+QdvmqsbJuj908SpcpDweZKnYMz/y+8SxCmkCZX9 X-Received: by 2002:a17:907:388:: with SMTP id ss8mr6544490ejb.26.1570089577151; Thu, 03 Oct 2019 00:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570089577; cv=none; d=google.com; s=arc-20160816; b=okbRFsY/YyXjlgGLRI9sSkFjPE3iuFrJPlwpSylgbZGwGHX4YuT64YtGovoL3A4LIW RJVEvC9WfUvHHgUUH8ffDmaDLGCNWCkG58XD9HMl/eHjx7qc17gaeDyY7onBrf11XWQB t2kucUk7GK8M/+zaqf8FJHLlD0Lm/v0wSzBVNgpdz2qE37tiB0naZeVwtYfsZlUTjjgI Uip5c29UerRAs/vCfdK7X1FmRM15ImCMjyyFy09lqzPQ4iSKNtPNlzmftjwq8/gwJKa9 VWtrFa5CKXU0x6PbeEtVYrnTQ1XNiW8ktakIuw/a2ODAv3/+0/3z2IW+Yom7Nc1aup1M 5SBA== 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=+2++qHqEb0DqRRYFRDlh3635ELQ/E4mk9ABraUBN90M=; b=zmG+rkWNmVsdp6qK2O50xKpqQ2meKxUs70NhQiSVx0WSXG+G9DRDSpAET2swtq2t+g WVTnkrD85k+1UYOBkGS4o1eEjOI+LDkkJ4ovNQ2/buqBMuXb9Q49hVPnlT+GxEHV4jNd HS5bHVFd1kVheUaQn84Rv11f/WCOSqbjD8XwLdMmJtzcTUcpO8vchnHDjGIT2TdP69aF 0LxJ0apr6lYwC82Z9wKpwW6HArTwx6YhyBwVJYQyyfFkrFxpH++dQlj7ymAnoXRbuOV8 PHc0xIHeYWz/CH6NxJNhWSF41Y7QkmdJ9/yNhTcAJD3FmI4JD8K0uH+YPSqdR7ndzrj0 AUog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=xzpHUKIW; 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 o17si790856ejm.261.2019.10.03.00.59.36; Thu, 03 Oct 2019 00:59:37 -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=xzpHUKIW; 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 S1728763AbfJCH7f (ORCPT + 27 others); Thu, 3 Oct 2019 03:59:35 -0400 Received: from conuserg-11.nifty.com ([210.131.2.78]:59224 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727452AbfJCH7Q (ORCPT ); Thu, 3 Oct 2019 03:59:16 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id x937wTkW007720; Thu, 3 Oct 2019 16:58:32 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com x937wTkW007720 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1570089513; bh=+2++qHqEb0DqRRYFRDlh3635ELQ/E4mk9ABraUBN90M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xzpHUKIW1Rdb+BGeVOTE9aitZme/b4Cfxbnx0ukpryA73Q4laaIZVJGwNI8EgBL11 m+uKhaOQFaL8e1PwVsafamEH4O56h27AmtxkNtTG6KI0ugDRwCQ7rSRUgK2aQaka0l M/Ph7mbYklGJwrBRwxK4BavnKcTVFXoPN3q6/Dbc3raiAeBUwo68O0yC92D6Mr/lq2 psMYe10UTW5BIQLpX3JB4Zr2JUg5sFAVaP1le7jQz8Cbn9I517yaTTo44qZOfrqqNA JLYFfDsJ/ak3lsxsO5PD+KT3jvexpQIMH8cdcXjE8jyCtEoT5j5IbFnHbJeSXbaDi6 j9JPu7ZbVh3ZA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Jessica Yu Cc: Matthias Maennich , Greg Kroah-Hartman , Shaun Ruffell , linux-kbuild@vger.kernel.org, Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH v2 4/6] kbuild: fix build error of 'make nsdeps' in clean tree Date: Thu, 3 Oct 2019 16:58:24 +0900 Message-Id: <20191003075826.7478-5-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191003075826.7478-1-yamada.masahiro@socionext.com> References: <20191003075826.7478-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 Reviewed-by: Matthias Maennich --- Changes in v2: None Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/Makefile b/Makefile index 6f54f2f95743..d97f38ad5d9f 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 Thu Oct 3 07:58:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 175053 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1855036ill; Thu, 3 Oct 2019 00:59:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOBmSeWCZQo2BHNf3yvADpdrowBhIE/pF5uT6kPvZmv4a9SXLDTDgR4ue3DcDieQLADh3U X-Received: by 2002:a50:fc0c:: with SMTP id i12mr8155493edr.82.1570089557926; Thu, 03 Oct 2019 00:59:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570089557; cv=none; d=google.com; s=arc-20160816; b=ri/YJ5A3K1LH61KYGu3P+oKxjhQTcy7P6SQA06zlb3Toi5m5JLd10IKohCePSc2ZrK W+fKd2Kf+AjM9JFfKuf7Qcb82nHzX5glXftIZX3n1qmgO2W+tiCKUppdqORsdO3ebS1u MdZVEriUkgTwZLaysIn3N9g+8Oo+T7C82KCzNvCvLMqlr5GV07t4THHyW9fceTwOKC4e xPr79Bya1Bi2LBWBBsK1KxJjgLpDbzB8VSrR+3RUZGCfycgzRMujPfcMIej0pIwwTbAr Bsh4q2ArpjIf7LDS4T1OKwWDSqaIOc6fDIiL0S0Bl6USFNmknY8+qekvyr1rtzwKqZeP CWVw== 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=wNrxE/R+8BhtQOYFz0ZDJvyWIepl6P4okkyZb4m/C9k=; b=TtpCMp4TIlFbrgKhKMSUCJvBD0nWHoPl0Oldi7Nt9H08Y9Frizu/4RypO6gK3kP7ir iI8Yp1QAUh2FwvPbCK5dvcJhM9zPD2L6HPalOwe1D1Hf6Zae0gIudQOoWLc4SKneNsLj COi9aNdfkl7dvrFNdoTUr2xUJ9e1r7q2phy2cHudYWeNKx1b/F/955bJeVEET2j6mcZE ei9/zw+VOfuPyxZG8DWSRogFU/mIekczi6yEQtq4IBYD3ZFWUe2EIT4pR3YL1k02F4NB Me4wsfF3ldI6ODoV2XwBJhoRL2lj0Szt0txrmjGoLK/scsLF/BJBLY+BtH6tQdrcdeBG +gSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=jy193E1E; 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 b9si786588eju.269.2019.10.03.00.59.17; Thu, 03 Oct 2019 00:59: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=jy193E1E; 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 S1728279AbfJCH7Q (ORCPT + 27 others); Thu, 3 Oct 2019 03:59:16 -0400 Received: from conuserg-11.nifty.com ([210.131.2.78]:59231 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728102AbfJCH7Q (ORCPT ); Thu, 3 Oct 2019 03:59:16 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id x937wTkX007720; Thu, 3 Oct 2019 16:58:33 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com x937wTkX007720 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1570089514; bh=wNrxE/R+8BhtQOYFz0ZDJvyWIepl6P4okkyZb4m/C9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jy193E1EhUdZpsYspNUk778eRK2ZGfe0ME/1rRNgBRezcpO6k88unUAKpy7f1GY7i GofB+lD9HSnLmCQqPbH+DSTWMl6v/f/p40yUxZCy9JcTpvQYUaojPr79q+0mzpnFlH UTzuaUtsmoiNLXt3SdW39VfHe5s4EbG+XxYALWvSsj07/GIuxq9/mSqaqtkCK96JRX 0M2qJH0kQyi46sU7ckLgvfjN482vKdWx6z/cDl9CnshicUug6PIlz/vt/f9g0uroyd d5OT0nZXC3nyXygQZPvhYRdUAvT3EAV/oRODmR0+Rr2vn9wHwe0ugZHgz3coWA0J0x lE4hmOcVz6PqA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Jessica Yu Cc: Matthias Maennich , Greg Kroah-Hartman , Shaun Ruffell , linux-kbuild@vger.kernel.org, Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 5/6] nsdeps: fix hashbang of scripts/nsdeps Date: Thu, 3 Oct 2019 16:58:25 +0900 Message-Id: <20191003075826.7478-6-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191003075826.7478-1-yamada.masahiro@socionext.com> References: <20191003075826.7478-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 Reviewed-by: Matthias Maennich --- Changes in v2: None scripts/nsdeps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 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 Thu Oct 3 07:58:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 175054 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1855056ill; Thu, 3 Oct 2019 00:59:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxYaXp0DD/q93/NvobS7Q3As2XQ/0EC84BV60upcIRyF60lNyrDYSP25h1VX3zjKvB1rQb X-Received: by 2002:aa7:dd8e:: with SMTP id g14mr8036124edv.233.1570089559123; Thu, 03 Oct 2019 00:59:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570089559; cv=none; d=google.com; s=arc-20160816; b=kaDNKkiZ3RNRBRXjs00QOSYj3GXvYh4vsMOBOrHwBonEll8oyr8t947hQkSvmGm6hW mesVsAC3uXHuDW8r9tk81a0pEVwZLy8/lxIWgQaw9q5hpMrPDUj5/Y5ZrZQaWdaJq5ni /zM+PvVrYlCxrAztEaaLMW57YQv6w0mn/xs0XIlP5Hxvf8KLFwV1SnPYchnuoW6HWgCw JtNV4gogNfTasJaGuYiCFO5ylsounUJOnN/EUpvt69X4O42mjtsWfkAxq0Vtw1nYYczO PFP/TKnNvNp7aRnTlw8vZ3IVLDsKzdrYqL1L7Kc426raaauRGetFtfDw/vquMrEGfshU WVdQ== 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=59eE/rGcp2OFwwXp+ofMwhXaVSnXW6C8LJ8vAqEhBT8=; b=UNse/iiVfvVQ5bLKfKVUYGlClV4NN3K7M/cUB5nwKMDIx7pX9HX0PvWX5qe0Lhz1P0 AGpSTQQjfM2cYfuZ/Gu0pFIZNoIkfvwXqju5kmhFknLKX8tWqHDNMh62AXGGqT89CFzu k07LCUHk78yOmnxd+k8eyTqwMNTm4630gb3JOYukEK0HVmVUZzaTZqeMvGdfUvCzmq+6 K6x2Ur7qyc6sE/qiG6U5EeTHaLN+Qbe6VmkLCwPHX15Tpu4ZzsfD3IdEn7+nphIc/yVi 4WEyU3w5YZPeQbt6LEKUPYbT+Up/dGqWHbciMF2Log3/YjRS8geEhkf8sSskTZdEp4UX hqgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=JkW9JFD3; 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 b9si786588eju.269.2019.10.03.00.59.18; Thu, 03 Oct 2019 00:59:19 -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=JkW9JFD3; 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 S1728496AbfJCH7S (ORCPT + 27 others); Thu, 3 Oct 2019 03:59:18 -0400 Received: from conuserg-11.nifty.com ([210.131.2.78]:59222 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728178AbfJCH7R (ORCPT ); Thu, 3 Oct 2019 03:59:17 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id x937wTkY007720; Thu, 3 Oct 2019 16:58:34 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com x937wTkY007720 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1570089514; bh=59eE/rGcp2OFwwXp+ofMwhXaVSnXW6C8LJ8vAqEhBT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JkW9JFD3WiK28/HG0qiHqAjyVx6xAYXVsr8kJZ1Brp9fIgb20YDB1nxm4XHsG7CzU H9I9whiVaS6vOFtE3y28YTYHxAPWBiyGtdvm6wjPNRr0ZwdZr5tWSsFRZMjZpSXNq9 UJWoUtH+w0F8ip47kjVGCQHmeVk5mn85mbal0ToUwgv8fuwUhF/OldGknyTOC3IH+p 91LewO4WtqsNVD+w7P5Ps6qkXtnofeJ1q7QSJKU2SmhpdL6/7tJwN1Cg9TUX2ovVRH +i5SZARSaLDGDXJo+PoTcI5eJJMUl3r7bP3+EXpCUXnXLUW3PLfByk0gmEt/5jxFtf /n5BF/hn6X18g== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Jessica Yu Cc: Matthias Maennich , Greg Kroah-Hartman , Shaun Ruffell , linux-kbuild@vger.kernel.org, Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 6/6] nsdeps: make generated patches independent of locale Date: Thu, 3 Oct 2019 16:58:26 +0900 Message-Id: <20191003075826.7478-7-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191003075826.7478-1-yamada.masahiro@socionext.com> References: <20191003075826.7478-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. For example, I got this: $ { echo usbstorage; echo usb_storage; } | LANG=en_US.UTF-8 sort usbstorage usb_storage $ { echo usbstorage; echo usb_storage; } | LANG=C sort usb_storage usbstorage 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. I added 'LANG=C' very close to the 'sort' command since changing locale affects the language of error messages etc. We should respect users' choice as much as possible. Signed-off-by: Masahiro Yamada Reviewed-by: Matthias Maennich --- Changes in v2: - Add more commit log about the locale impact scripts/nsdeps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 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}