Commit b9c54f91 authored by Andy Walker's avatar Andy Walker Committed by David S. Miller

[SPARC]: Fix regression in sys_getdomainname()

This patch corrects the buffer length checking in the
sys_getdomainname() implementation for sparc/sparc64.
Signed-off-by: default avatarAndy Walker <andy@puszczka.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b9b64e6e
...@@ -470,19 +470,21 @@ asmlinkage int sys_getdomainname(char __user *name, int len) ...@@ -470,19 +470,21 @@ asmlinkage int sys_getdomainname(char __user *name, int len)
{ {
int nlen, err; int nlen, err;
if (len < 0 || len > __NEW_UTS_LEN) if (len < 0)
return -EINVAL; return -EINVAL;
down_read(&uts_sem); down_read(&uts_sem);
nlen = strlen(system_utsname.domainname) + 1; nlen = strlen(system_utsname.domainname) + 1;
if (nlen < len) err = -EINVAL;
len = nlen; if (nlen > len)
goto out;
err = -EFAULT; err = -EFAULT;
if (!copy_to_user(name, system_utsname.domainname, len)) if (!copy_to_user(name, system_utsname.domainname, nlen))
err = 0; err = 0;
out:
up_read(&uts_sem); up_read(&uts_sem);
return err; return err;
} }
...@@ -707,19 +707,21 @@ asmlinkage long sys_getdomainname(char __user *name, int len) ...@@ -707,19 +707,21 @@ asmlinkage long sys_getdomainname(char __user *name, int len)
{ {
int nlen, err; int nlen, err;
if (len < 0 || len > __NEW_UTS_LEN) if (len < 0)
return -EINVAL; return -EINVAL;
down_read(&uts_sem); down_read(&uts_sem);
nlen = strlen(system_utsname.domainname) + 1; nlen = strlen(system_utsname.domainname) + 1;
if (nlen < len) err = -EINVAL;
len = nlen; if (nlen > len)
goto out;
err = -EFAULT; err = -EFAULT;
if (!copy_to_user(name, system_utsname.domainname, len)) if (!copy_to_user(name, system_utsname.domainname, nlen))
err = 0; err = 0;
out:
up_read(&uts_sem); up_read(&uts_sem);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment