diff options
-rw-r--r-- | kernel/sys.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index fe1f3ab20477..926bf9d7ac45 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -1923,6 +1923,16 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim) | |||
1923 | if (retval) | 1923 | if (retval) |
1924 | return retval; | 1924 | return retval; |
1925 | 1925 | ||
1926 | if (resource == RLIMIT_CPU && new_rlim.rlim_cur == 0) { | ||
1927 | /* | ||
1928 | * The caller is asking for an immediate RLIMIT_CPU | ||
1929 | * expiry. But we use the zero value to mean "it was | ||
1930 | * never set". So let's cheat and make it one second | ||
1931 | * instead | ||
1932 | */ | ||
1933 | new_rlim.rlim_cur = 1; | ||
1934 | } | ||
1935 | |||
1926 | task_lock(current->group_leader); | 1936 | task_lock(current->group_leader); |
1927 | *old_rlim = new_rlim; | 1937 | *old_rlim = new_rlim; |
1928 | task_unlock(current->group_leader); | 1938 | task_unlock(current->group_leader); |
@@ -1944,15 +1954,6 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim) | |||
1944 | unsigned long rlim_cur = new_rlim.rlim_cur; | 1954 | unsigned long rlim_cur = new_rlim.rlim_cur; |
1945 | cputime_t cputime; | 1955 | cputime_t cputime; |
1946 | 1956 | ||
1947 | if (rlim_cur == 0) { | ||
1948 | /* | ||
1949 | * The caller is asking for an immediate RLIMIT_CPU | ||
1950 | * expiry. But we use the zero value to mean "it was | ||
1951 | * never set". So let's cheat and make it one second | ||
1952 | * instead | ||
1953 | */ | ||
1954 | rlim_cur = 1; | ||
1955 | } | ||
1956 | cputime = secs_to_cputime(rlim_cur); | 1957 | cputime = secs_to_cputime(rlim_cur); |
1957 | read_lock(&tasklist_lock); | 1958 | read_lock(&tasklist_lock); |
1958 | spin_lock_irq(¤t->sighand->siglock); | 1959 | spin_lock_irq(¤t->sighand->siglock); |