From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f174.google.com (mail-dy1-f174.google.com [74.125.82.174]) (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 E36C72233A for ; Wed, 10 Jun 2026 00:06:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781049967; cv=none; b=ZpQxLB9t6/972OOMHC5ZLIuufQdBeLLqXWYj4JLpoounurs4ogSvOP9VxrirGysQVjwazss9LEDYsdiwrtIuWDOaBgJqtPEfSHYWtEikjwlVhsx+zZJh3Ag64P44UqUYojzdsOAdVLivo5rF278jy4pYR61fV96Yt+CJCFoutbw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781049967; c=relaxed/simple; bh=r1vbyfeCtYG6OGx7YM1c8slsjLM5GVhJMK4JM/LtzFE=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:From:To:Cc: References:In-Reply-To; b=Wn5zy/iOpMLFrqzSdJ0xtyr3mkbIri+COhe9gfwavtG1tu9JEtkDuQ8QOBdwa/wBFXJrc3xjTR0iCgF4gQZlY2vpIp3v9Z78rAkHV3/Uyhu0rXgpvjKTbxe/2T0Iaxyr7xR105ESbDFLcSde4lTiG3CZ0S0o62IngVUs4Hgsid0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com; spf=pass smtp.mailfrom=etsalapatis.com; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b=iuQ8spfK; arc=none smtp.client-ip=74.125.82.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=etsalapatis.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=etsalapatis-com.20251104.gappssmtp.com header.i=@etsalapatis-com.20251104.gappssmtp.com header.b="iuQ8spfK" Received: by mail-dy1-f174.google.com with SMTP id 5a478bee46e88-304d7f31215so5476637eec.1 for ; Tue, 09 Jun 2026 17:06:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=etsalapatis-com.20251104.gappssmtp.com; s=20251104; t=1781049965; x=1781654765; darn=vger.kernel.org; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kj983b4aP9iTymCXxslRDVIMvDkVOBbHTYZp1bhw+6s=; b=iuQ8spfK1Iat4dw7kvDF3eT0iRlrgXea8KgeclovNgqmuidX8lMZtX30UsXf7EZkZB w6p4NrXwy92qPMAekQNDEWW/W6I/zuY0H/u/Sc/7A2Upk0I5t95ph6JNR65U2rLgtpdm NLI+M/o5675+3eoCVCzu6KBAnDFu2j8IC5DkOpQS5QGGUzATHxtzSFz188Sn4xCaSvP2 sMY1/xCgDzwXzGzjdOG7yadGOhxkINQD6zEkTUg+u+A7PgJ33Qj+Ygg6PHf5P9nm9d7T u5+csh++zvP4PGTg1HzekkkDhVcU8tj0yJMXLjkgZleg5fGuiMGk6ExeLimeEN2iPixR CtsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781049965; x=1781654765; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=kj983b4aP9iTymCXxslRDVIMvDkVOBbHTYZp1bhw+6s=; b=mQBrkOqxo9/mEvdz+K3ZZ0uiVJX77RZysb4/C7rl3AOiklPChPaX+xkRu/uxSN3ol/ CxNFA3BHqreT6odnBbQ8IZOCQiH0MPiNAmp2jGezYEnXGUzFINhxyYdq775a0kFIbFgu TZ4Sy+TGHzcjdh4VuV8UOXNVYvootsbLhfm8cUkgUyFFjzwojGY+M1K8a4ne3VJUinzq vSBkOvRipxaJFBp5D31BdykO8jin0nlBL16bQ7IdOOOQOSU5HtiSNT6hFBC+Bza99yE0 KVwS5S80eA29tdd9IEdo79xhflDbQwnVkvaNkpcd+ofEwJ+GQC2xp/MxsiS5cGdrIVKC iBdA== X-Forwarded-Encrypted: i=1; AFNElJ8+wm3h9hMDunaGwYjqkUv/jALTe9w1OdeBP6I6qM1ywEdCEtuyL2yYZDptvcF7xq218iK3msosIoUi/dk=@vger.kernel.org X-Gm-Message-State: AOJu0YyMEaoxPJ2/Yw94u8Z0/BEBRRuVGcBPTLRe+n5LdW97oziPMBM5 DbNgjEvIDXDsly0fQ6NwHyBMUlObRX02AwQkNIFqEzhMbjZK3b776Srm1C0/+/9E6Bc= X-Gm-Gg: Acq92OEmbYV7vkA4Nt8rKOD4cQjWbX0PLHgh58/s1qvUG12Fsibm4T2nK/MLmnJVYLb y3mq5IPuU6s22wahA3mHdMBzknqjZqsrGdsvjpfcleEiB3MhlLIwE1XwrUQL1aye27ucRHEk5pe IpstIGq7mKBVFpxzziKyqWCZYUsl7rwr5+eDjSGMvY23QAUWRcMT+yMsMHQLT2gAoZhpkOP+QXo XcSDkYOxtAzTUKPbrh1+XQDedr314ThyWezi9yYjDFEdI+ikQo+3z10zAGx9efshRnJFxorLu/w WUkpFnyj1I2u8CMBncS+pwyWL1lplFXwh8awOMv04wt1T+cZMfD9Sj6fYDIrbtk0px2TssQVAGE q5j76UTLlwfGXUsr/PkCXVneLJasebOdITv5FB4QQikGHqsIc/Uxh+xGND2jEyVZScTQmxu9TSU PGBXCD0VhgZ5qofgQ= X-Received: by 2002:a05:7300:d70d:b0:304:c520:4e14 with SMTP id 5a478bee46e88-3077b32888bmr15659364eec.11.1781049964814; Tue, 09 Jun 2026 17:06:04 -0700 (PDT) Received: from localhost ([2620:10d:c090:600::3297]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3074db85f60sm28979462eec.8.2026.06.09.17.06.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Jun 2026 17:06:04 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 09 Jun 2026 20:06:01 -0400 Message-Id: Subject: Re: [PATCH] bpf: Unshare cloned skb before devmap egress XDP program From: "Emil Tsalapatis" To: "Menglong Dong" , "Sun Jian" Cc: , , , , , , , , , , , , , , X-Mailer: aerc 0.21.0-0-g5549850facc2 References: <20260609100214.337538-1-sun.jian.kdev@gmail.com> In-Reply-To: On Tue Jun 9, 2026 at 7:06 AM EDT, Menglong Dong wrote: > On 2026/6/9 18:02 Sun Jian write: >> dev_map_redirect_clone() uses skb_clone() when redirecting a generic XDP >> skb to multiple devmap destinations. The cloned skb can share packet dat= a >> with other clones. >>=20 >> If the destination devmap entry has an egress XDP program, that program >> can modify packet data. Such modifications can then be observed by other >> clones sharing the same packet data. >>=20 >> This can be reproduced by strengthening xdp_veth_egress to configure a >> different source MAC for each egress device and checking that store_mac_= 1/2 >> observe the MAC configured for their own egress devices. Without the fix= , >> the SKB_MODE subtest observes store_mac_1 receiving the MAC configured f= or >> the next egress device. >>=20 >> Fix this by unsharing the cloned skb before running the devmap egress XD= P >> program. Limit the extra copy to destinations with an attached egress >> program. > > Hi, Jian. > > This sounds like a good idea in this case. When I have a look at bpf_clon= e_redirect(), > I found that it use skb_clone() too, which means it has the same problem.= The > data can be modified by other xdp prog in the destination NIC if we use > bpf_clone_redirect(). > > So maybe this is the default logic, and I'm not sure if this patch can br= eak the > existing users :/ I think for use cases where we are using bpf_clone_redirect() to use one clone for inspection this would add an unnecessary copy. Maybe adding *_copy() variants instead of changing the *_clone() would be better? That way we wouldn't be changing the behavior for existing consumers and the naming would be consistent with the skb_* methods. But more importantly, is there an actual use case for the kind of API that the modified selftest requires? Nobody until now has considered the existing behavior to be a problem. > > Thanks! > Menglong Dong > >>=20 >> Tested with: >> ./test_progs -t xdp_veth_egress >> ./test_progs -t xdp_veth >> ./test_progs -t xdp > [...] >> =20 >> destroy_xdp_redirect_map: >> --=20 >> 2.43.0 >>=20 >>=20 >>=20