Skip to contentSkip to conversation

kmemtrace: move alloc_secdata() and free_secdata() linux/security.h

PATCH In review Pekka Enberg 1 participant 3 messages Mar 24, 2009 – Apr 3, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kmemtrace: move alloc_secdata() and free_secdata() linux/security.h

From: Pekka Enberg <[email protected]>

Impact: cleanup

As suggested by Alexey Dobriyan, move alloc_secdata() and free_secdata() to linux/security.h and make them static inlines again.

Cc Alexey Dobriyan <[email protected]>
Cc Eduard - Gabriel Munteanu <[email protected]>
---
 include/linux/fs.h       |   18 ------------------
 include/linux/security.h |   24 ++++++++++++++++++++++++
 2 files changed, 24 insertions(+), 18 deletions(-)
include/linux/fs.h +0 -18
index 11fdc57..159f7b8 100644
@@ -2230,24 +2230,6 @@ ssize_t simple_attr_read(struct file *file, char __user *buf,
 ssize_t simple_attr_write(struct file *file, const char __user *buf,
 			  size_t len, loff_t *ppos);
 
-
-#ifdef CONFIG_SECURITY
-/*
- * These need to be macros because we cannot include <linux/gfp.h> in this
- * header file.
- */
-#define alloc_secdata()       (char *)get_zeroed_page(GFP_KERNEL)
-#define free_secdata(secdata) free_page((unsigned long) secdata)
-#else
-static inline char *alloc_secdata(void)
-{
-	return (char *)1;
-}
-
-static inline void free_secdata(void *secdata)
-{ }
-#endif	/* CONFIG_SECURITY */
-
 struct ctl_table;
 int proc_nr_files(struct ctl_table *table, int write, struct file *filp,
 		  void __user *buffer, size_t *lenp, loff_t *ppos);
include/linux/security.h +24 -0
index 1f2ab63..e3e2f8a 100644
@@ -32,6 +32,7 @@
 #include <linux/sched.h>
 #include <linux/key.h>
 #include <linux/xfrm.h>
+#include <linux/gfp.h>
 #include <net/flow.h>
 
 /* Maximum number of letters for an LSM name string */
@@ -2966,5 +2967,28 @@ static inline void securityfs_remove(struct dentry *dentry)
 
 #endif
 
+#ifdef CONFIG_SECURITY
+
+static inline char *alloc_secdata(void)
+{
+	return (char *)get_zeroed_page(GFP_KERNEL);
+}
+
+static inline void free_secdata(void *secdata)
+{
+	free_page((unsigned long)secdata);
+}
+
+#else
+
+static inline char *alloc_secdata(void)
+{
+        return (char *)1;
+}
+
+static inline void free_secdata(void *secdata)
+{ }
+#endif /* CONFIG_SECURITY */
+
 #endif /* ! __LINUX_SECURITY_H */
 
Signature · 1 line
1.5.4.3
#1 lore raw

[tip:tracing/kmemtrace] kmemtrace, fs, security: move alloc_secdata() and free_secdata() linux/security.h

Commit-ID:  f3edf88c0f4cd0ef90b6dd18953fb8ca6842d5a8
Gitweb:     http://git.kernel.org/tip/f3edf88c0f4cd0ef90b6dd18953fb8ca6842d5a8
Author:     Pekka Enberg <[email protected]>
AuthorDate: Tue, 24 Mar 2009 17:00:03 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 24 Mar 2009 16:39:13 +0100

kmemtrace, fs, security: move alloc_secdata() and free_secdata() linux/security.h

Impact: cleanup

As suggested by Alexey Dobriyan, move alloc_secdata() and free_secdata() to linux/security.h and make them static inlines again.

LKML-Reference: <1237906803.25315.96.camel@penberg-laptop>

---
 include/linux/fs.h       |   18 ------------------
 include/linux/security.h |   24 ++++++++++++++++++++++++
 2 files changed, 24 insertions(+), 18 deletions(-)
include/linux/fs.h +0 -18
index 11fdc57..159f7b8 100644
@@ -2230,24 +2230,6 @@ ssize_t simple_attr_read(struct file *file, char __user *buf,
 ssize_t simple_attr_write(struct file *file, const char __user *buf,
 			  size_t len, loff_t *ppos);
 
-
-#ifdef CONFIG_SECURITY
-/*
- * These need to be macros because we cannot include <linux/gfp.h> in this
- * header file.
- */
-#define alloc_secdata()       (char *)get_zeroed_page(GFP_KERNEL)
-#define free_secdata(secdata) free_page((unsigned long) secdata)
-#else
-static inline char *alloc_secdata(void)
-{
-	return (char *)1;
-}
-
-static inline void free_secdata(void *secdata)
-{ }
-#endif	/* CONFIG_SECURITY */
-
 struct ctl_table;
 int proc_nr_files(struct ctl_table *table, int write, struct file *filp,
 		  void __user *buffer, size_t *lenp, loff_t *ppos);
include/linux/security.h +24 -0
index 1f2ab63..e3e2f8a 100644
@@ -32,6 +32,7 @@
 #include <linux/sched.h>
 #include <linux/key.h>
 #include <linux/xfrm.h>
+#include <linux/gfp.h>
 #include <net/flow.h>
 
 /* Maximum number of letters for an LSM name string */
@@ -2966,5 +2967,28 @@ static inline void securityfs_remove(struct dentry *dentry)
 
 #endif
 
+#ifdef CONFIG_SECURITY
+
+static inline char *alloc_secdata(void)
+{
+	return (char *)get_zeroed_page(GFP_KERNEL);
+}
+
+static inline void free_secdata(void *secdata)
+{
+	free_page((unsigned long)secdata);
+}
+
+#else
+
+static inline char *alloc_secdata(void)
+{
+        return (char *)1;
+}
+
+static inline void free_secdata(void *secdata)
+{ }
+#endif /* CONFIG_SECURITY */
+
 #endif /* ! __LINUX_SECURITY_H */
 
#2 lore raw

[tip:tracing/kmemtrace-v2] kmemtrace, fs, security: move alloc_secdata() and free_secdata() to linux/security.h

In reply to Pekka Enberg
Commit-ID:  3d544f411f2971eb82f5c52322251eb04494542a
Gitweb:     http://git.kernel.org/tip/3d544f411f2971eb82f5c52322251eb04494542a
Author:     Pekka Enberg <[email protected]>
AuthorDate: Tue, 24 Mar 2009 11:59:23 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 3 Apr 2009 12:08:57 +0200

kmemtrace, fs, security: move alloc_secdata() and free_secdata() to linux/security.h

Impact: cleanup

We want to remove percpu.h from rcupdate.h (for upcoming kmemtrace changes), but this is not possible currently without breaking the build because fs.h has implicit include file depedencies: it uses GFP_* types in inlines but does not include gfp.h.

In practice most fs.h using .c files get gfp.h included implicitly, via an indirect route: via rcupdate.h inclusion - so this underlying problem gets masked in practice.

So we want to solve fs.h's dependency on gfp.h.

gfp.h can not be included here directly because it is not exported and it would break the build the following way:

/home/mingo/tip/usr/include/linux/bsg.h:11: found __[us]{8,16,32,64} type without #include <linux/types.h> /home/mingo/tip/usr/include/linux/fs.h:11: included file 'linux/gfp.h' is not exported make[3]: *** [/home/mingo/tip/usr/include/linux/.check] Error 1
make[2]: *** [linux] Error 2

As suggested by Alexey Dobriyan, move alloc_secdata() and free_secdata() to linux/security.h - they belong there. This also cleans fs.h of GFP_* usage.

Cc Eduard - Gabriel Munteanu <[email protected]>

LKML-Reference: <1237906803.25315.96.camel@penberg-laptop>

---
 include/linux/fs.h       |   21 ---------------------
 include/linux/security.h |   24 ++++++++++++++++++++++++
 2 files changed, 24 insertions(+), 21 deletions(-)
include/linux/fs.h +0 -21
index 61211ad..fc4dc28 100644
@@ -2382,27 +2382,6 @@ ssize_t simple_attr_read(struct file *file, char __user *buf,
 ssize_t simple_attr_write(struct file *file, const char __user *buf,
 			  size_t len, loff_t *ppos);
 
-
-#ifdef CONFIG_SECURITY
-static inline char *alloc_secdata(void)
-{
-	return (char *)get_zeroed_page(GFP_KERNEL);
-}
-
-static inline void free_secdata(void *secdata)
-{
-	free_page((unsigned long)secdata);
-}
-#else
-static inline char *alloc_secdata(void)
-{
-	return (char *)1;
-}
-
-static inline void free_secdata(void *secdata)
-{ }
-#endif	/* CONFIG_SECURITY */
-
 struct ctl_table;
 int proc_nr_files(struct ctl_table *table, int write, struct file *filp,
 		  void __user *buffer, size_t *lenp, loff_t *ppos);
include/linux/security.h +24 -0
index 54ed157..d5fd616 100644
@@ -32,6 +32,7 @@
 #include <linux/sched.h>
 #include <linux/key.h>
 #include <linux/xfrm.h>
+#include <linux/gfp.h>
 #include <net/flow.h>
 
 /* Maximum number of letters for an LSM name string */
@@ -2953,5 +2954,28 @@ static inline void securityfs_remove(struct dentry *dentry)
 
 #endif
 
+#ifdef CONFIG_SECURITY
+
+static inline char *alloc_secdata(void)
+{
+	return (char *)get_zeroed_page(GFP_KERNEL);
+}
+
+static inline void free_secdata(void *secdata)
+{
+	free_page((unsigned long)secdata);
+}
+
+#else
+
+static inline char *alloc_secdata(void)
+{
+        return (char *)1;
+}
+
+static inline void free_secdata(void *secdata)
+{ }
+#endif /* CONFIG_SECURITY */
+
 #endif /* ! __LINUX_SECURITY_H */