f9dfbb37ac
Modify 0136-RHBZ-1304687-wait-for-map-add.patch * switch to missing_uev_wait_timeout to stop waiting for uev Refresh 0137-RHBZ-1280524-clear-chkr-msg.patch Refresh 0150-RHBZ-1253913-fix-startup-msg.patch Refresh 0154-UPBZ-1291406-disable-reinstate.patch Refresh 0156-UPBZ-1313324-dont-fail-discovery.patch Refresh 0161-RHBZ-1311659-no-kpartx.patch Refresh 0167-RHBZ-1335176-fix-show-cmds.patch Add 0173-RH-update-man-page.patch Add 0174-RHBZ-1362396-modprobe.patch * make starting the multipathd service modprobe dm-multipath in the sysvinit scripts Add 0175-RHBZ-1357382-ordering.patch * force multipathd.service to start after systemd-udev-trigger.service Add 0176-RHBZ-1363830-fix-rename.patch * initialized a variable to make dm_rename not fail randomly Add 0177-libmultipath-correctly-initialize-pp-sg_id.patch * This and all the following patches add the rbd patch checker Add 0178-libmultipath-add-rbd-discovery.patch Add 0179-multipath-tools-add-checker-callout-to-repair-path.patch Add 0180-multipath-tools-Add-rbd-checker.patch Add 0181-multipath-tools-Add-rbd-to-the-hwtable.patch Add 0182-multipath-tools-check-for-initialized-checker-before.patch Add 0183-multipathd-Don-t-call-repair-on-blacklisted-path.patch Add 0184-rbd-fix-sync-repair-support.patch Add 0185-rbd-check-for-nonshared-clients.patch Add 0186-rbd-check-for-exclusive-lock-enabled.patch Add 0187-rbd-fixup-log-messages.patch Add 0188-RHBZ-1368501-dont-exit.patch * make multipathd not exit if it encounters recoverable errors on startup Add 0189-RHBZ-1368211-remove-retries.patch * add "remove_retries" multipath.conf parameter to make multiple attempts to remove a multipath device if it is busy. Add 0190-RHBZ-1380602-rbd-lock-on-read.patch * pass lock_on_read when remapping image Add 0191-RHBZ-1169168-disable-changed-paths.patch * add "disabled_changed_wwids" multipath.conf parameter to disable paths whose wwid changes Add 0192-RHBZ-1362409-infinibox-config.patch Add 0194-RHBZ-1351964-kpartx-recurse.patch * fix recursion on corrupt dos partitions Add 0195-RHBZ-1359510-no-daemon-msg.patch * print a messages when multipathd isn't running Add 0196-RHBZ-1239173-dont-set-flag.patch * don't set reload flag on reloads when you gain your first valid path Add 0197-RHBZ-1394059-max-sectors-kb.patch * add "max_sectors_kb" multipath.conf parameter to set max_sectors_kb on a multipath device and all its path devices Add 0198-RHBZ-1372032-detect-path-checker.patch * add "detect_checker" multipath.conf parameter to detect ALUA arrays and set the path checker to TUR Add 0199-RHBZ-1279355-3pardata-config.patch Add 0200-RHBZ-1402092-orphan-status.patch * clear status on orphan paths Add 0201-RHBZ-1403552-silence-warning.patch Add 0202-RHBZ-1362120-skip-prio.patch * don't run prio on failed paths Add 0203-RHBZ-1363718-add-msgs.patch Add 0204-RHBZ-1406226-nimble-config.patch Add 0205-RHBZ-1416569-reset-stats.patch * add "reset maps stats" and "reset map <map> stats" multipathd interactive commands to reset the stats tracked by multipathd Add 0206-RHBZ-1239173-pt2-no-paths.patch * make multipath correctly disable scanning and rules running when it gets a uevent and there are not valid paths. Add 0207-UP-add-libmpathcmd.patch * New shared library, libmpathcmd, that sends and receives messages from multipathd. device-mapper-multipath now uses this library internally. Add 0208-UPBZ-1430097-multipathd-IPC-changes.patch * validation that modifying commands are coming from root. Add 0209-UPBZ-1430097-multipath-C-API.patch * New shared library. libdmmp, that presents the information from multipathd in a structured manner to make it easier for callers to use Add 0210-RH-fix-uninstall.patch * Minor compilation fixes Add 0211-RH-strlen-fix.patch * checks that variables are not NULL before passing them to strlen Add 0212-RHBZ-1431562-for-read-only.patch Make 3 new subpackages * device-mapper-multipath-devel, libdmmp, and libdmmp-devel. libmpathcmd and libmpathprio are in device-mapper-multipath-libs and device-mapper-multipath-devel. libdmmp is in its own subpackages Move libmpathprio devel files to device-mapper-multipath-devel Added BuildRequires on librados2-devel
281 lines
7.7 KiB
Diff
281 lines
7.7 KiB
Diff
[PATCH] Multipath: Remove duplicated memset() for multipathd show command.
|
|
[PATCH] multipath-tools: New way to limit the IPC command length.
|
|
[PATCH] multipath-tools: Perform socket client uid check on IPC commands.
|
|
|
|
Signed-off-by: Gris Ge <fge@redhat.com>
|
|
---
|
|
libmultipath/print.c | 10 ----------
|
|
libmultipath/uxsock.c | 38 +++++++++++++++++++++++++++++---------
|
|
libmultipath/uxsock.h | 9 +++++++++
|
|
multipathd/main.c | 15 +++++++++++++--
|
|
multipathd/uxlsnr.c | 31 ++++++++++++++++++++++++++-----
|
|
multipathd/uxlsnr.h | 8 +++++---
|
|
6 files changed, 82 insertions(+), 29 deletions(-)
|
|
|
|
Index: multipath-tools-130222/libmultipath/print.c
|
|
===================================================================
|
|
--- multipath-tools-130222.orig/libmultipath/print.c
|
|
+++ multipath-tools-130222/libmultipath/print.c
|
|
@@ -771,8 +771,6 @@ snprint_multipath_header (char * line, i
|
|
int fwd;
|
|
struct multipath_data * data;
|
|
|
|
- memset(line, 0, len);
|
|
-
|
|
do {
|
|
if (!TAIL)
|
|
break;
|
|
@@ -806,8 +804,6 @@ snprint_multipath (char * line, int len,
|
|
struct multipath_data * data;
|
|
char buff[MAX_FIELD_LEN] = {};
|
|
|
|
- memset(line, 0, len);
|
|
-
|
|
do {
|
|
if (!TAIL)
|
|
break;
|
|
@@ -842,8 +838,6 @@ snprint_path_header (char * line, int le
|
|
int fwd;
|
|
struct path_data * data;
|
|
|
|
- memset(line, 0, len);
|
|
-
|
|
do {
|
|
if (!TAIL)
|
|
break;
|
|
@@ -877,8 +871,6 @@ snprint_path (char * line, int len, char
|
|
struct path_data * data;
|
|
char buff[MAX_FIELD_LEN];
|
|
|
|
- memset(line, 0, len);
|
|
-
|
|
do {
|
|
if (!TAIL)
|
|
break;
|
|
@@ -914,8 +906,6 @@ snprint_pathgroup (char * line, int len,
|
|
struct pathgroup_data * data;
|
|
char buff[MAX_FIELD_LEN];
|
|
|
|
- memset(line, 0, len);
|
|
-
|
|
do {
|
|
if (!TAIL)
|
|
break;
|
|
Index: multipath-tools-130222/libmultipath/uxsock.c
|
|
===================================================================
|
|
--- multipath-tools-130222.orig/libmultipath/uxsock.c
|
|
+++ multipath-tools-130222/libmultipath/uxsock.c
|
|
@@ -20,6 +20,15 @@
|
|
|
|
#include "memory.h"
|
|
#include "uxsock.h"
|
|
+
|
|
+/*
|
|
+ * Code is similar with mpath_recv_reply() with data size limitation
|
|
+ * and debug-able malloc.
|
|
+ * When limit == 0, it means no limit on data size, used for socket client
|
|
+ * to receiving data from multipathd.
|
|
+ */
|
|
+static int _recv_packet(int fd, char **buf, ssize_t limit);
|
|
+
|
|
/*
|
|
* create a unix domain socket and start listening on it
|
|
* return a file descriptor open on the socket
|
|
@@ -95,27 +104,38 @@ int send_packet(int fd, const char *buf)
|
|
return ret;
|
|
}
|
|
|
|
-/*
|
|
- * receive a packet in length prefix format
|
|
- */
|
|
-int recv_packet(int fd, char **buf)
|
|
+static int _recv_packet(int fd, char **buf, ssize_t limit)
|
|
{
|
|
- int err;
|
|
- ssize_t len;
|
|
+ int err = 0;
|
|
+ ssize_t len = 0;
|
|
unsigned int timeout = DEFAULT_REPLY_TIMEOUT;
|
|
|
|
*buf = NULL;
|
|
len = mpath_recv_reply_len(fd, timeout);
|
|
if (len <= 0)
|
|
return len;
|
|
+ if ((limit > 0) && (len > limit))
|
|
+ return -EINVAL;
|
|
(*buf) = MALLOC(len);
|
|
if (!*buf)
|
|
return -ENOMEM;
|
|
err = mpath_recv_reply_data(fd, *buf, len, timeout);
|
|
- if (err) {
|
|
+ if (err != 0) {
|
|
FREE(*buf);
|
|
(*buf) = NULL;
|
|
- return err;
|
|
}
|
|
- return 0;
|
|
+ return err;
|
|
+}
|
|
+
|
|
+/*
|
|
+ * receive a packet in length prefix format
|
|
+ */
|
|
+int recv_packet(int fd, char **buf)
|
|
+{
|
|
+ return _recv_packet(fd, buf, 0 /* no limit */);
|
|
+}
|
|
+
|
|
+int recv_packet_from_client(int fd, char **buf)
|
|
+{
|
|
+ return _recv_packet(fd, buf, _MAX_CMD_LEN);
|
|
}
|
|
Index: multipath-tools-130222/libmultipath/uxsock.h
|
|
===================================================================
|
|
--- multipath-tools-130222.orig/libmultipath/uxsock.h
|
|
+++ multipath-tools-130222/libmultipath/uxsock.h
|
|
@@ -3,3 +3,12 @@ int ux_socket_listen(const char *name);
|
|
int send_packet(int fd, const char *buf);
|
|
int recv_packet(int fd, char **buf);
|
|
size_t write_all(int fd, const void *buf, size_t len);
|
|
+
|
|
+#define _MAX_CMD_LEN 512
|
|
+
|
|
+/*
|
|
+ * Used for receiving socket command from untrusted socket client where data
|
|
+ * size is restricted to 512(_MAX_CMD_LEN) at most.
|
|
+ * Return -EINVAL if data length requested by client exceeded the _MAX_CMD_LEN.
|
|
+ */
|
|
+int recv_packet_from_client(int fd, char **buf);
|
|
Index: multipath-tools-130222/multipathd/main.c
|
|
===================================================================
|
|
--- multipath-tools-130222.orig/multipathd/main.c
|
|
+++ multipath-tools-130222/multipathd/main.c
|
|
@@ -18,6 +18,7 @@
|
|
#include <linux/oom.h>
|
|
#include <libudev.h>
|
|
#include <semaphore.h>
|
|
+#include <stdbool.h>
|
|
#include <mpath_persist.h>
|
|
#include "prioritizers/alua_rtpg.h"
|
|
|
|
@@ -859,7 +860,8 @@ map_discovery (struct vectors * vecs)
|
|
}
|
|
|
|
int
|
|
-uxsock_trigger (char * str, char ** reply, int * len, void * trigger_data)
|
|
+uxsock_trigger (char * str, char ** reply, int * len, bool is_root,
|
|
+ void * trigger_data)
|
|
{
|
|
struct vectors * vecs;
|
|
int r;
|
|
@@ -872,6 +874,15 @@ uxsock_trigger (char * str, char ** repl
|
|
lock(vecs->lock);
|
|
pthread_testcancel();
|
|
|
|
+ if ((str != NULL) && (is_root == false) &&
|
|
+ (strncmp(str, "list", strlen("list")) != 0) &&
|
|
+ (strncmp(str, "show", strlen("show")) != 0)) {
|
|
+ *reply = STRDUP("permission deny: need to be root");
|
|
+ *len = strlen(*reply) + 1;
|
|
+ r = 1;
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
r = parse_cmd(str, reply, len, vecs);
|
|
|
|
if (r > 0) {
|
|
@@ -885,7 +896,7 @@ uxsock_trigger (char * str, char ** repl
|
|
r = 0;
|
|
}
|
|
/* else if (r < 0) leave *reply alone */
|
|
-
|
|
+out:
|
|
lock_cleanup_pop(vecs->lock);
|
|
return r;
|
|
}
|
|
Index: multipath-tools-130222/multipathd/uxlsnr.c
|
|
===================================================================
|
|
--- multipath-tools-130222.orig/multipathd/uxlsnr.c
|
|
+++ multipath-tools-130222/multipathd/uxlsnr.c
|
|
@@ -21,6 +21,7 @@
|
|
#include <sys/un.h>
|
|
#include <sys/poll.h>
|
|
#include <signal.h>
|
|
+#include <stdbool.h>
|
|
#include <checkers.h>
|
|
#include <memory.h>
|
|
#include <debug.h>
|
|
@@ -48,6 +49,23 @@ struct pollfd *polls;
|
|
volatile sig_atomic_t reconfig_sig = 0;
|
|
volatile sig_atomic_t log_reset_sig = 0;
|
|
|
|
+static bool _socket_client_is_root(int fd);
|
|
+
|
|
+static bool _socket_client_is_root(int fd)
|
|
+{
|
|
+ socklen_t len = 0;
|
|
+ struct ucred uc;
|
|
+
|
|
+ len = sizeof(struct ucred);
|
|
+ if ((fd >= 0) &&
|
|
+ (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &uc, &len) == 0) &&
|
|
+ (uc.uid == 0))
|
|
+ return true;
|
|
+
|
|
+ /* Treat error as not root client */
|
|
+ return false;
|
|
+}
|
|
+
|
|
/*
|
|
* handle a new client joining
|
|
*/
|
|
@@ -105,8 +123,7 @@ void uxsock_cleanup(void *arg)
|
|
/*
|
|
* entry point
|
|
*/
|
|
-void * uxsock_listen(int (*uxsock_trigger)(char *, char **, int *, void *),
|
|
- void * trigger_data)
|
|
+void * uxsock_listen(uxsock_trigger_fn uxsock_trigger, void * trigger_data)
|
|
{
|
|
int ux_sock;
|
|
int rlen;
|
|
@@ -171,12 +188,16 @@ void * uxsock_listen(int (*uxsock_trigge
|
|
struct client *next = c->next;
|
|
|
|
if (polls[i].revents & POLLIN) {
|
|
- if (recv_packet(c->fd, &inbuf) != 0) {
|
|
+ if (recv_packet_from_client(c->fd,
|
|
+ &inbuf) != 0) {
|
|
dead_client(c);
|
|
+ } else if (!inbuf) {
|
|
+ condlog(4, "recv_packet_from_client "
|
|
+ "get null request");
|
|
+ continue;
|
|
} else {
|
|
condlog(4, "Got request [%s]", inbuf);
|
|
- uxsock_trigger(inbuf, &reply, &rlen,
|
|
- trigger_data);
|
|
+ uxsock_trigger(inbuf, &reply, &rlen, _socket_client_is_root(c->fd), trigger_data);
|
|
if (reply) {
|
|
if (send_packet(c->fd,
|
|
reply) != 0) {
|
|
Index: multipath-tools-130222/multipathd/uxlsnr.h
|
|
===================================================================
|
|
--- multipath-tools-130222.orig/multipathd/uxlsnr.h
|
|
+++ multipath-tools-130222/multipathd/uxlsnr.h
|
|
@@ -1,9 +1,11 @@
|
|
#ifndef _UXLSNR_H
|
|
#define _UXLSNR_H
|
|
|
|
-void * uxsock_listen(int (*uxsock_trigger)
|
|
- (char *, char **, int *, void *),
|
|
- void * trigger_data);
|
|
+#include <stdbool.h>
|
|
+
|
|
+typedef int (uxsock_trigger_fn)(char *, char **, int *, bool, void *);
|
|
+
|
|
+void *uxsock_listen(uxsock_trigger_fn uxsock_trigger, void * trigger_data);
|
|
|
|
extern volatile sig_atomic_t reconfig_sig;
|
|
extern volatile sig_atomic_t log_reset_sig;
|