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] [day] [month] [year] [list]
Message-ID: <20110325122139.GA27651@dumpdata.com>
Date:	Fri, 25 Mar 2011 08:21:39 -0400
From:	Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
To:	John Stultz <john.stultz@...aro.org>
Cc:	tglx@...utronix.de, xen-devel@...ts.xensource.com,
	linux-kernel@...r.kernel.org
Subject: Re: [Xen-devel] Re: 2.6.39 crashes BUG: unable to handle kernel
 NULL pointer dereference at 000000000000042 .. cmos_checkintr+0x4d/0x55
 under Xen as PV guest.

On Thu, Mar 24, 2011 at 01:39:34PM -0700, John Stultz wrote:
> On Thu, 2011-03-24 at 12:05 -0700, John Stultz wrote:
> > Or... more likely, the added rtc_set_alarm is enabling interrupts,
> > allowing an irq to land before the rtc_device_register completes.
> > 
> > Oof.. ok. so that is a little gross.
> > 
> > 
> > Let me see if I can't work something out here.
> 
> Konrad: Can you give this patch a shot to see if it changes the
> behavior?

Yup. It fixes it. Tested on PV i386 and x86_64 case. And also
as the initial domain as 32-bit and 64-bit.

Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>

Thank you for fixing it!
> 
> Basically we still initialize the alarm timer from whatever the hardware
> is set to at boot time, but don't use the standard rtc_set_alarm, and
> instead initialize the aie_timer and enqueue it by hand.
> 
> That should avoid having rtc_set_alarm enabling irqs possibly too early.
> 
> thanks
> -john
> 
> 
> 
> Signed-off-by: John Stultz <john.stultz@...aro.org>
> 
> diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
> index 09b4437..3901386 100644
> --- a/drivers/rtc/class.c
> +++ b/drivers/rtc/class.c
> @@ -171,7 +171,7 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev,
>  	err = __rtc_read_alarm(rtc, &alrm);
>  
>  	if (!err && !rtc_valid_tm(&alrm.time))
> -		rtc_set_alarm(rtc, &alrm);
> +		rtc_initialize_alarm(rtc, &alrm);
>  
>  	strlcpy(rtc->name, name, RTC_DEVICE_NAME_SIZE);
>  	dev_set_name(&rtc->dev, "rtc%d", id);
> diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
> index 8ec6b06..b2fea80 100644
> --- a/drivers/rtc/interface.c
> +++ b/drivers/rtc/interface.c
> @@ -375,6 +375,32 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
>  }
>  EXPORT_SYMBOL_GPL(rtc_set_alarm);
>  
> +/* Called once per device from rtc_device_register */
> +int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
> +{
> +	int err;
> +
> +	err = rtc_valid_tm(&alarm->time);
> +	if (err != 0)
> +		return err;
> +
> +	err = mutex_lock_interruptible(&rtc->ops_lock);
> +	if (err)
> +		return err;
> +
> +	rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time);
> +	rtc->aie_timer.period = ktime_set(0, 0);
> +	if (alarm->enabled) {
> +		rtc->aie_timer.enabled = 1;
> +		timerqueue_add(&rtc->timerqueue, &rtc->aie_timer.node);
> +	}
> +	mutex_unlock(&rtc->ops_lock);
> +	return err;
> +}
> +EXPORT_SYMBOL_GPL(rtc_initialize_alarm);
> +
> +
> +
>  int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled)
>  {
>  	int err = mutex_lock_interruptible(&rtc->ops_lock);
> diff --git a/include/linux/rtc.h b/include/linux/rtc.h
> index 2ca7e8a..877ece4 100644
> --- a/include/linux/rtc.h
> +++ b/include/linux/rtc.h
> @@ -228,6 +228,8 @@ extern int rtc_read_alarm(struct rtc_device *rtc,
>  			struct rtc_wkalrm *alrm);
>  extern int rtc_set_alarm(struct rtc_device *rtc,
>  				struct rtc_wkalrm *alrm);
> +extern int rtc_initialize_alarm(struct rtc_device *rtc,
> +				struct rtc_wkalrm *alrm);
>  extern void rtc_update_irq(struct rtc_device *rtc,
>  			unsigned long num, unsigned long events);
>  
> 
--
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