From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 353F0C433DF for ; Sat, 10 Oct 2020 02:49:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE0912075E for ; Sat, 10 Oct 2020 02:49:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KgBdC8ka" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730514AbgJJCr6 (ORCPT ); Fri, 9 Oct 2020 22:47:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:23520 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730427AbgJJCc0 (ORCPT ); Fri, 9 Oct 2020 22:32:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602297146; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z0+yMqB5qWuc0BoeYtvqmNWdzEX4ZInq9BnlDhYqt00=; b=KgBdC8ka4pzzFX8+ylRSN7bTfgF9/IuE092YsI+crcZgMvdpRIcuRvyor5Tfh/6my4FnG5 YgrMOYO1fDcZLyfhs2UAQDfv/ZcyWz5WrMF1Jrz3FIYEh7yWl63a9/G5ubJt4Ldo/w/qZ6 MjOdwehFkLNU0AMXyomlTKHyZkYn7hY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-40-55hpNga7MaCPTcKGrULuZw-1; Fri, 09 Oct 2020 22:32:24 -0400 X-MC-Unique: 55hpNga7MaCPTcKGrULuZw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 71949879514; Sat, 10 Oct 2020 02:32:22 +0000 (UTC) Received: from [10.72.13.27] (ovpn-13-27.pek2.redhat.com [10.72.13.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D59260BE2; Sat, 10 Oct 2020 02:32:15 +0000 (UTC) Subject: Re: [PATCH v3 2/3] vhost: Use vhost_get_used_size() in vhost_vring_set_addr() To: Greg Kurz , "Michael S. Tsirkin" Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, qemu-devel@nongnu.org, Laurent Vivier , David Gibson References: <160171888144.284610.4628526949393013039.stgit@bahia.lan> <160171932300.284610.11846106312938909461.stgit@bahia.lan> From: Jason Wang Message-ID: <5fc896c6-e60d-db0b-f7b0-5b6806d70b8e@redhat.com> Date: Sat, 10 Oct 2020 10:32:13 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <160171932300.284610.11846106312938909461.stgit@bahia.lan> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/10/3 下午6:02, Greg Kurz wrote: > The open-coded computation of the used size doesn't take the event > into account when the VIRTIO_RING_F_EVENT_IDX feature is present. > Fix that by using vhost_get_used_size(). > > Signed-off-by: Greg Kurz > --- > drivers/vhost/vhost.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > index c3b49975dc28..9d2c225fb518 100644 > --- a/drivers/vhost/vhost.c > +++ b/drivers/vhost/vhost.c > @@ -1519,8 +1519,7 @@ static long vhost_vring_set_addr(struct vhost_dev *d, > /* Also validate log access for used ring if enabled. */ > if ((a.flags & (0x1 << VHOST_VRING_F_LOG)) && > !log_access_ok(vq->log_base, a.log_guest_addr, > - sizeof *vq->used + > - vq->num * sizeof *vq->used->ring)) > + vhost_get_used_size(vq, vq->num))) > return -EINVAL; > } > > > Acked-by: Jason Wang