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>] [day] [month] [year] [list]
Message-ID: <56AF7AD2.7000404@drnet.at>
Date:	Mon, 1 Feb 2016 16:33:38 +0100
From:	"Dr. Net! - Eugen Rieck" <eugen@...et.at>
To:	San Mehat <nettwerk@...inux.com>,
	Johannes Erdfelt <jerdfelt@...inux.com>,
	NeilBrown <neilb@....unsw.edu.au>
Cc:	linux-kernel@...r.kernel.org, trivial@...nel.org
Subject: [PATCH 1/1] umem driver: allow multiple magic numbers per model

From: Eugen Rieck <eugen@...et.at>

Allow for multiple magic numbers per model and include the magic number
for the PCIe-based 5453CN, that shares the device id of the older
PCI-X-based 5425CN.

Signed-off-by: Eugen Rieck <eugen@...et.at>
---
The umem driver for Micro Memory (now Curtiss-Wright) NVRAM cards relied
on a unique magic number for each PCI device id. Newer cards violate this
and were thus rejected by the driver.
Developed for 3.13.0 (Ubuntu 14.04,  ubuntu 3.13.0-76-generic), but merges
cleanly into current (4.5-rc2) as the driver is old and largely unchanged.

 umem.c |   29 +++++++++++++++++++++++------
 umem.h |    2 ++
 2 files changed, 25 insertions(+), 6 deletions(-)

--- drivers/block/umem.c.orig    2016-02-01 14:51:07.463944676 +0100
+++ drivers/block/umem.c    2016-02-01 15:03:52.815934423 +0100
@@ -32,6 +32,8 @@
  * 17May2002:NeilBrown   - remove init_mem initialisation.  Instead detect
  *             - a sequence of writes that cover the card, and
  *             - set initialised bit then.
+ * 01Feb2016:Eugen Rieck - allow multiple magic numbers per pci id to
+ *               acommodate newer models
  */
 
 #undef DEBUG    /* #define DEBUG if you want debugging info (pr_debug) */
@@ -799,6 +801,9 @@
     unsigned long    csr_base;
     unsigned long    csr_len;
     int        magic_number;
+    int        magic_numbers[MAGIC_NUMBERS_PER_DEV];
+    int         magic_number_ok = 0;
+    int         i;
     static int    printed_version;
 
     if (!printed_version++)
@@ -850,27 +855,39 @@
     switch (card->dev->device) {
     case 0x5415:
         card->flags |= UM_FLAG_NO_BYTE_STATUS | UM_FLAG_NO_BATTREG;
-        magic_number = 0x59;
+        magic_numbers[0] = 0x59;
+        magic_numbers[1] = 0x100;
         break;
 
     case 0x5425:
         card->flags |= UM_FLAG_NO_BYTE_STATUS;
-        magic_number = 0x5C;
+        magic_numbers[0] = 0x5C;
+        magic_numbers[1] = 0x5E;
+        magic_numbers[2] = 0x100;
         break;
 
     case 0x6155:
         card->flags |= UM_FLAG_NO_BYTE_STATUS |
                 UM_FLAG_NO_BATTREG | UM_FLAG_NO_BATT;
-        magic_number = 0x99;
+        magic_numbers[0] = 0x99;
+        magic_numbers[1] = 0x100;
         break;
 
     default:
-        magic_number = 0x100;
+        magic_numbers[0] = 0x100;
         break;
     }
 
-    if (readb(card->csr_remap + MEMCTRLSTATUS_MAGIC) != magic_number) {
-        dev_printk(KERN_ERR, &card->dev->dev, "Magic number invalid\n");
+    magic_number = readb(card->csr_remap + MEMCTRLSTATUS_MAGIC);
+    for (i = 0; i < MAGIC_NUMBERS_PER_DEV; i++) {
+        if (magic_numbers[i] == magic_number) {
+            magic_number_ok = 1;
+            break;
+        }
+        if (magic_numbers[i] >= 0x100) break;
+    }
+    if (!magic_number_ok) {
+        dev_printk(KERN_ERR, &card->dev->dev, "Magic number 0x%02x invalid for device 0x%04x\n", magic_number, card->dev->device);
         ret = -ENOMEM;
         goto failed_magic;
     }

--- drivers/block/umem.h.orig    2016-02-01 14:51:16.055944561 +0100
+++ drivers/block/umem.h    2016-02-01 14:47:38.463947477 +0100
@@ -15,6 +15,8 @@
 
 #define IRQ_TIMEOUT (1 * HZ)
 
+#define MAGIC_NUMBERS_PER_DEV    2
+
 /* CSR register definition */
 #define MEMCTRLSTATUS_MAGIC    0x00
 #define  MM_MAGIC_VALUE        (unsigned char)0x59

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ