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: <a002bb09-4a94-5c5b-b468-94ca028cd3f6@linux.ibm.com>
Date:   Tue, 6 Nov 2018 10:17:58 -0500
From:   Stefan Berger <stefanb@...ux.ibm.com>
To:     Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>,
        linux-integrity@...r.kernel.org
Cc:     linux-security-module@...r.kernel.org,
        James Bottomley <James.Bottomley@...senPartnership.com>,
        Tomas Winkler <tomas.winkler@...el.com>,
        Tadeusz Struk <tadeusz.struk@...el.com>,
        Stefan Berger <stefanb@...ux.vnet.ibm.com>,
        Nayna Jain <nayna@...ux.ibm.com>,
        Peter Huewe <peterhuewe@....de>,
        Jason Gunthorpe <jgg@...pe.ca>, Arnd Bergmann <arnd@...db.de>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 09/16] tpm: encapsulate tpm_dev_transmit()

On 11/4/18 8:45 PM, Jarkko Sakkinen wrote:
> Encapsulate tpm_transmit() call pattern to tpm_dev_transmit() because it
> is identically used from two places. Use unlocked version of
> tpm_transmit() so that we are able to move the calls to
> tpm2_prepare_space() and tpm2_commit_space() later on to this new
> function.
>
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>
Reviewed-by: Stefan Berger <stefanb@...ux.ibm.com>
> ---
>   drivers/char/tpm/tpm-dev-common.c | 25 ++++++++++++++++++-------
>   1 file changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm-dev-common.c b/drivers/char/tpm/tpm-dev-common.c
> index 99b5133a9d05..cbb0ee30b511 100644
> --- a/drivers/char/tpm/tpm-dev-common.c
> +++ b/drivers/char/tpm/tpm-dev-common.c
> @@ -27,7 +27,19 @@
>   static struct workqueue_struct *tpm_dev_wq;
>   static DEFINE_MUTEX(tpm_dev_wq_lock);
>
> -static void tpm_async_work(struct work_struct *work)
> +static ssize_t tpm_dev_transmit(struct tpm_chip *chip, struct tpm_space *space,
> +				u8 *buf, size_t bufsiz)
> +{
> +	ssize_t ret;
> +
> +	mutex_lock(&chip->tpm_mutex);
> +	ret = tpm_transmit(chip, space, buf, bufsiz, TPM_TRANSMIT_UNLOCKED);
> +	mutex_unlock(&chip->tpm_mutex);
> +
> +	return ret;
> +}
> +
> +static void tpm_dev_async_work(struct work_struct *work)
>   {
>   	struct file_priv *priv =
>   			container_of(work, struct file_priv, async_work);
> @@ -35,9 +47,8 @@ static void tpm_async_work(struct work_struct *work)
>
>   	mutex_lock(&priv->buffer_mutex);
>   	priv->command_enqueued = false;
> -	ret = tpm_transmit(priv->chip, priv->space, priv->data_buffer,
> -			   sizeof(priv->data_buffer), 0);
> -
> +	ret = tpm_dev_transmit(priv->chip, priv->space, priv->data_buffer,
> +			       sizeof(priv->data_buffer));
>   	tpm_put_ops(priv->chip);
>   	if (ret > 0) {
>   		priv->data_pending = ret;
> @@ -78,7 +89,7 @@ void tpm_common_open(struct file *file, struct tpm_chip *chip,
>   	mutex_init(&priv->buffer_mutex);
>   	timer_setup(&priv->user_read_timer, user_reader_timeout, 0);
>   	INIT_WORK(&priv->timeout_work, tpm_timeout_work);
> -	INIT_WORK(&priv->async_work, tpm_async_work);
> +	INIT_WORK(&priv->async_work, tpm_dev_async_work);
>   	init_waitqueue_head(&priv->async_wait);
>   	file->private_data = priv;
>   }
> @@ -163,8 +174,8 @@ ssize_t tpm_common_write(struct file *file, const char __user *buf,
>   		return size;
>   	}
>
> -	ret = tpm_transmit(priv->chip, priv->space, priv->data_buffer,
> -			   sizeof(priv->data_buffer), 0);
> +	ret = tpm_dev_transmit(priv->chip, priv->space, priv->data_buffer,
> +			       sizeof(priv->data_buffer));
>   	tpm_put_ops(priv->chip);
>
>   	if (ret > 0) {


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ