Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2706912pxv; Sun, 11 Jul 2021 23:20:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3CQ6wyHfnjrXLaOscjfUUC31wnOOLgrFx40jZ3YkOfXrR1fJUIxegql2mpxdkgLdAyNKY X-Received: by 2002:a92:ad02:: with SMTP id w2mr37028878ilh.8.1626070846180; Sun, 11 Jul 2021 23:20:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626070846; cv=none; d=google.com; s=arc-20160816; b=EW+Ha6j+6JZrkjy2Q+IYoDUF+Ry5JILoSioceXPO3ATY+8tsBoxYmnT+7bfDBDGKso 9RdfmaialTkJUBDLVlqex5xG9hRKfSFZtMzbpmYi+/5x8aOrTbxvLL01OfcKtu8U1XcN A8b+BxaazzupeLguyDm3mshVDHrgOiS/MSNuynqywf7xsuFz/YFXv6dxO4Z6JvMh1DC6 OGDPi9rblnbET+CKmXhbp9cldBrtM4eKz6JVGtcXoZAzVRaqySuFF4WD1fnOIniK43ve vMs36yPgqlk15UCozjkH6M3Kjj5qgrW6eDXZWRbAvul3F2yDBcZ/epMuhnUIPvTincaf KLhw== 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=9PHDuLgeEfkiMeSJ5suoBAwxTfp1GefCnp9RG7FCKrg=; b=jNiNXl5y98WxtvkmG9O4U31h0KargwGkbp2J2COcuuxVymIpQzA4QxtVbDhromWtSD OL1eA2JEFydbfr2vUtyeFXYzZdkKQqXEOlBFL4DvJXypjt0Ix6Id1LCpe2iM/esbT5cR 11W53YL/waXKEsPV/lfQhlG8Bi7i0jAB6FaCchjhB2HwVa7Hic5o35rb3kAw2tn1jTyt OCJVifnJjCH4rdSnUffpfdpqQzKop3uodLww+0Vvi4126IJxhMd07+8lCkdh85fnw00B +vc6vPtKk1NjT3yAMkZosmOxHINfwSNMvpPQrxncGg/FMn/Yj9n8+xF4kDeG7/0sj5KC pAXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ye7aYzkj; 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 f16si15701637iol.39.2021.07.11.23.20.34; Sun, 11 Jul 2021 23:20:46 -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=ye7aYzkj; 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 S234488AbhGLGV5 (ORCPT + 99 others); Mon, 12 Jul 2021 02:21:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:39276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233958AbhGLGUx (ORCPT ); Mon, 12 Jul 2021 02:20:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A6BA46101E; Mon, 12 Jul 2021 06:18:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626070685; bh=3er3/ZhZpIG+wIuMrxSwUwa2s/X04w9Ud+G1v3rj9Mw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ye7aYzkjoDSYeN8D/ur09fs1D5yaP2y2OUqKr0Za7djIAJ4YEl3t5JoApvQRlZPet 5nb6GKkzRtrousBYnmg+UzmreLaAYGvt99XIdOvpxziz2aXwGWL30TjXyvspFxkz0D M31BTe9ATJVRbsrK9ZjXYw/mcFZ7HndlRnsd/GYo= 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 5.4 096/348] media: dvb_net: avoid speculation from net slot Date: Mon, 12 Jul 2021 08:08:00 +0200 Message-Id: <20210712060714.440301756@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060659.886176320@linuxfoundation.org> References: <20210712060659.886176320@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 630509ecee20..9fed06ba88ef 100644 --- a/drivers/media/dvb-core/dvb_net.c +++ b/drivers/media/dvb-core/dvb_net.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -1462,14 +1463,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; @@ -1522,14 +1529,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