lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed,  6 Apr 2016 17:20:36 -0700
From:	Kees Cook <keescook@...omium.org>
To:	James Morris <jmorris@...ei.org>
Cc:	Kees Cook <keescook@...omium.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Joe Perches <joe@...ches.com>,
	Mimi Zohar <zohar@...ux.vnet.ibm.com>,
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
	"Serge E. Hallyn" <serge@...lyn.com>,
	Kalle Valo <kvalo@...eaurora.org>,
	Mauro Carvalho Chehab <mchehab@....samsung.com>,
	Guenter Roeck <linux@...ck-us.net>,
	Jiri Slaby <jslaby@...e.com>, Paul Moore <pmoore@...hat.com>,
	Stephen Smalley <sds@...ho.nsa.gov>,
	Casey Schaufler <casey@...aufler-ca.com>,
	Andreas Gruenbacher <agruenba@...hat.com>,
	Rasmus Villemoes <linux@...musvillemoes.dk>,
	Ulf Hansson <ulf.hansson@...aro.org>,
	Vitaly Kuznetsov <vkuznets@...hat.com>,
	linux-security-module@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v3 5/6] fs: provide function to report enum strings

Providing human-readable (and audit-parsable) strings for the READING_*
enums is needed by some LSMs.

Signed-off-by: Kees Cook <keescook@...omium.org>
---
v3:
- add general use function, zohar
---
 fs/exec.c          | 19 +++++++++++++++++++
 include/linux/fs.h |  1 +
 2 files changed, 20 insertions(+)

diff --git a/fs/exec.c b/fs/exec.c
index c4010b8207a1..05e71b6c0ef0 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -819,6 +819,25 @@ struct file *open_exec(const char *name)
 }
 EXPORT_SYMBOL(open_exec);
 
+const char *kernel_read_file_id_str(enum kernel_read_file_id id)
+{
+	switch (id) {
+	case READING_FIRMWARE:
+		return "firmware";
+	case READING_MODULE:
+		return "kernel-module";
+	case READING_KEXEC_IMAGE:
+		return "kexec-image";
+	case READING_KEXEC_INITRAMFS:
+		return "kexec-initramfs";
+	case READING_POLICY:
+		return "security-policy";
+	default:
+		return "unknown";
+	}
+}
+EXPORT_SYMBOL(kernel_read_file_id_str);
+
 int kernel_read(struct file *file, loff_t offset,
 		char *addr, unsigned long count)
 {
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 304991a80e23..596b403d5a28 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2589,6 +2589,7 @@ enum kernel_read_file_id {
 	READING_MAX_ID
 };
 
+extern const char *kernel_read_file_id_str(enum kernel_read_file_id id);
 extern int kernel_read(struct file *, loff_t, char *, unsigned long);
 extern int kernel_read_file(struct file *, void **, loff_t *, loff_t,
 			    enum kernel_read_file_id);
-- 
2.6.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ