Patch "sysctl: Allow creating permanently empty directories that serve as mountpoints." has been added to the 4.0-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
sysctl: Allow creating permanently empty directories that serve as mountpoints.
to the 4.0-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
sysctl-allow-creating-permanently-empty-directories-that-serve-as-mountpoints.patch
and it can be found in the queue-4.0 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
f9bd6733d3f11e24f3949becf277507d422ee1ebMon Sep 17 00:00:00 2001
From: "Eric W. Biederman" <[email protected]>
Date: Sat, 9 May 2015 22:09:14 -0500
Subject: sysctl: Allow creating permanently empty directories that serve as mountpoints.
From: "Eric W. Biederman" <[email protected]>
commit f9bd6733d3f11e24f3949becf277507d422ee1eb upstream.
Add a magic sysctl table sysctl_mount_point that when used to create a directory forces that directory to be permanently empty.
Update the code to use make_empty_dir_inode when accessing permanently empty directories.
Update the code to not allow adding to permanently empty directories.
Update /proc/sys/fs/binfmt_misc to be a permanently empty directory.
--- fs/proc/proc_sysctl.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/sysctl.h | 3 +++ kernel/sysctl.c | 8 +------- 3 files changed, 41 insertions(+), 7 deletions(-)
fs/proc/proc_sysctl.c +37 -0
@@ -19,6 +19,28 @@ static const struct inode_operations prostatic const struct file_operations proc_sys_dir_file_operations;static const struct inode_operations proc_sys_dir_operations; +/* Support for permanently empty directories */ + +struct ctl_table sysctl_mount_point[] = { + { } +}; + +static bool is_empty_dir (struct ctl_table_header *head) +{ +return head->ctl_table[0 ].child == sysctl_mount_point; +} + +static void set_empty_dir (struct ctl_dir *dir) +{ + dir->header.ctl_table[0 ].child = sysctl_mount_point; +} + +static void clear_empty_dir (struct ctl_dir *dir) + +{ + dir->header.ctl_table[0 ].child =NULL ; +} +void proc_sys_poll_notify (struct ctl_table_poll *poll) {if (!poll)
@@ -187,6 +209,17 @@ static int insert_header(struct ctl_dirstruct ctl_table *entry;int err; +/* Is this a permanently empty directory? */ +if (is_empty_dir (&dir->header)) +return -EROFS ; + +/* Am I creating a permanently empty directory? */ +if (header->ctl_table == sysctl_mount_point) { +if (!RB_EMPTY_ROOT (&dir->root)) +return -EINVAL ; +set_empty_dir (dir); + } + dir->header.nreg++; header->parent = dir; err =insert_links (header);
@@ -202,6 +235,8 @@ fail:erase_header (header);put_links (header); fail_links: +if (header->ctl_table == sysctl_mount_point) +clear_empty_dir (dir); header->parent =NULL ;drop_sysctl_table (&dir->header);return err;
@@ -419,6 +454,8 @@ static struct inode *proc_sys_make_inode inode->i_mode |=S_IFDIR ; inode->i_op = &proc_sys_dir_operations; inode->i_fop = &proc_sys_dir_file_operations; +if (is_empty_dir (head)) +make_empty_dir_inode (inode); } out:return inode;
include/linux/sysctl.h +3 -0
@@ -188,6 +188,9 @@ struct ctl_table_header *register_sysctlvoid unregister_sysctl_table (struct ctl_table_header * table);extern int sysctl_init (void ); + +extern struct ctl_table sysctl_mount_point[]; +#else /* CONFIG_SYSCTL */ static inline struct ctl_table_header *register_sysctl_table (struct ctl_table * table) {
kernel/sysctl.c +1 -7
@@ -1510,12 +1510,6 @@ static struct ctl_table vm_table[] = { { } }; -#if defined(CONFIG_BINFMT_MISC ) || defined(CONFIG_BINFMT_MISC_MODULE ) -static struct ctl_table binfmt_misc_table[] = { - { } -}; -#endif -static struct ctl_table fs_table[] = { { .procname ="inode-nr" ,
@@ -1669,7 +1663,7 @@ static struct ctl_table fs_table[] = { { .procname = "binfmt_misc", .mode = 0555, - .child = binfmt_misc_table, + .child = sysctl_mount_point, }, #endif {
Patches currently in stable-queue which might be from [email protected] are
queue-4.0/sysfs-create-mountpoints-with-sysfs_create_mount_point.patch queue-4.0/sysfs-add-support-for-permanently-empty-directories-to-serve-as-mount-points.patch queue-4.0/mnt-update-fs_fully_visible-to-test-for-permanently-empty-directories.patch queue-4.0/mnt-refactor-the-logic-for-mounting-sysfs-and-proc-in-a-user-namespace.patch queue-4.0/mnt-modify-fs_fully_visible-to-deal-with-locked-ro-nodev-and-atime.patch queue-4.0/fs-add-helper-functions-for-permanently-empty-directories.patch queue-4.0/sysctl-allow-creating-permanently-empty-directories-that-serve-as-mountpoints.patch queue-4.0/kernfs-add-support-for-always-empty-directories.patch queue-4.0/proc-allow-creating-permanently-empty-directories-that-serve-as-mount-points.patch