Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1172051ybl; Tue, 13 Aug 2019 08:27:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxocyvJlI665S1EH6xC2gR4vnsUaCfQdtzhIjqr9QDJz6cUj4MSfDzFPQqW7upRmtchhKOd X-Received: by 2002:a17:902:6847:: with SMTP id f7mr37570389pln.311.1565710022205; Tue, 13 Aug 2019 08:27:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565710022; cv=none; d=google.com; s=arc-20160816; b=VbPC0sPCknpzISL+Nh0Fk5ilSuD/seGdaf84evQw1zbizffKJF0VbeNeE2XzaW0/tO TmqU6Uo5WIR65MGnNX30IhPR/Gm1YaP3dn8f49Hp1n9GRjhzgwWH+WN/NHwcoNzpmcjx oelZNcE8rqInUp78ScI2j23R5w3kPM0Ra3SRNBOt3ZbhcDeGidUzWUCzxJcPbcy1DooC CcIdwBmDJk+TUA2YVYZOrjiKF1R+aNuZau8W8isITiwfuo72ERUvAY37j/vLpaviZzqT rmhF7xq/DzgR4lM/qNjQ2a+shmIFp8PP7QaHVj0IbtPGzV6zXFz75ooYCE9zP9viSm7D SF0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=Ey51rOQs6pREeIh9cdmyj66W3XNY9zI3cHQpc2k+3HQ=; b=OL1UNwFPCXp/65yh/xg7C6BThkZOS7iojW06ihMJslE6u8FXQfo76QejVY1QxKq8Oh Y/trBhk/VBIcXDDBZ4qXXosybj5+EQ758vR1b5UQzOFypwg13BtYoy0tsj7dODKbet5y 6vqNSHp2nrVrb6AL5sO5y7poeYBZ2WYqRjkK7AwqY4iJaIiDCteOQj+8o/F1IpWZ9+83 rvck4zWpZr5b31Ya3og1B3s2B3uFGqF2DmqmxWVebnP3uiehf9mem6LcGAIB06os/GMX pbmzSc8A3cgQOtJDUPHssWW46c/M6JhjEE1N23W+mvQvH3g7cB9S+MuAruSaPRibRpbZ PmAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Kj2QCgHK; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s70si32628139pgc.53.2019.08.13.08.26.46; Tue, 13 Aug 2019 08:27:02 -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=@google.com header.s=20161025 header.b=Kj2QCgHK; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727806AbfHMMTL (ORCPT + 99 others); Tue, 13 Aug 2019 08:19:11 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:57312 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727654AbfHMMTJ (ORCPT ); Tue, 13 Aug 2019 08:19:09 -0400 Received: by mail-qk1-f202.google.com with SMTP id j81so95855293qke.23 for ; Tue, 13 Aug 2019 05:19:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Ey51rOQs6pREeIh9cdmyj66W3XNY9zI3cHQpc2k+3HQ=; b=Kj2QCgHK1EXGXCElMh+j+E+YRK/wfgittksUPJYKcCq2HTXcsAROuHGcD8lwzMPeKN FRuEY4ZJ4B5K6zrA1HwL334EfWDTWdX3NtetiJHeWa9GorOQdftb7ZFl6EKSx4u3xZc/ 7wihld+w2BBSts7l0IWFmsA8phk/UcL6zJVHc/saACvhutCrFbaf8mO23uze0QWnNBrq vYTou4ilb8mGMgPL02Xng92+rEko2PdVT7rfXODuJ6MfFN3kroS9fkNmsFz5YKN59B1J z/cX3txyE3JspEYroOPPq3rlFHs4ewel3KUPhHTQrUFBOOUrKm5bW9fgQpBKQKrxy7dA pBzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Ey51rOQs6pREeIh9cdmyj66W3XNY9zI3cHQpc2k+3HQ=; b=ETGLKz3UluC00wOseCzAWzQ3qXLZRKLRNKCh5+4OdTTpaxsVMK1XfXbPaDjynIQlVK 2JRyWRvvRpSAIOe5Dh+ZnoTYaWgWn6DQUmg1suKU5VFG+9eZ1mgXnQ2PukF7bOx1vkLW +eSJ2BOinAaAEK79wma6Q+NF/xaz6a1fUm1X+u2s2VZV0Idjzdj1GDs0p2bauQ6IkjJA 3NP4154XNNjaU7hyjS/8mJcmXJOLUh0noLDS1oN4cQj1lB7WUABTxbqTVJI91Ghoa/F3 3vY2K8viab7L8s+mVgM+rzJvJrBitMd2DQ/ln22ZpjeXEE+k+cCPNDuMfrpA7H5n/H1D khiA== X-Gm-Message-State: APjAAAUnlvAxeaDnUf85kZODS9Oyud6qR/YB5WDzVt15NqE1cMtH6E+R Zi8pvQEGEIEY3+y7ikIA1bVxF6AitwY/tjEhGAst2tMWgazIzvk7cG7CKor6REltrVg7wQUD52w hE7weWk9mV1Vm5V2dU1jhCbDGl7D23nsWoQtqzMAm+0iSvc28URnvkbLrXlVOvaGfvf7AznJN5Z 8= X-Received: by 2002:a37:6844:: with SMTP id d65mr33008934qkc.398.1565698748030; Tue, 13 Aug 2019 05:19:08 -0700 (PDT) Date: Tue, 13 Aug 2019 13:16:58 +0100 In-Reply-To: <20190813121733.52480-1-maennich@google.com> Message-Id: <20190813121733.52480-2-maennich@google.com> Mime-Version: 1.0 References: <20180716122125.175792-1-maco@android.com> <20190813121733.52480-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.rc1.153.gdeed80330f-goog Subject: [PATCH v2 01/10] module: support reading multiple values per modinfo tag From: Matthias Maennich To: linux-kernel@vger.kernel.org, maco@android.com Cc: kernel-team@android.com, maennich@google.com, arnd@arndb.de, geert@linux-m68k.org, gregkh@linuxfoundation.org, hpa@zytor.com, jeyu@kernel.org, joel@joelfernandes.org, kstewart@linuxfoundation.org, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-modules@vger.kernel.org, linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org, lucas.de.marchi@gmail.com, maco@google.com, michal.lkml@markovi.net, mingo@redhat.com, oneukum@suse.com, pombredanne@nexb.com, sam@ravnborg.org, sboyd@codeaurora.org, sspatil@google.com, stern@rowland.harvard.edu, tglx@linutronix.de, usb-storage@lists.one-eyed-alien.net, x86@kernel.org, yamada.masahiro@socionext.com 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 Similar to modpost's get_next_modinfo(), introduce get_next_modinfo() in kernel/module.c to acquire any further values associated with the same modinfo tag name. That is useful for any tags that have multiple occurrences (such as 'alias'), but is in particular introduced here as part of the symbol namespaces patch series to read the (potentially) multiple namespaces a module is importing. Reviewed-by: Joel Fernandes (Google) Reviewed-by: Martijn Coenen Signed-off-by: Matthias Maennich --- kernel/module.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 5933395af9a0..a23067907169 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2481,7 +2481,8 @@ static char *next_string(char *string, unsigned long *secsize) return string; } -static char *get_modinfo(struct load_info *info, const char *tag) +static char *get_next_modinfo(const struct load_info *info, const char *tag, + char *prev) { char *p; unsigned int taglen = strlen(tag); @@ -2492,13 +2493,25 @@ static char *get_modinfo(struct load_info *info, const char *tag) * get_modinfo() calls made before rewrite_section_headers() * must use sh_offset, as sh_addr isn't set! */ - for (p = (char *)info->hdr + infosec->sh_offset; p; p = next_string(p, &size)) { + char *modinfo = (char *)info->hdr + infosec->sh_offset; + + if (prev) { + size -= prev - modinfo; + modinfo = next_string(prev, &size); + } + + for (p = modinfo; p; p = next_string(p, &size)) { if (strncmp(p, tag, taglen) == 0 && p[taglen] == '=') return p + taglen + 1; } return NULL; } +static char *get_modinfo(const struct load_info *info, const char *tag) +{ + return get_next_modinfo(info, tag, NULL); +} + static void setup_modinfo(struct module *mod, struct load_info *info) { struct module_attribute *attr; -- 2.23.0.rc1.153.gdeed80330f-goog