Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3560301pxb; Mon, 1 Mar 2021 13:21:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwAm8eUXky8fyjJliBO+zXpJTOASPB2o86LRVL3sJJ5oz9FC2bJteNmEcZidKw91s1uYaL X-Received: by 2002:a17:906:3849:: with SMTP id w9mr17844432ejc.7.1614633705804; Mon, 01 Mar 2021 13:21:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614633705; cv=none; d=google.com; s=arc-20160816; b=eB7QpopW2chVT//bj/P2AHy0hr/8JsF8qy1hjAObOhtMxHF2H2viB9ipYnXAzuOXmD A4L/sCPb6B8lf5Ss+8QSP6zgni2KzRRtiNlA5gKVUnaMUU5YYwIY+EqDPRDwZyl5Pdzg o6j0qup6iZtaDmYsWbdW5hWDvvMDEuPOz9dmoBVhgzG6eOUpCPkl343lbjnn7glh/EgV nF4r+3E3pZDsrXN4QmeRYhd8A6v7q4GrJnWEpqQSGeu2xlby68YMhM0hJdW7hoWBDylG ACGRx5ajD+4YD6KO+xyMRqKrdhPuGNaAg8DeZIV4Pp8Z/16jRNX+BSt8QePul4N+dO5F sBpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1TSSgN1jsKOuq74jLH10ZEVHBFMjcpqFlabSq0FyqLg=; b=sUQ8yGPt5NH+GnJrYxozDiGgnhYQAWeR0XhIq1u6Xa3/BaR3fCtzcxL2goaR99Q87D fjk74E71poS4ZP5gFpEAzxteVA/XTRBqcq7k0B55F0lp42OeAp/YGN+B8zFVqZ5st054 NaVa7eeinulw+abSS5NQTiLKnHwE0AH/oHaSweOCiJzuany5C38T4cIzyhIOsalx0Ny6 V7q00aemtQjoJz0FhX+8NGFrFkzjiVIv9/5fC4xXaK0WTI2CipCIeaMR4GYZlAMMXoG+ 34KcjzBcDX+jAnNEoxUDv0/jiuBV3QN7Nx1J1P3DMwWHzuMGRMxn4YT9H0mg5cfwQwfu 2DEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="nJn9/qGy"; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n20si12494585ejj.318.2021.03.01.13.21.23; Mon, 01 Mar 2021 13:21:45 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b="nJn9/qGy"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244235AbhCAVSe (ORCPT + 99 others); Mon, 1 Mar 2021 16:18:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:46226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232046AbhCAROC (ORCPT ); Mon, 1 Mar 2021 12:14:02 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1372F65034; Mon, 1 Mar 2021 16:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614617109; bh=E244ZyM4FbGv/nvusqc4Wa3S0nONGOmFsZYqhti3Rms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nJn9/qGyzmP3O/qZ2Za0Jk62bbAvVyaoMK/u/6ZMH+PShweSUlBALg3A1ngxIPxKo cJsVeaMU/42GQovzn6f2u3zUMc0+dK4BkBy0KAfkYMn2Zogs3k8JD+Ksi3OjW4fsFJ xTC5emvoA2j5R4ZG7wYFyZE2Y+zuDkvkdwwthcmk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+15ec7391f3d6a1a7cc7d@syzkaller.appspotmail.com, Sabyrzhan Tasbolatov Subject: [PATCH 4.19 206/247] drivers/misc/vmw_vmci: restrict too big queue size in qp_host_alloc_queue Date: Mon, 1 Mar 2021 17:13:46 +0100 Message-Id: <20210301161041.754746654@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sabyrzhan Tasbolatov commit 2fd10bcf0310b9525b2af9e1f7aa9ddd87c3772e upstream. syzbot found WARNING in qp_broker_alloc[1] in qp_host_alloc_queue() when num_pages is 0x100001, giving queue_size + queue_page_size bigger than KMALLOC_MAX_SIZE for kzalloc(), resulting order >= MAX_ORDER condition. queue_size + queue_page_size=0x8000d8, where KMALLOC_MAX_SIZE=0x400000. [1] Call Trace: alloc_pages include/linux/gfp.h:547 [inline] kmalloc_order+0x40/0x130 mm/slab_common.c:837 kmalloc_order_trace+0x15/0x70 mm/slab_common.c:853 kmalloc_large include/linux/slab.h:481 [inline] __kmalloc+0x257/0x330 mm/slub.c:3959 kmalloc include/linux/slab.h:557 [inline] kzalloc include/linux/slab.h:682 [inline] qp_host_alloc_queue drivers/misc/vmw_vmci/vmci_queue_pair.c:540 [inline] qp_broker_create drivers/misc/vmw_vmci/vmci_queue_pair.c:1351 [inline] qp_broker_alloc+0x936/0x2740 drivers/misc/vmw_vmci/vmci_queue_pair.c:1739 Reported-by: syzbot+15ec7391f3d6a1a7cc7d@syzkaller.appspotmail.com Signed-off-by: Sabyrzhan Tasbolatov Link: https://lore.kernel.org/r/20210209102612.2112247-1-snovitoll@gmail.com Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/misc/vmw_vmci/vmci_queue_pair.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/misc/vmw_vmci/vmci_queue_pair.c +++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c @@ -552,6 +552,9 @@ static struct vmci_queue *qp_host_alloc_ queue_page_size = num_pages * sizeof(*queue->kernel_if->u.h.page); + if (queue_size + queue_page_size > KMALLOC_MAX_SIZE) + return NULL; + queue = kzalloc(queue_size + queue_page_size, GFP_KERNEL); if (queue) { queue->q_header = NULL;