From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (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 07DF74CA27E for ; Tue, 9 Jun 2026 18:56:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781031415; cv=none; b=t28d7zvPImdTLmi3OML7i6ntrRJBYIoZK26d+Sf6hpj9OjLI4bFrZowSQGwGpUAgjweY7XbInLH2/7lpXvL7pHjH9LP9W9u323v0RnDelFKMWSYQDvCoTYPsHICEN+fnR2HSBPFge89ErWhpplyIY/5Jjwq2WZ0vifQYOErTW6E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781031415; c=relaxed/simple; bh=eJrryJR7FC2wXcvBjW9Isaw+U5WrFzf+qgsOKVPU91Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m1RCBsacSCiYVXjh24Nc4txycRSlb8YAzV8kveszZrLpxcbp6Hsm/iuIrINnk3kRqv+CKR/zxG7kmXymPr5B3Z2L0U/lhW0lita27cPqwSNNaCsInIW9QVDg3/sODPSq3VRIe2CApLqEdWiT/+xTrgKkxhpeDUBOx93t3G2P7NE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=trailofbits.com; spf=pass smtp.mailfrom=trailofbits.com; dkim=pass (2048-bit key) header.d=trailofbits.com header.i=@trailofbits.com header.b=P78xY7aM; arc=none smtp.client-ip=209.85.222.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=trailofbits.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=trailofbits.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=trailofbits.com header.i=@trailofbits.com header.b="P78xY7aM" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-9158fbaa4bbso655156385a.1 for ; Tue, 09 Jun 2026 11:56:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trailofbits.com; s=google; t=1781031413; x=1781636213; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UPa3Agakguu+yTP7S/VS7Anopqh6DOy/a2ofAVBPmuM=; b=P78xY7aMkl6+MYCnczOaIpAE/cmZfFqoGhah1y438V0079ncGNixFJgybKVAKJsbzB PBhvZZxgFxTTqz1knJ+2Y77dpA0lDvUuiNWFXQE4ZGBIwmx3HPgIcy4mc0mdExzfFU9X f4w5zQcNXlO2zXogSgyEBzzfoVQI8Eo2Kog4hMXWPUcGq4FqtURTaD1ew65JqOJkq+e1 CK2wPLwB/Cw2ILrQhBudsNHEMpeQgYvZK2C7v5TuJxuep6uV+eu1GmiVwAiwrg77W9gY uajf0F8V1puv1nmWz3e6C4B8B/yOJOCFNkfw961pKCo/t0tPNWy3QsaLmE1TLXxO/24C nvPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781031413; x=1781636213; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=UPa3Agakguu+yTP7S/VS7Anopqh6DOy/a2ofAVBPmuM=; b=SfCPcmtytH1+WLvSihwyqYyOn8CgbnFU8kXcSJckw5o7yqEXEOgZgXE2ltonL+GrJF m9Fr78W1ZEjLuQnrTa6wbG3XzVrR9bWkDHkDEkCuP1XkZogZRm4aIkJ711CudQ53Hv+U QkhUFQetyrGYardI45K9+c3+lgzt8KlulE5bbU7sq+fG07rxTJiNRZYPo3Jh37lgCh7b 8EX/3WTGkeP8j236XHJAl+PBuKr+b8D1m1vxG3u58Aa1wvHcKD1hWHJvwaL0hW6TRg9Z kPpzzZ7vJkWduswCm6sB5t1/Jt6duRiGRC+MKdBGvstAilWnPwnt6y/fZgUu+uxr3Jdp tLew== X-Forwarded-Encrypted: i=1; AFNElJ8fU4KvKf/DG/n9/Lvk6+MBZoCjPtGu+NhcmHF3Rz31wwD34YIpNHr147Svu6JIO0P9crin2NRr4D74LbA=@vger.kernel.org X-Gm-Message-State: AOJu0YwpDCXyKkaFjX70dUED3ubUFNWjBTBaWpU6WzqPuUgAI0/QQaJv G1oEjKi6KHIbJgoj1dqij08kB12TZsfIG/77hB9F/UL9aaV6sEVud8djqD5GwAu3MbE= X-Gm-Gg: Acq92OHQs4t5vSANnzPeeJi0Z+NwNPnzEbqM02Ww3BZzPk0JNYqQcDH7I8hAz/wxdgV ogt+nRBdaDAU8wfmojqmd3Y5/UVpU+l5vWSHH0wMzx1i+k/UwdsM61kHImQdvBDHzYzhMTghj+o PDiIA1MB57i60sZVoHTZY/8TxUXijwzp0ke/XumbCfIqd/DbiaW1ZnCxQzfPSM6NFFIaDVLuTNo Sr0R4dA058BvF1l1ZoA5PWOABmmU/SznAUqgMC637+86Fnkb21EAKZuB1jycOdcGkcohQgwlKMF F54ZAobxeuxwCfG1JFF2TSbFoNcyE2mQk3qVH1a2PBbbP/EPcSy5YeJLqMbHpcWaogE6AW6dNXv 1E697glTrsHtBDT+ulY+oAT4OHR+bG+Be1EB+qPB7VbM7cypSrRXOVsFBNawJDGmuCrFsPlUN4N PiuQkFmgQ23lqbQYnnlO1VhePm1nYWqmpNyucx2g== X-Received: by 2002:a05:620a:a29b:20b0:90d:501c:50 with SMTP id af79cd13be357-915a9c75e55mr2470804085a.26.1781031413022; Tue, 09 Jun 2026 11:56:53 -0700 (PDT) Received: from localhost ([161.35.96.86]) by smtp.gmail.com with UTF8SMTPSA id af79cd13be357-9158a00a4f4sm2355139185a.3.2026.06.09.11.56.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Jun 2026 11:56:52 -0700 (PDT) From: Samuel Moelius To: Jamal Hadi Salim Cc: Victor Nogueira , Jiri Pirko , Shuah Khan , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net v3 2/2] net/sched: act_pedit: require matching IPv4 L4 protocol Date: Tue, 9 Jun 2026 18:56:35 +0000 Message-ID: <20260609185636.1599359-3-sam.moelius@trailofbits.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260609185636.1599359-1-sam.moelius@trailofbits.com> References: <20260609185636.1599359-1-sam.moelius@trailofbits.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Victor Nogueira Add a tdc test that checks the act_pedit extended L4 header mode does not edit a packet whose IPv4 protocol does not match the selected transport header. The test installs an ingress pedit rule that sets the UDP destination port, then injects a TCP packet with dport 2222. The UDP and TCP destination ports sit at the same L4 offset, so a buggy kernel rewrites the TCP dport. A second flower filter matches TCP dport 2222 and drops the packet through an indexed gact action; the test then verifies via JSON that this action saw exactly one packet, i.e. the dport was left untouched and still matched 2222. Signed-off-by: Victor Nogueira --- Changes in v3: - Add test .../tc-testing/tc-tests/actions/pedit.json | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/pedit.json b/tools/testing/selftests/tc-testing/tc-tests/actions/pedit.json index 37c4103321749..d8b685cfc62de 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/pedit.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/pedit.json @@ -1920,5 +1920,54 @@ "teardown": [ "$TC actions flush action pedit" ] + }, + { + "id": "1a4f", + "name": "Pedit udp dport should not mangle TCP packet dport", + "category": [ + "actions", + "pedit" + ], + "plugins": { + "requires": [ + "nsPlugin", + "scapyPlugin" + ] + }, + "setup": [ + "$TC qdisc add dev $DEV1 clsact", + "$TC filter add dev $DEV1 ingress protocol ip pref 1 matchall action pedit ex munge udp dport set 18053 continue" + ], + "cmdUnderTest": "$TC filter add dev $DEV1 ingress protocol ip pref 2 flower ip_proto tcp dst_port 2222 action drop index 1", + "scapy": { + "iface": "$DEV0", + "count": 1, + "packet": "Ether()/IP(dst='10.10.10.1')/TCP(dport=2222)" + }, + "expExitCode": "0", + "verifyCmd": "$TC -j -s actions get action gact index 1", + "matchJSON": [ + { + "total acts": 0 + }, + { + "actions": [ + { + "order": 1, + "kind": "gact", + "control_action": { + "type": "drop" + }, + "index": 1, + "stats": { + "packets": 1 + } + } + ] + } + ], + "teardown": [ + "$TC qdisc del dev $DEV1 clsact" + ] } ] -- 2.54.0