|
@@ -1171,26 +1171,37 @@ static int s390_gs_cb_set(struct task_struct *target,
|
|
unsigned int pos, unsigned int count,
|
|
unsigned int pos, unsigned int count,
|
|
const void *kbuf, const void __user *ubuf)
|
|
const void *kbuf, const void __user *ubuf)
|
|
{
|
|
{
|
|
- struct gs_cb *data = target->thread.gs_cb;
|
|
|
|
|
|
+ struct gs_cb gs_cb = { }, *data = NULL;
|
|
int rc;
|
|
int rc;
|
|
|
|
|
|
if (!MACHINE_HAS_GS)
|
|
if (!MACHINE_HAS_GS)
|
|
return -ENODEV;
|
|
return -ENODEV;
|
|
- if (!data) {
|
|
|
|
|
|
+ if (!target->thread.gs_cb) {
|
|
data = kzalloc(sizeof(*data), GFP_KERNEL);
|
|
data = kzalloc(sizeof(*data), GFP_KERNEL);
|
|
if (!data)
|
|
if (!data)
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
- data->gsd = 25;
|
|
|
|
- target->thread.gs_cb = data;
|
|
|
|
- if (target == current)
|
|
|
|
- __ctl_set_bit(2, 4);
|
|
|
|
- } else if (target == current) {
|
|
|
|
- save_gs_cb(data);
|
|
|
|
}
|
|
}
|
|
|
|
+ if (!target->thread.gs_cb)
|
|
|
|
+ gs_cb.gsd = 25;
|
|
|
|
+ else if (target == current)
|
|
|
|
+ save_gs_cb(&gs_cb);
|
|
|
|
+ else
|
|
|
|
+ gs_cb = *target->thread.gs_cb;
|
|
rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
|
|
rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
|
|
- data, 0, sizeof(struct gs_cb));
|
|
|
|
- if (target == current)
|
|
|
|
- restore_gs_cb(data);
|
|
|
|
|
|
+ &gs_cb, 0, sizeof(gs_cb));
|
|
|
|
+ if (rc) {
|
|
|
|
+ kfree(data);
|
|
|
|
+ return -EFAULT;
|
|
|
|
+ }
|
|
|
|
+ preempt_disable();
|
|
|
|
+ if (!target->thread.gs_cb)
|
|
|
|
+ target->thread.gs_cb = data;
|
|
|
|
+ *target->thread.gs_cb = gs_cb;
|
|
|
|
+ if (target == current) {
|
|
|
|
+ __ctl_set_bit(2, 4);
|
|
|
|
+ restore_gs_cb(target->thread.gs_cb);
|
|
|
|
+ }
|
|
|
|
+ preempt_enable();
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
|
|
|