Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp640541pxk; Thu, 1 Oct 2020 10:18:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3FedvsvIZWa5eQAtqNk0dZDI82uSCs1yM+htTFElcVM/7bMq7cvW3pMw9KMzvV8KbS3Uy X-Received: by 2002:a05:6402:17b9:: with SMTP id j25mr9403663edy.203.1601572717069; Thu, 01 Oct 2020 10:18:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601572717; cv=none; d=google.com; s=arc-20160816; b=Ob26KIuStpwUNeFIMk4Lelq/mYv/edrpN1RB7P2KOPGGp2k/qpb2uPJnB6fdJHe8cY sAJe8yPlpI37XJxLI+XXd9xqbfvgKTiWE5AygxcdxKRtPlxxIhUSiigndItaLabaon3j x0qVx5r86sytcX31nIhnhNCMEQrHh0SnqMkko16mo5e4EEQdKMS2VaL72S8D6XU6HAKA ILHFnNCUhKUaH/SYknSDx8VxlpsejFVQbKUFKFU617KRH9PuGNJcpZTal/BvcuafxScs 8fx4HBydJD7l1aUCHuN7m3+qC079247wPRJ2ygVndyxFjQj4uI3+EUe1DSaFm5BOABgO UiIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=ZnJOADXNIo+6IgU8cMS5y3VHYnMbB5yJPJqBLynhtC0=; b=yANblkbxVm6mcv1O5G9hcpkoUyDSZXiXXbqcoTT2dUUq+9b6tlnNngWO4Jzv1eq94C 7/t/4Dg+3DI+LfmkBN/2lgLTWMiYt6GoxdKtQ06FrKkeUC17UyRBOzsIPUYg2MeEkzKV V7Lm8rJnEp2Wvc08hM2qoOefk6mIdAFsXVa9OuvQZ9LmpzVgWMWd0IqTHOE/HyGTed69 Ftby59N3zF8SWYe8F+uctzIqu9u+6QWpU5S3DZys+70sBZCM0/Z6sEHIlXJ78Shuyp2G gndAYcOmgli3rYQzb7RN8+yRTWb6arRDeigkkZHUXi3ovobJ3Nz5K1XYjfaQw7mPLU5F XAkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d5si3714144eds.427.2020.10.01.10.18.11; Thu, 01 Oct 2020 10:18:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732867AbgJARRF (ORCPT + 99 others); Thu, 1 Oct 2020 13:17:05 -0400 Received: from mga01.intel.com ([192.55.52.88]:62435 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732096AbgJARRF (ORCPT ); Thu, 1 Oct 2020 13:17:05 -0400 IronPort-SDR: 3U9/b3DvuAGqiaQMQMk9u7v+y2W9Og0vQzkAkWCI+erwzE5b6kPkbBqp2njil281XjRfhq5Ddc emQyp91yVevA== X-IronPort-AV: E=McAfee;i="6000,8403,9761"; a="180940018" X-IronPort-AV: E=Sophos;i="5.77,324,1596524400"; d="scan'208";a="180940018" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Oct 2020 10:17:03 -0700 IronPort-SDR: Qy9H7dXPMlyX8yx4rYKPmXJHd5qx2SPvXIFOuT2LtXocqtLi77HqI0gWkomHGvMFJhLIJaSdXP mu0UKvndlfqw== X-IronPort-AV: E=Sophos;i="5.77,324,1596524400"; d="scan'208";a="346154578" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.160]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Oct 2020 10:17:02 -0700 Date: Thu, 1 Oct 2020 10:17:01 -0700 From: Sean Christopherson To: Jarkko Sakkinen Cc: x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Jethro Beekman , Darren Kenny , Andy Lutomirski , akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, asapek@google.com, bp@alien8.de, cedric.xing@intel.com, chenalexchen@google.com, conradparker@google.com, cyhanish@google.com, dave.hansen@intel.com, haitao.huang@intel.com, josh@joshtriplett.org, kai.huang@intel.com, kai.svahn@intel.com, kmoy@google.com, ludloff@google.com, nhorman@redhat.com, npmccallum@redhat.com, puiterwijk@redhat.com, rientjes@google.com, tglx@linutronix.de, yaozhangx@google.com Subject: Re: [PATCH v38 15/24] x86/sgx: Enable provisioning for remote attestation Message-ID: <20201001171701.GF7474@linux.intel.com> References: <20200915110522.893152-1-jarkko.sakkinen@linux.intel.com> <20200915110522.893152-16-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200915110522.893152-16-jarkko.sakkinen@linux.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 15, 2020 at 02:05:13PM +0300, Jarkko Sakkinen wrote: > +/** > + * sgx_ioc_enclave_set_attribute - handler for %SGX_IOC_ENCLAVE_PROVISION > + * @filep: open file to /dev/sgx > + * @arg: userspace pointer to a struct sgx_enclave_provision instance > + * > + * Mark the enclave as being allowed to access a restricted attribute bit. > + * The requested attribute is specified via the attribute_fd field in the > + * provided struct sgx_enclave_provision. The attribute_fd must be a > + * handle to an SGX attribute file, e.g. "/dev/sgx/provision". > + * > + * Failure to explicitly request access to a restricted attribute will cause > + * sgx_ioc_enclave_init() to fail. Currently, the only restricted attribute > + * is access to the PROVISION_KEY. > + * > + * Note, access to the EINITTOKEN_KEY is disallowed entirely. > + * > + * Return: 0 on success, -errno otherwise > + */ > +static long sgx_ioc_enclave_provision(struct sgx_encl *encl, > + void __user *arg) > +{ > + struct sgx_enclave_provision params; > + struct file *attribute_file; > + int ret; > + > + if (copy_from_user(¶ms, arg, sizeof(params))) > + return -EFAULT; > + > + attribute_file = fget(params.attribute_fd); > + if (!attribute_file) > + return -EINVAL; > + > + if (attribute_file->f_op != &sgx_provision_fops) { > + ret = -EINVAL; > + goto out; > + } > + > + encl->attributes |= SGX_ATTR_PROVISIONKEY; This is wrong, it needs to be encl->attributes_mask |= SGX_ATTR_PROVISION; else sgx_encl_init() will fail this check if (encl->attributes & ~encl->attributes_mask) return -EACCES; This obviously needs a selftest... > + ret = 0; > + > +out: > + fput(attribute_file); > + return ret; > +}