Skip to contentSkip to conversation

Updated cluster log patch (take 4)

PATCH Jonathan Brassow 2 participants 2 messages Jun 2, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Evgeniy, I was wondering if I could get your thoughts on some of the security questions I am currently investigating below...

This patch contains very minor changes from the last posting.
- Variable/Macro name changes
- minor changes to comments

I am currently exploring the security of using connector/netlink. I am being sure to clear any buffers before populating them to prevent leaking any kernel memory contents to userspace. I am also double checking in-coming data length fields which are filled in from user space. I have these questions remaining:

1) Can a non-root user communicate with the kernel via connector? I saw this (http://lwn.net/Articles/329266/) regarding a privilege escalation (udev + netlink). The article tells how netlink used to allow userspace to both send and receive data, but now only allows data to be received. I think this behavior is protocol specific, though... So, what does connector allow?

2) If connector does allow non-root users to communicate, do I need to worry about a simple user being able to perform a DOS on my daemon because it somehow manages to monopolize/disrupt communication to the connector address I am using?

Thanks for any information,
brassow

agk, do you have any additional questions to ask?

This patch contains the cluster-aware device-mapper log module.

The log types contained herein ("clustered-disk" and "clustered-core") operate in the same way as their single machine counterparts (dm-log.c), but they are cluster coherent. This is done by forwarding most logging requests to userspace, where a daemon processes the request in an ordered fashion with the rest of the nodes in the cluster. This is necessary to prevent log state corruption. (Imagine if two machines are writing to the same region of a mirror. They would both mark the region dirty, but you need a cluster-aware entity that can handle properly marking the region clean when they are done. Otherwise, you might clear the region when the first machine is done, not the second.)

The structure used for communication between kernel and userspace are located in include/linux/dm-log-cluster.h. Due to the frequency, diversity, and 2-way communication nature of the exchanges between kernel and userspace, 'connector' is used as the interface for communication. One existing userspace implementation of the daemon uses openAIS/corosync in order to communicate with guaranteed ordering and delivery. This daemon, which is capable of coherently managing log state from multiple cluster machines, can be found in the LVM2 code repository. Other implementations of the daemon, with no association to LVM or openAIS/corosync, are certainly possible.

Providing a cluster-aware logging type gives device-mapper RAID1 (and potentially other RAIDs) the ability to operate in a cluster-coherent fashion.

drivers/md/Kconfig +10 -0
Index: linux-2.6/drivers/md/Kconfig
===================================================================
@@ -231,6 +231,16 @@ config DM_MIRROR
          Allow volume managers to mirror logical volumes, also
          needed for live data migration tools such as 'pvmove'.
 
+config DM_LOG_CLUSTERED
+	tristate "Mirror cluster logging (EXPERIMENTAL)"
+	depends on DM_MIRROR && EXPERIMENTAL
+	select CONNECTOR
+	---help---
+	  The cluster logging module provides a mechanism for
+	  keeping log state coherent in a shared-storage cluster.
+	  Device-mapper mirroring (RAID1) can leverage this log
+	  type to make mirrors that are cluster-aware.
+
 config DM_ZERO
 	tristate "Zero target"
 	depends on BLK_DEV_DM
drivers/md/Makefile +2 -0
Index: linux-2.6/drivers/md/Makefile
===================================================================
@@ -8,6 +8,7 @@ dm-multipath-y	+= dm-path-selector.o dm-
 dm-snapshot-y	+= dm-snap.o dm-exception.o dm-exception-store.o \
 		   dm-snap-transient.o dm-snap-persistent.o
 dm-mirror-y	+= dm-raid1.o
+dm-log-clustered-y += dm-log-cluster.o dm-log-cluster-transfer.o
 md-mod-y	+= md.o bitmap.o
 raid456-y	+= raid5.o
 raid6_pq-y	+= raid6algos.o raid6recov.o raid6tables.o \
@@ -38,6 +39,7 @@ obj-$(CONFIG_DM_DELAY)		+= dm-delay.o
 obj-$(CONFIG_DM_MULTIPATH)	+= dm-multipath.o dm-round-robin.o
 obj-$(CONFIG_DM_SNAPSHOT)	+= dm-snapshot.o
 obj-$(CONFIG_DM_MIRROR)		+= dm-mirror.o dm-log.o dm-region-hash.o
+obj-$(CONFIG_DM_LOG_CLUSTERED)	+= dm-log-clustered.o
 obj-$(CONFIG_DM_ZERO)		+= dm-zero.o
 
 quiet_cmd_unroll = UNROLL  $@
include/linux/dm-log-cluster.h new file +58 -0

58 lines not on this page · raw message

drivers/md/dm-log-cluster-transfer.c new file +286 -0

286 lines not on this page · raw message

drivers/md/dm-log-cluster-transfer.h new file +18 -0
Index: linux-2.6/drivers/md/dm-log-cluster-transfer.h
===================================================================
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2006-2009 Red Hat, Inc.
+ *
+ * This file is released under the LGPL.
+ */
+
+#ifndef __DM_LOG_CLUSTER_TRANSFER_H__
+#define __DM_LOG_CLUSTER_TRANSFER_H__
+
+#define DM_MSG_PREFIX "dm-log-clustered"
+
+int dm_clog_tfr_init(void);
+void dm_clog_tfr_exit(void);
+int dm_clog_consult_server(const char *uuid, int request_type,
+			   char *data, size_t data_size,
+			   char *rdata, size_t *rdata_size);
+
+#endif /* __DM_LOG_CLUSTER_TRANSFER_H__ */
drivers/md/dm-log-cluster.c new file +745 -0

745 lines not on this page · raw message

Documentation/dm-log.txt new file +63 -0

63 lines not on this page · raw message

include/linux/connector.h +3 -1
Index: linux-2.6/include/linux/connector.h
===================================================================
@@ -41,8 +41,10 @@
 #define CN_IDX_BB			0x5	/* BlackBoard, from the TSP GPL sampling framework */
 #define CN_DST_IDX			0x6
 #define CN_DST_VAL			0x1
+#define CN_IDX_DM			0x7	/* Device Mapper */
+#define CN_VAL_DM_CLUSTER_LOG		0x1
 
-#define CN_NETLINK_USERS		7
+#define CN_NETLINK_USERS		8
 
 /*
  * Maximum connector's message size.
include/linux/Kbuild +1 -0
Index: linux-2.6/include/linux/Kbuild
===================================================================
@@ -57,6 +57,7 @@ header-y += dlmconstants.h
 header-y += dlm_device.h
 header-y += dlm_netlink.h
 header-y += dm-ioctl.h
+header-y += dm-log-cluster.h
 header-y += dn.h
 header-y += dqblk_xfs.h
 header-y += efs_fs_sb.h
#1 lore raw

Hi Jonathan.

Quoted 20 lines · Jonathan Brassow

Evgeniy, I was wondering if I could get your thoughts on some of the security questions I am currently investigating below...

This patch contains very minor changes from the last posting.
- Variable/Macro name changes
- minor changes to comments

I am currently exploring the security of using connector/netlink. I am being sure to clear any buffers before populating them to prevent leaking any kernel memory contents to userspace. I am also double checking in-coming data length fields which are filled in from user space. I have these questions remaining:

1) Can a non-root user communicate with the kernel via connector? I saw this (http://lwn.net/Articles/329266/) regarding a privilege escalation (udev + netlink). The article tells how netlink used to allow userspace to both send and receive data, but now only allows data to be received. I think this behavior is protocol specific, though... So, what does connector allow?

Quoted 4 lines

2) If connector does allow non-root users to communicate, do I need to worry about a simple user being able to perform a DOS on my daemon because it somehow manages to monopolize/disrupt communication to the connector address I am using?

Connector allows to send packets from non-root user, but only root can receive the responses. I believe connector should have a default mode to allow only root to send data to the kernel.

Signature · 1 line
	Evgeniy Polyakov