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 C242115703D; Mon, 29 Jan 2024 17:11:41 +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=1706548301; cv=none; b=rO1zF7QPWP1R1jiZ8DGCIOmZSgKt9XY2wStkBPa0QNTXataqHTYyt9a/urL2piUtzE1bUmLunLpu1F1oJnPSb+HRBIa8sdHFN6RTXtqJwRX91rf84I+h/B3cSomsohmNL1BeBZejBPFR6PFMwhE/nte3dWIKdZ/FgpIyKDqpKvs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706548301; c=relaxed/simple; bh=n3nj6rtqocCFwlA/OObieaYy7b+sHbdw4dM7u7OicwY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rg+jchZuxo64LwwvdEywznp/xAHiLZ8loLN9hDgiOciNW8nbBFrFIyO0Aie38smj4wwB1rXZUAD1wg4Ncotf2ET8HJflNxJuFLhtjPeyaSV1qEaK+VIqMgkuAwQ2QFBIA+h4C1gvyTGZFXtlJvNmQhCZATso/sJWM2Q7EpVFSII= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=gAEmn9l/; 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="gAEmn9l/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A0DBC43390; Mon, 29 Jan 2024 17:11:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1706548301; bh=n3nj6rtqocCFwlA/OObieaYy7b+sHbdw4dM7u7OicwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gAEmn9l/eVw6OF60qf+87oFwBVQq67KD8gm3NEpsQNVZ1NBGCBWaYEqC1cFz3jDhl rT1vTVyeQEHDBJMlIJyU1utmrC3O/yRi/A2jzmc2feT+0ne2xXd7hVv96/cdlSxvsI ljEpNlKBTGfSidbypvtOTVdA7N6Cf4QurfFeZEq0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Lin Ma , Simon Horman , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 080/185] vlan: skip nested type that is not IFLA_VLAN_QOS_MAPPING Date: Mon, 29 Jan 2024 09:04:40 -0800 Message-ID: <20240129170001.168577139@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240129165958.589924174@linuxfoundation.org> References: <20240129165958.589924174@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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lin Ma [ Upstream commit 6c21660fe221a15c789dee2bc2fd95516bc5aeaf ] In the vlan_changelink function, a loop is used to parse the nested attributes IFLA_VLAN_EGRESS_QOS and IFLA_VLAN_INGRESS_QOS in order to obtain the struct ifla_vlan_qos_mapping. These two nested attributes are checked in the vlan_validate_qos_map function, which calls nla_validate_nested_deprecated with the vlan_map_policy. However, this deprecated validator applies a LIBERAL strictness, allowing the presence of an attribute with the type IFLA_VLAN_QOS_UNSPEC. Consequently, the loop in vlan_changelink may parse an attribute of type IFLA_VLAN_QOS_UNSPEC and believe it carries a payload of struct ifla_vlan_qos_mapping, which is not necessarily true. To address this issue and ensure compatibility, this patch introduces two type checks that skip attributes whose type is not IFLA_VLAN_QOS_MAPPING. Fixes: 07b5b17e157b ("[VLAN]: Use rtnl_link API") Signed-off-by: Lin Ma Reviewed-by: Simon Horman Link: https://lore.kernel.org/r/20240118130306.1644001-1-linma@zju.edu.cn Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/8021q/vlan_netlink.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c index 214532173536..a3b68243fd4b 100644 --- a/net/8021q/vlan_netlink.c +++ b/net/8021q/vlan_netlink.c @@ -118,12 +118,16 @@ static int vlan_changelink(struct net_device *dev, struct nlattr *tb[], } if (data[IFLA_VLAN_INGRESS_QOS]) { nla_for_each_nested(attr, data[IFLA_VLAN_INGRESS_QOS], rem) { + if (nla_type(attr) != IFLA_VLAN_QOS_MAPPING) + continue; m = nla_data(attr); vlan_dev_set_ingress_priority(dev, m->to, m->from); } } if (data[IFLA_VLAN_EGRESS_QOS]) { nla_for_each_nested(attr, data[IFLA_VLAN_EGRESS_QOS], rem) { + if (nla_type(attr) != IFLA_VLAN_QOS_MAPPING) + continue; m = nla_data(attr); err = vlan_dev_set_egress_priority(dev, m->from, m->to); if (err) -- 2.43.0