lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 24 Apr 2012 11:00:10 -0600
From:	Shuah Khan <shuahkhan@...il.com>
To:	Alexander Holler <holler@...oftware.de>
Cc:	shuahkhan@...il.com, linux-kernel@...r.kernel.org,
	Richard Purdie <rpurdie@...ys.net>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH v2] leds: heartbeat: stop on shutdown

On Tue, 2012-04-24 at 18:32 +0200, Alexander Holler wrote:
> Am 24.04.2012 17:24, schrieb Shuah Khan:
> > On Tue, 2012-04-24 at 17:07 +0200, Alexander Holler wrote:
> >> A halted kernel should not show a heartbeat.
> >>
> >> Signed-off-by: Alexander Holler <holler@...oftware.de>
> >> ---
> >>  drivers/leds/ledtrig-heartbeat.c |   18 +++++++++++++++++-
> >>  1 files changed, 17 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/drivers/leds/ledtrig-heartbeat.c b/drivers/leds/ledtrig-heartbeat.c
> >> index 759c0bb..1c05bd9 100644
> >> --- a/drivers/leds/ledtrig-heartbeat.c
> >> +++ b/drivers/leds/ledtrig-heartbeat.c
> >> @@ -18,6 +18,7 @@
> >>  #include <linux/timer.h>
> >>  #include <linux/sched.h>
> >>  #include <linux/leds.h>
> >> +#include <linux/reboot.h>
> >>  #include "leds.h"
> >>  
> >>  struct heartbeat_trig_data {
> >> @@ -101,13 +102,28 @@ static struct led_trigger heartbeat_led_trigger = {
> >>  	.deactivate = heartbeat_trig_deactivate,
> >>  };
> >>  
> >> +static int heartbeat_reboot_notifier(struct notifier_block *nb,
> >> +				     unsigned long code, void *unused)
> >> +{
> >> +	led_trigger_unregister(&heartbeat_led_trigger);
> >> +	return NOTIFY_DONE;
> >> +}
I am sorry I didn't catch this the last time. Do you need to call
unregister here? Looks like trigger is going away with a registered
reboot notifier. Might be fine, since reboot is going to happen.

> >> +
> >> +static struct notifier_block heartbeat_reboot_nb = {
> >> +	.notifier_call = heartbeat_reboot_notifier,
> >> +};
> >> +
> >>  static int __init heartbeat_trig_init(void)
> >>  {
> >> -	return led_trigger_register(&heartbeat_led_trigger);
> >> +	int rc = led_trigger_register(&heartbeat_led_trigger);
> >> +	if( ! rc )
> >> +		register_reboot_notifier(&heartbeat_reboot_nb);
> > 
> > Do you need to check return value here? I see return value being checked
> > in some places in the kernel and not in others. Not checking is fine for
> > now since register_reboot_notifier() always returns 0.
> > 
> > Maybe adding return handling might not be a bad idea to be consistent
> > with other places that do check.
> 
> What to do if it fails? As long as unregister_reboot_notifier() doesn't
> do something bad with non-registered notifiers (which it doesn't), I
> would let the init still succeed. 

Yes I agree that init should still succeed. It might be helpful to throw
out a kernel message when this occurs though since register shouldn't
fail unless there is an error.

> And to not unregister a
> non-registered-reboot_notifier, a long-living bool would be needed.

Yes keeping state is probably required to unregister conditionally.
Since unregistering is safe (simply returns -ENOENT) when called after
register fails. So I would think you can call unregister even when
register fails. 

-- Shuah



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ