Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2111161ybe; Tue, 3 Sep 2019 08:09:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsdjrMISBsRrtAsTm45ScnGSrW246/+dxHsTqSkMGsrEGx5gI7tSlp5+b96FGXCOM6YqCX X-Received: by 2002:a17:90a:c8a:: with SMTP id v10mr545262pja.6.1567523343530; Tue, 03 Sep 2019 08:09:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567523343; cv=none; d=google.com; s=arc-20160816; b=j9zv1EAaK746MrWBhZP4KgTJP7S97Hb24BjCyw8b6BKx0LTiyPii1n3rblcc9NjsaN 9rPa9dLKEKuUnC0+byo8Oo4xSOCJZYZRNmYc6oeJpJCh/swpMDl19z6CiXxL4d+sLC2V zVYqn9PkUCiBkEOEFSmz7iwo++8IToG2YEmuGO6o2j8CHdHXsQqU8SARXguExMRFAUM9 u6JkTxVQeZ/3xD470QAqCPG5T8855KS2DO+ODdmWVqie146CU7raMMl/Ock91xSSHIG8 79VvH4YyMzq+zWc2XcDYRsgi9iUdxtvyN2NN22cOfESUxG2FziRt+vlzdAuMlARnAxEV OWjQ== 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=XfkuPAzUg0cWTsSII8UxfvUGODgh66Dt0PdffmfP8ds=; b=jsjKYfs8/bx88PqjogGA2/GT6juh5HQrrbNIYKb63yywrwADVqKK+gAVePC9HFhbid PmCQP3GDM7chirPz4WRZMu2D/mKC74rvLSI+L9D8nQEStFNrPIDPT6iUkD2oqqCN7efH KYLYQQXdNzCatCEiY9+mCRHk4hzdn/AXne3Sl0sEk/HdepCnDlZ12dHiclHXANkVtI10 HrwLqrbivMH+QeKgs1h7QcLh7l28u/WysUuWiMpPbdi7PeVcWRC8qQ9BFTTix0AjZgDv +im7gD3aBxAh9rko7ID1Qlmkv1otgop5mtiwXvhV07CbR9udExGyPvm7ngxvcFYPZp+R d8lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=BYUxI3Mr; 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 14si7374263pfj.37.2019.09.03.08.08.34; Tue, 03 Sep 2019 08:09:03 -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=BYUxI3Mr; 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 S1729696AbfICPH2 (ORCPT + 99 others); Tue, 3 Sep 2019 11:07:28 -0400 Received: from mail-vk1-f201.google.com ([209.85.221.201]:38714 "EHLO mail-vk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729661AbfICPH1 (ORCPT ); Tue, 3 Sep 2019 11:07:27 -0400 Received: by mail-vk1-f201.google.com with SMTP id d21so7926603vkf.5 for ; Tue, 03 Sep 2019 08:07:27 -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=XfkuPAzUg0cWTsSII8UxfvUGODgh66Dt0PdffmfP8ds=; b=BYUxI3MrD4U+BDkDqOah6HY4Bw3pPfx8gK6OvtG3TXQTUxrmLgeaUM0pE8m3+shX6r a/m7v+yD6KHnNo+2ozvu18HPRGjOHvfslAqkS5IswlmTxW49zalq4r2NEg5CdB8oQkZJ pAapdfiGvhDtqiSUAMffWLVrPJkbibNXNTmF7aR7IOEMKWP7svSLCs82N06Qiv1VX1m/ 5vbEakyc4zD9nCo5vutlPMx63M7oy2fEEfWiVlMm+JhP/hBcAkGEKvPBGRSCkvuGoziM 55t1VRH8ly44VKnD8mGx4rlnGVDfwwQI67M2aRWLr9QioEbqXOZ2lppuU09AhqkaX4S+ GWeg== 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=XfkuPAzUg0cWTsSII8UxfvUGODgh66Dt0PdffmfP8ds=; b=qprRqIt3JM2zmQmLfBqDSMdr63gYFQaLyYkPRQWzuzJ402cIbwhc1zhvEcAPUtMG5m vcoaXwBmrIt38A7ey9Rf/N7qY+BcxfjK8RzgAZ16MppCJFQPvdiDSbY6dzt86A/9DK5y ou4E29TsBSk4D6ZW8fLPU1SmIOyivyIFla//8i453Ap8D596Et7WaWkdVJMlS9jqazlp mx9vb+PJib6kXy1jr/ZYmZPfUVv/fewj98ZM/WZ4bOWcS2YKXNrnp5lIhEAAHxmcruPg n19bqN8wVgUfp3zaFFT4WWfRSJLB+1Ha2ZKyjwrs5tvc6qxf7iEhScB//iVqy5W2YDlf cwIg== X-Gm-Message-State: APjAAAUfBcsZdvArKyR1IDJfXImQC84Lyrpn1Ju74gWqSELJ3JsRcYQO NiVjAcqIeYqHqFwX7j/t8W6KzwkuO3ALK0vlMsXryJRGjlAfAlqFy1WJ6FrIQOjrK54P9Memiox BzGTTQeSR9AgK/2TdGq+fD5aOEoT8Iy1w/xq4E+sEuF18UCp/LUtY5WSdio490vU+6xqJElMpL9 E= X-Received: by 2002:a67:fb90:: with SMTP id n16mr19342370vsr.7.1567523246431; Tue, 03 Sep 2019 08:07:26 -0700 (PDT) Date: Tue, 3 Sep 2019 16:06:27 +0100 In-Reply-To: <20190903150638.242049-1-maennich@google.com> Message-Id: <20190903150638.242049-2-maennich@google.com> Mime-Version: 1.0 References: <20180716122125.175792-1-maco@android.com> <20190903150638.242049-1-maennich@google.com> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog Subject: [PATCH v4 01/12] module: support reading multiple values per modinfo tag From: Matthias Maennich To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, maennich@google.com, arnd@arndb.de, gregkh@linuxfoundation.org, jeyu@kernel.org, joel@joelfernandes.org, lucas.de.marchi@gmail.com, maco@android.com, sspatil@google.com, will@kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, linux-modules@vger.kernel.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-watchdog@vger.kernel.org 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 Reviewed-by: Greg Kroah-Hartman 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 9ee93421269c..3ee507c0a92f 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.187.g17f5b7556c-goog