Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2459682yba; Mon, 15 Apr 2019 12:06:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+Ig9xGakDmdaPRXHShaamM5h4qFSEvfXqM13jm1ifvc0jFIgeEG4zCTuuGxxbaJzYHc7I X-Received: by 2002:a63:cf:: with SMTP id 198mr19844338pga.228.1555355168732; Mon, 15 Apr 2019 12:06:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555355168; cv=none; d=google.com; s=arc-20160816; b=FOz9cizg4SrFzP3U2fLOxGlFg+XfzB3IUYQilk3ahrsKbfbEq7cJy6G+bPADfiZ2XS CxBozZBDvZp87XawW4bwrp6V86njXsTNuVJrGa5R5ZDSSf0qplI2YqSgMML1j9hOEARn gTZawsj4VVXSJFRKfRUP8eSjHXuM5kXfV/eeeFe2WozgIowaf1iOzmvZcmr7EEB3roaP WKT9EPEphppsxnw5u/bdfkMzg+OWhiHeHuvqzrRKQICd4kErBGnIikkCDvTxsTTrhB+c occje5WsaXnI5urWQRc0seOUy2CLq/sAU4i5XdxdYOjIIt7INbS0t6qkhtn4WbB8/MvI SZUw== 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=Eg3/wRMHTv8NeA/XDdpIWoFvDIxdHScaMnWZbKVqUsU=; b=jUqNP/pDbHefqBB9+bZgyBga0x4PQQO7thMeOVSK2XJZD1ScdYOYP2ECo9G37Tc9eK CbHNSkuaM87/+5JeTC0+nZzV0IbQDSLxNHI47Tm7g8SmUhudq02A/vGyDKXNPrRzoInl RDtt2yNP8qjg4wmx2SlL1QUZ7vEHqU074cQhhYDxDP/xeObBB6AZx6pu9nv8TFCXxAEM 7nKCStwHOZWZQnxh2s5uQTDOTByK3OiqpD0A+RDiUeRWo9Z37tDqcX/I5v2JcGOJ2+aL 0m5A87vkHkLEQi0G0INwb9u1Qk5bfTwqlNbGAq5R4tqY8wgvOTUpq1pciXtjExOZC0SI z0ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sQfx1Zfv; 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 j10si46562482plb.346.2019.04.15.12.05.52; Mon, 15 Apr 2019 12:06:08 -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=sQfx1Zfv; 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 S1729565AbfDOTEd (ORCPT + 99 others); Mon, 15 Apr 2019 15:04:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:37412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729519AbfDOTE1 (ORCPT ); Mon, 15 Apr 2019 15:04:27 -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 596D1218DA; Mon, 15 Apr 2019 19:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355066; bh=FSot5ajDooOK5ejFH0Px/bpFGRjRkguVbJL6pzZxERY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sQfx1ZfvW+42acFMTQ5X4KaJDYCxkBm9b7Ik1q1ZdSs7U9mdyTal/IxP9JFSNL/9N LlPhCNZhkNvajtNjRDXZiBw/4V0awkRDpLYHLM/0fcjQ2Ty9scy2BPsHsVYXfs0jdT PT/GPP0WodOgTxH231yLKA9722ppuytYkRJVC3iI= 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.14 60/69] xen: Prevent buffer overflow in privcmd ioctl Date: Mon, 15 Apr 2019 20:59:18 +0200 Message-Id: <20190415183735.614134038@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183726.036654568@linuxfoundation.org> References: <20190415183726.036654568@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 @@ -217,6 +217,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