linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Lino Sanfilippo <LinoSanfilippo@gmx.de>
Cc: peterhuewe@gmx.de, jgg@ziepe.ca, stefanb@linux.vnet.ibm.com,
	linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
	p.rosenberger@kunbus.com,
	Lino Sanfilippo <l.sanfilippo@kunbus.com>
Subject: Re: [PATCH 3/4] tpm: in tpm2_del_space check if ops pointer is still valid
Date: Sun, 17 Jan 2021 20:13:27 +0200	[thread overview]
Message-ID: <YAR+R0c8HYsVUhZQ@kernel.org> (raw)
In-Reply-To: <1610760161-21982-4-git-send-email-LinoSanfilippo@gmx.de>

On Sat, Jan 16, 2021 at 02:22:40AM +0100, Lino Sanfilippo wrote:
> From: Lino Sanfilippo <l.sanfilippo@kunbus.com>
> 
> In tpm2_del_space() the sessions are flushed by means of the tpm_chip
> operations. However the concerning operations pointer my already be NULL at
> this time in case that the chip has been unregistered (see
> tpm_chip_unregister() which calls tpm_del_char_device() which sets
> chip->ops to NULL).
> Avoid the NULL pointer access by first calling tpm_try_get_ops() to check
> if the operations pointer is still valid and skipping the session flushing
> in case of an unregistered chip.
> 
> Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com>
> ---
>  drivers/char/tpm/tpm2-space.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c
> index 784b8b3..ea6eee9 100644
> --- a/drivers/char/tpm/tpm2-space.c
> +++ b/drivers/char/tpm/tpm2-space.c
> @@ -59,7 +59,7 @@ int tpm2_init_space(struct tpm_space *space, unsigned int buf_size)
>  void tpm2_del_space(struct tpm_chip *chip, struct tpm_space *space)
>  {
>  	mutex_lock(&chip->tpm_mutex);
> -	if (!tpm_chip_start(chip)) {
> +	if (!tpm_try_get_ops(chip) && !tpm_chip_start(chip)) {
>  		tpm2_flush_sessions(chip, space);
>  		tpm_chip_stop(chip);
>  	}
> -- 
> 2.7.4
> 

I have hard time to believe that any of these patches are based on
actual regressions.

/Jarko

  reply	other threads:[~2021-01-17 18:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-16  1:22 [PATCH 0/4] TPM fixes Lino Sanfilippo
2021-01-16  1:22 ` [PATCH 1/4] tpm: in case of error properly cleanup in tpmm_chip_alloc Lino Sanfilippo
2021-01-17 18:08   ` Jarkko Sakkinen
2021-01-16  1:22 ` [PATCH 2/4] tpm: fix reference counting for struct tpm_chip Lino Sanfilippo
2021-01-17 18:11   ` Jarkko Sakkinen
2021-01-16  1:22 ` [PATCH 3/4] tpm: in tpm2_del_space check if ops pointer is still valid Lino Sanfilippo
2021-01-17 18:13   ` Jarkko Sakkinen [this message]
2021-01-24 16:47     ` Lino Sanfilippo
2021-01-26 15:29       ` Jarkko Sakkinen
2021-01-27 15:14         ` Lino Sanfilippo
2021-01-16  1:22 ` [PATCH 4/4] tpm: Provide a function tpm_chip_free() to free tpm chips Lino Sanfilippo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YAR+R0c8HYsVUhZQ@kernel.org \
    --to=jarkko@kernel.org \
    --cc=LinoSanfilippo@gmx.de \
    --cc=jgg@ziepe.ca \
    --cc=l.sanfilippo@kunbus.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.rosenberger@kunbus.com \
    --cc=peterhuewe@gmx.de \
    --cc=stefanb@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).