Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp121934pxk; Thu, 24 Sep 2020 00:54:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBXUkw5opgaR/Ie5PupWWmX6hNgdWhikmWDNTdmIBrVc/JCCvu9cHusazWLMqCrw8RWDtx X-Received: by 2002:a17:906:2619:: with SMTP id h25mr3304330ejc.142.1600934075381; Thu, 24 Sep 2020 00:54:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600934075; cv=none; d=google.com; s=arc-20160816; b=g/ysJcndDBcKQq6qufB9cw5WuVgeu1wTgDok21l3fOQeZZUYdSTymJHUEfAjdifiKc 9vMN/RWYefVoAYVKZM5VNOKmSUX1phxugh23r5fvBx4qJJbUu/E2RUrARGhoFpsfLHVV eECAVb60aAJEiFIBl/raoyKrOeQ4ObKZUj/7VLYQUqb75uaAR6o1/2rTl+/xZtTowSK0 uRz+3GNFijWi8w+ym+YVxGbChd0QfZD/UjrLzuSR6JkTlTtF88A1J7b40FNSMLyci7xC i2kxEU5MHuE1QXA40AC24UEoYu9ZSCz0if8feG71R/iqdf0MT9lC+ArdyaPzoyxOvO6o wzCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=sqHArwthT57JphmHaTiMSE/ABTSL+yhvvPSNJ4OWT20=; b=Q52lmjQF/7vPhj4RyoYJkRKLad1F54GNB6+4gKB9n3hKKY8t2MEWNXadAVSHdKN0k2 UKyBjeRG1Bgd6XtRQqym08ns/ST8Nx8Wd4o4GAAFHMNtMVCOmRhk6QBFUGZnUawgBYqq FIMnW9o6RzNQf5wP2rZuIDOJUTqfIB8Q4VU+9HCl11HV6kUI/WolrQHkwrUPhL+ncmL7 HqjrSw6igXI1GNZv93Giw7yRa/PovVLNCXA55cRybftr4/c7lxwXBzrK7AM9nVCznzfa Z/SHn/i5tyvaTvCkUFz5gJvgubfFz6kaltDVfpcqZ+k8jREjn/B8C2LjB7idGQUtgZcN C6xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RFZF4p6u; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z14si1387749eja.502.2020.09.24.00.54.12; Thu, 24 Sep 2020 00:54:35 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=RFZF4p6u; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727263AbgIXHuU (ORCPT + 99 others); Thu, 24 Sep 2020 03:50:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:24432 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727013AbgIXHuT (ORCPT ); Thu, 24 Sep 2020 03:50:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600933817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sqHArwthT57JphmHaTiMSE/ABTSL+yhvvPSNJ4OWT20=; b=RFZF4p6ulQ0Hfp9QydZh+8u9zYUfDZ7Onk60mVy2gPkNKFcoym8WIoBDNunayCFbllpVSk f9xXmaMiFu+GsFKPu05EoVAfLE8+VpTuSYhbaC/AySqL0IDirHVqD8wYI5SiIWtc3TWO/f 12boFnae1mMiF5+l+IX/QZkq+U3LRt8= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-582-UMK4PyBCMCKnugMSFet4pQ-1; Thu, 24 Sep 2020 03:50:15 -0400 X-MC-Unique: UMK4PyBCMCKnugMSFet4pQ-1 Received: by mail-wr1-f69.google.com with SMTP id y3so887337wrl.21 for ; Thu, 24 Sep 2020 00:50:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=sqHArwthT57JphmHaTiMSE/ABTSL+yhvvPSNJ4OWT20=; b=TRjyqQJZoMdkIHzrQdnrwbzFnM5EkmRrZg86iBg9c7QDmQlS4mV9XmZIuw3AaPkBI6 RAXFlQLrciNK63/ZgTXj3/FyhxztDjTtG5moZW8fs93PwwEofyQqHrjZtId1+8nmFj+e mnD3+P3mC/9x2VaMHlznn4OI+zJoYe2y07F0xIVGJ48uW6ybfMBZTekfCo4yTR3cS8Jt NPx9umfvN+tC5IYs2YL644ROUGs+eaZgn43NgqSwMPOyhrjNnkBpVK70dJRSLOCw7wgT Xdq2cXXtUZfQYwp5D+SspgnuhlSsglJI/xgCEMMjWYKewGBZTORHQmsqQmKXmUDzYFsI c8sQ== X-Gm-Message-State: AOAM5304+QpQO9nXvLCpoSGKignSsjgX2nSXiUeHz+YEN/C5agvD7x7D PTJAzprNZFWLEKLcyqyqVyO8W0XhQHP9H5wQCxH4e9XTbHKg7PpsU7Qeo8AK3juMPRCyOPMnkOI wgQKgUp4+6vZbo3TH73J4g2ZA X-Received: by 2002:a1c:4d4:: with SMTP id 203mr3444739wme.102.1600933814577; Thu, 24 Sep 2020 00:50:14 -0700 (PDT) X-Received: by 2002:a1c:4d4:: with SMTP id 203mr3444708wme.102.1600933814287; Thu, 24 Sep 2020 00:50:14 -0700 (PDT) Received: from redhat.com (bzq-79-179-71-128.red.bezeqint.net. [79.179.71.128]) by smtp.gmail.com with ESMTPSA id y1sm2301869wma.36.2020.09.24.00.50.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2020 00:50:13 -0700 (PDT) Date: Thu, 24 Sep 2020 03:50:09 -0400 From: "Michael S. Tsirkin" To: Jason Wang Cc: lulu@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, rob.miller@broadcom.com, lingshan.zhu@intel.com, eperezma@redhat.com, hanand@xilinx.com, mhabets@solarflare.com, eli@mellanox.com, amorenoz@redhat.com, maxime.coquelin@redhat.com, stefanha@redhat.com, sgarzare@redhat.com, Eli Cohen Subject: Re: [RFC PATCH 01/24] vhost-vdpa: fix backend feature ioctls Message-ID: <20200924034940-mutt-send-email-mst@kernel.org> References: <20200924032125.18619-1-jasowang@redhat.com> <20200924032125.18619-2-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200924032125.18619-2-jasowang@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 24, 2020 at 11:21:02AM +0800, Jason Wang wrote: > Commit 653055b9acd4 ("vhost-vdpa: support get/set backend features") > introduces two malfunction backend features ioctls: > > 1) the ioctls was blindly added to vring ioctl instead of vdpa device > ioctl > 2) vhost_set_backend_features() was called when dev mutex has already > been held which will lead a deadlock > > This patch fixes the above issues. > > Cc: Eli Cohen > Reported-by: Zhu Lingshan > Fixes: 653055b9acd4 ("vhost-vdpa: support get/set backend features") > Signed-off-by: Jason Wang Don't we want the fixes queued right now, as opposed to the rest of the RFC? > --- > drivers/vhost/vdpa.c | 30 ++++++++++++++++-------------- > 1 file changed, 16 insertions(+), 14 deletions(-) > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > index 3fab94f88894..796fe979f997 100644 > --- a/drivers/vhost/vdpa.c > +++ b/drivers/vhost/vdpa.c > @@ -353,8 +353,6 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, > struct vdpa_callback cb; > struct vhost_virtqueue *vq; > struct vhost_vring_state s; > - u64 __user *featurep = argp; > - u64 features; > u32 idx; > long r; > > @@ -381,18 +379,6 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, > > vq->last_avail_idx = vq_state.avail_index; > break; > - case VHOST_GET_BACKEND_FEATURES: > - features = VHOST_VDPA_BACKEND_FEATURES; > - if (copy_to_user(featurep, &features, sizeof(features))) > - return -EFAULT; > - return 0; > - case VHOST_SET_BACKEND_FEATURES: > - if (copy_from_user(&features, featurep, sizeof(features))) > - return -EFAULT; > - if (features & ~VHOST_VDPA_BACKEND_FEATURES) > - return -EOPNOTSUPP; > - vhost_set_backend_features(&v->vdev, features); > - return 0; > } > > r = vhost_vring_ioctl(&v->vdev, cmd, argp); > @@ -440,8 +426,20 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, > struct vhost_vdpa *v = filep->private_data; > struct vhost_dev *d = &v->vdev; > void __user *argp = (void __user *)arg; > + u64 __user *featurep = argp; > + u64 features; > long r; > > + if (cmd == VHOST_SET_BACKEND_FEATURES) { > + r = copy_from_user(&features, featurep, sizeof(features)); > + if (r) > + return r; > + if (features & ~VHOST_VDPA_BACKEND_FEATURES) > + return -EOPNOTSUPP; > + vhost_set_backend_features(&v->vdev, features); > + return 0; > + } > + > mutex_lock(&d->mutex); > > switch (cmd) { > @@ -476,6 +474,10 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, > case VHOST_VDPA_SET_CONFIG_CALL: > r = vhost_vdpa_set_config_call(v, argp); > break; > + case VHOST_GET_BACKEND_FEATURES: > + features = VHOST_VDPA_BACKEND_FEATURES; > + r = copy_to_user(featurep, &features, sizeof(features)); > + break; > default: > r = vhost_dev_ioctl(&v->vdev, cmd, argp); > if (r == -ENOIOCTLCMD) > -- > 2.20.1