diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2015-09-10 00:39:06 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-10 22:29:01 +0200 |
commit | 9a5bc726d559221a3394bb8ef97d0abc1ee94d00 (patch) | |
tree | 8d6bcc02409b4754e9641488b03599b28af8e6e4 /fs/affs/super.c | |
parent | kexec: export KERNEL_IMAGE_SIZE to vmcoreinfo (diff) | |
download | linux-9a5bc726d559221a3394bb8ef97d0abc1ee94d00.tar.xz linux-9a5bc726d559221a3394bb8ef97d0abc1ee94d00.zip |
sysctl: fix int -> unsigned long assignments in INT_MIN case
The following
if (val < 0)
*lvalp = (unsigned long)-val;
is incorrect because the compiler is free to assume -val to be positive
and use a sign-extend instruction for extending the bit pattern. This is
a problem if val == INT_MIN:
# echo -2147483648 >/proc/sys/dev/scsi/logging_level
# cat /proc/sys/dev/scsi/logging_level
-18446744071562067968
Cast to unsigned long before negation - that way we first sign-extend and
then negate an unsigned, which is well defined. With this:
# cat /proc/sys/dev/scsi/logging_level
-2147483648
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Cc: Mikulas Patocka <mikulas@twibright.com>
Cc: Robert Xiao <nneonneo@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to '')
0 files changed, 0 insertions, 0 deletions