* [PATCH nft] src: delete the old cache when dumping is interrupted
@ 2017-05-14 7:56 Liping Zhang
2017-05-17 18:14 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Liping Zhang @ 2017-05-14 7:56 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel, Liping Zhang
From: Liping Zhang <zlpnobody@gmail.com>
When the dumping operation is interrupted, we will restart the
cache_init(), but unfortunatly, we forget to delete the old cache.
So in extreme case, we will leak a huge amount of memory.
Running the following commands can simulate the extreme case:
# nft add table t
# nft add set t s {type inet_service \;}
# for i in $(seq 65000); do
nft add element t s {$i}
done &
# while : ; do
time nft list ruleset -nn
done
After a while, oom killer will be triggered:
[ 2808.243537] Out of memory: Kill process 16975 (nft) score 649 or
sacrifice child
[ 2808.255372] Killed process 16975 (nft) total-vm:1955348kB,
anon-rss:1952120kB, file-rss:0kB, shmem-rss:0kB
[ 2858.353729] nft invoked oom-killer: gfp_mask=0x14201ca(GFP_HIGHUSER_
MOVABLE|__GFP_COLD), nodemask=(null), order=0,
oom_score_adj=0
[ 2858.374521] nft cpuset=/ mems_allowed=0
...
Signed-off-by: Liping Zhang <zlpnobody@gmail.com>
---
src/rule.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rule.c b/src/rule.c
index 209cf2d..5923bf6 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -156,11 +156,11 @@ replay:
netlink_genid_get();
ret = cache_init(cmd, msgs);
if (ret < 0) {
+ cache_release();
if (errno == EINTR) {
netlink_restart();
goto replay;
}
- cache_release();
return -1;
}
cache_initialized = true;
--
2.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH nft] src: delete the old cache when dumping is interrupted
2017-05-14 7:56 [PATCH nft] src: delete the old cache when dumping is interrupted Liping Zhang
@ 2017-05-17 18:14 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2017-05-17 18:14 UTC (permalink / raw)
To: Liping Zhang; +Cc: netfilter-devel, Liping Zhang
On Sun, May 14, 2017 at 03:56:12PM +0800, Liping Zhang wrote:
> From: Liping Zhang <zlpnobody@gmail.com>
>
> When the dumping operation is interrupted, we will restart the
> cache_init(), but unfortunatly, we forget to delete the old cache.
> So in extreme case, we will leak a huge amount of memory.
>
> Running the following commands can simulate the extreme case:
> # nft add table t
> # nft add set t s {type inet_service \;}
> # for i in $(seq 65000); do
> nft add element t s {$i}
> done &
> # while : ; do
> time nft list ruleset -nn
> done
>
> After a while, oom killer will be triggered:
> [ 2808.243537] Out of memory: Kill process 16975 (nft) score 649 or
> sacrifice child
> [ 2808.255372] Killed process 16975 (nft) total-vm:1955348kB,
> anon-rss:1952120kB, file-rss:0kB, shmem-rss:0kB
> [ 2858.353729] nft invoked oom-killer: gfp_mask=0x14201ca(GFP_HIGHUSER_
> MOVABLE|__GFP_COLD), nodemask=(null), order=0,
> oom_score_adj=0
> [ 2858.374521] nft cpuset=/ mems_allowed=0
> ...
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-05-17 18:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-14 7:56 [PATCH nft] src: delete the old cache when dumping is interrupted Liping Zhang
2017-05-17 18:14 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).