Merge ~fheimes/ubuntu/+source/scapy/+git/scapy:scapy-lp1908280-hirsute into ~fheimes/ubuntu/+source/scapy/+git/scapy:importer/ubuntu/hirsute-devel

Proposed by Frank Heimes
Status: Needs review
Proposed branch: ~fheimes/ubuntu/+source/scapy/+git/scapy:scapy-lp1908280-hirsute
Merge into: ~fheimes/ubuntu/+source/scapy/+git/scapy:importer/ubuntu/hirsute-devel
Diff against target: 137 lines (+105/-1)
4 files modified
debian/changelog (+9/-0)
debian/control (+2/-1)
debian/patches/scapy-lp1908280-hirsute.patch (+93/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Approve
Review via email: mp+397377@code.launchpad.net

Description of the change

scapy fails to load BPF program
 The scapy sniff() function loads a BPF program into the kernel
 which apparently fails to load on s390x
 This patch contains a backport of upstream commit 474eb1f6
 - scapy/arch/common.py: remove workaround for bpf handling that's broken
   in PyPy 7.3.0 from common code
 - scapy/arch/linux.py: and add the workaround for bp handling to Linux code
   that's broken PyPy in 7.3.2
 - scapy/libs/structures.py: add class sock_fprog

To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

LGTM, and the fact that it is applied upstream will help to make it a sync later on.
There isn't much more to say, the old issues we discussed in the past on other cases are no more present (yay), so +1 from me.

Let me know if you want/need sponsoring of this.

review: Approve
Revision history for this message
Frank Heimes (fheimes) wrote :

Thanks Christian for the review and +1.

Yes, sponsoring on top would be great ! :-)

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Ah while checking in git, one thing to mention - it is one commit.
Since it isn't in gut-ubuntu properly it won't make a difference.
But if it would have been then individual commits would be better.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Sponsored

Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading scapy_2.4.4-4ubuntu1.dsc: done.
  Uploading scapy_2.4.4-4ubuntu1.debian.tar.xz: done.
  Uploading scapy_2.4.4-4ubuntu1_source.buildinfo: done.
  Uploading scapy_2.4.4-4ubuntu1_source.changes: done.
Successfully uploaded packages.

(We discussed an odd unclean'ness of this git repo), but I double checked the generated changes - they LGTM just as the proposed changes here.

Unmerged commits

930d9aa... by Frank Heimes

scapy-lp1908280-hirsute.patch - scapy fails to load BPF program on s390x

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 27fd49d..cd83b74 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,12 @@
6+scapy (2.4.4-4ubuntu1) hirsute; urgency=medium
7+
8+ * debian/patches/scapy-lp1908280-hirsute.patch:
9+ scapy fails to load BPF program
10+ sock_fprog needs to be used instead of bpf_program
11+ Thanks to Ilya Leoshkevich (LP: #1908280)
12+
13+ -- Frank Heimes <frank.heimes@canonical.com> Tue, 02 Feb 2021 20:10:19 +0100
14+
15 scapy (2.4.4-4) unstable; urgency=medium
16
17 * Team upload.
18diff --git a/debian/control b/debian/control
19index be231b8..5cc669c 100644
20--- a/debian/control
21+++ b/debian/control
22@@ -1,5 +1,6 @@
23 Source: scapy
24-Maintainer: Debian Security Tools <team+pkg-security@tracker.debian.org>
25+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
26+XSBC-Original-Maintainer: Debian Security Tools <team+pkg-security@tracker.debian.org>
27 Uploaders: Raphaël Hertzog <raphael@offensive-security.com>
28 Section: python
29 Priority: optional
30diff --git a/debian/patches/scapy-lp1908280-hirsute.patch b/debian/patches/scapy-lp1908280-hirsute.patch
31new file mode 100644
32index 0000000..6956882
33--- /dev/null
34+++ b/debian/patches/scapy-lp1908280-hirsute.patch
35@@ -0,0 +1,93 @@
36+Description: scapy fails to load BPF program
37+ The scapy sniff() function loads a BPF program into the kernel
38+ which apparently fails to load on s390x
39+ This patch contains a backport of upstream commit 474eb1f6
40+ - scapy/arch/common.py: remove workaround for bpf handling that's broken
41+ in PyPy 7.3.0 from common code
42+ - scapy/arch/linux.py: and add the workaround for bp handling to Linux code
43+ that's broken PyPy in 7.3.2
44+ - scapy/libs/structures.py: add class sock_fprog
45+Author: Ilya Leoshkevich <iii@linux.ibm.com>
46+Origin: https://github.com/secdev/scapy/commit/474eb1f6930601e444227445f9e315b35c06a996
47+Bug-IBM: IBM Bugzilla 188965
48+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1908280
49+Forwarded: not-needed
50+Applied-Upstream: > v2.4.4
51+Reviewed-by: Frank Heimes <frank.heimes@canonical.com>
52+Last-Update: 2021-02-02
53+---
54+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
55+--- a/scapy/arch/common.py
56++++ b/scapy/arch/common.py
57+@@ -10,7 +10,6 @@
58+ import ctypes
59+ import socket
60+ import struct
61+-import sys
62+ import time
63+ from scapy.consts import WINDOWS
64+ from scapy.config import conf
65+@@ -128,11 +127,4 @@
66+ raise Scapy_Exception(
67+ "Failed to compile filter expression %s (%s)" % (filter_exp, ret)
68+ )
69+- if conf.use_pypy and sys.pypy_version_info <= (7, 3, 0):
70+- # PyPy < 7.3.0 has a broken behavior
71+- # https://bitbucket.org/pypy/pypy/issues/3114
72+- return struct.pack(
73+- 'HL',
74+- bpf.bf_len, ctypes.addressof(bpf.bf_insns.contents)
75+- )
76+ return bpf
77+--- a/scapy/arch/linux.py
78++++ b/scapy/arch/linux.py
79+@@ -11,11 +11,13 @@
80+
81+
82+ import array
83++import ctypes
84+ from fcntl import ioctl
85+ import os
86+ from select import select
87+ import socket
88+ import struct
89++import sys
90+ import time
91+
92+ import subprocess
93+@@ -24,6 +26,7 @@
94+ from scapy.consts import LINUX
95+ import scapy.utils
96+ import scapy.utils6
97++from scapy.libs.structures import sock_fprog
98+ from scapy.packet import Packet, Padding
99+ from scapy.config import conf
100+ from scapy.data import MTU, ETH_P_ALL, SOL_PACKET, SO_ATTACH_FILTER, \
101+@@ -140,6 +143,15 @@
102+ :param iface: the interface used to compile
103+ """
104+ bp = compile_filter(bpf_filter, iface)
105++ if conf.use_pypy and sys.pypy_version_info <= (7, 3, 2):
106++ # PyPy < 7.3.2 has a broken behavior
107++ # https://foss.heptapod.net/pypy/pypy/-/issues/3298
108++ bp = struct.pack(
109++ 'HL',
110++ bp.bf_len, ctypes.addressof(bp.bf_insns.contents)
111++ )
112++ else:
113++ bp = sock_fprog(bp.bf_len, bp.bf_insns)
114+ sock.setsockopt(socket.SOL_SOCKET, SO_ATTACH_FILTER, bp)
115+
116+
117+--- a/scapy/libs/structures.py
118++++ b/scapy/libs/structures.py
119+@@ -21,3 +21,9 @@
120+ """"Structure for BIOCSETF"""
121+ _fields_ = [('bf_len', ctypes.c_int),
122+ ('bf_insns', ctypes.POINTER(bpf_insn))]
123++
124++
125++class sock_fprog(ctypes.Structure):
126++ """"Structure for SO_ATTACH_FILTER"""
127++ _fields_ = [('len', ctypes.c_ushort),
128++ ('filter', ctypes.POINTER(bpf_insn))]
129diff --git a/debian/patches/series b/debian/patches/series
130index 00e700d..c3610a8 100644
131--- a/debian/patches/series
132+++ b/debian/patches/series
133@@ -5,3 +5,4 @@ Change-path-in-test-for-autopkgtest.patch
134 add-support-for-python3.9.patch
135 Fix-find-library-libc-for-python-3.9.patch
136 upstream-42d58d8729.patch
137+scapy-lp1908280-hirsute.patch

Subscribers

People subscribed via source and target branches

to all changes: