Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp532202ybr; Fri, 22 May 2020 12:28:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNnQLHnyM01cI6pTqiAhmg1KUDsfFNRqQDb285exXaWrSJSZ/t+kZKHzOB5v8Fr1++h8xH X-Received: by 2002:a17:906:814b:: with SMTP id z11mr9032577ejw.531.1590175681107; Fri, 22 May 2020 12:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590175681; cv=none; d=google.com; s=arc-20160816; b=xo5UjbkuJ7JRq30Ao1U5GDvuejFOaMn+dUHauCqult8/dgBfilX+RO3mcQwMY/I9pY tl3sP00J/g0SXZPwZwXgrxVEXefm1J9g/LX2S153X1BlzQNwd7jbqlblM9MlcSQHT9xI igwO9AcfJpyXthxaR4oGOMEyhxyxdXxnuj+y29pBvSCUm16CrGcyXQOfiYLEjDU82wPT SroRd2RPDjHCyYpnlfR1ufdvb623u3Yu8z49FiS8dvchOzwzXsXIAwl24BjtzoZfMeXT ywRT1KIDZszMgsWbwtvw2e+OpSNjiReGf7wjDnsY5r5LWeOkO7OSIpxH3eCXIMarqtab XNkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=N/ssHtFFER9k3BWB1QXe7X0QkAejXSdFwkpWCODq1b0=; b=BQGFG6sCsyop6B5WVPb2LCMQ5aQI67iOSTFxlHsJr76SUCHztvonCwG/BQyRf8/A8y aLXMRQK6eDoMilSup6etJWN8AaKTBNKX8uXmZCvuqdjEykh848xIh8vQn9WmzVHYszQt imlXK3S1m6h6uUP0liVOcXEC7ZuS/iMffRlW296+HVjWttIh2RoGdTxCG4iKtipj6Z4k ggefVD/T+FbcdLG9ksmfDEqL14u5DnXIYwz/SiSCmBDTYvrI24p5CeZCR2t6EdiHZWHH bdyt299rGlsAkvj70gNct4xBkzXMCRHQviIqPACBNJakZwmCfNvkQI1eEGet4knlVP8P FIFg== 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 oz18si5441357ejb.581.2020.05.22.12.27.38; Fri, 22 May 2020 12:28:01 -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 S1730918AbgEVT0R (ORCPT + 99 others); Fri, 22 May 2020 15:26:17 -0400 Received: from mga03.intel.com ([134.134.136.65]:19921 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730689AbgEVT0Q (ORCPT ); Fri, 22 May 2020 15:26:16 -0400 IronPort-SDR: X5L2zUcyoPXFR6heNei79v1IiZYSU5ZZXTScWyzcdBq2qPe469IuwRpLYBcrMZbKX6+uigRX51 5yZGr25e+qbw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2020 12:26:15 -0700 IronPort-SDR: byZjjo03dLCqvP6zTjKxKcmePMihPj+c61mrPmnwykVcBKNwMfmTQJrnKOPRqZTk0ZxpJEi6WO ec3hAJilTBtw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,422,1583222400"; d="scan'208";a="412848366" Received: from rpurrx-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.58.10]) by orsmga004.jf.intel.com with ESMTP; 22 May 2020 12:26:09 -0700 Date: Fri, 22 May 2020 22:26:09 +0300 From: Jarkko Sakkinen To: Sean Christopherson Cc: linux-kernel@vger.kernel.org, x86@kernel.org, linux-sgx@vger.kernel.org, akpm@linux-foundation.org, dave.hansen@intel.com, nhorman@redhat.com, npmccallum@redhat.com, haitao.huang@intel.com, andriy.shevchenko@linux.intel.com, tglx@linutronix.de, kai.svahn@intel.com, bp@alien8.de, josh@joshtriplett.org, luto@kernel.org, kai.huang@intel.com, rientjes@google.com, cedric.xing@intel.com, puiterwijk@redhat.com, linux-security-module@vger.kernel.org, Suresh Siddha , Jethro Beekman , Haitao Huang , Chunyang Hui , Jordan Hand , Seth Moore Subject: Re: [PATCH v30 10/20] x86/sgx: Linux Enclave Driver Message-ID: <20200522192609.GE10319@linux.intel.com> References: <20200515004410.723949-1-jarkko.sakkinen@linux.intel.com> <20200515004410.723949-11-jarkko.sakkinen@linux.intel.com> <20200521191236.GA23043@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200521191236.GA23043@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 21, 2020 at 12:12:36PM -0700, Sean Christopherson wrote: > On Fri, May 15, 2020 at 03:44:00AM +0300, Jarkko Sakkinen wrote: > > +long sgx_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) > > +{ > > + struct sgx_encl *encl = filep->private_data; > > + int ret, encl_flags; > > + > > + encl_flags = atomic_fetch_or(SGX_ENCL_IOCTL, &encl->flags); > > + if (encl_flags & SGX_ENCL_IOCTL) > > + return -EBUSY; > > + > > + if (encl_flags & SGX_ENCL_DEAD) > > + return -EFAULT; > > Returning immediately is wrong as it leaves SGX_ENCL_IOCTL set. This results > in the application seeing -EBUSY on future ioctls() instead of -EFAULT. Can be > fixed as below. Do you want me to send a formal patch on linux-sgx? I just rewrote the same thing. /Jarkko