Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp473765rdb; Wed, 17 Jan 2024 07:38:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAu4Kk4ozTNwsV6PG5QW/8ZlKWosOMnMsHCttgFGfgfpJq6iYZMUKq9g7U73lxs2oKC510 X-Received: by 2002:a05:6a00:9391:b0:6d9:aad2:46c with SMTP id ka17-20020a056a00939100b006d9aad2046cmr1660340pfb.7.1705505921783; Wed, 17 Jan 2024 07:38:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705505921; cv=pass; d=google.com; s=arc-20160816; b=WIDsENNkEwxnpHmWjpcLk2WcUe2wkXeVOYK+YYVOIRqmuVJSjdqXYlCESncQzxpvE9 qC4jp3glLFRQDbEnk5Ej02XUpidd8fFfJYkQT3ftaeqVPGdKCJtUDmKxgMomxalndDDS 8AEiy1WfdvljuSRZdXo4DO0iHu6P9R1PeTdKwaWD/wymkWNqPwsjJMY4pFDRfV26cjXX +1jknJLvF47eWa40r5+laYCzm8yeS7KidwMJ137eCJTANj3zWH2FA94/dJ8bVTO24ZMe VWtYMsmciILemDqLvrhopYlt/nGQIoQRn0sZb60CVdYMB/aWuDoWdJgfR/W8EOgaaFQh 4LwQ== 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=wJoC9NKKLm/bHMbQqFvUBO3dymYq+PVq/IlWFUSWMhA=; fh=O2TD8qzhHzlwC5nKiPsQ22v824lTL8BpsYH/N6ixZ58=; b=CPvuQHUHAw043aeoQaBzRVyvm/co08IFZ2xpq6xVQ5yfhEqomk5runnrwxhyedZLcW 6S7M9I2jY1rwvlEk3Etinpk0yDC0AaOauLXAvRPiaSmxgEOD4otEgIu7g/98aeERDwsY M1Eof36ZgbAIdFThotyMzc97fMPTUJDQU/7kO1xzBDDbnge7NlkVvL0zfMxEdXFU4tz0 RyCTEjWDaOEP3UjywoZWNTSZ5duWbzXOZ7JTiRUC7iutVVWTGgvU/1CU1IIzuAP48x25 t3Iz3CUF8oVAyMfyrnj1QUQtjsLXqvj9oC3i/j9pQA04+caiKNCSIZjqXwggqvUZ+OAE /75Q== 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-29162-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29162-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e30-20020a630f1e000000b005ceb19326e3si11708656pgl.251.2024.01.17.07.38.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 07:38:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29162-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=zju.edu.cn); spf=pass (google.com: domain of linux-kernel+bounces-29162-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29162-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 874B7B2462C for ; Wed, 17 Jan 2024 15:38:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 039A521A13; Wed, 17 Jan 2024 15:38:29 +0000 (UTC) Received: from sgoci-sdnproxy-4.icoremail.net (sgoci-sdnproxy-4.icoremail.net [129.150.39.64]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 36C7D21379; Wed, 17 Jan 2024 15:38:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=129.150.39.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705505908; cv=none; b=hXmDIgtSZOUMomCAdM09adKj6khfDcaukTCKC8QMPw5u6YMJGjexTMfbzY51EnhVqqGftgLA5MrEklPUX8BnSYpYs4Y6AwMirv0mZy3az/m1ix8AwXoMAMd2IXiwO59aemHk1/ptJGuFl+e7eJmgkBBe795m3jRYcqc7mg4iybY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705505908; c=relaxed/simple; bh=QlbmZ4ud6YNtdBK9dZFHWL3ew6WArzBT1tdPfKW9s+U=; h=Received:From:To:Subject:Date:Message-Id:X-Mailer:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; b=duOyIQSR3n/b1OJeTFU982N247KDNVFhTQKfAENHOwjOfYtqwXYgBWBdcQD60aCBRYu86gky+XaqL52L6czA+87sveNHpN4FK9sgQ0sb808a4peczUDm0koZ+RcncTm5QD5OKjoP1WQf+d/AE1WYiYEbtTaUGHULOXJMrbieXx4= 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=129.150.39.64 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-app2 (Coremail) with SMTP id by_KCgDHdqVi9Kdlv61AAA--.11252S4; Wed, 17 Jan 2024 23:38:10 +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-next v1] vlan: skip nested type that is not IFLA_VLAN_QOS_MAPPING Date: Wed, 17 Jan 2024 23:38:10 +0800 Message-Id: <20240117153810.1197794-1-linma@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID:by_KCgDHdqVi9Kdlv61AAA--.11252S4 X-Coremail-Antispam: 1UD129KBjvJXoW7Kr47ZrWrZF17Kw1xtF43Jrb_yoW8AFW8pF y5GFy7GwsrJF9agFWIqF48XayxZFnrJr18uF1rKa1Fkrn8Kr9rtFWUGFnF9r17ZFZ5Aa43 tF1avF4j934DWrDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvv14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc7CjxVAaw2AFwI0_ JF0_Jw1lc2xSY4AK67AK6ryrMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r 4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF 67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2I x0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2 z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73Uj IFyTuYvjfU8KZXUUUUU 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. Signed-off-by: Lin Ma --- 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