Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1287768pxx; Tue, 27 Oct 2020 12:49:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFpmlyNrnqlqmk8pTBl0vQEidJXjGPqdAgdLsNLH0Ud9sqrV+QVLOh4shpoZW/OEG32xh6 X-Received: by 2002:a17:906:ec9:: with SMTP id u9mr4113776eji.400.1603828179703; Tue, 27 Oct 2020 12:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603828179; cv=none; d=google.com; s=arc-20160816; b=HloQnZE5/bNNv7utsF408sU7sS406wjMMR2RPW+H9sZZDXtRIy12Dg42J1kbCzTWkV 02NneqP0z0whCZhr+tyEOpLzWotwl7Ld1HWwHLmKaIBiiTO154fmAHyXX0pbgdD/Mxdl ZmJddACJpCBhzyPHdhkMBFlMAO4BqXXdix6EAU8HAxZwTIQHyBse87y7y9lgMTQsTp90 toTd3he2eTRlATS6wR+MnzuxSG3bf0HooKQlb7E6aFe8E5eV5iCxeAn0HjuexFeoTyG8 54k0LQtQ2r7S+VFWoSCyhWNGEfwLlFLLMzs5LZRSBObk458lprI+0+m8GhROdVHNxGV4 2nKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=g3XKLaDHzT43BnFvHWNewHZCY35mbcF9+HX7QvmwSAU=; b=Z1zRqFApj5r8owjfsGk9XedzhVX9LfMGc0NPC9syUz3rdOyc9/xQSE1CK3Zc10j+7K YCILuyr1U9c0ubc4Y3TMMA8XCnto5nZaOFqsylWdTEgvDt1nxDYzlQLcywMVOJohRWBv HPGSGOpmKRqbQL8lRx02fzUJpwZzMzuemx9XUVbUBNuaw0Q0oL8x//H++0CrSnWzPzaU X/e1FP5mVZPUm+W8YTkEoeA4x/1IN55exDJCgoyTjX05XQYQOGTskdwhO2GnV+Oqb2Au v6ZW/t+RjvE692yKoVJbw8yP2IC1TpTuiSVI5vNB4jh884UexzRwy4VavPXQfNCLx6sr Vqnw== 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 j19si1695581edr.278.2020.10.27.12.49.17; Tue, 27 Oct 2020 12:49:39 -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 S2504164AbgJ0Bwj (ORCPT + 99 others); Mon, 26 Oct 2020 21:52:39 -0400 Received: from mga11.intel.com ([192.55.52.93]:51802 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504096AbgJ0Bwi (ORCPT ); Mon, 26 Oct 2020 21:52:38 -0400 IronPort-SDR: rNjZPY7aXlEG+ybqppJ4uP6hZ1jupA49ZkwTXhGPsjjJS1qYrsygtj+2DogbNy1rJXLol89HWE Uy5NdqKJzNQg== X-IronPort-AV: E=McAfee;i="6000,8403,9786"; a="164514575" X-IronPort-AV: E=Sophos;i="5.77,422,1596524400"; d="scan'208";a="164514575" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2020 18:52:38 -0700 IronPort-SDR: WdrM7rPOQvoovwU+u7WV+/22loPSyDzXqJN6/dML2KH4k8uF1KXsZboyYCxa/AgDGp4BUGR0vK RDCFNvCQj0tw== X-IronPort-AV: E=Sophos;i="5.77,422,1596524400"; d="scan'208";a="303599154" Received: from ksprzacz-mobl1.ger.corp.intel.com (HELO linux.intel.com) ([10.252.59.214]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2020 18:52:26 -0700 Date: Tue, 27 Oct 2020 03:52:22 +0200 From: Jarkko Sakkinen To: Dave Hansen Cc: Borislav Petkov , x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Jethro Beekman , Haitao Huang , Chunyang Hui , Jordan Hand , Nathaniel McCallum , Seth Moore , Sean Christopherson , Suresh Siddha , akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, asapek@google.com, cedric.xing@intel.com, chenalexchen@google.com, conradparker@google.com, cyhanish@google.com, haitao.huang@intel.com, josh@joshtriplett.org, kai.huang@intel.com, kai.svahn@intel.com, kmoy@google.com, ludloff@google.com, luto@kernel.org, nhorman@redhat.com, puiterwijk@redhat.com, rientjes@google.com, tglx@linutronix.de, yaozhangx@google.com Subject: Re: [PATCH v33 11/21] x86/sgx: Linux Enclave Driver Message-ID: <20201027015222.GC20485@linux.intel.com> References: <20200617220844.57423-1-jarkko.sakkinen@linux.intel.com> <20200617220844.57423-12-jarkko.sakkinen@linux.intel.com> <20200626153400.GE27151@zn.tnic> <1ada871a-2350-1007-c625-a00bdb0d439b@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1ada871a-2350-1007-c625-a00bdb0d439b@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 26, 2020 at 02:26:13PM -0700, Dave Hansen wrote: > On 6/26/20 8:34 AM, Borislav Petkov wrote: > >> + if (!(atomic_read(&encl->flags) & SGX_ENCL_CREATED)) > >> + return -EINVAL; > >> + > >> + if (copy_from_user(&addp, arg, sizeof(addp))) > >> + return -EFAULT; > >> + > >> + if (!IS_ALIGNED(addp.offset, PAGE_SIZE) || > >> + !IS_ALIGNED(addp.src, PAGE_SIZE)) > >> + return -EINVAL; > >> + > >> + if (!(access_ok(addp.src, PAGE_SIZE))) > >> + return -EFAULT; > >> + > >> + if (addp.length & (PAGE_SIZE - 1)) > >> + return -EINVAL; > > How many pages are allowed? Unlimited? I'm hoping some limits are > > checked somewhere... > > What were you concerned about here? Was it how long the syscall could > take, or that one user could exhaust all the enclave memory in one call? > > Some later versions of this patch have a 1MB limit per to reduce how > long each SGX_IOC_ENCLAVE_ADD_PAGES call spends in the kernel. But, I'm > not _sure_ that's what you were intending. The loop does check for pending signals, i.e. it is possible to interrupt it. /Jarkko