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]
Message-Id: <1362682267-10188-3-git-send-email-tiwai@suse.de>
Date:	Thu,  7 Mar 2013 19:51:06 +0100
From:	Takashi Iwai <tiwai@...e.de>
To:	Jörn Engel <joern@...fs.org>
Cc:	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	Borislav Petkov <bp@...en8.de>, Jeff Moyer <jmoyer@...hat.com>
Subject: [PATCH 2/3] block/partitions: Support dynamic addition of partition checkers

Add helper functions to add / remove the partition checker function
dynamically.  This also allows to move the partition checker code into
the driver itself, e.g. the blockconsole partition checker can be in a
part of blockconsole driver (even as a module).

Signed-off-by: Takashi Iwai <tiwai@...e.de>
---
 block/partitions/check.c | 35 +++++++++++++++++++++++++++++++++++
 block/partitions/check.h |  8 ++++++++
 2 files changed, 43 insertions(+)

diff --git a/block/partitions/check.c b/block/partitions/check.c
index 21786ed..d71cb02 100644
--- a/block/partitions/check.c
+++ b/block/partitions/check.c
@@ -17,6 +17,7 @@
 #include <linux/vmalloc.h>
 #include <linux/ctype.h>
 #include <linux/genhd.h>
+#include <linux/export.h>
 
 #include "check.h"
 
@@ -110,6 +111,9 @@ static int (*check_part[])(struct parsed_partitions *) = {
 	NULL
 };
 
+static DEFINE_MUTEX(check_part_mutex);
+static LIST_HEAD(check_part_list);
+
 static struct parsed_partitions *allocate_partitions(struct gendisk *hd)
 {
 	struct parsed_partitions *state;
@@ -172,6 +176,21 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
 		}
 
 	}
+
+	if (res <= 0) {
+		struct partition_checker *c;
+		mutex_lock(&check_part_mutex);
+		list_for_each_entry(c, &check_part_list, list) {
+			memset(state->parts, 0, state->limit * sizeof(state->parts[0]));
+			res = c->check(state);
+			if (res < 0) {
+				err = res;
+				res = 0;
+			}
+		}
+		mutex_unlock(&check_part_mutex);
+	}
+
 	if (res > 0) {
 		printk(KERN_INFO "%s", state->pp_buf);
 
@@ -194,3 +213,19 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
 	free_partitions(state);
 	return ERR_PTR(res);
 }
+
+void append_partition_checker(struct partition_checker *c)
+{
+	mutex_lock(&check_part_mutex);
+	list_add_tail(&c->list, &check_part_list);
+	mutex_unlock(&check_part_mutex);
+}
+EXPORT_SYMBOL_GPL(append_partition_checker);
+
+void remove_partition_checker(struct partition_checker *c)
+{
+	mutex_lock(&check_part_mutex);
+	list_del(&c->list);
+	mutex_unlock(&check_part_mutex);
+}
+EXPORT_SYMBOL_GPL(remove_partition_checker);
diff --git a/block/partitions/check.h b/block/partitions/check.h
index bca9624..53c8508 100644
--- a/block/partitions/check.h
+++ b/block/partitions/check.h
@@ -55,3 +55,11 @@ extern int warn_no_part;
 #ifdef CONFIG_BLOCKCONSOLE
 int blockconsole_partition(struct parsed_partitions *state);
 #endif
+
+struct partition_checker {
+	int (*check)(struct parsed_partitions *);
+	struct list_head list;
+};
+
+void append_partition_checker(struct partition_checker *c);
+void remove_partition_checker(struct partition_checker *c);
-- 
1.8.1.4

--
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