Skip to content

Commit

Permalink
Merge branch 'limits_cleanup' of git://decibel.fi.muni.cz/~xslaby/linux
Browse files Browse the repository at this point in the history
* '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
  • Loading branch information
Linus Torvalds committed Jan 4, 2010
2 parents 14107c7 + 3e10e71 commit c5974b8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
8 changes: 6 additions & 2 deletions include/linux/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#include <linux/time.h>

struct task_struct;

/*
* Resource control/accounting header file for linux
*/
Expand Down Expand Up @@ -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
22 changes: 22 additions & 0 deletions include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit c5974b8

Please sign in to comment.