diff options
author | Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> | 2010-02-10 19:41:58 -0500 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2010-02-14 17:00:16 -0500 |
commit | bf24fb016c861b7f52be0c36c4cedd3e89afa2e2 (patch) | |
tree | f485ca2e70d8305d9aaecf45b5fd929b68b971b2 /security/tomoyo/realpath.h | |
parent | ca0b7df3374c5566468c17f26fa2dfd3fe3c6a37 (diff) |
TOMOYO: Add refcounter on string data.
Add refcounter to "struct tomoyo_name_entry" and replace tomoyo_save_name()
with tomoyo_get_name()/tomoyo_put_name() pair so that we can kfree() when
garbage collector is added.
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/tomoyo/realpath.h')
-rw-r--r-- | security/tomoyo/realpath.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/security/tomoyo/realpath.h b/security/tomoyo/realpath.h index da4f06ff6f8d..b94cb512adb5 100644 --- a/security/tomoyo/realpath.h +++ b/security/tomoyo/realpath.h | |||
@@ -43,7 +43,7 @@ bool tomoyo_memory_ok(void *ptr); | |||
43 | * Keep the given name on the RAM. | 43 | * Keep the given name on the RAM. |
44 | * The RAM is shared, so NEVER try to modify or kfree() the returned name. | 44 | * The RAM is shared, so NEVER try to modify or kfree() the returned name. |
45 | */ | 45 | */ |
46 | const struct tomoyo_path_info *tomoyo_save_name(const char *name); | 46 | const struct tomoyo_path_info *tomoyo_get_name(const char *name); |
47 | 47 | ||
48 | /* Check for memory usage. */ | 48 | /* Check for memory usage. */ |
49 | int tomoyo_read_memory_counter(struct tomoyo_io_buffer *head); | 49 | int tomoyo_read_memory_counter(struct tomoyo_io_buffer *head); |
@@ -54,4 +54,23 @@ int tomoyo_write_memory_quota(struct tomoyo_io_buffer *head); | |||
54 | /* Initialize realpath related code. */ | 54 | /* Initialize realpath related code. */ |
55 | void __init tomoyo_realpath_init(void); | 55 | void __init tomoyo_realpath_init(void); |
56 | 56 | ||
57 | /* | ||
58 | * tomoyo_name_entry is a structure which is used for linking | ||
59 | * "struct tomoyo_path_info" into tomoyo_name_list . | ||
60 | */ | ||
61 | struct tomoyo_name_entry { | ||
62 | struct list_head list; | ||
63 | atomic_t users; | ||
64 | struct tomoyo_path_info entry; | ||
65 | }; | ||
66 | |||
67 | static inline void tomoyo_put_name(const struct tomoyo_path_info *name) | ||
68 | { | ||
69 | if (name) { | ||
70 | struct tomoyo_name_entry *ptr = | ||
71 | container_of(name, struct tomoyo_name_entry, entry); | ||
72 | atomic_dec(&ptr->users); | ||
73 | } | ||
74 | } | ||
75 | |||
57 | #endif /* !defined(_SECURITY_TOMOYO_REALPATH_H) */ | 76 | #endif /* !defined(_SECURITY_TOMOYO_REALPATH_H) */ |