Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp298789imj; Sat, 16 Feb 2019 00:19:09 -0800 (PST) X-Google-Smtp-Source: AHgI3IYg5ur/5GzU7xM42+sNBUe1vXRK1JqNNk8t5aeV0aNPEPb7aVINXl26wxnePnR92kzLdlaz X-Received: by 2002:a17:902:9a81:: with SMTP id w1mr13987007plp.19.1550305149257; Sat, 16 Feb 2019 00:19:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550305149; cv=none; d=google.com; s=arc-20160816; b=P2Nj0UT8dWsEw4uoDr4aOKUM8pgrlvkE+9btHbkFrVe03Zv/OUsKnuL8FSVXX1jimJ kdQykjyBqqMseScx6ezok8IEHOyPkqJjsH2Nb0L6f4yfU0ufOY9aeFv30PNvwNf63Nj2 n+vTFFJQlsxaNbZcVui31fs4aOJidRJFiHRi6aWwkrjKPsVTxFKdAAsIC6JaTFi6xtns GMc9EogRN9XC4E5Ogb4njG9wqcymgoojdt0B1nEdz1OogLFwPd1SCmYsQVZW7RdYXFYh Dp5MhkWYkmm2k6m+vq9BZ0PPczPh9+SQ0Zf77wgqW3JhDW7Zg7TnmAq/qx9y57PMUNWp rH2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=DvfEVQuzN4hFXKlkv8lR/BAs8Y6HS7QftF00vIpNslw=; b=Mj4BvDoXiLvwy4hh3vvPQdtlKzgD+YUpmLlppQt/hLZ8iWZEIa/hMsOE2oHbvV6w3H tp5EtRNcI11oyC4Aa7htTyvDU4JgApgpqA/C2qeecza4yysNVf19D/x5ouUbt7Bl02Ua Ml4o8J0iJu1SSnK2wJx/u5/sp7oqvHy1204s4k/wqLlpzmIYQ+fRZjwUpbrt1SpSVBza 5z2Sjs6q8Eg2dFy4nV2R0aJZE7vnYY3El2CDU010IrzV8/KBbTgRpr/v5DdlrqSXhGEm xR/pV3VEQ4pb/BZ7xmDe2fTkNHnJzDt+o2h5sBThOOn0xApfFQ9Jpxgs85y4rHO0JNDo usgA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2si2721433pfj.111.2019.02.16.00.18.53; Sat, 16 Feb 2019 00:19:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390596AbfBOWAA (ORCPT + 99 others); Fri, 15 Feb 2019 17:00:00 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:41449 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729958AbfBOWAA (ORCPT ); Fri, 15 Feb 2019 17:00:00 -0500 Received: by mail-qk1-f196.google.com with SMTP id u188so6631535qkh.8 for ; Fri, 15 Feb 2019 13:59:59 -0800 (PST) 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=DvfEVQuzN4hFXKlkv8lR/BAs8Y6HS7QftF00vIpNslw=; b=oon3oZXSSpRQc2SVhYtBGv3aj6zJFazF3wNqbkxPo3FAxx/RvsfG0Cf57qX7JZ9LTN kwiBX25BOhaLCXOF48CeVF0lD2SZu9/faLoaYmSbx1VpmarVTbT73opP26GL8wONiFtI IOFu0rbSZKUduUaZ5mqhJr0WUsvlAjyMG4Xy8Nc/FfdmdxY1yOkOTSaYsEqBkzD++1t8 NOJpKCN+YyvWeOxEVce2Td7uhZzOxyynGg1KIy3zSvnAt5Q+9kszucDdYIILCDwR6Qjs El+Tsr3NwGHZGk3AMeybnC9rBD+BHda2CU/OV4bHc3fW2BaJ6dwAo3+WyUzl8r7LZayQ F20g== X-Gm-Message-State: AHQUAuannxZ5+SOzOZmw6+LCmzT3WlD3hosO1Vx8kOSWeN2MwSP9veg7 nGnkE7TVOL8yhYw1rRVXnN6j2Q== X-Received: by 2002:a37:4a83:: with SMTP id x125mr8688241qka.30.1550267998977; Fri, 15 Feb 2019 13:59:58 -0800 (PST) Received: from redhat.com (pool-173-76-246-42.bstnma.fios.verizon.net. [173.76.246.42]) by smtp.gmail.com with ESMTPSA id k5sm4132929qti.41.2019.02.15.13.59.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Feb 2019 13:59:58 -0800 (PST) Date: Fri, 15 Feb 2019 16:59:56 -0500 From: "Michael S. Tsirkin" To: Jason Wang Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stephen@networkplumber.org Subject: Re: [PATCH net] vhost: correctly check the return value of translate_desc() in log_used() Message-ID: <20190215165929-mutt-send-email-mst@kernel.org> References: <20190215075324.18891-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190215075324.18891-1-jasowang@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 15, 2019 at 03:53:24PM +0800, Jason Wang wrote: > When fail, translate_desc() returns negative value, otherwise the > number of iovs. So we should fail when the return value is negative > instead of a blindly check against zero. > > Reported-by: Stephen Hemminger > Fixes: cc5e71075947 ("vhost: log dirty page correctly") > Signed-off-by: Jason Wang Acked-by: Michael S. Tsirkin and I guess the log was backported to stable so we want this backported too. > --- > drivers/vhost/vhost.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > index 24a129fcdd61..a2e5dc7716e2 100644 > --- a/drivers/vhost/vhost.c > +++ b/drivers/vhost/vhost.c > @@ -1788,7 +1788,7 @@ static int log_used(struct vhost_virtqueue *vq, u64 used_offset, u64 len) > > ret = translate_desc(vq, (uintptr_t)vq->used + used_offset, > len, iov, 64, VHOST_ACCESS_WO); > - if (ret) > + if (ret < 0) > return ret; > > for (i = 0; i < ret; i++) { > -- > 2.17.1