All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] crypto: ccp - Move SEV_INIT retry for corrupted data
@ 2022-01-10 13:02 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2022-01-10 13:02 UTC (permalink / raw)
  To: pgonda; +Cc: linux-crypto

Hello Peter Gonda,

The patch e423b9d75e77: "crypto: ccp - Move SEV_INIT retry for
corrupted data" from Dec 7, 2021, leads to the following Smatch
static checker warning:

	drivers/crypto/ccp/sev-dev.c:430 __sev_platform_init_locked()
	error: uninitialized symbol 'psp_ret'.

drivers/crypto/ccp/sev-dev.c
    412 static int __sev_platform_init_locked(int *error)
    413 {
    414         struct psp_device *psp = psp_master;
    415         struct sev_device *sev;
    416         int rc, psp_ret;
    417         int (*init_function)(int *error);
    418 
    419         if (!psp || !psp->sev_data)
    420                 return -ENODEV;
    421 
    422         sev = psp->sev_data;
    423 
    424         if (sev->state == SEV_STATE_INIT)
    425                 return 0;
    426 
    427         init_function = sev_init_ex_buffer ? __sev_init_ex_locked :
    428                         __sev_init_locked;
    429         rc = init_function(&psp_ret);
--> 430         if (rc && psp_ret == SEV_RET_SECURE_DATA_INVALID) {

There are a bunch of failure paths where "rc" is set and "psp_ret" is
not initialized.

    431                 /*
    432                  * Initialization command returned an integrity check failure
    433                  * status code, meaning that firmware load and validation of SEV
    434                  * related persistent data has failed. Retrying the
    435                  * initialization function should succeed by replacing the state
    436                  * with a reset state.
    437                  */
    438                 dev_dbg(sev->dev, "SEV: retrying INIT command");
    439                 rc = init_function(&psp_ret);
    440         }
    441         if (error)
    442                 *error = psp_ret;
    443 
    444         if (rc)
    445                 return rc;
    446 
    447         sev->state = SEV_STATE_INIT;
    448 
    449         /* Prepare for first SEV guest launch after INIT */
    450         wbinvd_on_all_cpus();
    451         rc = __sev_do_cmd_locked(SEV_CMD_DF_FLUSH, NULL, error);
    452         if (rc)
    453                 return rc;
    454 
    455         dev_dbg(sev->dev, "SEV firmware initialized\n");
    456 
    457         dev_info(sev->dev, "SEV API:%d.%d build:%d\n", sev->api_major,
    458                  sev->api_minor, sev->build);
    459 
    460         return 0;
    461 }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-10 13:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-10 13:02 [bug report] crypto: ccp - Move SEV_INIT retry for corrupted data Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.