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] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 8 Oct 2021 10:52:05 -0500
From:   Brijesh Singh <brijesh.singh@....com>
To:     Peter Gonda <pgonda@...gle.com>, thomas.lendacky@....com
Cc:     brijesh.singh@....com, Marc Orr <marcorr@...gle.com>,
        Joerg Roedel <jroedel@...e.de>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        David Rientjes <rientjes@...gle.com>,
        John Allen <john.allen@....com>,
        "David S. Miller" <davem@...emloft.net>,
        linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] crypto: ccp - Consolidate sev INIT logic


On 10/5/21 12:52 PM, Peter Gonda wrote:
>  
> +static int sev_init_if_required(int cmd_id, bool writable,
> +				struct sev_issue_cmd *argp)
> +{
> +	struct sev_device *sev = psp_master->sev_data;
> +
> +	lockdep_assert_held(&sev_cmd_mutex);
> +
> +	if (!writable)
> +		return -EPERM;
> +
> +	if (cmd_id == SEV_FACTORY_RESET || cmd_id == SEV_PLATFORM_STATUS ||
> +	    cmd_id == SEV_GET_ID || cmd_id == SEV_GET_ID2)
> +		return 0;
> +
> +	if (sev->state == SEV_STATE_UNINIT)
> +		return __sev_platform_init_locked(&argp->error);
> +
> +	return 0;
> +}
> +
>  static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg)
>  {
>  	void __user *argp = (void __user *)arg;
> @@ -840,8 +825,11 @@ static long sev_ioctl(struct file *file, unsigned int ioctl, unsigned long arg)
>  
>  	mutex_lock(&sev_cmd_mutex);
>  
> -	switch (input.cmd) {
> +	ret = sev_init_if_required(input.cmd, writable, &input);
> +	if (ret)
> +		goto copy_out;

We need to call this function only for the SEV commands (i.e input.cmd
>=0 && input.cmd <= SEV_GET_ID2). Otherwise a invalid command may
trigger SEV_INIT. e.g below sequence:

1) SEV_FACTORY_RESET   // this will transition the fw to UNINIT state.

2) <INVALID_CMD_ID>   // since fw was in uninit this invalid command
will initialize the fw and then later switch will fail.

thanks


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ