Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1087247pxk; Fri, 25 Sep 2020 06:02:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjGRTXsnlHastrpQW+UsuCN2csy85rTqAOykOFFlfuNQIOa+tJum9jGFpatW288WaD8MYZ X-Received: by 2002:a17:906:d11a:: with SMTP id b26mr2512270ejz.191.1601038966428; Fri, 25 Sep 2020 06:02:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601038966; cv=none; d=google.com; s=arc-20160816; b=UWhp98EukFBehwpJd10bctnsz3EBwzBrPfNVe10FaamIGKCKLeeprDXbcoFMIFpWgM oN2CWSxqSaYN0X7lRzAFj3aMsG5bnqRHbTH/nW+6rZEk6Fc5uvvasniIk6zMgMmSK6fm RzA1zokF/dyBQmSU1TopZnpB5zFGXwUPivIDLVUlKwN2wocngU6EgYMMnVxBrI9Gq4Zh H9x34gE+j4AAuYMw3wTLf7+jy1Sm0NDRlB1RKsnGsrsNTl5qwUJ8pIvXe/0XaTuuLlu3 5YMPz7iPN0MzhSDMcOU5VWKmDhaL5QcExLNrxH3oCFbzxVU1XBCCK4minj8gBosRCtHl 7nAw== 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=BmWENpV88LPyPkeO62wYYB2qqfYToGi7GeMpMfKOTQo=; b=FJ5UbueCJoLM9t6esm+B5viptvJALff/Ruq8HK4G7ZfO3kJsna8kTlo/Pu7FxfuLai IPSQhiYPyvSY5ChNrXU5KC8R8wDbLO9Vc68QpVNdUzqfnrcnrLHDvwhaL7a+DF6f/E25 29yC3xow9h8xBA0lAw5rL+X48cdNSiBxRhJe0FuzTW3LaY4tCxVDRISFBWpu09M/q+CE DNIASwSf7mNQnZpemfiffJOxF6KZFrdjDiNjij1kHbwzotrPgd5UVlSASLM+Rmvo7Grb sETeXwBwDAE6NmyGTYMwpSe6BBmCaM8tB4ncK+ZKgPfSLb5qxdU8ZE/nbrcp8riWM/kE tWQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EqpIcWkc; 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=fail (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 w3si1667127edv.488.2020.09.25.06.02.19; Fri, 25 Sep 2020 06:02: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=@kernel.org header.s=default header.b=EqpIcWkc; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728760AbgIYMs6 (ORCPT + 99 others); Fri, 25 Sep 2020 08:48:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:52256 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728693AbgIYMsy (ORCPT ); Fri, 25 Sep 2020 08:48:54 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 57E2721D91; Fri, 25 Sep 2020 12:48:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601038133; bh=PPN/qdWXlnXkKZBiVulHZK1tcJ6jUktf+89bZU+dDeU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EqpIcWkcXh2yONTagQVaMQ5cqeIVkEj18UJCOfZltMCqZ+7OC+jBeVVnX85qFipF/ ydvlMS3o4mmOPuHG923i4zXmvB+eExYZ1vpoqgyB2bul51sB0OM47r84b/UymV2f8L cRTzTHzUs3U7yavi2iex2TjAJV1XTGNEXcPFMz+k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Parav Pandit , Saeed Mahameed , Petr Machata , Ido Schimmel , Jiri Pirko , "David S. Miller" Subject: [PATCH 5.8 16/56] net: DCB: Validate DCB_ATTR_DCB_BUFFER argument Date: Fri, 25 Sep 2020 14:48:06 +0200 Message-Id: <20200925124730.256745774@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200925124727.878494124@linuxfoundation.org> References: <20200925124727.878494124@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: Petr Machata [ Upstream commit 297e77e53eadb332d5062913447b104a772dc33b ] The parameter passed via DCB_ATTR_DCB_BUFFER is a struct dcbnl_buffer. The field prio2buffer is an array of IEEE_8021Q_MAX_PRIORITIES bytes, where each value is a number of a buffer to direct that priority's traffic to. That value is however never validated to lie within the bounds set by DCBX_MAX_BUFFERS. The only driver that currently implements the callback is mlx5 (maintainers CCd), and that does not do any validation either, in particual allowing incorrect configuration if the prio2buffer value does not fit into 4 bits. Instead of offloading the need to validate the buffer index to drivers, do it right there in core, and bounce the request if the value is too large. CC: Parav Pandit CC: Saeed Mahameed Fixes: e549f6f9c098 ("net/dcb: Add dcbnl buffer attribute") Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel Reviewed-by: Jiri Pirko Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/dcb/dcbnl.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/net/dcb/dcbnl.c +++ b/net/dcb/dcbnl.c @@ -1426,6 +1426,7 @@ static int dcbnl_ieee_set(struct net_dev { const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops; struct nlattr *ieee[DCB_ATTR_IEEE_MAX + 1]; + int prio; int err; if (!ops) @@ -1475,6 +1476,13 @@ static int dcbnl_ieee_set(struct net_dev struct dcbnl_buffer *buffer = nla_data(ieee[DCB_ATTR_DCB_BUFFER]); + for (prio = 0; prio < ARRAY_SIZE(buffer->prio2buffer); prio++) { + if (buffer->prio2buffer[prio] >= DCBX_MAX_BUFFERS) { + err = -EINVAL; + goto err; + } + } + err = ops->dcbnl_setbuffer(netdev, buffer); if (err) goto err;