Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3755340pxv; Mon, 19 Jul 2021 08:02:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEhZwsket+v8+xEqgJh/nobMm2tkTcQrjSBRfsJm4JZg9Sdizp/+Ul8zBKWFFauEWh56aD X-Received: by 2002:a17:906:a04f:: with SMTP id bg15mr27873268ejb.417.1626706961506; Mon, 19 Jul 2021 08:02:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626706961; cv=none; d=google.com; s=arc-20160816; b=ObusorXvL2Luih7p98LejQHrBuXnFpRmcKaJAHigFjc0tz+oSFTz38NstZ215uLXjx qcD+IGuBt2DDcO8EX+6jxS0AgXoC1KCgY8vANB+xfVqkebgt/6a7+KbBn9ldvkVRLQZL NQeP1YfLza5eaF4fkYFWWsGYII6brx57pIfuWpJDGTPulxbp/KZ0Eq9oxRfLFlYrPUC2 x+qhiVw+XBBna8JrJEWDBUC7zjMB/fwkGnnuShJViDQ6s2lXlOuS4sJmgHQDMh8ZPjaA Depp01DYqxlsnjJOD3jRQ0F16sU2Yp6SXY5V9QRJAxihtigTJf9xn6IFOX2EuGSTuBUW IpfQ== 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=tPM0tNyK8UmWuf/o+hjh1KKfeH7hrZEGs8jL1DQPIl4=; b=YEGZ2pBRQ/Zubhbs3HfWAxf+0JEuNchQijbSgu4D6FRipYHh1Ziv9Cn6CMOdpQJEOa GsuCCiisJFZxvXVfaFijo5Kj5pOH57I5xVdHc27ZEm7FGTNVbq6SOKJsjWWjmgLKB8hj XswVtBxJZ8RJfNyAfRyUT5DWLM8WO+nvUK4l/dAi4EQOZ+inXJRK67xXN2GENlM9VJ5a vQYEYJPiyAPN00D1TVGijuXuj6WoC7mvhEE71oXgm29rBge3ElVkqgkuXfyH2DkiuHLc JkRD+LpZDx8Pz/HQLYADGnFqgffy+c+Yx+aMl8tkxdsqfIzd8qzjogLkOjiFiWfuykGD x7RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="fI2bp/Nm"; 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 k22si20902483eds.0.2021.07.19.08.02.14; Mon, 19 Jul 2021 08:02:41 -0700 (PDT) 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="fI2bp/Nm"; 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 S242159AbhGSOSR (ORCPT + 99 others); Mon, 19 Jul 2021 10:18:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:51666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241505AbhGSORa (ORCPT ); Mon, 19 Jul 2021 10:17:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3887E610D2; Mon, 19 Jul 2021 14:58:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626706689; bh=goPWnGR9FFZQkpBa1JFvefYOOvvJ/dsmy54RL39bWxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fI2bp/NmhCHvq3ryvzVOgqiFvHVeerGPrz5LdUdAT0zKg8pSxOd4W4kdhrj/TsOuE G6HYaeQ1rDh+wiQNDWFXbDCL+7DGBSKdT315WXkt/tC3plCrhE48dCnQBn4WfCktgB ieKDGPkttnpg/chaGAvbAX3Dq6WyfLSItJyF0jok= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.4 038/188] media: dvb_net: avoid speculation from net slot Date: Mon, 19 Jul 2021 16:50:22 +0200 Message-Id: <20210719144922.016641894@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144913.076563739@linuxfoundation.org> References: <20210719144913.076563739@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: Mauro Carvalho Chehab [ Upstream commit abc0226df64dc137b48b911c1fe4319aec5891bb ] The risk of especulation is actually almost-non-existing here, as there are very few users of TCP/IP using the DVB stack, as, this is mainly used with DVB-S/S2 cards, and only by people that receives TCP/IP from satellite connections, which limits a lot the number of users of such feature(*). (*) In thesis, DVB-C cards could also benefit from it, but I'm yet to see a hardware that supports it. Yet, fixing it is trivial. Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/dvb-core/dvb_net.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c index ce4332e80a91..735baa74043c 100644 --- a/drivers/media/dvb-core/dvb_net.c +++ b/drivers/media/dvb-core/dvb_net.c @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -1350,14 +1351,20 @@ static int dvb_net_do_ioctl(struct file *file, struct net_device *netdev; struct dvb_net_priv *priv_data; struct dvb_net_if *dvbnetif = parg; + int if_num = dvbnetif->if_num; - if (dvbnetif->if_num >= DVB_NET_DEVICES_MAX || - !dvbnet->state[dvbnetif->if_num]) { + if (if_num >= DVB_NET_DEVICES_MAX) { ret = -EINVAL; goto ioctl_error; } + if_num = array_index_nospec(if_num, DVB_NET_DEVICES_MAX); - netdev = dvbnet->device[dvbnetif->if_num]; + if (!dvbnet->state[if_num]) { + ret = -EINVAL; + goto ioctl_error; + } + + netdev = dvbnet->device[if_num]; priv_data = netdev_priv(netdev); dvbnetif->pid=priv_data->pid; @@ -1410,14 +1417,20 @@ static int dvb_net_do_ioctl(struct file *file, struct net_device *netdev; struct dvb_net_priv *priv_data; struct __dvb_net_if_old *dvbnetif = parg; + int if_num = dvbnetif->if_num; + + if (if_num >= DVB_NET_DEVICES_MAX) { + ret = -EINVAL; + goto ioctl_error; + } + if_num = array_index_nospec(if_num, DVB_NET_DEVICES_MAX); - if (dvbnetif->if_num >= DVB_NET_DEVICES_MAX || - !dvbnet->state[dvbnetif->if_num]) { + if (!dvbnet->state[if_num]) { ret = -EINVAL; goto ioctl_error; } - netdev = dvbnet->device[dvbnetif->if_num]; + netdev = dvbnet->device[if_num]; priv_data = netdev_priv(netdev); dvbnetif->pid=priv_data->pid; -- 2.30.2