diff options
Diffstat (limited to 'kernel/seppl.c')
-rw-r--r-- | kernel/seppl.c | 44 |
1 files changed, 13 insertions, 31 deletions
diff --git a/kernel/seppl.c b/kernel/seppl.c index c580bcd..3b13b0e 100644 --- a/kernel/seppl.c +++ b/kernel/seppl.c @@ -21,15 +21,6 @@ #include <linux/config.h> -#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS) - #define MODVERSIONS -#endif - -#if defined(MODVERSIONS) && !defined(__GENKSYMS__) - #include <linux/modversions.h> - #include "seppl.ver" -#endif - #include <linux/module.h> #include <linux/skbuff.h> #include <linux/interrupt.h> @@ -57,7 +48,6 @@ static spinlock_t keyring_lock = SPIN_LOCK_UNLOCKED; #define PROC_FILE_NAME "seppl_keyring" static struct proc_dir_entry* proc_file = NULL; - struct cipher_info { char *name; int bits; @@ -70,14 +60,14 @@ static const struct cipher_info cipher_dict[CIPHER_DICT_MAX] = { { "aes", 192 } }; -const struct cipher_info *seppl_find_cipher(u8 id) { +static const struct cipher_info *seppl_find_cipher(u8 id) { if (id < CIPHER_DICT_MAX) return &cipher_dict[id]; return NULL; } -struct seppl_key* seppl_find_key(u8 algorithm, const char *name, int r) { +static struct seppl_key* seppl_find_key(u8 algorithm, const char *name, int r) { struct seppl_key *key = NULL, *l; for (l = keyring; l; l = l->next) @@ -95,10 +85,8 @@ struct seppl_key* seppl_claim_key(u8 algorithm, const char *name) { spin_lock_bh(&keyring_lock); // FIXME: BH? - if ((key = seppl_find_key(algorithm, name, 1))) { + if ((key = seppl_find_key(algorithm, name, 1))) atomic_inc(&key->usage); - MOD_INC_USE_COUNT; - } spin_unlock_bh(&keyring_lock); @@ -107,7 +95,6 @@ struct seppl_key* seppl_claim_key(u8 algorithm, const char *name) { void seppl_release_key(struct seppl_key* key) { atomic_dec(&key->usage); - MOD_DEC_USE_COUNT; } // not spinlocked! @@ -129,7 +116,7 @@ void seppl_copy_iv(struct seppl_key *key, u8* iv) { spin_unlock_bh(&key->iv_spinlock); } -int seppl_add_key(u8 algorithm, const char *name, const u8 *key_data) { +static int seppl_add_key(u8 algorithm, const char *name, const u8 *key_data) { struct seppl_key* key = NULL; int r = -EINVAL; int locked = 1; @@ -290,7 +277,8 @@ finish: return r; } -void seppl_clear_keyring(void) { +static void seppl_clear_keyring(void) { + unsigned n = 0; struct seppl_key *key, *prev; printk(KERN_INFO "SEPPL: Clearing keyring\n"); @@ -324,25 +312,23 @@ void seppl_clear_keyring(void) { kfree(k); continue; - } + } else + n++; prev = key; key = key->next; } spin_unlock(&keyring_lock); -} -#ifndef MIN -#define MIN(a,b) ((a)>(b)?(b):(a)) -#endif + printk(KERN_INFO "SEPPL: Cleared keyring, %u keys remain.\n", n); +} static int seppl_proc_read_func(char* page, char** start, off_t off, int count, int* eof, void* data) { struct seppl_key *key; char *e = page; int d = 0; - MOD_INC_USE_COUNT; spin_lock(&keyring_lock); for (key = keyring; key; key = key->next) { @@ -353,12 +339,12 @@ static int seppl_proc_read_func(char* page, char** start, off_t off, int count, if (count <= 0) break; - memcpy(e, key->name, d = MIN(7, count)); + memcpy(e, key->name, d = min(7, count)); e += d; count -= d; if (count <= 0) break; - memcpy(e, key->key, d = MIN(key->keysize, count)); + memcpy(e, key->key, d = min_t(unsigned int, key->keysize, count)); e += d; count -= d; if (count <= 0) break; @@ -369,7 +355,6 @@ static int seppl_proc_read_func(char* page, char** start, off_t off, int count, } spin_unlock(&keyring_lock); - MOD_DEC_USE_COUNT; return e-page; } @@ -378,7 +363,6 @@ static int seppl_proc_read_func(char* page, char** start, off_t off, int count, static int seppl_proc_write_func(struct file* file, const char* buffer, unsigned long count, void* data) { int r = -EINVAL; u8* buf = NULL; - MOD_INC_USE_COUNT; count = count > 10*1024 ? 10*1024 : count; @@ -435,7 +419,6 @@ finish: if (buf) kfree(buf); - MOD_DEC_USE_COUNT; return r; } @@ -448,7 +431,7 @@ static int __init init(void) { proc_file->owner = THIS_MODULE; proc_file->size = 0; - printk("SEPPL: Loaded SEPPL "PACKAGE_VERSION", 2003 by Lennart Poettering <"PACKAGE_BUGREPORT">.\n"); + printk("SEPPL: Loaded SEPPL "PACKAGE_VERSION", 2003,2004 by Lennart Poettering <"PACKAGE_BUGREPORT">.\n"); return 0; } @@ -470,4 +453,3 @@ module_exit(fini); EXPORT_SYMBOL(seppl_copy_iv); EXPORT_SYMBOL(seppl_claim_key); EXPORT_SYMBOL(seppl_release_key); - |