Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiroslav Benes <mbenes@suse.cz>2018-12-11 11:27:23 +0100
committerMiroslav Benes <mbenes@suse.cz>2018-12-11 11:27:23 +0100
commitd4e00de0b0a3f858fec4e83640f12e1f17298667 (patch)
treed3d156cd6491581be242ca323222a67ffa6ee359
parentcf2464af30b57408c3fb25f78534afa86a3c6091 (diff)
uname_patch: don't hold uts_sem while accessing userspace memory
Backport upstream patch 42a0cc347858 ("sys: don't hold uts_sem while accessing userspace memory"). Signed-off-by: Miroslav Benes <mbenes@suse.cz>
-rw-r--r--uname_patch/kgr_patch_uname.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/uname_patch/kgr_patch_uname.c b/uname_patch/kgr_patch_uname.c
index 3a53f83..fb2dae2 100644
--- a/uname_patch/kgr_patch_uname.c
+++ b/uname_patch/kgr_patch_uname.c
@@ -107,23 +107,23 @@ out:
asmlinkage long kgr_sys_newuname(struct new_utsname __user *name)
{
- int errno = 0;
+ struct new_utsname tmp;
char kgr_version[65] = { 0 };
down_read(kgr_uts_sem);
- if (copy_to_user(name, utsname(), sizeof *name))
- errno = -EFAULT;
+ memcpy(&tmp, utsname(), sizeof(tmp));
memcpy(kgr_version, utsname()->version, sizeof(utsname()->version));
up_read(kgr_uts_sem);
+ if (copy_to_user(name, &tmp, sizeof(tmp)))
+ return -EFAULT;
- if (!errno && override_release(name->release, sizeof(name->release)))
- errno = -EFAULT;
- if (!errno && override_architecture(name))
- errno = -EFAULT;
- if (!errno && override_version(name->version, sizeof(name->version),
- kgr_version))
- errno = -EFAULT;
- return errno;
+ if (override_release(name->release, sizeof(name->release)))
+ return -EFAULT;
+ if (override_architecture(name))
+ return -EFAULT;
+ if (override_version(name->version, sizeof(name->version), kgr_version))
+ return -EFAULT;
+ return 0;
}
int kgr_patch_uname_init(void)