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, 28 Jun 2017 17:47:01 +0200
From:   Aleksandar Markovic <aleksandar.markovic@...rk.com>
To:     linux-mips@...ux-mips.org
Cc:     Miodrag Dinic <miodrag.dinic@...tec.com>,
        Goran Ferenc <goran.ferenc@...tec.com>,
        Aleksandar Markovic <aleksandar.markovic@...tec.com>,
        Douglas Leung <douglas.leung@...tec.com>,
        James Hogan <james.hogan@...tec.com>,
        Jonas Gorski <jogo@...nwrt.org>, linux-kernel@...r.kernel.org,
        Marcin Nowakowski <marcin.nowakowski@...tec.com>,
        Paul Burton <paul.burton@...tec.com>,
        Petar Jovanovic <petar.jovanovic@...tec.com>,
        Raghu Gandham <raghu.gandham@...tec.com>,
        Ralf Baechle <ralf@...ux-mips.org>
Subject: [PATCH v2 08/10] MIPS: Introduce check_legacy_ioport() interface

From: Miodrag Dinic <miodrag.dinic@...tec.com>

Some drivers may try to probe some I/O ports which can lead to kernel
panic if the device is not present and mapped. This function should be
used to check for existence of such devices and return 0 for MIPS
boards which implement them, otherwise it should return -ENODEV and
the affected device driver should never try to read/write the
requested I/O port.

This is particularly useful for multiplaform kernels which are board
agnostic and this interface can be used to match drivers against
available devices on a specific board in runtime.

This patch just adds a no-op check_legacy_ioport() function which will
be enriched with logic in a later patch.

Signed-off-by: Miodrag Dinic <miodrag.dinic@...tec.com>
Signed-off-by: Goran Ferenc <goran.ferenc@...tec.com>
Signed-off-by: Aleksandar Markovic <aleksandar.markovic@...tec.com>
---
 arch/mips/include/asm/io.h |  5 +++++
 arch/mips/kernel/setup.c   | 25 +++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index ecabc00..62b9f89 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -78,6 +78,11 @@ static inline void set_io_port_base(unsigned long base)
 }
 
 /*
+ * Check for existence of legacy devices
+ */
+extern int check_legacy_ioport(unsigned long base_port);
+
+/*
  * Thanks to James van Artsdalen for a better timing-fix than
  * the two short jumps: using outb's to a nonexistent port seems
  * to guarantee better timings even on fast machines.
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 01d1dbd..c22cde8 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -78,6 +78,31 @@ static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
 const unsigned long mips_io_port_base = -1;
 EXPORT_SYMBOL(mips_io_port_base);
 
+/*
+ * Check for existence of legacy devices
+ *
+ * Some drivers may try to probe some I/O ports which can lead to
+ * kernel panic if the device is not present and mapped. This method
+ * should check for existence of such devices and return 0 for MIPS
+ * boards which actually have them, otherwise it will return -ENODEV
+ * and the affected device driver should never try to read/write the
+ * requested I/O port.
+ */
+int check_legacy_ioport(unsigned long base_port)
+{
+	int ret = 0;
+
+	switch (base_port) {
+	default:
+		/* We will assume that the I/O device port exists if
+		 * not explicitly added to the blacklist match table
+		 */
+		break;
+	}
+	return ret;
+}
+EXPORT_SYMBOL(check_legacy_ioport);
+
 static struct resource code_resource = { .name = "Kernel code", };
 static struct resource data_resource = { .name = "Kernel data", };
 
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ