Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2447164yba; Mon, 15 Apr 2019 11:49:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqx93ZU3tLspthzgbb2PrBmLzB5wmex0upFbX5Sv5sB9d9uPEsl5+dj+vGqFd+MoaEY8Hdw9 X-Received: by 2002:a17:902:302:: with SMTP id 2mr53950591pld.232.1555354191405; Mon, 15 Apr 2019 11:49:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555354191; cv=none; d=google.com; s=arc-20160816; b=az39yZHJZSX5z9sVP5sCygixVuc1Mga92mQCyanM7I35PhngKhIG8VbwmxVNDDL40s 3/FHuAmHi/DWkfYGjra9a2RKHfcw0wqKDFyGDLEmObq0cowwKc2nEmolfb1QM02kNfTe 9XEVgG5zvd2FnkVnANZ8E6rwU755x7rLadpGub6AcWWJyn5QKqtjAxzox0BB/K0KK24b HXOvw8J8vaWmRJDqzEGqt5ghquHAVotYuTabNgGfEzVaVxfMG+xRZFe4Is6U0iYM13tO T7sewymTnhzhsFSfPiMHftst7TslUZ4L+7sFrfwpNhN2kpynZ7lcKbS74+2gM2xKnDyE 44Ow== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BanAMUgUUh7K/9qDp9VNLAe/Ucmbicx2TYQ5N9+6/xA=; b=YDKZuWR3jnl+vNS5SibJDEXJxGYEekHu2G/m4ztycByYUyzHjzB2gPaE4VBPiEN/u9 ziRDxwfz40cJWQEsv45lHoNDg2sid9Q0glV2UttLhLSFm4cf/vEFKEOTwV2DQReQd5AF OIYiqsgMn3capQG7S52tO6CTfAGYnj3rAUMylDxLSywYJ2XE8aCGEK+bE8FyuDH1fEcL N/Eg7gd65kZeSI2kJ5m2y/AIlJfhOVFgeIF/dT7C7naposX39MDE82mwoMHtCcvS2AI/ OrbC7y3jte3KU3MDLWoiVYUh4vVx8duf71ZDNFqEkGEZOBA57bSoiiVOL1wBxju8wsgv MECw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="p4L/gzTG"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 82si47376147pft.35.2019.04.15.11.49.35; Mon, 15 Apr 2019 11:49:51 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b="p4L/gzTG"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728604AbfDOSsT (ORCPT + 99 others); Mon, 15 Apr 2019 14:48:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:52112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729095AbfDOSsQ (ORCPT ); Mon, 15 Apr 2019 14:48:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 13A91218A1; Mon, 15 Apr 2019 18:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555354095; bh=SY+UyONV8wP7f3PvhZP+xucsYBGez/OGqrhjyq/DTAo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p4L/gzTGb2kvjCxMTT8MXbqFGGNiWzvOg6iWqviL6cTzrpqIwyg+aUlKtb+LtN0UI f4Vc61uPV2h2aJpNhVJ7nGUWdXjgwEDOcSSBZudfGnXkLuwrVK5G828qDe/toXXX0o 30hQtOQusUqxPYn3lgT3ENcQ1MKb10bgr6PTtldQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Boris Ostrovsky , Juergen Gross Subject: [PATCH 4.9 73/76] xen: Prevent buffer overflow in privcmd ioctl Date: Mon, 15 Apr 2019 20:44:37 +0200 Message-Id: <20190415183729.388192500@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183707.712011689@linuxfoundation.org> References: <20190415183707.712011689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter commit 42d8644bd77dd2d747e004e367cb0c895a606f39 upstream. The "call" variable comes from the user in privcmd_ioctl_hypercall(). It's an offset into the hypercall_page[] which has (PAGE_SIZE / 32) elements. We need to put an upper bound on it to prevent an out of bounds access. Cc: stable@vger.kernel.org Fixes: 1246ae0bb992 ("xen: add variable hypercall caller") Signed-off-by: Dan Carpenter Reviewed-by: Boris Ostrovsky Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/xen/hypercall.h | 3 +++ 1 file changed, 3 insertions(+) --- a/arch/x86/include/asm/xen/hypercall.h +++ b/arch/x86/include/asm/xen/hypercall.h @@ -216,6 +216,9 @@ privcmd_call(unsigned call, __HYPERCALL_DECLS; __HYPERCALL_5ARG(a1, a2, a3, a4, a5); + if (call >= PAGE_SIZE / sizeof(hypercall_page[0])) + return -EINVAL; + stac(); asm volatile(CALL_NOSPEC : __HYPERCALL_5PARAM