diff --git a/fs/namespace.c b/fs/namespace.c index 8c1b585a3065..fa63b49e993b 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -3106,19 +3106,24 @@ char *copy_mount_string(const void __user *data) * adb shell mount -r -w sdcard /system_ext * adb shell mount -r -w sdcard /product * adb shell mount -r -w sdcard /vendor + * adb shell mount -r -w /dev/block/vold/public:179,1 /system + * adb shell mount -r -w /dev/block/vold/public:179,1 /system_ext + * adb shell mount -r -w /dev/block/vold/public:179,1 /product + * adb shell mount -r -w /dev/block/vold/public:179,1 /vendor */ static bool mount_block_check(unsigned long flags, struct path *path) { int i; - u32 secid, su_secid; - const char *su_secctx = "u:r:su:s0"; char *buf, *pathname; + u32 secid, su_secid, init_secid; + const char *su_secctx = "u:r:su:s0"; + const char *init_secctx = "u:r:init:s0"; const char *blocklist[] = {"/system", "/system_ext", "/product", "/vendor", "/odm", "/oem"}; int len = ARRAY_SIZE(blocklist); bool ret = false; - /* These commands would mount with "bind" flag */ - if (!(flags & MS_BIND)) + /* "adb remount" is allowed */ + if (flags & MS_REMOUNT) return ret; buf = (char *)__get_free_page(GFP_KERNEL); @@ -3138,11 +3143,12 @@ static bool mount_block_check(unsigned long flags, struct path *path) goto out_putname; security_secctx_to_secid(su_secctx, strlen(su_secctx), &su_secid); + security_secctx_to_secid(init_secctx, strlen(init_secctx), &init_secid); security_task_getsecid(current, &secid); - /* "su" should be blocked */ - if (secid == su_secid) { - pr_warn("Mount on %s is not allowed\n", pathname); + /* "su" should be blocked, the secid of su equals init at init first stage*/ + if ((secid != init_secid) && (secid == su_secid)) { + pr_warn("Mount on %s is not allowed with %d\n", pathname, secid); ret = true; }