Skip to content

Crash in iptables OUTPUT chain  #25

Closed

Description

@genesisgardian

Hi,
I'm writing a simple code to capture the packet, and print the packet, just as the example code which you give to us. It works fine as the INPUT chain of iptables, but when I change to capture the output packet with OUTPUT chain of iptables, it crash and show the 'segmentation fault'.

I'm working on Ubuntu 16.04

Activity

  1. dany-fu commented on Jan 26, 2017

    @dany-fu

    I ran into a similar issue with version 0.8 and 0.6 on Ubuntu 14.04; PREROUTE works fine, POSTROUTE crashes. Seems ok so far on 0.7

  2. Tey commented on Jan 27, 2017

    @Tey

    Problem is at line 65 of netfilterqueue.pyx:

            self.hw_addr = self._hw.hw_addr

    When sending packets, self._hw is NULL so the copy crashes. I have no idea how to fix that in the PYX file (what should be the value of self.hw_addr when self._hw is NULL?), but as a workaround, you can just comment the following lines in netfilterqueue.c and compile/install the module again:

      __pyx_t_2 = __pyx_v_self->_hw->hw_addr;
      memcpy(&(__pyx_v_self->hw_addr[0]), __pyx_t_2, sizeof(__pyx_v_self->hw_addr[0]) * (8 - 0));
  3. ojalexander commented on Jan 27, 2017

    @ojalexander

    I ran into the same issue using OUTPUT. Thanks for the workaround.

  4. mattfox commented on Jan 27, 2017

    @mattfox
    Collaborator

    Thanks for the details. I'll see if I can duplicate and fix within a few days.

  5. added a commit that references this issue on Jan 31, 2017
    1a9815f
  6. mattfox commented on Jan 31, 2017

    @mattfox
    Collaborator

    The fix leaves calling and parsing of nfq_get_packet_hw data until the get_hw() call, and just returns None if nfq_get_packet_hw returns NULL. I believe hw_addr was private on Packet, so this should be compatible with 0.8.

    I've uploaded 0.8.1 to Pypi but reviews and improvements are welcome. Thanks for reporting this, all.

  7. Tey commented on Feb 6, 2017

    @Tey

    Thanks @mattfox I experience no more crash with 0.8.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions