Skip to content

libpcap: pass positive BIOCIMMEDIATE to ioctl - #5213

Merged
gpotter2 merged 1 commit into
secdev:masterfrom
evverx:positive-biocimmediate
Oct 1, 2026
Merged

gpotter2 merged 1 commit into
secdev:masterfrom
evverx:positive-biocimmediate

Conversation

@evverx

@evverx evverx commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

to prevent ioctl from failing with

 14115  14115 python3  CALL  ioctl(3,0xffffffff80044270,0x7f7fff1415b0)
 14115  14115 python3  GIO   fd 3 wrote 4 bytes
       "\^A\0\0\0"
 14115  14115 python3  RET   ioctl -1 errno 22 Invalid argument

and actually turn on immediate mode on 64-bit NetBSD machines.

With this patch applied tests waiting for timely replies receive those replies in time in libpcap mode.

The negative value was most likely used to get around a bug in Python 2.4 where ioctl failed with

OverflowError: signed integer is greater than maximum

when the positive value was passed instead. That bug was fixed in Python 2.5 in https://bugs.python.org/issue1231069 and scapy no longer supports Python 2 anyway.

(It should also make it easier to test #5209)

@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.17%. Comparing base (b0a6933) to head (a3dc2b7).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5213      +/-   ##
==========================================
+ Coverage   80.87%   81.17%   +0.29%     
==========================================
  Files         393      393              
  Lines       98134    98134              
==========================================
+ Hits        79368    79662     +294     
+ Misses      18766    18472     -294     
Files with missing lines Coverage Δ
scapy/arch/libpcap.py 77.16% <100.00%> (+2.36%) ⬆️

... and 21 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

to prevent ioctl from failing with
```
 14115  14115 python3  CALL  ioctl(3,0xffffffff80044270,0x7f7fff1415b0)
 14115  14115 python3  GIO   fd 3 wrote 4 bytes
       "\^A\0\0\0"
 14115  14115 python3  RET   ioctl -1 errno 22 Invalid argument
```
and actually turn on immediate mode on 64-bit NetBSD machines.

With this patch applied tests waiting for timely replies
receive those replies in time in libpcap mode.

The negative value was most likely used to get around a bug in Python
2.4 where ioctl failed with
```
OverflowError: signed integer is greater than maximum
```
when the positive value was passed instead. That bug was fixed in Python
2.5 in https://bugs.python.org/issue1231069 and scapy no longer supports
Python 2 anyway.

AI-Assisted: no
@evverx
evverx force-pushed the positive-biocimmediate branch from 5b06e4e to a3dc2b7 Compare October 1, 2026 00:44
@gpotter2
gpotter2 merged commit 580c62e into secdev:master Oct 1, 2026
23 checks passed
@gpotter2

gpotter2 commented Oct 1, 2026

Copy link
Copy Markdown
Member

Thanks for the PR !

@gpotter2 gpotter2 added this to the 2.8.0 milestone Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants