Merge branch 'limits_cleanup' of git://decibel.fi.muni.cz/~xslaby/linux

* 'limits_cleanup' of git://decibel.fi.muni.cz/~xslaby/linux:
  resource: add helpers for fetching rlimits
  resource: move kernel function inside __KERNEL__
  SECURITY: selinux, fix update_rlimit_cpu parameter
This commit is contained in:
Linus Torvalds 2010-01-04 12:36:54 -08:00
commit c5974b835a
3 changed files with 29 additions and 3 deletions

View File

@ -3,8 +3,6 @@
#include <linux/time.h>
struct task_struct;
/*
* Resource control/accounting header file for linux
*/
@ -70,6 +68,12 @@ struct rlimit {
*/
#include <asm/resource.h>
#ifdef __KERNEL__
struct task_struct;
int getrusage(struct task_struct *p, int who, struct rusage __user *ru);
#endif /* __KERNEL__ */
#endif

View File

@ -2601,6 +2601,28 @@ static inline void mm_init_owner(struct mm_struct *mm, struct task_struct *p)
}
#endif /* CONFIG_MM_OWNER */
static inline unsigned long task_rlimit(const struct task_struct *tsk,
unsigned int limit)
{
return ACCESS_ONCE(tsk->signal->rlim[limit].rlim_cur);
}
static inline unsigned long task_rlimit_max(const struct task_struct *tsk,
unsigned int limit)
{
return ACCESS_ONCE(tsk->signal->rlim[limit].rlim_max);
}
static inline unsigned long rlimit(unsigned int limit)
{
return task_rlimit(current, limit);
}
static inline unsigned long rlimit_max(unsigned int limit)
{
return task_rlimit_max(current, limit);
}
#endif /* __KERNEL__ */
#endif

View File

@ -2365,7 +2365,7 @@ static void selinux_bprm_committing_creds(struct linux_binprm *bprm)
initrlim = init_task.signal->rlim + i;
rlim->rlim_cur = min(rlim->rlim_max, initrlim->rlim_cur);
}
update_rlimit_cpu(rlim->rlim_cur);
update_rlimit_cpu(current->signal->rlim[RLIMIT_CPU].rlim_cur);
}
}