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]
Message-ID: <20140827173142.GA11183@obsidianresearch.com>
Date:	Wed, 27 Aug 2014 11:31:42 -0600
From:	Jason Gunthorpe <jgunthorpe@...idianresearch.com>
To:	Scot Doyle <lkml14@...tdoyle.com>
Cc:	Peter Huewe <peterhuewe@....de>, Ashley Lai <ashley@...leylai.com>,
	Marcel Selhorst <tpmdd@...horst.net>,
	Stefan Berger <stefanb@...ux.vnet.ibm.com>,
	Luigi Semenzato <semenzato@...gle.com>,
	tpmdd-devel@...ts.sourceforge.net, linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH v2] tpm_tis: verify interrupt during init

On Wed, Aug 27, 2014 at 04:31:56AM +0000, Scot Doyle wrote:
> > I think you'll have to directly test in the tis driver if the
> > interrupt is working.
> >
> > The ordering in the TIS driver is wrong, interrupts should be turned
> > on before any TPM commands are issued. This is what other drivers are
> > doing.
> >
> > If you fix this, tis can then just count interrupts recieved and check
> > if that is 0 to detect failure and then turn them off.
> 
> How about something like this?
> 
> It doesn't enable stock SeaBIOS machines to suspend/resume before the 30 
> second interrupt timeout, unless using interrupts=0 or force=1.

? Can you explain that a bit more? interrupts should be detected off
by suspend/resume time, surely?

> +static bool interrupted = false;
> +

This needs to be stored in the private data.

>  static irqreturn_t tis_int_handler(int dummy, void *dev_id)
>  {
>  	struct tpm_chip *chip = dev_id;
> @@ -511,6 +513,8 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
>  		for (i = 0; i < 5; i++)
>  			if (check_locality(chip, i) >= 0)
>  				break;
> +	if (interrupt & TPM_INTF_CMD_READY_INT)
> +		interrupted = true;

Hmm, I'd think any interrupt will do for this purpose, drop the if?

> -	if (tpm_do_selftest(chip)) {
> -		dev_err(dev, "TPM self test failed\n");
> -		rc = -ENODEV;
> -		goto out_err;
> -	}

Move gettimeout too

> -	if (chip->vendor.irq) {
> +	if (interrupts && chip->vendor.irq) {

Unrelated? Looks unnecessary:

        if (!interrupts) {
                irq = 0;

        chip->vendor.irq = irq;

        if (chip->vendor.irq) {

> +	/* Test interrupt and/or prepare for later save state */
> +	interrupted = false;
> +	if (tpm_do_selftest(chip)) {

As you pointed out before, the commands don't actually fail if
interrupts are not enabled, they just take a longer time to complete.

So this should just be:

if (!tpm_get_timeouts(chip))
   goto ..failed..;

if (!dev->interrupts) {
			/* Turn off interrupt */
			iowrite32(intmask,
				  chip->vendor.iobase +
				  TPM_INT_ENABLE(chip->vendor.locality));
			free_irq(chip->vendor.irq, chip);
			chip->vendor.irq = 0;
dev_err(dev, FIRMWARE_BUG "TPM interrupt is not working, polling instead\n");

// No retry needed, the command completed already.
}

Jason
--
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