qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] spapr-tpm-proxy: Drop misleading check
@ 2019-09-09 18:10 Greg Kurz
  2019-09-09 19:05 ` Michael Roth
  2019-09-09 23:01 ` David Gibson
  0 siblings, 2 replies; 3+ messages in thread
From: Greg Kurz @ 2019-09-09 18:10 UTC (permalink / raw)
  To: David Gibson
  Cc: qemu-trivial, Peter Maydell, qemu-ppc, qemu-devel, Michael Roth

Coverity is reporting in CID 1405304 that tpm_execute() may pass a NULL
tpm_proxy->host_path pointer to open(). This is based on the fact that
h_tpm_comm() does a NULL check on tpm_proxy->host_path and then passes
tpm_proxy to tpm_execute().

The check in h_tpm_comm() is abusive actually since a spapr-proxy-tpm
requires a non NULL host_path property, as checked during realize.

Fixes: 0fb6bd073230
Signed-off-by: Greg Kurz <groug@kaod.org>
---
 hw/ppc/spapr_tpm_proxy.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/ppc/spapr_tpm_proxy.c b/hw/ppc/spapr_tpm_proxy.c
index b835d25be6f6..ca1caec113f0 100644
--- a/hw/ppc/spapr_tpm_proxy.c
+++ b/hw/ppc/spapr_tpm_proxy.c
@@ -114,7 +114,7 @@ static target_ulong h_tpm_comm(PowerPCCPU *cpu,
         return H_FUNCTION;
     }
 
-    trace_spapr_h_tpm_comm(tpm_proxy->host_path ?: "null", op);
+    trace_spapr_h_tpm_comm(tpm_proxy->host_path, op);
 
     switch (op) {
     case TPM_COMM_OP_EXECUTE:



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] spapr-tpm-proxy: Drop misleading check
  2019-09-09 18:10 [Qemu-devel] [PATCH] spapr-tpm-proxy: Drop misleading check Greg Kurz
@ 2019-09-09 19:05 ` Michael Roth
  2019-09-09 23:01 ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Roth @ 2019-09-09 19:05 UTC (permalink / raw)
  To: David Gibson, Greg Kurz; +Cc: qemu-trivial, Peter Maydell, qemu-ppc, qemu-devel

Quoting Greg Kurz (2019-09-09 13:10:09)
> Coverity is reporting in CID 1405304 that tpm_execute() may pass a NULL
> tpm_proxy->host_path pointer to open(). This is based on the fact that
> h_tpm_comm() does a NULL check on tpm_proxy->host_path and then passes
> tpm_proxy to tpm_execute().
> 
> The check in h_tpm_comm() is abusive actually since a spapr-proxy-tpm
> requires a non NULL host_path property, as checked during realize.
> 
> Fixes: 0fb6bd073230
> Signed-off-by: Greg Kurz <groug@kaod.org>

Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>

Thanks for the quick fix!

> ---
>  hw/ppc/spapr_tpm_proxy.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/ppc/spapr_tpm_proxy.c b/hw/ppc/spapr_tpm_proxy.c
> index b835d25be6f6..ca1caec113f0 100644
> --- a/hw/ppc/spapr_tpm_proxy.c
> +++ b/hw/ppc/spapr_tpm_proxy.c
> @@ -114,7 +114,7 @@ static target_ulong h_tpm_comm(PowerPCCPU *cpu,
>          return H_FUNCTION;
>      }
> 
> -    trace_spapr_h_tpm_comm(tpm_proxy->host_path ?: "null", op);
> +    trace_spapr_h_tpm_comm(tpm_proxy->host_path, op);
> 
>      switch (op) {
>      case TPM_COMM_OP_EXECUTE:
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] spapr-tpm-proxy: Drop misleading check
  2019-09-09 18:10 [Qemu-devel] [PATCH] spapr-tpm-proxy: Drop misleading check Greg Kurz
  2019-09-09 19:05 ` Michael Roth
@ 2019-09-09 23:01 ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: David Gibson @ 2019-09-09 23:01 UTC (permalink / raw)
  To: Greg Kurz; +Cc: qemu-trivial, Peter Maydell, qemu-ppc, qemu-devel, Michael Roth

[-- Attachment #1: Type: text/plain, Size: 1353 bytes --]

On Mon, Sep 09, 2019 at 08:10:09PM +0200, Greg Kurz wrote:
> Coverity is reporting in CID 1405304 that tpm_execute() may pass a NULL
> tpm_proxy->host_path pointer to open(). This is based on the fact that
> h_tpm_comm() does a NULL check on tpm_proxy->host_path and then passes
> tpm_proxy to tpm_execute().
> 
> The check in h_tpm_comm() is abusive actually since a spapr-proxy-tpm
> requires a non NULL host_path property, as checked during realize.
> 
> Fixes: 0fb6bd073230
> Signed-off-by: Greg Kurz <groug@kaod.org>

Applied to ppc-for-4.2, thanks.

> ---
>  hw/ppc/spapr_tpm_proxy.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/ppc/spapr_tpm_proxy.c b/hw/ppc/spapr_tpm_proxy.c
> index b835d25be6f6..ca1caec113f0 100644
> --- a/hw/ppc/spapr_tpm_proxy.c
> +++ b/hw/ppc/spapr_tpm_proxy.c
> @@ -114,7 +114,7 @@ static target_ulong h_tpm_comm(PowerPCCPU *cpu,
>          return H_FUNCTION;
>      }
>  
> -    trace_spapr_h_tpm_comm(tpm_proxy->host_path ?: "null", op);
> +    trace_spapr_h_tpm_comm(tpm_proxy->host_path, op);
>  
>      switch (op) {
>      case TPM_COMM_OP_EXECUTE:
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-09-09 23:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-09 18:10 [Qemu-devel] [PATCH] spapr-tpm-proxy: Drop misleading check Greg Kurz
2019-09-09 19:05 ` Michael Roth
2019-09-09 23:01 ` David Gibson

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).