Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp328995rdb; Thu, 18 Jan 2024 05:03:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6usMxOTPHvJHv5uujG8WzYY6bP/sJ0avU9ZCrDjONrA21iNH+9/DCKOBOgbCBnbRQpN1K X-Received: by 2002:a17:906:1cdb:b0:a28:e870:97b1 with SMTP id i27-20020a1709061cdb00b00a28e87097b1mr471788ejh.131.1705583024757; Thu, 18 Jan 2024 05:03:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705583024; cv=pass; d=google.com; s=arc-20160816; b=dyRkrmzcojRLtY9vqXI/NS3V/Go2CfORIijyHuCjjdJ74SuMTKRiWmpkNlzOmcA7IT RxYQUHaAGSAFNB5MbvsFiklAMv6i9vfmnPj0tQToNKh09QWQOZ4RjzqQrNi5HvKObKtP JpV+XlxSZUm24ooirj3e6+hy/M+C1vuZ7cEJDUwtVXVrjK0lNc77ewfEyfPdVti4p4Ya etXqS7mqh0p8t1tiAu0zKKViDAXVix2n669QA28CqKEMT2MtQBBeGkU0kWXtOYdFkPNy 24FVSH8JLkQF6AU9SjJZk0Drnov1saftkxIjP/BvkAcI9Yyx2Pu2N3NTHV8wFR6y0TGA LBDA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:to:from; bh=PX0oUSiJFBtos1+p1NnrVZcQ4Etspn+vqMY05IqtSr4=; fh=O2TD8qzhHzlwC5nKiPsQ22v824lTL8BpsYH/N6ixZ58=; b=qfiVZNKizzG8Q1Fml28dKBH8a7L4vL+vs6r6UQsO5ObGUx6oFcICoJBWMH52joCWP3 Bu65eedapMqB8aXi8/qE7kzEVh062GViH6BxctTh2LFHr2BtYsPvG1aksk3uZlg+b8/K 5Gizl47TtywiiXx7MCE6CqTZnf5LyfIZZMFJbP84PPcInQG6YUxIbS7bQiHNRss9xS0+ uF3oAUQlYkRNzkt3mR0FgajCy4xn6t0rwCQn/UmpheF4rbYmpeW78ck6lGVV619M3zz8 7JxNq6CrWmkj4dP1sffFaSpUsRRCVwdBeM3NBS+cjTiaIv1xxCx2EBmHyHXLAzgYZ/mC bbiw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-30127-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30127-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l19-20020a17090612d300b00a28f4208352si6660336ejb.740.2024.01.18.05.03.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 05:03:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30127-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-30127-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30127-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8378B1F241CE for ; Thu, 18 Jan 2024 13:03:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E15DE25105; Thu, 18 Jan 2024 13:03:31 +0000 (UTC) Received: from zg8tmty3ljk5ljewns4xndka.icoremail.net (zg8tmty3ljk5ljewns4xndka.icoremail.net [167.99.105.149]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C77082C9D; Thu, 18 Jan 2024 13:03:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=167.99.105.149 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705583011; cv=none; b=ihBcy18nBkqEbCygG9PG96hQjXgu2ngMwKy3rDWhaEiJM32CJBvwsjHZW0niwjAVUs3cTcsC57u9hq9ly15MZu9cxPpNuFFXcaUqMfkRn1EVc4KwvNYP0xxsBOBlL4eN1dc/IAImqCRHyoLivjYJ9/BnGQldodyuVQnbRwXNG6Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705583011; c=relaxed/simple; bh=b/kcvM1x17lzfUd+fGdYlf9PnRElI5xtL5KheTucpFg=; h=Received:From:To:Subject:Date:Message-Id:X-Mailer:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; b=Te4ToO0rUMtP11URIstnHkVSTHQ3OATlgcE/Kb1/FDDgOb+ofX40nJ+TvE9Hm1SZVVVfnHq/Y6SziFQvykX7CS2tDFbrm55F9BgL6+AivHj6nMRLrvS8WNY4AVn02gY64MFWgF1OqP7JKRiSKvKj8dE0IpguttI9xW1ei0VOHGA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn; spf=pass smtp.mailfrom=zju.edu.cn; arc=none smtp.client-ip=167.99.105.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=zju.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zju.edu.cn Received: from localhost.localdomain (unknown [36.24.98.148]) by mail-app4 (Coremail) with SMTP id cS_KCgCXs4KQIally_c8AA--.46623S4; Thu, 18 Jan 2024 21:03:13 +0800 (CST) From: Lin Ma To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linma@zju.edu.cn, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v2] vlan: skip nested type that is not IFLA_VLAN_QOS_MAPPING Date: Thu, 18 Jan 2024 21:03:06 +0800 Message-Id: <20240118130306.1644001-1-linma@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID:cS_KCgCXs4KQIally_c8AA--.46623S4 X-Coremail-Antispam: 1UD129KBjvJXoW7Kr47ZrWrZF17Kw1xtF43Jrb_yoW8Cw18pF y5Gry7Gw4DJF9YgFWIqF48XayxZFnrJr18uF1Fka1Fkrn8tF9rtFWUWFnF9r13ZFZ5Aa45 tFnIvF4j934DWrDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkC14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc7CjxVAaw2AFwI0_ JF0_Jw1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67 AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIY rxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14 v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8 JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUYCJmUU UUU X-CM-SenderInfo: qtrwiiyqvtljo62m3hxhgxhubq/ Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 --- V1 -> V2: make net-next to net as suggested by Paolo and add Fixes tag for this one 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.17.1