From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 DEBB03BF699 for ; Thu, 18 Jun 2026 14:50:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781794210; cv=none; b=DCvGIEoQ7zMfn0FzTWQRUjN/LK+MvsO4CL56yUrSnn31oJ/cLf40jOuOi8C9F/7NOLNKyuXzh7SIT8rflzbC8EOSQ4emiSKwAm3eAulGsZm8Nfo/287t8c+JDvxD0PFptMDHDLOMG3wf/jvHf7XHQNZJjze+9Me/6w0R3hKgy6o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781794210; c=relaxed/simple; bh=ebfiHxJXCBorfmGp3WjFdqGfKJbX3u6ZqUXNuY7295I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=h33MJc2snfZQdejDlFR6IkLgzgTN4+NmujFjmT9JS5ILcFuRlKI7qd7sr8PVvoVFtzlCPr/F5pgG4vMW1x/RwDf6M+rc9mzQe6qtdO6uQYtwNxQGvT1NhQ/ZoB2DyuuWHTUQ4i4lQR7G/noq9eNh8MUadxXu7xjQN3qfbtOoXX8= 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=OWe3wKCp; arc=none smtp.client-ip=209.85.221.53 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="OWe3wKCp" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-4645995069bso485312f8f.1 for ; Thu, 18 Jun 2026 07:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0sec.ai; s=google; t=1781794206; x=1782399006; 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=FGgWyECjMo0A+7T5xX6MZZ8UBQzM1ZYjMx5fmvyGYBI=; b=OWe3wKCpatSlqAJ0W4mfntjH8iNWNZGerCIVxVNBwcq3/U9JgJ2m3yFpLQ5LuLdjND xWrZjRN1+qrQhoUP61bExW1pJox9IjKseH/HgNbVyigGjyM1GQAPHK/QNPBbPjHijAcp 0YRmG2ZTAC0NMUf/qqV3zuQFbf+mkMtSHMZoOHDFUi3u9hwDvKkGZ8Ri+sW9VI0+SX1U QKByRdO+B1GyOzIiGww8Y//Zc5KDFyk6uphFfLFeFjfhZG/Is1U0diZ8ETYG2mQSo0tY LCcIh7LVAeOFOYsVzQkZFRD2mNsKz2C3jz00bdodGoOC+Ni4nEyySfhQU66P35nr9Jvx FFvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781794206; x=1782399006; 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=FGgWyECjMo0A+7T5xX6MZZ8UBQzM1ZYjMx5fmvyGYBI=; b=ToNlxPuxnBtTwTVUlAS1CmHEA+305RJfHEmLh01a66v0dycgwBn+xjqsCRhkbx3rT8 t3fGOktdPRzm5ZylxxUtqklF3PBiCfTY8YhqqFkRkyLP0iuxsYlFItkvcivKErt/6HxK yxOOrwQNqA06TXDsquGWHqm06sqvLlZc2tZNaPTL+ncCrfCNs64zEB5Mqb3L9ACen2Ej kwSATgMLrzx6W0T4PDLJdJO7zKWdW4yENgufNJbDU4BgVRzEy/jaah5mdrb4GQdard/D AgF9+kWGdmGO8ziLjxZzoRQQpOTjqIdZNWAVH29j2rcNiv70x16QvD0E6kGaOE1wNpak 9v5g== X-Forwarded-Encrypted: i=1; AFNElJ81CYl5h05Og3Ul+JccA0FNSbq2hXD7ngWjZvGDLKg1Xh1OltzclACS0mi8GC1DV0mLSt+sVuEBgWQPIj8=@vger.kernel.org X-Gm-Message-State: AOJu0YyPc73bnHzKVs2AELua89RA7dGVkxvqsqFu+co1RIBtulm1Fp9r L0I6+iDVasbIS3I1lxrh4NK9ZOah+rcvc+tQWfShVH+RYXZM8dBZo9dKRTXkAYqHcgam X-Gm-Gg: AfdE7ckmG9VuIvp0egy+2EMw/SlbiZIRNjn4jxR6nRiSh7B+jVIYjLr85nh9lYM9UTT jbooMFbVwcLflaMmaJWMV0YhSH74HvXc+pqhBrP14E2rq/ifql4+aoeqmAcwVKcLHjqIbGrigKT sCaFMbjp+WzNKWBTufA0C8vA9QG9JMHohX1tRvDYF4OrummZleUdhkXv07iPqh3RcxYPC3iUjdk DtberDKNicwW4fYa1L/0mRKtaGp2FP8TWvwuEgvNk7eo+1yFGlKo7jCwRDFURO0GeSRkTJrXNuA LBCC3jp+5/ad8YrDXCr76+IDSfaTFjN22OpK/+BlOUkMEVCp9/LASzjc5Ex6jyWoZ3bIoP76S1O jb0HNJxuGcpKJJpD/jIFVaXKqNAvhDFZutBU480o+YC9w7V+WwyG68LRy620+l9CFdldNIV8eGM EVJF8vFIZl8qJ8GqU9ctuvANBauZHkzo4Qwn7wq78rM01YlWcPery+LeK+tsMHh0HsEK+iIyEc+ LwCR/3c8colrMqYHsV2PBHEj0iPQA1JKF4= X-Received: by 2002:a5d:5f87:0:b0:45d:3cb0:5ab1 with SMTP id ffacd0b85a97d-463ad9ade76mr6300952f8f.38.1781794205917; Thu, 18 Jun 2026 07:50:05 -0700 (PDT) Received: from PeakBook-Mini.tail8e484.ts.net ([178.197.218.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4606f2e592csm66701717f8f.36.2026.06.18.07.50.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 18 Jun 2026 07:50:05 -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, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, horms@kernel.org Subject: [PATCH net v2] ice: eswitch: fix use-after-free of metadata_dst in repr release Date: Thu, 18 Jun 2026 16:50:03 +0200 Message-ID: <20260618145003.47471-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 1a1c40df2e80 ("ice: set and release switchdev environment"); the previously cited fff292b47ac1 only moved the affected code rather than introducing the unbalanced free, and the bug dates back to when switchdev support was added (Simon Horman). - Add Simon Horman's Reviewed-by. No functional change. 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