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=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 EAD5EC10F11 for ; Wed, 24 Apr 2019 17:22:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC0B12190A for ; Wed, 24 Apr 2019 17:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556126565; bh=Y15mdb/FX2OjdgrljJXjBehOVD4p0q/aeD6RWdNMAeg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=mSOckD2gKwTtrn3w0hBI+eRgHa1qVHtXKDzkdRMArVfWgHWCOW6YErS1A6RBQXIUb vszYMwk0V/7pqRBdfSNuduPld1QFPY5WEVchhYVX9CQJU+PjZo0bSJPXtxwASZapbB MyJ6ISpNDfb5RUKbXWgh4QXDcbyssaoo6xOtKvn8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389614AbfDXRWo (ORCPT ); Wed, 24 Apr 2019 13:22:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:48268 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729896AbfDXRWi (ORCPT ); Wed, 24 Apr 2019 13:22:38 -0400 Received: from localhost (62-193-50-229.as16211.net [62.193.50.229]) (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 065EE21904; Wed, 24 Apr 2019 17:22:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556126558; bh=Y15mdb/FX2OjdgrljJXjBehOVD4p0q/aeD6RWdNMAeg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LZT5OaGZC0s2zfGIOOoUOK9dKWFAboRR+BKRvz2KZsM3V4r1FpH9gyGAW6047KUdn KYG0xhzk8gg/+RuUPGDQ4aqMng6E75I2skD1k4MG6CwY1ucE+4OJmIIOIN8O5NZYM4 rKHWgiGtSelI4FNl2HJGbygWH97ctJJU6Pvm7Ix0= 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.4 094/168] xen: Prevent buffer overflow in privcmd ioctl Date: Wed, 24 Apr 2019 19:08:58 +0200 Message-Id: <20190424170929.278349054@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170923.452349382@linuxfoundation.org> References: <20190424170923.452349382@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 @@ -215,6 +215,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