Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp6460644pxb; Wed, 17 Feb 2021 05:19:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVNdp6escVs3vNIaD8p9J6Qwvc5wAahhKdkCPMRpG7TqTevnGhGZY5zd/1qsmg0itAa7t2 X-Received: by 2002:a05:6402:2683:: with SMTP id w3mr26094129edd.378.1613567991672; Wed, 17 Feb 2021 05:19:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613567991; cv=none; d=google.com; s=arc-20160816; b=rvLSQaVcUp/fNsBMTbS3wI3kZr1vikf9OQP/AxabyeE0UhotwcWiwpKgzahrzPppsc hEchGw1sxq7EJ1GombTixRGMZTpJpLlf3DpbAmOE1vbbuGhBRbTJG9VsynDWWmTdEQUB PszTqe6n6/IARL0H/1MW1I9nfSqZ25lEf0J3TXHXIGwjqyI+tzlAmPpm4omAphpgK9UZ WhSHsMXNvC41Zn4DmlaePwnlEMgA7BckVxb8nO1TaCekfApVBbR1EPavoNFg9/gq653o w7UVPtEeLdYEo5bVkWBEU9yFQDhnRykkK5vznczvcpKdg2si2C3LAUOMywr77KGucQeG +OZw== 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=71JEf55uEKtIMqBwC8ohnnZyynB4QI/rx9fq/lWvnRM=; b=kBmpJ+jBRxa+5Eb1u/G1NHrS+ywDSniCGszFcxSmpQppOlO0MelbDW/OE86jVPP0Jj iieT15XzD3C6Ys2s5MSbojMMQz94xDoATJRI/rtHg7Sxh3vRK+px22/KMffYTOpkULg4 9pW6GDwCm8MZsQCAKWmYc3Op9M8gU7QipSNEXQVGT3+dFi5oa5jLM4zn7iX6hL9UTDR6 MX8Om2T7l5BB8evPIP7R2kWVCELuDH2Q/CAlrE4B44AZfkN7JbaGNEFW6F5x7kD4j5Oj CxeZjol7fyuRUW4ek2CACNytNS1Wrr9RFjH27CnKSr/d3FlYQCiJpy6HnuVxVZplhpyD klNg== 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 p24si1290587edw.248.2021.02.17.05.19.27; Wed, 17 Feb 2021 05:19:51 -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 S231766AbhBQJ5P (ORCPT + 99 others); Wed, 17 Feb 2021 04:57:15 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:2579 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231470AbhBQJ5N (ORCPT ); Wed, 17 Feb 2021 04:57:13 -0500 Received: from fraeml707-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4DgY545pj4z67nyq; Wed, 17 Feb 2021 17:51:20 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml707-chm.china.huawei.com (10.206.15.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Wed, 17 Feb 2021 10:56:31 +0100 Received: from localhost (10.47.29.73) 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; Wed, 17 Feb 2021 09:56:30 +0000 Date: Wed, 17 Feb 2021 09:55:24 +0000 From: Jonathan Cameron To: Ben Widawsky CC: , , , , , Bjorn Helgaas , "Chris Browy" , Christoph Hellwig , "Dan Williams" , David Hildenbrand , David Rientjes , Ira Weiny , "Jon Masters" , Rafael Wysocki , Randy Dunlap , Vishal Verma , "John Groves (jgroves)" , "Kelley, Sean V" , kernel test robot Subject: Re: [PATCH v4 4/9] cxl/mem: Add basic IOCTL interface Message-ID: <20210217095524.000071f5@Huawei.com> In-Reply-To: <20210216183432.lf2uj63uckogfad4@intel.com> References: <20210216014538.268106-1-ben.widawsky@intel.com> <20210216014538.268106-5-ben.widawsky@intel.com> <20210216152223.000009e8@Huawei.com> <20210216175314.ut2dn5ujayj57zp2@intel.com> <20210216182849.00002c8c@Huawei.com> <20210216183432.lf2uj63uckogfad4@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.29.73] X-ClientProxiedBy: lhreml704-chm.china.huawei.com (10.201.108.53) 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 Tue, 16 Feb 2021 10:34:32 -0800 Ben Widawsky wrote: ... > > > diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c > > > index 237b956f0be0..4ca4f5afd9d2 100644 > > > --- a/drivers/cxl/mem.c > > > +++ b/drivers/cxl/mem.c > > > @@ -686,7 +686,11 @@ static int cxl_validate_cmd_from_user(struct cxl_mem *cxlm, > > > > > > memcpy(out_cmd, c, sizeof(*c)); > > > out_cmd->info.size_in = send_cmd->in.size; > > > - out_cmd->info.size_out = send_cmd->out.size; > > > + /* > > > + * XXX: out_cmd->info.size_out will be controlled by the driver, and the > > > + * specified number of bytes @send_cmd->out.size will be copied back out > > > + * to userspace. > > > + */ > > > > > > return 0; > > > } > > > > This deals with the buffer overflow being triggered from userspace. > > > > I'm still nervous. I really don't like assuming hardware will do the right > > thing and never send us more data than we expect. > > > > Given the check that it will fit in the target buffer is simple, > > I'd prefer to harden it and know we can't have a problem. > > > > Jonathan > > I'm working on hardening __cxl_mem_mbox_send_cmd now per your request. With > that, I think this solves the issue, right? Should do. Thanks, Jonathan