Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1084485pxk; Fri, 25 Sep 2020 05:59:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgjxZUGeci3OTIxXFnz8KykY60TGSUilx/eSTuamo7+QWEuEfOIk7aFnC8OcsxmpS+pbkO X-Received: by 2002:aa7:dcd2:: with SMTP id w18mr1194174edu.288.1601038754955; Fri, 25 Sep 2020 05:59:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601038754; cv=none; d=google.com; s=arc-20160816; b=VfwS9RQ9mk/6h97TSuMt2/mglBqJYNSwjk6dD59mVJZ8+kFiX193HwrzQ+1/fc+cmP CiWIxERAS6NIzjxB9cCESN+hS196ko+hoYW3ErkuY/9e1hhEyWvByo0U8sKVjf17zHAW /swxjPC6TQvC/hZomE34k0817koDODOjn4oG3TOK8hbwSh8MtDNUHPun2BLWFzxrosU/ DFi3728s/dBjnZMhjdXInzLW2zGqMDly0uIHRaGXcvVmcoYlAHQ8yguxMX9gMkIfm9Xx j5yp+h4o7Xx6UsSY93naceoKQFBlQ5GfOqUoqky6WKyrFvtWgjqtH7TdZzgmda9S9O5O MQPA== 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=D5nA9YlMWzxr/L+ZzD+rkwPk9gTrGexdLfcj0qC4teg=; b=fDkbx5M2jYCYQJNMGA/gB4ATZQKBDwY6elJiWBewdts3tyYXHoqcPxGs3D2OxT0dcj luBrs0sttju4wo1Ry6amiM0B2cPdE/hQEO0ukBAyXHmSYDGUiW3T+feMxpENon1hmMh4 YwuCtI0+uI4p9ZSHGtLj3rfN4od8QO/Yu5h0CiWzJWnnCE8YbeNQFodQj5dLiDjkkjxx bW/3LZPdR2KU6F14RYlO2Y2lowIoxrrbRjXFYTcAk83tBstHbVwVqZHFqIUx07Lvb2KO 4QGVXLTvlxiMgKZL2zfwCLzTLQMNoRFQZ7+7GakfeBRBce3IhzvsyOR1pcIot0RwHenN v+OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kT1hJ9B9; 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 gu21si1800417ejb.127.2020.09.25.05.58.51; Fri, 25 Sep 2020 05:59:14 -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=kT1hJ9B9; 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 S1729629AbgIYMy4 (ORCPT + 99 others); Fri, 25 Sep 2020 08:54:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:33996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729616AbgIYMyw (ORCPT ); Fri, 25 Sep 2020 08:54:52 -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 D2DF3206DB; Fri, 25 Sep 2020 12:54:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601038492; bh=oCEO3l2SqYTgG5TOA0nDptZZvjG6lrB864tuU+mM7Ss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kT1hJ9B90MkA0kqQfUGcNJWsS1h1/d9HHcTQC2RdAoYOACg2YU5PTMIayeQZ2G+yg SHURK4XBF3vH7fRyVXYO9KqpF6M3FYf0sH1PQFKCd2vWJeQ1eEiVQRTvLVuLMkefDG uOAWTxgvEH03PUdCPHZAPEjNxggVqkBvxTCd1lHk= 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 4.19 10/37] net: DCB: Validate DCB_ATTR_DCB_BUFFER argument Date: Fri, 25 Sep 2020 14:48:38 +0200 Message-Id: <20200925124722.503844295@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200925124720.972208530@linuxfoundation.org> References: <20200925124720.972208530@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 @@ -1421,6 +1421,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) @@ -1469,6 +1470,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;