-
Notifications
You must be signed in to change notification settings - Fork 864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not subtract the SLL[2]_HDR_LEN if the location is negative. #820
Do not subtract the SLL[2]_HDR_LEN if the location is negative. #820
Conversation
The commit message does not seem to reflect the committed code, which seems to be just addition of a cast. |
k is a bpf_u_int32. (bpf_u_int32)-4068 is > SLL2_HDR_LEN. |
By the way, for testing purposes I added Index: libpcap-1.10.0-dev/pcap-linux.c
===================================================================
--- libpcap-1.10.0-dev.orig/pcap-linux.c
+++ libpcap-1.10.0-dev/pcap-linux.c
@@ -3071,6 +3071,10 @@ pcap_setfilter_linux_common(pcap_t *hand
* work in the kernel.
*/
can_filter_in_kernel = 0;
+ if (1) {
+ printf( "Filtering in userland:\n" );
+ bpf_dump(&fcode, 1);
+ }
break;
case 1:
@@ -3078,6 +3082,10 @@ pcap_setfilter_linux_common(pcap_t *hand
* We have a filter that'll work in the kernel.
*/
can_filter_in_kernel = 1;
+ if (1) {
+ printf( "Installing in kernel:\n" );
+ bpf_dump(&fcode, 1);
+ }
break;
}
} and the dumped code for |
Presumably you mean tcpdump issue 480, i.e. the-tcpdump-group/tcpdump#480, not just #480, which refers to libpcap issue 480. |
And that'd be this comment. |
Thanks, Guy, I wasn't being careful about what I wrote. I've updated the description. |
76fe740
to
926dacf
Compare
926dacf
to
0dfc47a
Compare
I updated the code to match Guy's suggestion, and the test is:
vs.
(The filter debug output is identical with |
So the question is whether an offset of -4097 should be interpreted as
So it looks as if the intent is that the only ancillary data offsets that are valid are the ones of the form
The comment before that is
although the structure for the instruction is
so the offset, being unsigned, is never negative. It's almost certainly past the end of the packet, and they may, in fact, limit offsets somewhere to be < 2^31-1. They also define
I don't know whether "MAX" means "this is the largest valid ancillary data offset" or "this is just past the largest valid ancillary data offset" - if it's the former, they're presumably reserving it or something. So should we 1) treat all offsets with the uppermost bit set as being special, 2) treat all offsets > |
Your (1) is more like my original code's behavior. (2) is what my current code does. I'm fine with either. (3) is funny because what we do is subtract from k, so |
0dfc47a
to
c0e2634
Compare
c0e2634
to
a43b1c9
Compare
a43b1c9
to
b80c6a6
Compare
I've been rebasing to make it easier to accept. Would you like me to change the behavior to treat all negative offsets as special (your (1)), or leave the current behavior (your (2))? |
b80c6a6
to
007f487
Compare
007f487
to
844c858
Compare
I've been rebasing to make it easier to accept. Would you like me to change the behavior to treat all negative offsets as special (your (1)), or leave the current behavior (your (2))? |
This fixes the offset issue I mention in the-tcpdump-group/tcpdump#480 (comment)
844c858
to
eebbdd4
Compare
This fixes the offset issue I mention in tcpdump issue 480 about dumping on multiple interfaces - fix_program() modifies even negative offsets to take the SLL header into account, so the special SKF_AD_ values are not usable directly when using the SLL DLTs.