From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753737AbdJaRGK (ORCPT ); Tue, 31 Oct 2017 13:06:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56588 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753577AbdJaRGI (ORCPT ); Tue, 31 Oct 2017 13:06:08 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6C84783F3D Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=mst@redhat.com Date: Tue, 31 Oct 2017 19:06:05 +0200 From: "Michael S. Tsirkin" To: "Hatayama, Daisuke" Cc: "'marcandre.lureau@redhat.com'" , "'somlo@cmu.edu'" , "linux-kernel@vger.kernel.org" , "'qemu-devel@nongnu.org'" Subject: Re: [PATCH v3 5/5] RFC: fw_cfg: add DMA write operation in sysfs Message-ID: <20171031185505-mutt-send-email-mst@kernel.org> References: <33710E6CAA200E4583255F4FB666C4E21B120583@G01JPEXMBYT03> <20171030181711-mutt-send-email-mst@kernel.org> <33710E6CAA200E4583255F4FB666C4E21B153BF6@G01JPEXMBYT03> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <33710E6CAA200E4583255F4FB666C4E21B153BF6@G01JPEXMBYT03> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 31 Oct 2017 17:06:08 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 31, 2017 at 09:55:39AM +0000, Hatayama, Daisuke wrote: > > > > -----Original Message----- > > From: linux-kernel-owner@vger.kernel.org > > [mailto:linux-kernel-owner@vger.kernel.org] On Behalf Of Michael S. Tsirkin > > Sent: Tuesday, October 31, 2017 1:19 AM > > To: Hatayama, Daisuke > > Cc: 'marcandre.lureau@redhat.com' ; > > 'somlo@cmu.edu' ; linux-kernel@vger.kernel.org; > > 'qemu-devel@nongnu.org' > > Subject: Re: [PATCH v3 5/5] RFC: fw_cfg: add DMA write operation in sysfs > > > > On Mon, Oct 30, 2017 at 11:07:20AM +0000, Hatayama, Daisuke wrote: > > > > From: Marc-André Lureau > > > > > > > > Since qemu 2.9, DMA write operations are allowed. However, usage of this > > > > interface from kernel or user-space is strongly discouraged by the > > > > maintainers. This patch is meant for experimentations for now. > > > > > > > > > > Could you (or maintainers?) tell me how experimental the DMA write > > > operations from kernel are? > > > > > > From some technical reason? > > > Or simply there has not been enough test yet so far? > > > > The concern is security, talking from userspace to hypervisor > > might become a trivial DOS vector. > > > > If there's need for a specific entry to be accessible from userspace, > > I'd rather white-list it. > > > > Thanks for the explanation. > > If so, I guess the white-list is done in userspace qemu side, > and no additional change would be needed for this kernel-side patch set for the white-list feature. > Is this understanding correct? No - host side has no idea whether it's guest userspace or kernel initiating the access. > > > > Signed-off-by: Marc-André Lureau > > > > --- > > > > drivers/firmware/qemu_fw_cfg.c | 21 ++++++++++++++++++++- > > > > 1 file changed, 20 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/firmware/qemu_fw_cfg.c > > b/drivers/firmware/qemu_fw_cfg.c > > > > index 54b569da3257..e2f2ad1c9c0c 100644 > > > > --- a/drivers/firmware/qemu_fw_cfg.c > > > > +++ b/drivers/firmware/qemu_fw_cfg.c > > > > @@ -524,9 +524,28 @@ static ssize_t fw_cfg_sysfs_read_raw(struct file *filp, > > struct kobject *kobj, > > > > return fw_cfg_read_blob(entry->f.select, buf, pos, count, true); > > > > } > > > > > > > > +static ssize_t fw_cfg_sysfs_write_raw(struct file *filp, struct kobject > > *kobj, > > > > + struct bin_attribute *bin_attr, > > > > + char *buf, loff_t pos, size_t count) > > > > +{ > > > > + struct fw_cfg_sysfs_entry *entry = to_entry(kobj); > > > > + > > > > + if (!fw_cfg_dma_enabled()) > > > > + return -ENOTSUPP; > > > > + > > > > + if (pos > entry->f.size) > > > > + return -EINVAL; > > > > + > > > > + if (count > entry->f.size - pos) > > > > + count = entry->f.size - pos; > > > > + > > > > + return fw_cfg_write_blob(entry->f.select, buf, pos, count); > > > > +} > > > > + > > > > static struct bin_attribute fw_cfg_sysfs_attr_raw = { > > > > - .attr = { .name = "raw", .mode = S_IRUSR }, > > > > + .attr = { .name = "raw", .mode = S_IRUSR | S_IWUSR }, > > > > .read = fw_cfg_sysfs_read_raw, > > > > + .write = fw_cfg_sysfs_write_raw, > > > > }; > > > > > > > > /* > > > > -- > > > > 2.14.1.146.gd35faa819 > > > > > > Thanks. > > > HATAYAMA, Daisuke > > > > > >