Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 700453A1D02 for ; Wed, 17 Jun 2026 10:06:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781690762; cv=none; b=Bq2FhmKAE8taH3XMRJvMRWsgCD45aPyT2YIfu6TZK9QAakL8E7L/Dzd6e1PmZA4FzEsWI4hnOlNrwBe93QFl8/uXTe/n7xnMdJUcPuB/XFCYxn44M1puCFWL0kPiXC38abhCrZ2yHJw8Z+q2iX/G1UGRiITPkVWDxzNIq0Z0goo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781690762; c=relaxed/simple; bh=hmliK8samJNpT3PJSWzQYDk1lSB+31K5rpAqv2pdv9Q=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=hbWJjI8b1mtIO6v8FLq0bwqTWo2gZjrUZA3aERz7/wlQRnIPjXSBzivGKI63p3BJzZaOmLlGZFABcoFNvESbtp2DEkE/ed3enUOFoIuzNh5t+ERhiFkw0KGXcepnDXH8tbSTA5nJOi+yV9yiOllvAAcBrQtq0PFRbl4AIfxVJs0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0sec.ai; spf=pass smtp.mailfrom=0sec.ai; dkim=temperror (0-bit key) header.d=0sec.ai header.i=@0sec.ai header.b=pg1mEsUN; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0sec.ai Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0sec.ai Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=0sec.ai header.i=@0sec.ai header.b="pg1mEsUN" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-461a5a39da1so1348497f8f.2 for ; Wed, 17 Jun 2026 03:06:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0sec.ai; s=google; t=1781690759; x=1782295559; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=aFsSmP6aMO4TG59Hc8Zv34xLQSsBRpaPGd67pr1FIwc=; b=pg1mEsUNBDfRY+gSf/5TCzF8zqn9ST1QFtFYhIYqiGXayoKnoQHaHM+wYvMdm8VPiy kTRyJRrNf0huBCJXUF5eWqVoxhpFqjofmzUO1OMWAp4oN7s1IiQzCITUnhF0fGePqv3S H/MGnjyvxUrSbKNnMhp6/2bBkPlwzpTTreRhLxaSRZAJD5SGDgJQZOu/FWq96luCsx3W fQy7Jgq9PejRZFvHk0tDMRGWFbxc92F7tAAr7VsHkE0nzixmGYtzOPNlV4iPk9CaV5Fr pelBJfRSRWbRVoHEtNik2lLrHkdPTprqkZbfEtwcVd9+4M/Dkvp2nxmL+TcKK/qlNMFU Ns+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781690759; x=1782295559; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=aFsSmP6aMO4TG59Hc8Zv34xLQSsBRpaPGd67pr1FIwc=; b=GaipxTVqiuO/YN8wQnohWk7p1I8fo3soa64FUUI69FEqr9MIlc8P8CTZj11EY6suUe r42qn/0PHbGdyq5nQeOFdgYb93FZ8v/DKfmbTBqpqhczLmM/ck2BX+tjW9mrVKIq4Gyu SfMH3f+EXIxqRoDaHY3QzoF89UmYkCFnYv7CNbf3vX4zitYfEcSKFM4Anq4UREFXaI5/ YuKhxTx9B6o9ZrxSoLQ8OxfQ5unLi2hdNv9NvuJ9Zumo/ih0fSP7Xj3d1xYSrrLLSZ10 A2z3mOAy7qaKHUCxvZYOKHMjgQELuwdNkUfS4/Au6dJEhs8LxmNmiC1TBGnL6gwp8bOs RoYg== X-Forwarded-Encrypted: i=1; AFNElJ92jr+roqNqefcUa/5/f/7MzbXg5nkqx0yQMHZCUtzo/5/cDx9UGSczyIGg6aNw4eFvgrLNwSUFiP5qbJY=@vger.kernel.org X-Gm-Message-State: AOJu0YwObyiLUFdoZBpyjJJOhDo6CKs0DnvKcMrlmobUFf43+ufyMKnw OdySp7n8yxWv5aMUzR6MItBgfTC/jAzO7rW+4HIBmBh0GrZOW/5gtbWMb7x9k828bRp1 X-Gm-Gg: AfdE7cnFUu9euy2QN/pSvaepLPcUgyW1G2FDTmUN0U4epQdBKE5HZGhgUV8jscQHx5X W0sD/ZkA5TyJigSe2iDDnbb3cbqrsKbOx4oEqd7L54uHbwcDuRqzls9fYKlXJPPHYn6h1l1kFtc 31VxiIBUQSDeSxRFTKJqmzQMam1SRPpE7gdnQxo7GuKGohzSrDtvBGWGDYPEM1c7rpzbL4kx0eJ 0A0QoWqfV5dcMD46NWGY7MhOyVebpe02H5DinAO6COzSe2myF5fmy4Yp+t9SL9EQViXauuLUQh6 +WGf9rnk5oidvcDy4Rt5w8i1zMSeCrsAUqBxT9kVgrlSOIsd8gb9wTejUxvld36uO1LrcUrPaPz Ysoh0dB/tp52c6SabUth6zYHnsilHKy4BDK5R3mQE/tlwCfvsL0lSau4YjiN/h5EYctRtJYCJFt HCz4mXHnPibtTbezmGWpk/iwPWgsMbXlyf6e1v7x06NHV3G8XMqwLBTjpBJbDHjqJmbN28NYzG6 pGPZsbn6bk6vQ5wr/QLUldt0UuQ4s0Udck= X-Received: by 2002:a05:6000:2302:b0:461:a159:98c6 with SMTP id ffacd0b85a97d-46235e9ac51mr5885239f8f.6.1781690758585; Wed, 17 Jun 2026 03:05:58 -0700 (PDT) Received: from PeakBook-Mini.tail8e484.ts.net ([178.197.218.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4606f26f1cdsm55033847f8f.11.2026.06.17.03.05.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 17 Jun 2026 03:05:58 -0700 (PDT) From: Doruk Tan Ozturk To: anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: michal.swiatkowski@linux.intel.com, wojciech.drewek@intel.com, horms@kernel.org, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Doruk Tan Ozturk , stable@vger.kernel.org Subject: [PATCH net v2] ice: eswitch: fix use-after-free of metadata_dst in repr release Date: Wed, 17 Jun 2026 12:05:56 +0200 Message-ID: <20260617100556.83620-1-doruk@0sec.ai> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ice_eswitch_release_repr() frees the port representor metadata_dst via metadata_dst_free(), which directly kfree()s the object and ignores the dst_entry refcount. The eswitch slow-path TX routine ice_eswitch_port_start_xmit() takes a reference on this dst with dst_hold() and attaches it to the skb via skb_dst_set(). If such an skb is still in flight (e.g. queued in a qdisc) when the representor is torn down, the metadata_dst is freed while the skb still points at it. When the skb is later freed, dst_release() operates on already-freed memory. Replace metadata_dst_free() with dst_release() so the metadata_dst is freed only after the last reference is dropped. The dst subsystem frees metadata_dst objects from dst_destroy() once the refcount reaches zero (DST_METADATA is set by metadata_dst_alloc()). Same class of bug and fix as commit c32b26aaa2f9 ("netfilter: nft_tunnel: fix use-after-free on object destroy"). Fixes: 1a1c40df2e80 ("ice: set and release switchdev environment") Cc: stable@vger.kernel.org Signed-off-by: Doruk Tan Ozturk Reviewed-by: Simon Horman --- v2: - Correct the Fixes: tag to the commit that introduced the switchdev teardown (Simon Horman); add his Reviewed-by. No functional change. v1: https://lore.kernel.org/netdev/20260615140532.52676-1-doruk@0sec.ai/ drivers/net/ethernet/intel/ice/ice_eswitch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c index 2e4f0969035f..41b30a7ca4a9 100644 --- a/drivers/net/ethernet/intel/ice/ice_eswitch.c +++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c @@ -95,7 +95,7 @@ ice_eswitch_release_repr(struct ice_pf *pf, struct ice_repr *repr) return; ice_vsi_update_security(vsi, ice_vsi_ctx_set_antispoof); - metadata_dst_free(repr->dst); + dst_release(&repr->dst->dst); repr->dst = NULL; ice_fltr_add_mac_and_broadcast(vsi, repr->parent_mac, ICE_FWD_TO_VSI); -- 2.43.0