Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] off-by-1 in kernel/power/main.c

There's an off-by-1 in kernel/power/main.c:state_store() ... if your
kernel just happens to have some non-zero data at pm_states[PM_SUSPEND_MAX]
(i.e. one past the end of the array) then it'll let you write anything you
want to /sys/power/state and in response the box will enter S5.

Signed-off-by: dean gaudet <dean@arctic.org>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

dean gaudet and committed by
Linus Torvalds
47bb7899 37e53db8

+1 -1
+1 -1
kernel/power/main.c
··· 272 272 if (*s && !strncmp(buf, *s, len)) 273 273 break; 274 274 } 275 - if (*s) 275 + if (state < PM_SUSPEND_MAX && *s) 276 276 error = enter_state(state); 277 277 else 278 278 error = -EINVAL;