lkml.org 
[lkml]   [2010]   [May]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 06/11] rlimits: do security check under task_lock
    Date
    Do security_task_setrlimit under task_lock. Other tasks may
    change limits under our hands while we are checking limits
    inside the function. From now on, they can't.

    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Acked-by: James Morris <jmorris@namei.org>
    Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Ingo Molnar <mingo@elte.hu>
    ---
    kernel/sys.c | 16 +++++++---------
    1 files changed, 7 insertions(+), 9 deletions(-)

    diff --git a/kernel/sys.c b/kernel/sys.c
    index eb21661..9e9a3a7 100644
    --- a/kernel/sys.c
    +++ b/kernel/sys.c
    @@ -1277,7 +1277,7 @@ int do_setrlimit(struct task_struct *tsk, unsigned int resource,
    struct rlimit *new_rlim)
    {
    struct rlimit *old_rlim;
    - int retval;
    + int retval = 0;

    if (resource >= RLIM_NLIMITS)
    return -EINVAL;
    @@ -1293,10 +1293,6 @@ int do_setrlimit(struct task_struct *tsk, unsigned int resource,
    goto out;
    }

    - retval = security_task_setrlimit(tsk, resource, new_rlim);
    - if (retval)
    - goto out;
    -
    if (resource == RLIMIT_CPU && new_rlim->rlim_cur == 0) {
    /*
    * The caller is asking for an immediate RLIMIT_CPU
    @@ -1309,11 +1305,13 @@ int do_setrlimit(struct task_struct *tsk, unsigned int resource,

    old_rlim = tsk->signal->rlim + resource;
    task_lock(tsk->group_leader);
    - if ((new_rlim->rlim_max <= old_rlim->rlim_max) ||
    - capable(CAP_SYS_RESOURCE))
    - *old_rlim = *new_rlim;
    - else
    + if ((new_rlim->rlim_max > old_rlim->rlim_max) &&
    + !capable(CAP_SYS_RESOURCE))
    retval = -EPERM;
    + if (!retval)
    + retval = security_task_setrlimit(tsk, resource, new_rlim);
    + if (!retval)
    + *old_rlim = *new_rlim;
    task_unlock(tsk->group_leader);

    if (retval || resource != RLIMIT_CPU)
    --
    1.7.1



    \
     
     \ /
      Last update: 2010-05-07 11:21    [W:0.021 / U:128.140 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site