Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp471921pxb; Thu, 14 Jan 2021 10:14:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqdiwMkKnrlbWLtnTQBO/3imtFC+4EAKLiBK4UPqe2eMcidGdTMeh79HZH6k5FjTpKOACt X-Received: by 2002:a05:6402:129a:: with SMTP id w26mr6949453edv.355.1610648041208; Thu, 14 Jan 2021 10:14:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610648041; cv=none; d=google.com; s=arc-20160816; b=KSLuWXGrgJS2Ryygyv1xMwlMf8LBz+6OH3Z17q5u1D5eUfSnglkwNqIY6g1y38Tzxv Up68bZczuSZXo4xyloZWKRX8qtQWTG+xL0siDf6Ptpj4wV2TK0fwfQeFNOTLdgREv+bU OAQg4e+FPdQqTgPIAT0byrbqqyoC/MUwKgHzlyYWpAjftj89S/gZYyav5on274ckYniS LnJjEc4fakDszNXYfK7W+N544bvwAOCMpAZlXvmM7bAGr5daYV7uHw+/xmY5DvVC5Hzm Z+oCFzAYVurOQjymkwvJ7S05+mDStLGK9rk5QkwhkSDXLmBeCLKPthcT9uRBOU/+bij8 f65Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=u1j8Af/0oJ1mf4zh4Ml7gW6GcyYtlOuA/daecQshylw=; b=xCbHvZ9if3k06pFvf2tVYGm3XJ/XllsAR4twEhH5b9HhZsKvL1dnuhQ2/g0xjpL7Zo GD9HiQJ6WfXg97CyuldI0mRPHsx8eDa3dDJfKOgmNhpNt6C9WYvMNjJEFReNg4bMwnAd Lrq/r9jZlXdT0ykpWF8soUX7XvkxPJ3J7uEpB/65NVNAtuwvJVwdupIinlcWLC/7a8S4 e759p6D/39QpVulbTjH4gcpbmUDJD1i20iPvUPTSvR+riZspgnQRPZrdL7BwC1gFyemO d17dsHrEtjL5/8DzB7qhOR34ZrYSXQsdBjKcFE42RlqFNfhZptFaaPY+yE79iMqpIqHK 3zuQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x60si2835480ede.80.2021.01.14.10.13.37; Thu, 14 Jan 2021 10:14:01 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729313AbhANSJv (ORCPT + 99 others); Thu, 14 Jan 2021 13:09:51 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:2350 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727533AbhANSJu (ORCPT ); Thu, 14 Jan 2021 13:09:50 -0500 Received: from fraeml734-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4DGsfc4sVyz67bdg; Fri, 15 Jan 2021 02:05:12 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml734-chm.china.huawei.com (10.206.15.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Thu, 14 Jan 2021 19:09:08 +0100 Received: from localhost (10.47.30.252) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2106.2; Thu, 14 Jan 2021 18:09:07 +0000 Date: Thu, 14 Jan 2021 18:08:26 +0000 From: Jonathan Cameron To: Ben Widawsky CC: , , , "linux-acpi@vger.kernel.org, Ira Weiny" , Dan Williams , "Vishal Verma" , "Kelley, Sean V" , Rafael Wysocki , "Bjorn Helgaas" , Jon Masters , Chris Browy , Randy Dunlap , "Christoph Hellwig" , Subject: Re: [RFC PATCH v3 15/16] cxl/mem: Add limited Get Log command (0401h) Message-ID: <20210114180826.000072f0@Huawei.com> In-Reply-To: <20210111225121.820014-17-ben.widawsky@intel.com> References: <20210111225121.820014-1-ben.widawsky@intel.com> <20210111225121.820014-17-ben.widawsky@intel.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.30.252] X-ClientProxiedBy: lhreml709-chm.china.huawei.com (10.201.108.58) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 11 Jan 2021 14:51:20 -0800 Ben Widawsky wrote: > The Get Log command returns the actual log entries that are advertised > via the Get Supported Logs command (0400h). CXL device logs are selected > by UUID which is part of the CXL spec. Because the driver tries to > sanitize what is sent to hardware, there becomes a need to restrict the > types of logs which can be accessed by userspace. For example, the > vendor specific log might only be consumable by proprietary, or offline > applications, and therefore a good candidate for userspace. > > The current driver infrastructure does allow basic validation for all > commands, but doesn't inspect any of the payload data. Along with Get > Log support comes new infrastructure to add a hook for payload > validation. This infrastructure is used to filter out the CEL UUID, > which the userspace driver doesn't have business knowing, and taints on > invalid UUIDs being sent to hardware. > > Signed-off-by: Ben Widawsky Just a minor question for this one. Thanks, J ... \ > @@ -515,6 +529,15 @@ static int handle_mailbox_cmd_from_user(struct cxl_memdev *cxlmd, > int rc; > > if (cmd->info.size_in) { > + if (cmd->validate_payload) { > + rc = cmd->validate_payload(u64_to_user_ptr(in_payload), > + cmd->info.size_in); Is it worth moving this out of the region in which we hold the mbox? (after fixing the bug that I think means we don't actually hold it at this point) Perhaps not, but it does feel odd to do validation under the lock. > + if (rc) { > + cxl_mem_mbox_put(cxlmd->cxlm); > + return -EFAULT; > + } > + } > + > /* > * Directly copy the userspace payload into the hardware. UAPI > * states that the buffer must already be little endian.