diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-06-16 22:57:16 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-06-17 20:49:05 +0200 |
commit | 6b060c1dc5486cbf51f13d168c442e7df116b26c (patch) | |
tree | 45ab36ae9f4a405c22dc082b226c361e886fe726 /ncr-limits.c | |
parent | 5797051e8b1f3ac4d6cc5edf181a04536b496d3d (diff) | |
download | cryptodev-linux-6b060c1dc5486cbf51f13d168c442e7df116b26c.tar.gz cryptodev-linux-6b060c1dc5486cbf51f13d168c442e7df116b26c.tar.xz cryptodev-linux-6b060c1dc5486cbf51f13d168c442e7df116b26c.zip |
Use current_euid() and task_pid_nr(current) to get identifiers for owners (for imposed limits).
Diffstat (limited to 'ncr-limits.c')
-rw-r--r-- | ncr-limits.c | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/ncr-limits.c b/ncr-limits.c index 857fc2e..378233c 100644 --- a/ncr-limits.c +++ b/ncr-limits.c @@ -51,7 +51,7 @@ struct limit_user_item_st { struct limit_process_item_st { struct list_head list; - struct pid * pid; + pid_t pid; limits_type_t type; atomic_t cnt; }; @@ -93,21 +93,12 @@ struct limit_user_item_st* uitem, *utmp; } -int ncr_limits_add_and_check(struct file *filp, limits_type_t type) +int ncr_limits_add_and_check(uid_t uid, pid_t pid, limits_type_t type) { struct limit_process_item_st* pitem; struct limit_user_item_st* uitem; -uid_t uid; int add = 1; -/* FIXME: is this uid ok? - */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27) - uid = filp->f_uid; -#else - uid = filp->f_cred->fsuid; -#endif - down(&limits.users.sem); list_for_each_entry(uitem, &limits.users.list, list) { if (uitem->uid == uid && uitem->type == type) { @@ -139,7 +130,7 @@ int add = 1; /* check process limits */ down(&limits.processes.sem); list_for_each_entry(pitem, &limits.processes.list, list) { - if (pitem->pid == filp->f_owner.pid && pitem->type == type) { + if (pitem->pid == pid && pitem->type == type) { add = 0; if (atomic_add_unless(&pitem->cnt, 1, max_per_process[type])==0) { err(); @@ -156,7 +147,7 @@ int add = 1; err(); return -ENOMEM; } - pitem->pid = filp->f_owner.pid; + pitem->pid = task_pid_nr(current); pitem->type = type; atomic_set(&pitem->cnt, 1); @@ -167,19 +158,10 @@ int add = 1; return 0; } -void ncr_limits_remove(struct file *filp, limits_type_t type) +void ncr_limits_remove(uid_t uid, pid_t pid, limits_type_t type) { struct limit_process_item_st* pitem; struct limit_user_item_st* uitem; -uid_t uid; - -/* FIXME: is this uid ok? - */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27) - uid = filp->f_uid; -#else - uid = filp->f_cred->fsuid; -#endif down(&limits.users.sem); list_for_each_entry(uitem, &limits.users.list, list) { @@ -192,11 +174,11 @@ uid_t uid; /* check process limits */ down(&limits.processes.sem); list_for_each_entry(pitem, &limits.processes.list, list) { - if (pitem->pid == filp->f_owner.pid && pitem->type == type) { + if (pitem->pid == pid && pitem->type == type) { atomic_dec(&pitem->cnt); } } - up(&limits.processes.sem); + up(&limits.processes.sem); return; } |