lkml.org 
[lkml]   [2020]   [Jul]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 04/24] devtmpfs: open code do_mount
Date
Replace do_umount with an open coded version that takes the proper
kernel pointer instead of relying on the implicit set_fs(KERNEL_DS)
during early init.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/base/devtmpfs.c | 17 +++++++++++++++--
fs/namespace.c | 2 +-
include/linux/mount.h | 3 +++
3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index c9017e0584c003..5e8d677ee783bc 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -345,6 +345,19 @@ static int handle_remove(const char *nodename, struct device *dev)
return err;
}

+static int devtmpfs_do_mount(const char __user *dir_name)
+{
+ struct path p;
+ int ret;
+
+ ret = kern_path(dir_name, LOOKUP_FOLLOW, &p);
+ if (ret)
+ return ret;
+ ret = path_mount("devtmpfs", &p, "devtmpfs", MS_SILENT, NULL);
+ path_put(&p);
+ return ret;
+}
+
/*
* If configured, or requested by the commandline, devtmpfs will be
* auto-mounted after the kernel mounted the root filesystem.
@@ -359,7 +372,7 @@ int __init devtmpfs_mount(void)
if (!thread)
return 0;

- err = do_mount("devtmpfs", "dev", "devtmpfs", MS_SILENT, NULL);
+ err = devtmpfs_do_mount("dev");
if (err)
printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
else
@@ -385,7 +398,7 @@ static int devtmpfs_setup(void *p)
err = ksys_unshare(CLONE_NEWNS);
if (err)
goto out;
- err = do_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, NULL);
+ err = devtmpfs_do_mount("/");
if (err)
goto out;
ksys_chdir("/.."); /* will traverse into overmounted root */
diff --git a/fs/namespace.c b/fs/namespace.c
index 43834b59eff6c3..2c4d7592097485 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -3111,7 +3111,7 @@ char *copy_mount_string(const void __user *data)
* Therefore, if this magic number is present, it carries no information
* and must be discarded.
*/
-static int path_mount(const char *dev_name, struct path *path,
+int path_mount(const char *dev_name, struct path *path,
const char *type_page, unsigned long flags, void *data_page)
{
unsigned int mnt_flags = 0, sb_flags;
diff --git a/include/linux/mount.h b/include/linux/mount.h
index de657bd211fa64..bf9896f86a48f4 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -113,4 +113,7 @@ extern bool path_is_mountpoint(const struct path *path);

extern void kern_unmount_array(struct vfsmount *mnt[], unsigned int num);

+int path_mount(const char *dev_name, struct path *path, const char *type_page,
+ unsigned long flags, void *data_page);
+
#endif /* _LINUX_MOUNT_H */
--
2.27.0
\
 
 \ /
  Last update: 2020-07-21 18:29    [W:0.227 / U:0.428 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site