Skip to contentSkip to conversation

use clamp_t in UNAME26 fix

PATCH In review Kees Cook 3 participants 4 messages Oct 20, 2012 – Oct 24, 2012

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 use clamp_t in UNAME26 fix

The min/max call needed to have explicit types on some architectures (e.g. mn10300). Use clamp_t instead to avoid the warning.

kernel/sys.c: In function 'override_release':
kernel/sys.c:1287:10: warning: comparison of distinct pointer types lacks a cast [enabled by default]

---
 kernel/sys.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sys.c +1 -1
index 01865c6..e6e0ece 100644
@@ -1284,7 +1284,7 @@ static int override_release(char __user *release, size_t len)
 			rest++;
 		}
 		v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40;
-		copy = min(sizeof(buf), max_t(size_t, 1, len));
+		copy = clamp_t(size_t, len, 1, sizeof(buf));
 		copy = scnprintf(buf, copy, "2.6.%u%s", v, rest);
 		ret = copy_to_user(release, buf, copy + 1);
 	}
Signature · 6 lines
1.7.9.5


-- 
Kees Cook
Chrome OS Security
#1 lore raw
Quoted 9 lines · On Fri, 19 Oct 2012 18:45:53 -0700 Kees Cook <[email protected]> wrote:

The min/max call needed to have explicit types on some architectures (e.g. mn10300). Use clamp_t instead to avoid the warning.

kernel/sys.c: In function 'override_release':
kernel/sys.c:1287:10: warning: comparison of distinct pointer types lacks a cast [enabled by default]

Needs a cc:stable in the changelog before committing, please.

author
#2 lore raw

Argh, whoops. Greg, can you please include 31fd84b95eb211d5db460a1dda85e004800a7b52 in stable?

Thanks,

-Kees

Quoted 13 lines · Andrew Morton
Quoted 9 lines · On Fri, 19 Oct 2012 18:45:53 -0700 Kees Cook <[email protected]> wrote:

The min/max call needed to have explicit types on some architectures (e.g. mn10300). Use clamp_t instead to avoid the warning.

kernel/sys.c: In function 'override_release':
kernel/sys.c:1287:10: warning: comparison of distinct pointer types lacks a cast [enabled by default]

Needs a cc:stable in the changelog before committing, please.

Signature · 2 lines
Kees Cook
Chrome OS Security
#3 lore raw
Quoted 2 lines · Kees Cook

Argh, whoops. Greg, can you please include 31fd84b95eb211d5db460a1dda85e004800a7b52 in stable?

Now applied, thanks.

greg k-h