Bug 176935 - NPTL: Error checking in sched_setscheduler
NPTL: Error checking in sched_setscheduler
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel (Show other bugs)
4.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jason Baron
Brian Brock
http://nptl.bullopensource.org/Tests/...
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-01-04 10:27 EST by Tony Reix
Modified: 2013-03-06 00:59 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-06-20 12:12:19 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Tony Reix 2006-01-04 10:27:02 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.7.8) Gecko/20050524 Fedora/1.0.4-4 Firefox/1.0.4

Description of problem:
OPTS test:

sched_setscheduler/19-5.c

 	Tests that an invalid policy cannot be passed to sched_setscheduler.


Details are available at:
http://nptl.bullopensource.org/Tests/results/report.php
Browse: (TC2) 2xi686HT - RHAS4u2 Run 1,2,3

See:
http://nptl.bullopensource.org/Tests/results/detailed.php?run_id=12&testcase_id=3619

Version-Release number of selected component (if applicable):
Unmodified RHEL4u2

How reproducible:
Always

Steps to Reproduce:
Use OPTS.
(Used version was:  OPTS cvs repository on Nov 14, 2005)

Actual Results:  See:
http://nptl.bullopensource.org/Tests/results/detailed.php?run_id=12&testcase_id=3619

Additional info:
Comment 1 Jakub Jelinek 2006-01-04 10:55:42 EST
The test certainly goes beyond what the standard requires, nobody says that
policy number is invalid.
Reassigning to kernel, as glibc sched_setscheduler is just trivial wrapper
around kernel syscall.
And on Linux, policy < 0 means "use the previous policy".
If you pass 136 as policy value, it will certainly fail:
        if (policy < 0)
                policy = oldpolicy = p->policy;
        else {
                retval = -EINVAL;
                if (policy != SCHED_FIFO && policy != SCHED_RR &&
                                policy != SCHED_NORMAL)
                        goto out_unlock;
        }
Comment 2 Tony Reix 2006-01-04 11:01:41 EST
Use the 3 (correct !) URLS:

http://nptl.bullopensource.org/Tests/TC2/report.php#problems

http://nptl.bullopensource.org/Tests/results/run-browse.php
     Click the "Browse" button of : (TC2) 2xi686HT - RHAS4u2 Run 3
     You can also select 2 runs and click the "Compare Selected" button.
Comment 3 Jason Baron 2006-01-16 15:01:08 EST
yes, setcheduler() treats negative values as 'use current policy', but that is
used to implement sys_sched_setparam(), see:

asmlinkage long sys_sched_setparam(pid_t pid, struct sched_param __user *param)
{
        return setscheduler(pid, -1, param);
}

I tend to agree that any invalid value for sched_setscheduler should return
-EINVAL. The manpage has:

EINVAL The scheduling policy is not one of  the  recognized  policies,  or  the
              parameter p does not make sense for the policy.


Therefore, i think the kernel should be changed as follows:

--- linux-2.6.9/kernel/sched.c.bak      2006-01-16 15:07:05.000000000 -0500
+++ linux-2.6.9/kernel/sched.c  2006-01-16 15:08:32.000000000 -0500
@@ -3406,6 +3406,10 @@ out_nounlock:
 asmlinkage long sys_sched_setscheduler(pid_t pid, int policy,
                                       struct sched_param __user *param)
 {
+       /* negative values for policy are not valid */
+       if (policy < 0)
+               return -EINVAL;
+
        return setscheduler(pid, policy, param);
 }



Comment 4 Ulrich Drepper 2006-01-16 15:16:48 EST
Yes, the patch is correct and necessary.  This is a "shall" error which must be
reported.
Comment 5 Jiri Pallich 2012-06-20 12:12:19 EDT
Thank you for submitting this issue for consideration in Red Hat Enterprise Linux. The release for which you requested us to review is now End of Life. 
Please See https://access.redhat.com/support/policy/updates/errata/

If you would like Red Hat to re-consider your feature request for an active release, please re-open the request via appropriate support channels and provide additional supporting details about the importance of this issue.

Note You need to log in before you can comment on or make changes to this bug.