Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5453294pxu; Tue, 22 Dec 2020 18:28:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxP5e+jEHlWQDP1eCcfyD/hh8UMAURlJ0AASd7qYTjJFB91wLLzld4iyi+l36A7aDH3o7dx X-Received: by 2002:a17:906:22c7:: with SMTP id q7mr22378698eja.486.1608690504626; Tue, 22 Dec 2020 18:28:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608690504; cv=none; d=google.com; s=arc-20160816; b=LHfFXtslRvSakUN4ybaVVSUJoC48lZtqYnJzvgnD/bFj5b38TidApm9W1IcFbdpN0V cTQCViYwKdq5lcBEdiMzsM9PfFDbhe+I88JmYMxqDPWH2VME5tbupmOJhNv7fR+J6zJr ngFHUVHCWbSM7/GRtUkh+UoNbjxIrcLmIOw01JC+sRuizCRGuJRkCYCPzguRe0BforHl UufGXA4EHxdpkQdN+9JKOf1WD/Lwub/hpHHJhCFc12HLqIk0gWy5DCN0wwO9zcuyt54H MYsOrydchUytyBhddgulXqJNlCM2t4a7dZTEvQsvfTcKkP2NTAIZ9Htzbk+obZDGT4sj rzrA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S+kkMRIDpGTA58FGjwtKpqWdipQT3/xlSfn7Q8ZhNEE=; b=XiiaLftjMPCGLFvJSdZwzFSZSRyJ+h/ZNNiWtBTWV8XVtA0Wza7sdrTFuuyXgT679c UGygfrhPIPkT3hr/oik+pNpcdH+520dfdSQdXCfnMI5mRMf8naon+l185gM5FdJlgYWv Ka+fgysLQRDZVdJC7wBZHcbx36I+/Doe6L4wixv3DBp3K4qH92ADeRzOWP1HgET9MNRp kK/2cH+nya3RlPdapDtvlZ4zOoyDzKhO+NCR+qQLQKdusj2vIVz3n1F56k2WH+Up2ZDb BaSVLFDzYDVkSDqKZxd9Y541FuNShc/1kyo6+hoC3xaL+YP3Hs+IX6YmPxTwAqY0KDuT nfrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=d0aKETvT; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m15si12991544edp.363.2020.12.22.18.28.02; Tue, 22 Dec 2020 18:28:24 -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=@kernel.org header.s=k20201202 header.b=d0aKETvT; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730241AbgLWCYa (ORCPT + 99 others); Tue, 22 Dec 2020 21:24:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:54254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730193AbgLWCYY (ORCPT ); Tue, 22 Dec 2020 21:24:24 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 84E66229C5; Wed, 23 Dec 2020 02:23:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608690223; bh=Df0DxbSAYSyYMU6NKNk1/U88ie/hjegk9tYCULiAtNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d0aKETvTlnWOjI7jAKw+T/7olhy6+jWSpTK9C5InuSCzbhhtCgtXNG9mF2aABv2qd 5EKgMcgWeRtJLOMyPTaoQSl/FqptRaUcpeYM4ZH6NoS1jsULNBYA7+XcFTOQwD60rO UmTjtEdtt1ejY60siZaXAcEmDvxIOmTkfw2FlWNZijhk1XgrdvnIqaf7UE6t8f6aqb kSRgb9M7VHubQNVoOMcO8Oc7o23dMyK43xFC9xKCgqFSaLguEtLfur4yt0krYTM2mq fS5i0qhloe0d+FiN6K6fmjGkcIj/knkkZWWyYu2lMLiwuaLB3mCa98hTdJIh9an2Vd ByMnlJnW9++WQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Andrea Parri (Microsoft)" , Saruhan Karademir , Haiyang Zhang , Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org, Wei Liu , Sasha Levin , linux-hyperv@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 40/66] hv_netvsc: Validate number of allocated sub-channels Date: Tue, 22 Dec 2020 21:22:26 -0500 Message-Id: <20201223022253.2793452-40-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223022253.2793452-1-sashal@kernel.org> References: <20201223022253.2793452-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Andrea Parri (Microsoft)" [ Upstream commit 206ad34d52a2f1205c84d08c12fc116aad0eb407 ] Lack of validation could lead to out-of-bound reads and information leaks (cf. usage of nvdev->chan_table[]). Check that the number of allocated sub-channels fits into the expected range. Suggested-by: Saruhan Karademir Signed-off-by: Andrea Parri (Microsoft) Reviewed-by: Haiyang Zhang Acked-by: Jakub Kicinski Cc: "David S. Miller" Cc: Jakub Kicinski Cc: netdev@vger.kernel.org Link: https://lore.kernel.org/r/20201118153310.112404-1-parri.andrea@gmail.com Signed-off-by: Wei Liu Signed-off-by: Sasha Levin --- drivers/net/hyperv/rndis_filter.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index aa0bbffe49005..1db34b7a423ef 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -1100,6 +1100,11 @@ int rndis_set_subchannel(struct net_device *ndev, struct netvsc_device *nvdev) return -EIO; } + /* Check that number of allocated sub channel is within the expected range */ + if (init_packet->msg.v5_msg.subchn_comp.num_subchannels > nvdev->num_chn - 1) { + netdev_err(ndev, "invalid number of allocated sub channel\n"); + return -EINVAL; + } nvdev->num_chn = 1 + init_packet->msg.v5_msg.subchn_comp.num_subchannels; -- 2.27.0