seccomp: add a return code to trap to userspace
[sfrench/cifs-2.6.git] / ipc / ipc_sysctl.c
index f87cb29436ef404375a46e825219328623a2aa9e..49f9bf4ffc7f1ae09bc04b833891fcc7d7a5a5a5 100644 (file)
@@ -88,12 +88,33 @@ static int proc_ipc_auto_msgmni(struct ctl_table *table, int write,
        return proc_dointvec_minmax(&ipc_table, write, buffer, lenp, ppos);
 }
 
+static int proc_ipc_sem_dointvec(struct ctl_table *table, int write,
+       void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+       int ret, semmni;
+       struct ipc_namespace *ns = current->nsproxy->ipc_ns;
+
+       semmni = ns->sem_ctls[3];
+       ret = proc_ipc_dointvec(table, write, buffer, lenp, ppos);
+
+       if (!ret)
+               ret = sem_check_semmni(current->nsproxy->ipc_ns);
+
+       /*
+        * Reset the semmni value if an error happens.
+        */
+       if (ret)
+               ns->sem_ctls[3] = semmni;
+       return ret;
+}
+
 #else
 #define proc_ipc_doulongvec_minmax NULL
 #define proc_ipc_dointvec         NULL
 #define proc_ipc_dointvec_minmax   NULL
 #define proc_ipc_dointvec_minmax_orphans   NULL
 #define proc_ipc_auto_msgmni      NULL
+#define proc_ipc_sem_dointvec     NULL
 #endif
 
 static int zero;
@@ -175,7 +196,7 @@ static struct ctl_table ipc_kern_table[] = {
                .data           = &init_ipc_ns.sem_ctls,
                .maxlen         = 4*sizeof(int),
                .mode           = 0644,
-               .proc_handler   = proc_ipc_dointvec,
+               .proc_handler   = proc_ipc_sem_dointvec,
        },
 #ifdef CONFIG_CHECKPOINT_RESTORE
        {