From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 58BF9503BC8; Wed, 30 Sep 2026 16:42:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790786561; cv=none; b=paiXCgowUd9ypuL8hmMvw3rlXV316zDoHobKGZyPlcp+qoNTBorgfO21AdLZVThhFBc/HFIadYUB8P/kilBhXM63gAEeggnVCwFLtmTAow2azsuRoQ7SPMsRu6FihMSBWpqCzwQekUtFAbOlNRpsutmKREDu195APCKFZyoOWE0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790786561; c=relaxed/simple; bh=ceXRkYFInP4A0d6hvO1tW2bq+qvk/dbICcKv19ipoWw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WUD2voDM0oJzV3XySFM5h4nAdoHxiPmZe3zzl+hMAAV9Ym4CxCYACFIdmZlfMVK3S4LY0Sypsx44SWA1SF5vPpV93R9lPUDX5vL9TNjMhuxdJ0EIAcZhJ+YH3kIWq0tL3VjRiflb4gY1kLVp/OEdBkCdAPImSmxejxRxkQxg4xc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=pbYupNrj; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="pbYupNrj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B16A21F000FF; Wed, 30 Sep 2026 16:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790786560; bh=BBn7uOtMiUc0eP8FjX6A2Tuber7cNu/+OIlc0mhe37A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pbYupNrjZ0iKN9N0R0K+zJ1Hn0I/PUBuFKvXpUY9VJ8Ym26Dv/KJSLF+0v67nFFYz vgTYiypqRVRc4XQKz9vcaj/w0XV0i+CprEcqnwWPK2UWdDK3yfyAqcnQ6tZ4APHhgU GL12USFtNosbHXAExfoyYVvkkCL5Cowjgy7Ka/PY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xuanqiang Luo , Ido Schimmel , Hangbin Liu , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 905/982] ip_gre: Reject enabling collect metadata through changelink Date: Wed, 30 Sep 2026 17:27:21 +0200 Message-ID: <20260930152436.179278294@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152416.775402466@linuxfoundation.org> References: <20260930152416.775402466@linuxfoundation.org> User-Agent: quilt/0.69 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: Xuanqiang Luo [ Upstream commit a3f315be9d30eeb6938d11fa17fd4b32d52f7c42 ] ipgre_netlink_parms() can enable collect_md on an existing GRE, GRETAP or ERSPAN device. Unlike newlink, changelink does not enforce metadata tunnel uniqueness. Converting a non-metadata device can therefore replace the metadata receive entry for another device of the same type in the same netns. Deleting either device then clears the shared entry, breaking metadata receive lookup for the surviving device. If parameter validation fails after collect_md is set, deleting the modified device can also clear an entry it never owned. Reject enabling metadata mode in both changelink callbacks before any encapsulation or tunnel parameters are modified. Allow requests that repeat the metadata attribute on an existing metadata device. Fixes: 2e15ea390e6f ("ip_gre: Add support to collect tunnel metadata.") Signed-off-by: Xuanqiang Luo Reviewed-by: Ido Schimmel Reviewed-by: Hangbin Liu Link: https://patch.msgid.link/20260921031859.9283-1-xuanqiang.luo@linux.dev Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv4/ip_gre.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index b635d2fedd2db..66c35ced1e887 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -1409,6 +1409,12 @@ static int ipgre_changelink(struct net_device *dev, struct nlattr *tb[], if (!rtnl_dev_link_net_capable(dev, t->net)) return -EPERM; + if (data && data[IFLA_GRE_COLLECT_METADATA] && !t->collect_md) { + NL_SET_ERR_MSG(extack, + "Enabling collect_md on an existing device is not supported"); + return -EOPNOTSUPP; + } + err = ipgre_newlink_encap_setup(dev, data); if (err) return err; @@ -1441,6 +1447,12 @@ static int erspan_changelink(struct net_device *dev, struct nlattr *tb[], if (!rtnl_dev_link_net_capable(dev, t->net)) return -EPERM; + if (data && data[IFLA_GRE_COLLECT_METADATA] && !t->collect_md) { + NL_SET_ERR_MSG(extack, + "Enabling collect_md on an existing device is not supported"); + return -EOPNOTSUPP; + } + err = ipgre_newlink_encap_setup(dev, data); if (err) return err; -- 2.53.0