Skip to contentSkip to conversation

Python bindings crash when more than one Nftables is instantiated

DISCUSSION Eugene Crosser 2 participants 2 messages Sep 14, 2021 – Sep 15, 2021 netfilter

lore
Share & tools
lore
#0 lore raw

Hello,

it seems to me that this should not be happening. Use case is not as pathological as it may seem: your program may be using different third party modules, each of them instantiate Nftables interface.

$ sudo python
[sudo] password for echerkashin:
Python 3.9.7 (default, Sep  3 2021, 06:18:44)
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

from nftables import Nftables
n1=Nftables()
n2=Nftables()
<Ctrl-D>

double free or corruption (top)
Aborted

Note that it happens on exit (possibly on the second call to __del__()).

nftables v0.9.9

Regards,

Eugene

#1 lore raw
Quoted 15 lines · Eugene Crosser

Hello,

it seems to me that this should not be happening. Use case is not as pathological as it may seem: your program may be using different third party modules, each of them instantiate Nftables interface.

$ sudo python
[sudo] password for echerkashin:
Python 3.9.7 (default, Sep  3 2021, 06:18:44)
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

from nftables import Nftables
n1=Nftables()
n2=Nftables()
<Ctrl-D>

Quoted 6 lines

double free or corruption (top)
Aborted

Note that it happens on exit (possibly on the second call to __del__()).

nftables v0.9.9

Upstream fix:

http://git.netfilter.org/nftables/commit/?id=b85769f9397c72ab62387ccc5b7a66d0c3ff5f21

Thanks for reporting.