[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.00.1110171752300.19024@chino.kir.corp.google.com>
Date: Mon, 17 Oct 2011 17:55:58 -0700 (PDT)
From: David Rientjes <rientjes@...gle.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
cc: Henrik Grindal Bakken <henribak@...co.com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
linux-kernel@...r.kernel.org
Subject: [patch] Avoid using hardcoded values in kernel/sys.c
The release field of struct new_utsname may always change, so avoid
hardcoded values when setting up a buffer to copy to it.
Signed-off-by: David Rientjes <rientjes@...gle.com>
---
kernel/sys.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/kernel/sys.c b/kernel/sys.c
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1169,10 +1169,11 @@ DECLARE_RWSEM(uts_sem);
* Work around broken programs that cannot handle "Linux 3.0".
* Instead we map 3.x to 2.6.40+x, so e.g. 3.0 would be 2.6.40
*/
-static int override_release(char __user *release, int len)
+static int override_release(char __user *release)
{
+ const int len = sizeof(release);
int ret = 0;
- char buf[65];
+ char buf[len];
if (current->personality & UNAME26) {
char *rest = UTS_RELEASE;
@@ -1202,7 +1203,7 @@ SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
errno = -EFAULT;
up_read(&uts_sem);
- if (!errno && override_release(name->release, sizeof(name->release)))
+ if (!errno && override_release(name->release))
errno = -EFAULT;
if (!errno && override_architecture(name))
errno = -EFAULT;
@@ -1225,7 +1226,7 @@ SYSCALL_DEFINE1(uname, struct old_utsname __user *, name)
error = -EFAULT;
up_read(&uts_sem);
- if (!error && override_release(name->release, sizeof(name->release)))
+ if (!error && override_release(name->release))
error = -EFAULT;
if (!error && override_architecture(name))
error = -EFAULT;
@@ -1261,7 +1262,7 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
if (!error && override_architecture(name))
error = -EFAULT;
- if (!error && override_release(name->release, sizeof(name->release)))
+ if (!error && override_release(name->release))
error = -EFAULT;
return error ? -EFAULT : 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists