aboutsummaryrefslogtreecommitdiffstats
path: root/security/yama/yama_lsm.c
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2013-02-27 11:37:56 -0500
committerKees Cook <keescook@chromium.org>2015-02-27 19:53:09 -0500
commit41a4695ca46d8798f89b477855973eb2ad3f4f69 (patch)
tree5cd16b1a1cdd12c89da6e72995f05b2ce68e1fcb /security/yama/yama_lsm.c
parent04f81f0154e4bf002be6f4d85668ce1257efa4d9 (diff)
Yama: do not modify global sysctl table entry
When the sysctl table is constified, we won't be able to directly modify it. Instead, use a table copy that carries any needed changes. Suggested-by: PaX Team <pageexec@freemail.hu> Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'security/yama/yama_lsm.c')
-rw-r--r--security/yama/yama_lsm.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
index 13c88fbcf037..24aae2ae2b30 100644
--- a/security/yama/yama_lsm.c
+++ b/security/yama/yama_lsm.c
@@ -379,20 +379,17 @@ static struct security_operations yama_ops = {
379static int yama_dointvec_minmax(struct ctl_table *table, int write, 379static int yama_dointvec_minmax(struct ctl_table *table, int write,
380 void __user *buffer, size_t *lenp, loff_t *ppos) 380 void __user *buffer, size_t *lenp, loff_t *ppos)
381{ 381{
382 int rc; 382 struct ctl_table table_copy;
383 383
384 if (write && !capable(CAP_SYS_PTRACE)) 384 if (write && !capable(CAP_SYS_PTRACE))
385 return -EPERM; 385 return -EPERM;
386 386
387 rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
388 if (rc)
389 return rc;
390
391 /* Lock the max value if it ever gets set. */ 387 /* Lock the max value if it ever gets set. */
392 if (write && *(int *)table->data == *(int *)table->extra2) 388 table_copy = *table;
393 table->extra1 = table->extra2; 389 if (*(int *)table_copy.data == *(int *)table_copy.extra2)
390 table_copy.extra1 = table_copy.extra2;
394 391
395 return rc; 392 return proc_dointvec_minmax(&table_copy, write, buffer, lenp, ppos);
396} 393}
397 394
398static int zero; 395static int zero;