|
|
b4b3ce |
From bfbc99003ebd96d79bbf8ad50be0b5e714a92fd7 Mon Sep 17 00:00:00 2001
|
|
|
b4b3ce |
From: ytakeshita <y.takeshita0311@gmail.com>
|
|
|
b4b3ce |
Date: Fri, 7 Jun 2019 15:20:52 +0900
|
|
|
b4b3ce |
Subject: [PATCH] Medium: Filesystem: Prevents to all root user processes are
|
|
|
b4b3ce |
killed when bind mounting a directory on rootfs.
|
|
|
b4b3ce |
|
|
|
b4b3ce |
if a directory is bound mounting on rootfs and "force_umount" is not set "safe", change "force_umount" to "safe".
|
|
|
b4b3ce |
---
|
|
|
b4b3ce |
heartbeat/Filesystem | 23 +++++++++++++++++++++++
|
|
|
b4b3ce |
1 file changed, 23 insertions(+)
|
|
|
b4b3ce |
|
|
|
b4b3ce |
diff --git a/heartbeat/Filesystem b/heartbeat/Filesystem
|
|
|
b4b3ce |
index c46ec3cca..1b29a08b3 100755
|
|
|
b4b3ce |
--- a/heartbeat/Filesystem
|
|
|
b4b3ce |
+++ b/heartbeat/Filesystem
|
|
|
b4b3ce |
@@ -314,6 +314,24 @@ bind_kernel_check() {
|
|
|
b4b3ce |
[ $? -ne 0 ] &&
|
|
|
b4b3ce |
ocf_log warn "kernel `uname -r` cannot handle read only bind mounts"
|
|
|
b4b3ce |
}
|
|
|
b4b3ce |
+
|
|
|
b4b3ce |
+bind_rootfs_check() {
|
|
|
b4b3ce |
+ local SOURCE
|
|
|
b4b3ce |
+ local TARGET
|
|
|
b4b3ce |
+ local ROOTFS
|
|
|
b4b3ce |
+
|
|
|
b4b3ce |
+ SOURCE=$1
|
|
|
b4b3ce |
+ TARGET=$(df --output=target $SOURCE | tail -n 1)
|
|
|
b4b3ce |
+
|
|
|
b4b3ce |
+ ROOTFS=$(list_mounts | grep -w rootfs | cut -d' ' -f 2)
|
|
|
b4b3ce |
+
|
|
|
b4b3ce |
+ if [ "${TARGET}" = "${ROOTFS}" ]; then
|
|
|
b4b3ce |
+ return 1
|
|
|
b4b3ce |
+ else
|
|
|
b4b3ce |
+ return 0
|
|
|
b4b3ce |
+ fi
|
|
|
b4b3ce |
+}
|
|
|
b4b3ce |
+
|
|
|
b4b3ce |
bind_mount() {
|
|
|
b4b3ce |
if is_bind_mount && [ "$options" != "-o bind" ]
|
|
|
b4b3ce |
then
|
|
|
b4b3ce |
@@ -476,6 +494,11 @@ get_pids()
|
|
|
b4b3ce |
local procs
|
|
|
b4b3ce |
local mmap_procs
|
|
|
b4b3ce |
|
|
|
b4b3ce |
+ if is_bind_mount && ocf_is_true "$FORCE_UNMOUNT" && ! bind_rootfs_check "$DEVICE"; then
|
|
|
b4b3ce |
+ ocf_log debug "Change force_umount from '$FORCE_UNMOUNT' to 'safe'"
|
|
|
b4b3ce |
+ FORCE_UNMOUNT=safe
|
|
|
b4b3ce |
+ fi
|
|
|
b4b3ce |
+
|
|
|
b4b3ce |
if ocf_is_true "$FORCE_UNMOUNT"; then
|
|
|
b4b3ce |
if [ "X${HOSTOS}" = "XOpenBSD" ];then
|
|
|
b4b3ce |
fstat | grep $dir | awk '{print $3}'
|