[Devel] [PATCH RHEL7 COMMIT] ve/sysctl: add macro sysctl_virtual to unify sysctl's virtualization

Konstantin Khorenko khorenko at virtuozzo.com
Wed Feb 3 07:05:23 PST 2016


The commit is pushed to "branch-rh7-3.10.0-327.3.1-vz7.10.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.3.1.vz7.10.9
------>
commit fc72222d5ab7dd9c69644cccf6d12b77f9391cf6
Author: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Date:   Wed Feb 3 19:05:21 2016 +0400

    ve/sysctl: add macro sysctl_virtual to unify sysctl's virtualization
    
    Need in next patch for kernel.core_pattern sysctl.
    
    https://jira.sw.ru/browse/PSBM-43596
    
    v2: put syscall_virtual closer to the top of kernel/sysctl.c
    
    Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
    Reviewed-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 kernel/sysctl.c | 33 +++++++++++++--------------------
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index a32154d..c2dbbf7 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -173,6 +173,17 @@ extern int unaligned_dump_stack;
 extern int no_unaligned_warning;
 #endif
 
+static bool virtual_ptr(void **ptr, void *base, size_t size, void *cur);
+#define sysctl_virtual(sysctl)							\
+int sysctl ## _virtual(struct ctl_table *table, int write,			\
+		        void __user *buffer, size_t *lenp, loff_t *ppos)	\
+{										\
+	struct ctl_table tmp = *table;						\
+	if (virtual_ptr(&tmp.data, &ve0, sizeof(ve0), get_exec_env()))		\
+		return sysctl(&tmp, write, buffer, lenp, ppos);			\
+	return -EINVAL;								\
+}
+
 #ifdef CONFIG_PROC_SYSCTL
 static int proc_do_cad_pid(struct ctl_table *table, int write,
 		  void __user *buffer, size_t *lenp, loff_t *ppos);
@@ -2742,26 +2753,8 @@ static bool virtual_ptr(void **ptr, void *base, size_t size, void *cur)
 	return false;
 }
 
-int proc_dointvec_virtual(struct ctl_table *table, int write,
-		void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-	struct ctl_table tmp = *table;
-
-	if (virtual_ptr(&tmp.data, &ve0, sizeof(ve0), get_exec_env()))
-		return proc_dointvec(&tmp, write, buffer, lenp, ppos);
-	return -EINVAL;
-}
-
-int proc_doulongvec_minmax_virtual(struct ctl_table *table, int write,
-				void __user *buffer, size_t *lenp,
-				loff_t *ppos)
-{
-	struct ctl_table tmp = *table;
-
-	if (virtual_ptr(&tmp.data, &ve0, sizeof(ve0), get_exec_env()))
-		return proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
-	return -EINVAL;
-}
+sysctl_virtual(proc_dointvec);
+sysctl_virtual(proc_doulongvec_minmax);
 
 static inline bool sysctl_in_container(void)
 {


More information about the Devel mailing list