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, 31 Aug 2016 17:47:33 +0200
From:   Jean Delvare <jdelvare@...e.de>
To:     Greg KH <gregkh@...uxfoundation.org>
Cc:     Mario_Limonciello@...l.com, Allen_Hung@...l.com,
        rmk+kernel@....linux.org.uk, somlo@....edu,
        bjorn.andersson@...ymobile.com, jens.wiklander@...aro.org,
        agross@...eaurora.org, arnd@...db.de, sudeep.holla@....com,
        eric@...olt.net, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 2/2] dmi-id: add dmi/id/oem group for exporting oem
 strings to sysfs

Hi all,

On Wed, 31 Aug 2016 16:43:26 +0200, Greg KH wrote:
> On Wed, Aug 31, 2016 at 02:01:23PM +0000, Mario_Limonciello@...l.com wrote:
> > Jean Delvare would rather see this implemented in userspace dmidecode.
> > Jean raised a concern in an earlier submission that this runs on every
> > machine (https://lkml.org/lkml/2016/8/2/799).
> 
> Ah, yeah, just use dmidecode, much simpler, keeps the kernel smaller, I
> like it.

I wrote a proof of concept patch for dmidecode before my vacation, I
can't remember if I sent it out or not, so I guess it did not happen.
Here it is:

From: Jean Delvare <jdelvare@...e.de>
Subject: dmidecode: New option --oem-string

Add a new option to extract OEM strings, like we already have for
many other strings.

Signed-off-by: Jean Delvare <jdelvare@...e.de>
---
 dmidecode.c |    7 +++++++
 dmiopt.c    |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

--- dmidecode.orig/dmiopt.c	2015-10-01 08:41:43.533806256 +0200
+++ dmidecode/dmiopt.c	2016-08-05 10:32:44.907196966 +0200
@@ -171,6 +171,10 @@ static const struct string_keyword opt_s
 	{ "processor-frequency", 4, 0x16 },     /* dmi_processor_frequency() */
 };
 
+/* This is a template, 3rd field is set at runtime. */
+static struct string_keyword opt_oem_string_keyword =
+	{ NULL, 11, 0x00 };
+
 static void print_opt_string_list(void)
 {
 	unsigned int i;
@@ -206,6 +210,29 @@ static int parse_opt_string(const char *
 	return -1;
 }
 
+static int parse_opt_oem_string(const char *arg)
+{
+	unsigned long val;
+	char *next;
+
+	if (opt.string)
+	{
+		fprintf(stderr, "Only one string can be specified\n");
+		return -1;
+	}
+
+	val = strtoul(arg, &next, 10);
+	if (next == arg || val <= 0x00 || val > 0xff)
+	{
+		fprintf(stderr, "Invalid OEM string number: %s\n", arg);
+		return -1;
+	}
+
+	opt_oem_string_keyword.offset = val;
+	opt.string = &opt_oem_string_keyword;
+	return 0;
+}
+
 
 /*
  * Command line options handling
@@ -225,6 +252,7 @@ int parse_command_line(int argc, char *
 		{ "dump", no_argument, NULL, 'u' },
 		{ "dump-bin", required_argument, NULL, 'B' },
 		{ "from-dump", required_argument, NULL, 'F' },
+		{ "oem-string", required_argument, NULL, 'O' },
 		{ "no-sysfs", no_argument, NULL, 'S' },
 		{ "version", no_argument, NULL, 'V' },
 		{ NULL, 0, NULL, 0 }
@@ -255,6 +283,11 @@ int parse_command_line(int argc, char *
 					return -1;
 				opt.flags |= FLAG_QUIET;
 				break;
+			case 'O':
+				if (parse_opt_oem_string(optarg) < 0)
+					return -1;
+				opt.flags |= FLAG_QUIET;
+				break;
 			case 't':
 				opt.type = parse_opt_type(opt.type, optarg);
 				if (opt.type == NULL)
--- dmidecode.orig/dmidecode.c	2016-07-22 10:26:50.190119889 +0200
+++ dmidecode/dmidecode.c	2016-08-05 10:41:53.746645533 +0200
@@ -4370,6 +4370,13 @@ static void dmi_table_string(const struc
 	int key;
 	u8 offset = opt.string->offset;
 
+	if (opt.string->type == 11) /* OEM strings */
+	{
+		if (h->length >= 5 && offset <= data[4])
+			printf("%s\n", dmi_string(h, offset));
+		return;
+	}
+
 	if (offset >= h->length)
 		return;
 
I know it's not a universal way to decide where to put the code, but
note how it's half the side of your kernel-side implementation proposal.

-- 
Jean Delvare
SUSE L3 Support

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ