Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp568723ybz; Fri, 24 Apr 2020 05:36:12 -0700 (PDT) X-Google-Smtp-Source: APiQypJgtoryAMeA0GHhOvldJ8NnhJtRmrECbztLVrgGDNL4moLHJ1YdTh/xRGyR9y+QYihnDxdi X-Received: by 2002:a17:906:bb07:: with SMTP id jz7mr6653730ejb.317.1587731772608; Fri, 24 Apr 2020 05:36:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587731772; cv=none; d=google.com; s=arc-20160816; b=IspZPWPnHBfGDuMxB6NsqSqHu5Ppzq9s7KzgLY8liX0pH6TiiGL3pd0cLs645uQANQ iE2PA011UJ0LHbXSXuOa93QZrZpMwoxN0BRL27oOgni8rwpNLgiBGmFbrGYlBojLOPZ2 u6RW0tMY0NttsSsaDuOdgjpcxfsssTZfCIyX2/W/mf+6w1CU0GJVUVv2TOPsAG6UIew9 t/x0jDiDK4/49u6F0JobQ6XMiir3PF+GmvlYUZMjXrqmcyHc0srW2OeNV60AW+KhI4lm i7znYmnq7+xmYxNsOAE/g6H0NliJHonFrL3F0CD9yM8QN+vQgV/34dmW06JOFhQKXKi7 OXGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5uqTmWsPNi48LsyzzPDxx8bICw4tniZdtTWEnO982qA=; b=mSqvYhJC476NU54E0mMQMHayrECtwFVBIct/tpvevoAUyL/jzA6x/gewJgb6EpZHnQ 9GpPmTeo1owXOTLE1Lob25ABH22KDfOZh80X4aplG0cKz2TZWGHB3V2alMK1kshf9sMd FaftC/81VBAY0N52eh7b25+TQo/J8bOMs+ZV1JG+a6WaBeuf91wqdClmYo4y1ERrH2kf b46/Y0QRwWOmlyXqgkI4Fj9as3VvF/ZVtjDR9lTQ1NrFL6Gx1flXJNNrhfc6EED5OKNj Auu/MGTHq88C8/NW96kT+YZa+IgMUWYiP1lwLXsm23op9lvWYT0xX31MM2XOhwOtopwW SzTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JVikgC06; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y13si3109980edp.47.2020.04.24.05.35.49; Fri, 24 Apr 2020 05:36:12 -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=@kernel.org header.s=default header.b=JVikgC06; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728528AbgDXMcP (ORCPT + 99 others); Fri, 24 Apr 2020 08:32:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:52448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727796AbgDXMXC (ORCPT ); Fri, 24 Apr 2020 08:23:02 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 52F7A2087E; Fri, 24 Apr 2020 12:23:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587730982; bh=IUCErDYU5+chUFB9+LblbUcLmt79a5CAIndVF79zzyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JVikgC0657Ql78XqcS/AYFOJZmBrwAdGlK9pf3f3BHClWX+4b3ksLDUN6Tvaevbj6 T8o4J5/kGWcxgmmNbOTBq0XFJQmIqL9+d4aT4Mn9AAnRCtphBMuKV8IR7mkzhYbX81 fvTnKRf9z+1rtskeh5bmsdIhyMVmzs3oMS//9SuI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Juergen Gross , Wei Liu , Sasha Levin , xen-devel@lists.xenproject.org Subject: [PATCH AUTOSEL 5.6 21/38] xen/xenbus: ensure xenbus_map_ring_valloc() returns proper grant status Date: Fri, 24 Apr 2020 08:22:19 -0400 Message-Id: <20200424122237.9831-21-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424122237.9831-1-sashal@kernel.org> References: <20200424122237.9831-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Juergen Gross [ Upstream commit 6b51fd3f65a22e3d1471b18a1d56247e246edd46 ] xenbus_map_ring_valloc() maps a ring page and returns the status of the used grant (0 meaning success). There are Xen hypervisors which might return the value 1 for the status of a failed grant mapping due to a bug. Some callers of xenbus_map_ring_valloc() test for errors by testing the returned status to be less than zero, resulting in no error detected and crashing later due to a not available ring page. Set the return value of xenbus_map_ring_valloc() to GNTST_general_error in case the grant status reported by Xen is greater than zero. This is part of XSA-316. Signed-off-by: Juergen Gross Reviewed-by: Wei Liu Link: https://lore.kernel.org/r/20200326080358.1018-1-jgross@suse.com Signed-off-by: Juergen Gross Signed-off-by: Sasha Levin --- drivers/xen/xenbus/xenbus_client.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c index e17ca81561713..a38292ef79f6d 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c @@ -448,7 +448,14 @@ EXPORT_SYMBOL_GPL(xenbus_free_evtchn); int xenbus_map_ring_valloc(struct xenbus_device *dev, grant_ref_t *gnt_refs, unsigned int nr_grefs, void **vaddr) { - return ring_ops->map(dev, gnt_refs, nr_grefs, vaddr); + int err; + + err = ring_ops->map(dev, gnt_refs, nr_grefs, vaddr); + /* Some hypervisors are buggy and can return 1. */ + if (err > 0) + err = GNTST_general_error; + + return err; } EXPORT_SYMBOL_GPL(xenbus_map_ring_valloc); -- 2.20.1