|
@@ -130,14 +130,20 @@ static int rseq_get_rseq_cs(struct task_struct *t, struct rseq_cs *rseq_cs)
|
|
urseq_cs = (struct rseq_cs __user *)ptr;
|
|
urseq_cs = (struct rseq_cs __user *)ptr;
|
|
if (copy_from_user(rseq_cs, urseq_cs, sizeof(*rseq_cs)))
|
|
if (copy_from_user(rseq_cs, urseq_cs, sizeof(*rseq_cs)))
|
|
return -EFAULT;
|
|
return -EFAULT;
|
|
- if (rseq_cs->version > 0)
|
|
|
|
- return -EINVAL;
|
|
|
|
|
|
|
|
|
|
+ if (rseq_cs->start_ip >= TASK_SIZE ||
|
|
|
|
+ rseq_cs->start_ip + rseq_cs->post_commit_offset >= TASK_SIZE ||
|
|
|
|
+ rseq_cs->abort_ip >= TASK_SIZE ||
|
|
|
|
+ rseq_cs->version > 0)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ /* Check for overflow. */
|
|
|
|
+ if (rseq_cs->start_ip + rseq_cs->post_commit_offset < rseq_cs->start_ip)
|
|
|
|
+ return -EINVAL;
|
|
/* Ensure that abort_ip is not in the critical section. */
|
|
/* Ensure that abort_ip is not in the critical section. */
|
|
if (rseq_cs->abort_ip - rseq_cs->start_ip < rseq_cs->post_commit_offset)
|
|
if (rseq_cs->abort_ip - rseq_cs->start_ip < rseq_cs->post_commit_offset)
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
- usig = (u32 __user *)(rseq_cs->abort_ip - sizeof(u32));
|
|
|
|
|
|
+ usig = (u32 __user *)(unsigned long)(rseq_cs->abort_ip - sizeof(u32));
|
|
ret = get_user(sig, usig);
|
|
ret = get_user(sig, usig);
|
|
if (ret)
|
|
if (ret)
|
|
return ret;
|
|
return ret;
|
|
@@ -146,7 +152,7 @@ static int rseq_get_rseq_cs(struct task_struct *t, struct rseq_cs *rseq_cs)
|
|
printk_ratelimited(KERN_WARNING
|
|
printk_ratelimited(KERN_WARNING
|
|
"Possible attack attempt. Unexpected rseq signature 0x%x, expecting 0x%x (pid=%d, addr=%p).\n",
|
|
"Possible attack attempt. Unexpected rseq signature 0x%x, expecting 0x%x (pid=%d, addr=%p).\n",
|
|
sig, current->rseq_sig, current->pid, usig);
|
|
sig, current->rseq_sig, current->pid, usig);
|
|
- return -EPERM;
|
|
|
|
|
|
+ return -EINVAL;
|
|
}
|
|
}
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|