diff mbox

[V2,07/12] linux-user: Handle NULL sched_param argument to sched_*

Message ID 1407869623-11185-8-git-send-email-tommusta@gmail.com
State New
Headers show

Commit Message

Tom Musta Aug. 12, 2014, 6:53 p.m. UTC
The sched_getparam, sched_setparam and sched_setscheduler system
calls take a pointer argument to a sched_param structure.  When
this pointer is null, errno should be set to EINVAL.

Signed-off-by: Tom Musta <tommusta@gmail.com>
---
V2: Including sched_setscheduler in the changes per Peter Maydell's
review.

 linux-user/syscall.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

Comments

David Gibson Aug. 26, 2014, 12:43 a.m. UTC | #1
On Tue, Aug 12, 2014 at 01:53:38PM -0500, Tom Musta wrote:
> The sched_getparam, sched_setparam and sched_setscheduler system
> calls take a pointer argument to a sched_param structure.  When
> this pointer is null, errno should be set to EINVAL.
> 
> Signed-off-by: Tom Musta <tommusta@gmail.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
diff mbox

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 79fb3cb..49b8a07 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7702,6 +7702,9 @@  abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             struct sched_param *target_schp;
             struct sched_param schp;
 
+            if (arg2 == 0) {
+                return -TARGET_EINVAL;
+            }
             if (!lock_user_struct(VERIFY_READ, target_schp, arg2, 1))
                 goto efault;
             schp.sched_priority = tswap32(target_schp->sched_priority);
@@ -7713,6 +7716,10 @@  abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         {
             struct sched_param *target_schp;
             struct sched_param schp;
+
+            if (arg2 == 0) {
+                return -TARGET_EINVAL;
+            }
             ret = get_errno(sched_getparam(arg1, &schp));
             if (!is_error(ret)) {
                 if (!lock_user_struct(VERIFY_WRITE, target_schp, arg2, 0))
@@ -7726,6 +7733,9 @@  abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         {
             struct sched_param *target_schp;
             struct sched_param schp;
+            if (arg3 == 0) {
+                return -TARGET_EINVAL;
+            }
             if (!lock_user_struct(VERIFY_READ, target_schp, arg3, 1))
                 goto efault;
             schp.sched_priority = tswap32(target_schp->sched_priority);