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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 24 Nov 2022 02:55:22 +0200
From:   Jarkko Sakkinen <jarkko@...nel.org>
To:     Lino Sanfilippo <LinoSanfilippo@....de>
Cc:     peterhuewe@....de, jgg@...pe.ca, stefanb@...ux.vnet.ibm.com,
        linux@...ewoehner.de, linux-integrity@...r.kernel.org,
        linux-kernel@...r.kernel.org, jandryuk@...il.com,
        pmenzel@...gen.mpg.de, l.sanfilippo@...bus.com, lukas@...ner.de,
        p.rosenberger@...bus.com
Subject: Re: [PATCH v10 05/14] tpm, tpm_tis: Claim locality before writing
 interrupt registers

On Sun, Nov 20, 2022 at 02:31:25PM +0100, Lino Sanfilippo wrote:
> From: Lino Sanfilippo <l.sanfilippo@...bus.com>
> 
> In tpm_tis_probe_single_irq() interrupt registers TPM_INT_VECTOR,
> TPM_INT_STATUS and TPM_INT_ENABLE are modified to setup the interrupts.
> Currently these modifications are done without holding a locality thus they
> have no effect. Fix this by claiming the (default) locality before the
> registers are written.
> 
> Since now tpm_tis_gen_interrupt() is called with the locality already
> claimed remove locality request and release from this function.
> 
> Signed-off-by: Lino Sanfilippo <l.sanfilippo@...bus.com>
> ---
>  drivers/char/tpm/tpm_tis_core.c | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> index 1eac1279594d..58a53ec534aa 100644
> --- a/drivers/char/tpm/tpm_tis_core.c
> +++ b/drivers/char/tpm/tpm_tis_core.c
> @@ -734,18 +734,11 @@ static void tpm_tis_gen_interrupt(struct tpm_chip *chip)
>  	const char *desc = "attempting to generate an interrupt";
>  	u32 cap2;
>  	cap_t cap;
> -	int ret;
> -
> -	ret = request_locality(chip, 0);
> -	if (ret < 0)
> -		return;
>  
>  	if (chip->flags & TPM_CHIP_FLAG_TPM2)
>  		tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
>  	else
>  		tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0);
> -
> -	release_locality(chip, 0);
>  }
>  
>  /* Register the IRQ and issue a command that will cause an interrupt. If an
> @@ -768,10 +761,16 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
>  	}
>  	priv->irq = irq;
>  
> +	rc = request_locality(chip, 0);
> +	if (rc < 0)
> +		return rc;
> +
>  	rc = tpm_tis_read8(priv, TPM_INT_VECTOR(priv->locality),
>  			   &original_int_vec);
> -	if (rc < 0)
> +	if (rc < 0) {
> +		release_locality(chip, priv->locality);
>  		return rc;
> +	}
>  
>  	rc = tpm_tis_write8(priv, TPM_INT_VECTOR(priv->locality), irq);
>  	if (rc < 0)
> @@ -805,10 +804,12 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
>  	if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) {
>  		tpm_tis_write8(priv, original_int_vec,
>  			       TPM_INT_VECTOR(priv->locality));
> -		return -1;
> +		rc = -1;
>  	}
>  
> -	return 0;
> +	release_locality(chip, priv->locality);
> +
> +	return rc;
>  }
>  
>  /* Try to find the IRQ the TPM is using. This is for legacy x86 systems that
> -- 
> 2.36.1
> 


Reviewed-by: Jarkko Sakkinen <jarkko@...nel.org>

BR, Jarkko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ