[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YCwK9SblYCh/1lZS@zeniv-ca.linux.org.uk>
Date: Tue, 16 Feb 2021 18:12:05 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: Ben Widawsky <ben.widawsky@...el.com>
Cc: linux-cxl@...r.kernel.org, linux-acpi@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-nvdimm@...ts.01.org,
linux-pci@...r.kernel.org, Bjorn Helgaas <helgaas@...nel.org>,
Chris Browy <cbrowy@...ry-design.com>,
Christoph Hellwig <hch@...radead.org>,
Dan Williams <dan.j.williams@...el.com>,
David Hildenbrand <david@...hat.com>,
David Rientjes <rientjes@...gle.com>,
Ira Weiny <ira.weiny@...el.com>,
Jon Masters <jcm@...masters.org>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Rafael Wysocki <rafael.j.wysocki@...el.com>,
Randy Dunlap <rdunlap@...radead.org>,
Vishal Verma <vishal.l.verma@...el.com>,
"John Groves (jgroves)" <jgroves@...ron.com>,
"Kelley, Sean V" <sean.v.kelley@...el.com>,
kernel test robot <lkp@...el.com>
Subject: Re: [PATCH v4 4/9] cxl/mem: Add basic IOCTL interface
On Mon, Feb 15, 2021 at 05:45:33PM -0800, Ben Widawsky wrote:
> + if (cmd->info.size_in) {
> + mbox_cmd.payload_in = kvzalloc(cmd->info.size_in, GFP_KERNEL);
> + if (!mbox_cmd.payload_in) {
> + rc = -ENOMEM;
> + goto out;
> + }
> +
> + if (copy_from_user(mbox_cmd.payload_in,
> + u64_to_user_ptr(in_payload),
> + cmd->info.size_in)) {
> + rc = -EFAULT;
> + goto out;
> + }
Umm... Do you need to open-code vmemdup_user()? The only difference is
GFP_KERNEL allocation instead of GFP_USER one, and the latter is arguably
saner here... Zeroing is definitely pointless - you either overwrite
the entire buffer with copy_from_user(), or you fail and free the damn
thing.
Powered by blists - more mailing lists