Files
erofs-linux/kernel
Ilya Dryomov 9a5bc726d5 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 <[email protected]>
Cc: Mikulas Patocka <[email protected]>
Cc: Robert Xiao <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Kees Cook <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
2015-09-10 13:29:01 -07:00
..
…
…
…
…
…
…
…
…
…
2015-08-07 13:59:49 +02:00
…
…
…
2015-08-03 11:34:16 +02:00
…
2015-08-27 19:40:58 -04:00
…
…
…
…
…
…
…
…
…
…
…
…
…
2015-09-04 16:54:41 -07:00
…
…
…
…
…
…
…