Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp469399yba; Wed, 15 May 2019 04:40:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyA23J8dZb1UxKWVvIXUdmz55DAvTFEn+YwalZSZp+YpA+gOjRMKUvDeJPuTaz4MgxcLShJ X-Received: by 2002:a17:902:a508:: with SMTP id s8mr25641384plq.186.1557920445571; Wed, 15 May 2019 04:40:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557920445; cv=none; d=google.com; s=arc-20160816; b=Cn2MHJijzJ+MoD48bXOmzzhOsWut5TH6lU98bWmXmiymxeydlmhabv8QbsJXo1qxxM b/BwHbIN5jJ9EoqdqXYW5YVqwpsARedA9YmQ1nsXi2+wd5pncFiKoIRcU/ayMTrcR5DZ dh49qI6B7PeyS7rd81cSRotm5yr0Kzw/SqmTNnXaKnztrd+HQzxhokF0gRYfKJwRRgiV l6kvwiZ1CevLFrPtChvQ302rIuT1BXPQYdPCpC8cH99IxNG4vDksY1EvXe21NZg/urxY LsOj4I+OGMAT7ba+6+lrrElLDhaKfGo8NJlbihRMr7KZ/2qBv9lGATs+YONG4HoAj+OC daXQ== 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=fxTOhbODm1AR2UcAuMbMQCES/TJ1tTAW8l1nUuXdV3I=; b=LB+xCu60owiurC3tQej4nWf4BwiDVme0vZReZ0RmdPrPp6RF4FFsirSGT9A1wPNsVj PmcyPdQ2IJfWgszLzk1twBeRnCQfJpe1mnpgoEeStmmOU3Qhd9EgrvoinNdL+rLyPiXC RpUsY1VWW184w6giSRncnf7vnucPNIXWsdd/7vL5KdWyNwD7ta+PC08vFnfRfGLD4wer rNHUKef0LX+b+pOqcUZE+ZAXbgmB+0QiTshNdi45YOmkRBL+zoLO7O85uaFtD7ikL0iz Hi2P8qgYzqQVTIuSA7yUXgZ7BMCw4Z/Vl9viwa3C/2ppiJkWgWo4U62Na/64/6Ygyi2y A9GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uk5btYLO; 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 f2si1620116pgv.441.2019.05.15.04.40.30; Wed, 15 May 2019 04:40:45 -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=uk5btYLO; 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 S1732916AbfEOLh2 (ORCPT + 99 others); Wed, 15 May 2019 07:37:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:43776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732950AbfEOLb6 (ORCPT ); Wed, 15 May 2019 07:31:58 -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 CD8842084F; Wed, 15 May 2019 11:31:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557919918; bh=xSihnVmtY+9iC4up/Mcox0MkU/6kFtZPpELlpQf8rew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uk5btYLOy2kj30AvIg5Zr0d9R0bkKCDGC0uZR6lPp5Jme5v+PPEKDEhC3VsOmnEkP m+yZsTiQUCDzWj/q9+dq0XeOpd1rufyErLyoPlVVIKacwcRg+m5kzQjtthgH4iFrKC CuWFIEhs10atmdqI/RuahorjypR67RxsX3Sw+7l4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Andrew Morton , Timur Tabi , Mihai Caraman , Kumar Gala , Linus Torvalds Subject: [PATCH 5.0 129/137] drivers/virt/fsl_hypervisor.c: prevent integer overflow in ioctl Date: Wed, 15 May 2019 12:56:50 +0200 Message-Id: <20190515090703.253516189@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090651.633556783@linuxfoundation.org> References: <20190515090651.633556783@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 6a024330650e24556b8a18cc654ad00cfecf6c6c upstream. The "param.count" value is a u64 thatcomes from the user. The code later in the function assumes that param.count is at least one and if it's not then it leads to an Oops when we dereference the ZERO_SIZE_PTR. Also the addition can have an integer overflow which would lead us to allocate a smaller "pages" array than required. I can't immediately tell what the possible run times implications are, but it's safest to prevent the overflow. Link: http://lkml.kernel.org/r/20181218082129.GE32567@kadam Fixes: 6db7199407ca ("drivers/virt: introduce Freescale hypervisor management driver") Signed-off-by: Dan Carpenter Reviewed-by: Andrew Morton Cc: Timur Tabi Cc: Mihai Caraman Cc: Kumar Gala Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- drivers/virt/fsl_hypervisor.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/virt/fsl_hypervisor.c +++ b/drivers/virt/fsl_hypervisor.c @@ -215,6 +215,9 @@ static long ioctl_memcpy(struct fsl_hv_i * hypervisor. */ lb_offset = param.local_vaddr & (PAGE_SIZE - 1); + if (param.count == 0 || + param.count > U64_MAX - lb_offset - PAGE_SIZE + 1) + return -EINVAL; num_pages = (param.count + lb_offset + PAGE_SIZE - 1) >> PAGE_SHIFT; /* Allocate the buffers we need */