Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp475385pxb; Sat, 20 Feb 2021 09:51:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyivVyWoNGwo2dMZZ8ofUkD5yowb6CqUTooJi/8MA2d57DfBhz019ZNjyrsM7FRxpia5Xja X-Received: by 2002:a17:906:af63:: with SMTP id os3mr14066438ejb.69.1613843498321; Sat, 20 Feb 2021 09:51:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613843498; cv=none; d=google.com; s=arc-20160816; b=cTHcBA2dOwRnILdM0dk5SOzvzVih7ad1g5RP59hvZB3GrRuTH1XQEkPgPuMlrmf2GP Jl4S0/Q6naB8AY8Rj0ciRs8SbSqy9l46+1bAQBwAaUyT11tdJId3qqrA+NPsa+zP2eMD u4d04WUsqLAr+/TMc5BHBeWVo4hbFHqgNEpEoxt/usv/P09WTVR7XrrTU3+0Wa+Sd8oD LJJNbDX01qOBnAjyPvdVqQMux/ID/FY+wq+RgyBz4jXnIc8wAKa5IfckV3f7/vqZOTaa kmPRByTzOHCG9ONU5YCA+Gt4/YPqLZAw4xc4BGc7/BuM0TwSqnitY+DrW12F9eswmwLt m1/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=niF1k3dVyqWcVFhX7Jys8F/FWOuqyr/3JpoSyGWUad4=; b=yx/1F5xF0rkMSMrHx2n9Tc8EsArJwuxUd6V7ukEPyDlRXiiO46pZD6djkurka3Vu0d o6dOFYUqSw9x6LslLHkQwynxnM85IB7Ika0a5OmC4OtfFE0Ws7+vJhU35spIDhFIAXOW jPRkQtvUjVTfTFwJYR/nxDccHObryxGu7BSqje3Ro7wbrp/gV9woiiXUUgD2DS8So9q+ t4Nh0rIKFzEcBd/degEcGVrLmIvy0kR4A/mMSWByJI7ckZGL6Q34svakhx2KqIb//nAT 5kDCy4hsHHFTpiGHVg1B6Kz8wXUfwb7OUSMz5277nD9h8+b5DY3uId+stOL9ln6oj6E+ 4fKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=SJiJGOm9; 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 he44si8071017ejc.386.2021.02.20.09.51.14; Sat, 20 Feb 2021 09:51:38 -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; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=SJiJGOm9; 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 S229826AbhBTRtN (ORCPT + 99 others); Sat, 20 Feb 2021 12:49:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229847AbhBTRtM (ORCPT ); Sat, 20 Feb 2021 12:49:12 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85E29C06178B for ; Sat, 20 Feb 2021 09:48:31 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id w1so21846792ejf.11 for ; Sat, 20 Feb 2021 09:48:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=niF1k3dVyqWcVFhX7Jys8F/FWOuqyr/3JpoSyGWUad4=; b=SJiJGOm92EOLuEmD8ZxINHCPgWL9FHxOSQ3VIYWX9zoyH2E9wOjXIS9rFt4qflATpv hSN/bjk3gMWmOoic96yidZvVl7/B4XMCsqfh0PkuMvTvPzxsbnnAAzqFwvJBX/EHx6Jq lEXEZ04J4mAMFF3qpTPsBe+t1d1hZCpoZ1tHexVfyV6BEj3IJZ6FxOnS5w7SFjV4xaQB bzdJovpxJgMpQMBdOPWU4kOe8uTftngZHfL80X3V4NBKw6dQvwl3+V0eAaAFtkaj7Nyw q6pWkVkKDyqb9Tw8d5bxJN+VZ9kPSu7gfMjLM+uXAWL9W050qu1qq3zAwkiaymsFO0Qm BLwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=niF1k3dVyqWcVFhX7Jys8F/FWOuqyr/3JpoSyGWUad4=; b=gsepjtsoTOFvXHYI0fIhs9/T4ZOYai76XTDYUhDc4YvHxGEWXGraheG06XxZGFXtB1 dKjC9os9gx36tj3C2l+0g2SQNuqQd+DdghwMcbiI492//LZ2QzJOUf0bCucUCQbFycUf jEh3Sxuzt6BPTitW/z/qVhlbQvCQAIJZqSePIHjkNaCrCZwJ6sQWHYKJZFJ1EfB0WBzV ptWZcE1h13c1GJ0oBAoWCG2mzwmLmTHFNxnxOgcL8mM5DyS0NuBgwHhd71HC9L0SgmEZ y6E7+EmuIIV395im+d4hMEDkudfhvclritGAs7c/gKoiKN4Iwky7d2WP9hA2Ygd+Lk6f 8AkA== X-Gm-Message-State: AOAM530J18K22LugLzxvwFVXZktIcM51CjP+twnKYTh/jOlqkPbh/AFu Q/dOHZF9yfbDgjwKWOVWySWCqtAIE9kXsVOSw02lNw== X-Received: by 2002:a17:907:373:: with SMTP id rs19mr1248541ejb.341.1613843310167; Sat, 20 Feb 2021 09:48:30 -0800 (PST) MIME-Version: 1.0 References: <20210217040958.1354670-1-ben.widawsky@intel.com> <20210217040958.1354670-5-ben.widawsky@intel.com> <20210220163344.csczmkyxkpu4fxah@intel.com> In-Reply-To: <20210220163344.csczmkyxkpu4fxah@intel.com> From: Dan Williams Date: Sat, 20 Feb 2021 09:48:22 -0800 Message-ID: Subject: Re: [PATCH v5 4/9] cxl/mem: Add basic IOCTL interface To: Ben Widawsky Cc: Konrad Rzeszutek Wilk , linux-cxl@vger.kernel.org, Linux ACPI , Linux Kernel Mailing List , linux-nvdimm , Linux PCI , Bjorn Helgaas , Chris Browy , Christoph Hellwig , David Hildenbrand , David Rientjes , Ira Weiny , Jon Masters , Jonathan Cameron , Rafael Wysocki , Randy Dunlap , Vishal Verma , "John Groves (jgroves)" , "Kelley, Sean V" , kernel test robot , Stephen Rothwell , Al Viro Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 20, 2021 at 8:33 AM Ben Widawsky wrote: > > On 21-02-19 20:22:00, Konrad Rzeszutek Wilk wrote: > > ..snip.. > > > +static int handle_mailbox_cmd_from_user(struct cxl_mem *cxlm, > > > + const struct cxl_mem_command *cmd, > > > + u64 in_payload, u64 out_payload, > > > + s32 *size_out, u32 *retval) > > > +{ > > > + struct device *dev = &cxlm->pdev->dev; > > > + struct mbox_cmd mbox_cmd = { > > > + .opcode = cmd->opcode, > > > + .size_in = cmd->info.size_in, > > > + .size_out = cmd->info.size_out, > > > + }; > > > + int rc; > > > + > > > + if (cmd->info.size_out) { > > > + mbox_cmd.payload_out = kvzalloc(cmd->info.size_out, GFP_KERNEL); > > > + if (!mbox_cmd.payload_out) > > > + return -ENOMEM; > > > + } > > > + > > > + if (cmd->info.size_in) { > > > + mbox_cmd.payload_in = vmemdup_user(u64_to_user_ptr(in_payload), > > > + cmd->info.size_in); > > > + if (IS_ERR(mbox_cmd.payload_in)) > > > + return PTR_ERR(mbox_cmd.payload_in); > > > > Not that this should happen, but what if info.size_out was set? Should > > you also free mbox_cmd.payload_out? > > > > Thanks Konrad. > > Dan, do you want me to send a fixup patch? This bug was introduced from v4->v5. Yes, please, incremental to libnvdimm-for-next which I'm planning to send to Linus on Tuesday.