Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp409161pxb; Wed, 18 Nov 2020 07:35:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJws92dLpGAa/tvUGJo1dfF9ZRWtym3pIckzwa/rlwprRWiHArsBrX3Ae4UIm2CNtM9wH61B X-Received: by 2002:a05:6402:14cf:: with SMTP id f15mr25946818edx.18.1605713737716; Wed, 18 Nov 2020 07:35:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605713737; cv=none; d=google.com; s=arc-20160816; b=Gieu2f1B9HeXuL9f1N4Jc1LyeYMK+jN1SWaNG7NuFa/Y1h2QVT7clb8clq3L4fm/1t PCABXrrEQr2zofa7vweEFpNOrxGTgS7wAH6tGXuaoFlyZOZJKG7aCi+Uv8GWsgIvCilO gyHGpr+wrMMQIHauiuo80H9llBWuwgPsgrxAqKTuq9uLHE3uGnFmnUTpKYhw5vTmeACU fpHWQDpyIa+yI/TkWkXzHVDXk3CIRg0vpRfqtNaexx8dtd+UNa2rBy0OKWbENPMTBl8G cPNjG+ZhD+R2UCrRh/QcljGCPXadmKj6gW+0C5Y6NnHuGEzmYD4ue8Yz+8RsQhGAow1I GJ+Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=8wny3kzVC1IR5EcyDuj2RgrjJgW1k6C8oLglaDehiy8=; b=P7I9h2+bVJqiBFgjbPgKQhGw+ouuJDrvYvFAvsaIL1V5+i0va70C1bAVhUOKVtLx92 d4Ah6y2B/9FKq+8uag59DHGbZwUzVZ7iZ95RspzOa7IB4PtufE59LH35DD4SbWzGfWue td834UAEBWn+ZxWS1FFdJ2N7SiU1ysQr3EO1WdUiq9mavkYDRx8Z41ibQeaoDdWq3xBi bywcIrYmnX8KG8lVNM/lXlsWfIV4Jd2DWFJi3ypPY6Wh8DtG4G0ZdneGFFjdSK56ZNTm 0SUap8X+8auhbFxcaHV8TQ6P9hS2xCsLooU08/rRCVnfhMdIlPh3o+qIq26sbO/MoNOO ISWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=c4N9dhSe; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i23si13529452eja.270.2020.11.18.07.35.12; Wed, 18 Nov 2020 07:35:37 -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=@gmail.com header.s=20161025 header.b=c4N9dhSe; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726677AbgKRPd3 (ORCPT + 99 others); Wed, 18 Nov 2020 10:33:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725804AbgKRPd3 (ORCPT ); Wed, 18 Nov 2020 10:33:29 -0500 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEDE7C0613D4; Wed, 18 Nov 2020 07:33:28 -0800 (PST) Received: by mail-wr1-x441.google.com with SMTP id u12so2684130wrt.0; Wed, 18 Nov 2020 07:33:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8wny3kzVC1IR5EcyDuj2RgrjJgW1k6C8oLglaDehiy8=; b=c4N9dhSeYwm6VvvieK5qW8KPOFOb1Wz2H51Q7yNynXg8juBv//gERwBeLKzbwe7SYD gRYs8sJUqzU4fU1K9rptXIZ3eD4PSiDudVOWVfQazs2IK9r0SIO75oNldS19wvQNsen3 laZGh20fuAcG5rdpYNSDFevl0ku0DWv72c798Mp5s/GQKTUX2VvPqSLNdwsb2ata6Q4M +XIJk9GCoG9MK5W5+eF3WKSy8DK5YZ5r0ARcUYJc1Gn3NZ43JFYwDNKwlIvyY7PlZrzE RUYYUPg9YgAQvFDo2PA9GXRNBcD1x0Wv8N9h/5pvuf3DY1Eruu/VL24OEcbIIUCAtlGs U1cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8wny3kzVC1IR5EcyDuj2RgrjJgW1k6C8oLglaDehiy8=; b=Oo0c10BkwxEHXeZRI4XVUxEv6G9PaehkXH/ENVdBmYGLRTa1k6NwWSC2M3r8SMIcSb GOu1uqvAYNBFecPHVHYOYGDxS9d1CP894xPyE4DB+r8OFJSODjYPjBNBYgHidLRo01hb WzrYmDEXPguopUnXwnSQtsJlO9N13vn0csag/VJPGmiVRRGQ1BW1UuT7847ACUROsuIr S5YCGbqDXsYh+bNLTWdcPdoe4E7Qt3KoKVoc7AkETiHlWmg0iFm5XfJW7Gky1c4kjyAN C4/iT0aM6xwEww2+AgBeXJwriI/nrsKOnxHp78ApZT2lJ563BGCv3lckhsmJflJ3iHHo pBXw== X-Gm-Message-State: AOAM5309lG8JUDzkQzNHm3mC0hXGi7/TCHIeaS9vR4NQnxcuJvcug7JU 9pnW3JYMdVNwc2DwvsVO1EpeBXOULzYMIC69 X-Received: by 2002:a5d:6447:: with SMTP id d7mr5525080wrw.96.1605713607160; Wed, 18 Nov 2020 07:33:27 -0800 (PST) Received: from localhost.localdomain (host-82-51-6-75.retail.telecomitalia.it. [82.51.6.75]) by smtp.gmail.com with ESMTPSA id v19sm4394146wmj.31.2020.11.18.07.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 07:33:26 -0800 (PST) From: "Andrea Parri (Microsoft)" To: linux-kernel@vger.kernel.org Cc: "K . Y . Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , linux-hyperv@vger.kernel.org, Michael Kelley , Juan Vazquez , Saruhan Karademir , "Andrea Parri (Microsoft)" , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH] hv_netvsc: Validate number of allocated sub-channels Date: Wed, 18 Nov 2020 16:33:10 +0100 Message-Id: <20201118153310.112404-1-parri.andrea@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) Cc: "David S. Miller" Cc: Jakub Kicinski Cc: netdev@vger.kernel.org --- Based on hyperv-next. 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 3835d9bea1005..c5a709f67870f 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -1226,6 +1226,11 @@ int rndis_set_subchannel(struct net_device *ndev, 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.25.1