lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 29 Nov 2017 18:36:04 -0800
From:   "Luis R. Rodriguez" <mcgrof@...nel.org>
To:     jeyu@...hat.com, rusty@...tcorp.com.au
Cc:     keescook@...omium.org, tixxdz@...il.com, mbenes@...e.cz,
        atomlin@...hat.com, pmladek@...e.com, hare@...e.com,
        james.l.morris@...cle.com, ebiederm@...ssion.com,
        davem@...emloft.net, akpm@...ux-foundation.org,
        torvalds@...ux-foundation.org, linux-kernel@...r.kernel.org,
        "Luis R. Rodriguez" <mcgrof@...nel.org>
Subject: [PATCH 2/3] module: add helper get_modinfo_idx()

get_modinfo() lets you look for at the modinfo section for
a value using a specific tag, this however is limited to
only give you the first tag found. In practice you can have
multiple entries using the same tag, one example are aliases

We have not had a need to support hunting for beyond the first
tag entry on the modinfo sectin of a module. For aliases we'll
need infrastructure to pick and choose which tag entry we want.

Add get_modinfo_idx() to enable us to pick and chooes *which*
tag entry we wish to get. get_modinfo() becomes then a wrapper
which uses get_modinfo_idx() to get the first entry.

Signed-off-by: Luis R. Rodriguez <mcgrof@...nel.org>
---
 kernel/module.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index bb595dc87651..6d5f02e86681 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2485,20 +2485,28 @@ static char *next_string(char *string, unsigned long *secsize)
 	return string;
 }
 
-static char *get_modinfo(struct load_info *info, const char *tag)
+static const char *get_modinfo_idx(struct load_info *info, const char *tag,
+				   unsigned int tag_idx)
 {
 	char *p;
 	unsigned int taglen = strlen(tag);
 	Elf_Shdr *infosec = &info->sechdrs[info->index.info];
 	unsigned long size = infosec->sh_size;
+	unsigned int num_tags = 0;
 
 	for (p = (char *)infosec->sh_addr; p; p = next_string(p, &size)) {
-		if (strncmp(p, tag, taglen) == 0 && p[taglen] == '=')
+		if (strncmp(p, tag, taglen) == 0 && p[taglen] == '=' &&
+		    num_tags++ == tag_idx)
 			return p + taglen + 1;
 	}
 	return NULL;
 }
 
+static const char *get_modinfo(struct load_info *info, const char *tag)
+{
+	return get_modinfo_idx(info, tag, 0);
+}
+
 static void setup_modinfo(struct module *mod, struct load_info *info)
 {
 	struct module_attribute *attr;
-- 
2.15.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ