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-next>] [day] [month] [year] [list]
Message-ID: <45646330.9010402@indt.org.br>
Date:	Wed, 22 Nov 2006 10:48:16 -0400
From:	Anderson Briglia <anderson.briglia@...t.org.br>
To:	"Linux-omap-open-source@...ux.omap.com" 
	<linux-omap-open-source@...ux.omap.com>
CC:	Russell King <rmk+lkml@....linux.org.uk>,
	Pierre Ossman <drzeus-list@...eus.cx>,
	Tony Lindgren <tony@...mide.com>,
	"Aguiar Carlos (EXT-INdT/Manaus)" <carlos.aguiar@...t.org.br>,
	ext David Brownell <david-b@...bell.net>,
	"Lizardo Anderson (EXT-INdT/Manaus)" <anderson.lizardo@...t.org.br>,
	linux-kernel@...r.kernel.org
Subject: [patch 1/5] [RFC] Add MMC Password Protection (lock/unlock) support
 V7: mmc_ignore_locked.diff

When a card is locked, only commands from the "basic" and "lock card" classes
are accepted. To be able to use the other commands, the card must be unlocked
first.

This patch prevents the device drivers from trying to run privileged class
commands on locked MMC cards, which will fail anyway.

Signed-off-by: Carlos Eduardo Aguiar <carlos.aguiar <at> indt.org.br>
Signed-off-by: Anderson Lizardo <anderson.lizardo <at> indt.org.br>
Signed-off-by: Anderson Briglia <anderson.briglia <at> indt.org.br>
Signed-off-by: David Brownell <david-b <at> pacbell.net>

Index: linux-omap-2.6.git/drivers/mmc/mmc_sysfs.c
===================================================================
--- linux-omap-2.6.git.orig/drivers/mmc/mmc_sysfs.c	2006-11-22 07:58:20.000000000 -0400
+++ linux-omap-2.6.git/drivers/mmc/mmc_sysfs.c	2006-11-22 09:19:16.000000000 -0400
@@ -17,6 +17,7 @@

  #include <linux/mmc/card.h>
  #include <linux/mmc/host.h>
+#include <linux/mmc/protocol.h>

  #include "mmc.h"

@@ -73,10 +74,19 @@ static void mmc_release_card(struct devi
   * This currently matches any MMC driver to any MMC card - drivers
   * themselves make the decision whether to drive this card in their
   * probe method.  However, we force "bad" cards to fail.
+ *
+ * We also fail for all locked cards; drivers expect to be able to do block
+ * I/O still on probe(), which is not possible while the card is locked.
+ * Device probing must be triggered sometime later to make the card available
+ * to the block driver.
   */
  static int mmc_bus_match(struct device *dev, struct device_driver *drv)
  {
  	struct mmc_card *card = dev_to_mmc_card(dev);
+	if (mmc_card_lockable(card) && mmc_card_locked(card)) {
+		dev_dbg(&card->dev, "card is locked; binding is deferred\n");
+		return 0;
+	}
  	return !mmc_card_bad(card);
  }

Index: linux-omap-2.6.git/include/linux/mmc/card.h
===================================================================
--- linux-omap-2.6.git.orig/include/linux/mmc/card.h	2006-11-22 07:58:20.000000000 -0400
+++ linux-omap-2.6.git/include/linux/mmc/card.h	2006-11-22 09:07:23.000000000 -0400
@@ -62,6 +62,7 @@ struct mmc_card {
  #define MMC_STATE_BAD		(1<<2)		/* unrecognised device */
  #define MMC_STATE_SDCARD	(1<<3)		/* is an SD card */
  #define MMC_STATE_READONLY	(1<<4)		/* card is read-only */
+#define MMC_STATE_LOCKED	(1<<5)		/* card is currently locked */
  	u32			raw_cid[4];	/* raw card CID */
  	u32			raw_csd[4];	/* raw card CSD */
  	u32			raw_scr[2];	/* raw card SCR */
@@ -75,12 +76,19 @@ struct mmc_card {
  #define mmc_card_bad(c)		((c)->state & MMC_STATE_BAD)
  #define mmc_card_sd(c)		((c)->state & MMC_STATE_SDCARD)
  #define mmc_card_readonly(c)	((c)->state & MMC_STATE_READONLY)
+#define mmc_card_locked(c)	((c)->state & MMC_STATE_LOCKED)
+
+#define mmc_card_lockable(c)    (((c)->csd.cmdclass & CCC_LOCK_CARD) && \
+				((c)->host->caps & MMC_CAP_BYTEBLOCK))

  #define mmc_card_set_present(c)	((c)->state |= MMC_STATE_PRESENT)
  #define mmc_card_set_dead(c)	((c)->state |= MMC_STATE_DEAD)
  #define mmc_card_set_bad(c)	((c)->state |= MMC_STATE_BAD)
  #define mmc_card_set_sd(c)	((c)->state |= MMC_STATE_SDCARD)
  #define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY)
+#define mmc_card_set_locked(c)	((c)->state |= MMC_STATE_LOCKED)
+
+#define mmc_card_clear_locked(c)	((c)->state &= ~MMC_STATE_LOCKED)

  #define mmc_card_name(c)	((c)->cid.prod_name)
  #define mmc_card_id(c)		((c)->dev.bus_id)
Index: linux-omap-2.6.git/drivers/mmc/mmc.c
===================================================================
--- linux-omap-2.6.git.orig/drivers/mmc/mmc.c	2006-11-22 07:58:20.000000000 -0400
+++ linux-omap-2.6.git/drivers/mmc/mmc.c	2006-11-22 09:19:13.000000000 -0400
@@ -922,6 +922,11 @@ static void mmc_discover_cards(struct mm
  			if (err != MMC_ERR_NONE)
  				mmc_card_set_dead(card);
  		}
+
+		if (cmd.resp[0] & R1_CARD_IS_LOCKED)
+			mmc_card_set_locked(card);
+		else
+			mmc_card_clear_locked(card);
  	}
  }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ