diff options
Diffstat (limited to 'kernel/sys.c')
-rw-r--r-- | kernel/sys.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index c5cb5b99cb81..e6e0ece5f6a0 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -1265,15 +1265,16 @@ DECLARE_RWSEM(uts_sem); | |||
1265 | * Work around broken programs that cannot handle "Linux 3.0". | 1265 | * Work around broken programs that cannot handle "Linux 3.0". |
1266 | * Instead we map 3.x to 2.6.40+x, so e.g. 3.0 would be 2.6.40 | 1266 | * Instead we map 3.x to 2.6.40+x, so e.g. 3.0 would be 2.6.40 |
1267 | */ | 1267 | */ |
1268 | static int override_release(char __user *release, int len) | 1268 | static int override_release(char __user *release, size_t len) |
1269 | { | 1269 | { |
1270 | int ret = 0; | 1270 | int ret = 0; |
1271 | char buf[65]; | ||
1272 | 1271 | ||
1273 | if (current->personality & UNAME26) { | 1272 | if (current->personality & UNAME26) { |
1274 | char *rest = UTS_RELEASE; | 1273 | const char *rest = UTS_RELEASE; |
1274 | char buf[65] = { 0 }; | ||
1275 | int ndots = 0; | 1275 | int ndots = 0; |
1276 | unsigned v; | 1276 | unsigned v; |
1277 | size_t copy; | ||
1277 | 1278 | ||
1278 | while (*rest) { | 1279 | while (*rest) { |
1279 | if (*rest == '.' && ++ndots >= 3) | 1280 | if (*rest == '.' && ++ndots >= 3) |
@@ -1283,8 +1284,9 @@ static int override_release(char __user *release, int len) | |||
1283 | rest++; | 1284 | rest++; |
1284 | } | 1285 | } |
1285 | v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40; | 1286 | v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40; |
1286 | snprintf(buf, len, "2.6.%u%s", v, rest); | 1287 | copy = clamp_t(size_t, len, 1, sizeof(buf)); |
1287 | ret = copy_to_user(release, buf, len); | 1288 | copy = scnprintf(buf, copy, "2.6.%u%s", v, rest); |
1289 | ret = copy_to_user(release, buf, copy + 1); | ||
1288 | } | 1290 | } |
1289 | return ret; | 1291 | return ret; |
1290 | } | 1292 | } |