[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200513152108.25669-3-mcgrof@kernel.org>
Date: Wed, 13 May 2020 15:21:07 +0000
From: Luis Chamberlain <mcgrof@...nel.org>
To: viro@...iv.linux.org.uk, gregkh@...uxfoundation.org,
rafael@...nel.org, ebiederm@...ssion.com, jeyu@...nel.org,
jmorris@...ei.org, keescook@...omium.org, paul@...l-moore.com,
stephen.smalley.work@...il.com, eparis@...isplace.org,
nayna@...ux.ibm.com, zohar@...ux.ibm.com
Cc: scott.branden@...adcom.com, dan.carpenter@...cle.com,
skhan@...uxfoundation.org, geert@...ux-m68k.org,
tglx@...utronix.de, bauerman@...ux.ibm.com, dhowells@...hat.com,
linux-integrity@...r.kernel.org, linux-fsdevel@...r.kernel.org,
kexec@...ts.infradead.org, linux-security-module@...r.kernel.org,
selinux@...r.kernel.org, linux-kernel@...r.kernel.org,
Luis Chamberlain <mcgrof@...nel.org>
Subject: [PATCH 2/3] security: add symbol namespace for reading file data
Certain symbols are not meant to be used by everybody, the security
helpers for reading files directly is one such case. Use a symbol
namespace for them.
This will prevent abuse of use of these symbols in places they were
not inteded to be used, and provides an easy way to audit where these
types of operations happen as a whole.
Signed-off-by: Luis Chamberlain <mcgrof@...nel.org>
---
drivers/base/firmware_loader/fallback.c | 1 +
fs/exec.c | 2 ++
kernel/kexec.c | 2 ++
kernel/module.c | 2 ++
security/security.c | 6 +++---
5 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/base/firmware_loader/fallback.c b/drivers/base/firmware_loader/fallback.c
index d9ac7296205e..b088886dafda 100644
--- a/drivers/base/firmware_loader/fallback.c
+++ b/drivers/base/firmware_loader/fallback.c
@@ -19,6 +19,7 @@
*/
MODULE_IMPORT_NS(FIRMWARE_LOADER_PRIVATE);
+MODULE_IMPORT_NS(SECURITY_READ);
extern struct firmware_fallback_config fw_fallback_config;
diff --git a/fs/exec.c b/fs/exec.c
index 9791b9eef9ce..30bd800ab1d6 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -72,6 +72,8 @@
#include <trace/events/sched.h>
+MODULE_IMPORT_NS(SECURITY_READ);
+
int suid_dumpable = 0;
static LIST_HEAD(formats);
diff --git a/kernel/kexec.c b/kernel/kexec.c
index f977786fe498..8d572b41a157 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -19,6 +19,8 @@
#include "kexec_internal.h"
+MODULE_IMPORT_NS(SECURITY_READ);
+
static int copy_user_segment_list(struct kimage *image,
unsigned long nr_segments,
struct kexec_segment __user *segments)
diff --git a/kernel/module.c b/kernel/module.c
index 80faaf2116dd..8973a463712e 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -59,6 +59,8 @@
#include <uapi/linux/module.h>
#include "module-internal.h"
+MODULE_IMPORT_NS(SECURITY_READ);
+
#define CREATE_TRACE_POINTS
#include <trace/events/module.h>
diff --git a/security/security.c b/security/security.c
index 8ae66e4c370f..bdbd1fc5105a 100644
--- a/security/security.c
+++ b/security/security.c
@@ -1654,7 +1654,7 @@ int security_kernel_read_file(struct file *file, enum kernel_read_file_id id)
return ret;
return ima_read_file(file, id);
}
-EXPORT_SYMBOL_GPL(security_kernel_read_file);
+EXPORT_SYMBOL_NS_GPL(security_kernel_read_file, SECURITY_READ);
int security_kernel_post_read_file(struct file *file, char *buf, loff_t size,
enum kernel_read_file_id id)
@@ -1666,7 +1666,7 @@ int security_kernel_post_read_file(struct file *file, char *buf, loff_t size,
return ret;
return ima_post_read_file(file, buf, size, id);
}
-EXPORT_SYMBOL_GPL(security_kernel_post_read_file);
+EXPORT_SYMBOL_NS_GPL(security_kernel_post_read_file, SECURITY_READ);
int security_kernel_load_data(enum kernel_load_data_id id)
{
@@ -1677,7 +1677,7 @@ int security_kernel_load_data(enum kernel_load_data_id id)
return ret;
return ima_load_data(id);
}
-EXPORT_SYMBOL_GPL(security_kernel_load_data);
+EXPORT_SYMBOL_NS_GPL(security_kernel_load_data, SECURITY_READ);
int security_task_fix_setuid(struct cred *new, const struct cred *old,
int flags)
--
2.26.2
Powered by blists - more mailing lists