From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B34E13D61B; Wed, 3 Jul 2024 11:01:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720004492; cv=none; b=VObyCXqvCNbDG76wesFj1Jzg3A4fXiwBm5rck+4Kt1DQdvV6fLsZ6VTP/RplJXpLXgWBsz4GliHAtX2AKMnaXr2IMO0fHmph9Atqeezk4qe4YJJO9P8ubHPESaJ9F5n0iIgXUYJBlCImxbqMugTjKIurrkmfx+El94xqTYP8uuI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720004492; c=relaxed/simple; bh=Lkgze3pxJmcxLb382kd2X0EVDiE0o34+mH7+J72dyY8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gyXGyii9WvbcRq6d7m2WjRXscuIdv+pfGHv9ZXQMN9O3p9jnXoULOuoyVRaP3LYAn6Js/p8QNyW5KekeElaQBVf0FswDd4EqCmkOQew1z9qDUSk4bIPzSbSGr4pgoEDpSmvLphJJNIrvPwVkVU4kjvrWj1B9f3k96VoVhCAIhG8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=C9Z3fZrK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="C9Z3fZrK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 863AFC2BD10; Wed, 3 Jul 2024 11:01:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1720004491; bh=Lkgze3pxJmcxLb382kd2X0EVDiE0o34+mH7+J72dyY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C9Z3fZrKaHlpL3MVvQUA+d3/45oBvlQp5AfWmn2kDTHsYOKAU0rW7+tnMaR42M7U8 l9vkknYDcpGJqpRoXbjxj9pzF6bQnapxqQfag8ZlBnHWOLh/uTZSpXAD+Au+g6x/Yx lbo8V/c6Xa7aUCahQPVl53yLjdDwLy2facLHfy84= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Noam Rathaus , Eric Dumazet , Vinicius Costa Gomes , Vladimir Oltean , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10 018/290] net/sched: taprio: always validate TCA_TAPRIO_ATTR_PRIOMAP Date: Wed, 3 Jul 2024 12:36:39 +0200 Message-ID: <20240703102904.880834086@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240703102904.170852981@linuxfoundation.org> References: <20240703102904.170852981@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit f921a58ae20852d188f70842431ce6519c4fdc36 ] If one TCA_TAPRIO_ATTR_PRIOMAP attribute has been provided, taprio_parse_mqprio_opt() must validate it, or userspace can inject arbitrary data to the kernel, the second time taprio_change() is called. First call (with valid attributes) sets dev->num_tc to a non zero value. Second call (with arbitrary mqprio attributes) returns early from taprio_parse_mqprio_opt() and bad things can happen. Fixes: a3d43c0d56f1 ("taprio: Add support adding an admin schedule") Reported-by: Noam Rathaus Signed-off-by: Eric Dumazet Acked-by: Vinicius Costa Gomes Reviewed-by: Vladimir Oltean Link: https://lore.kernel.org/r/20240604181511.769870-1-edumazet@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sched/sch_taprio.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 2d842f31ec5a8..ec6b24edf5f93 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -925,16 +925,13 @@ static int taprio_parse_mqprio_opt(struct net_device *dev, { int i, j; - if (!qopt && !dev->num_tc) { - NL_SET_ERR_MSG(extack, "'mqprio' configuration is necessary"); - return -EINVAL; - } - - /* If num_tc is already set, it means that the user already - * configured the mqprio part - */ - if (dev->num_tc) + if (!qopt) { + if (!dev->num_tc) { + NL_SET_ERR_MSG(extack, "'mqprio' configuration is necessary"); + return -EINVAL; + } return 0; + } /* Verify num_tc is not out of max range */ if (qopt->num_tc > TC_MAX_QUEUE) { -- 2.43.0