* [PATCH] off-by-1 in kernel/power/main.c
@ 2006-04-22 4:05 dean gaudet
2006-04-22 21:37 ` Pavel Machek
0 siblings, 1 reply; 5+ messages in thread
From: dean gaudet @ 2006-04-22 4:05 UTC (permalink / raw)
To: linux-kernel; +Cc: len.brown
there's an off-by-1 in 2.6.16.9 (and 2.6.17-rc2)
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.
i randomly discovered this because i really wanted to put my box into S5
(for wake on lan) and tried "echo off >/sys/power/state" and was quite
happy that the box entered S5... happy until i compiled a different kernel
and this S5 trick stopped working :)
anyhow, this begs the question, what is the correct way to get a box to
shutdown into s5? on a fc4 box i have here it does that happily, but
ubuntu boxes don't seem to go into s5... and i couldn't figure out from
fc4 patches if they'd changed anything in this area. pointers
appreciated.
btw i can whip up a patch making "off" a valid value for /sys/power/state
...
-dean
Signed-off-by: dean gaudet <dean@arctic.org>
--- linux/kernel/power/main.c.orig 2006-03-19 21:53:29.000000000 -0800
+++ linux/kernel/power/main.c 2006-04-21 20:54:12.000000000 -0700
@@ -272,7 +272,7 @@
if (*s && !strncmp(buf, *s, len))
break;
}
- if (*s)
+ if (state < PM_SUSPEND_MAX && *s)
error = enter_state(state);
else
error = -EINVAL;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] off-by-1 in kernel/power/main.c
2006-04-22 4:05 [PATCH] off-by-1 in kernel/power/main.c dean gaudet
@ 2006-04-22 21:37 ` Pavel Machek
[not found] ` <Pine.LNX.4.64.0604231958020.22072@twinlark.arctic.org>
0 siblings, 1 reply; 5+ messages in thread
From: Pavel Machek @ 2006-04-22 21:37 UTC (permalink / raw)
To: dean gaudet; +Cc: linux-kernel, len.brown
Hi!
> there's an off-by-1 in 2.6.16.9 (and 2.6.17-rc2)
> 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.
>
> i randomly discovered this because i really wanted to put my box into S5
> (for wake on lan) and tried "echo off >/sys/power/state" and was quite
> happy that the box entered S5... happy until i compiled a different kernel
> and this S5 trick stopped working :)
>
> anyhow, this begs the question, what is the correct way to get a box to
> shutdown into s5? on a fc4 box i have here it does that happily, but
> ubuntu boxes don't seem to go into s5... and i couldn't figure out from
> fc4 patches if they'd changed anything in this area. pointers
> appreciated.
>
> btw i can whip up a patch making "off" a valid value for /sys/power/state
> ...
Looks okay to me. Can you add acked-by: Pavel Machek and mail it to
akpm?
Valid way to power off machine is by shutdown -o now, and there's a
syscall to do that. It should not be done by /sys/power/state.
Pavel
--
Thanks for all the (sleeping) penguins.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-04-25 21:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-22 4:05 [PATCH] off-by-1 in kernel/power/main.c dean gaudet
2006-04-22 21:37 ` Pavel Machek
[not found] ` <Pine.LNX.4.64.0604231958020.22072@twinlark.arctic.org>
2006-04-24 7:57 ` Pavel Machek
2006-04-25 21:38 ` dean gaudet
2006-04-25 21:46 ` Pavel Machek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®