[Devel] [PATCH v2 RH7 1/2] ve/sysctl: add macro sysctl_virtual to unify sysctl's virtualization

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Tue Feb 2 06:26:34 PST 2016


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>
---
 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)
 {
-- 
1.9.3



More information about the Devel mailing list