Bug 274310 - pf leaks memory
Summary: pf leaks memory
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 15.0-CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Tom Jones
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-06 16:25 UTC by Tom Jones
Modified: 2024-02-05 15:48 UTC (History)
7 users (show)

See Also:


Attachments
Script to run pf tests and check for module memory leaks (1009 bytes, application/x-shellscript)
2023-10-06 16:25 UTC, Tom Jones
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Jones freebsd_committer freebsd_triage 2023-10-06 16:25:29 UTC
Created attachment 245467 [details]
Script to run pf tests and check for module memory leaks

pf can leak memory, this can be seen by running the test suite and unloading the pf kernel mode.


With the attached script the following pf tests trigger memory leaks:


- sys/netpfil/pf/anchor:pr183198 
- sys/netpfil/pf/anchor:nested_anchor 
- sys/netpfil/pf/anchor:wildcard 
- sys/netpfil/pf/nat:nested_anchor 
- sys/netpfil/pf/pass_block:nested_inline 
- sys/netpfil/pf/rules_counter:get_clear 
- sys/netpfil/pf/table:anchor
Comment 1 commit-hook freebsd_committer freebsd_triage 2023-11-29 18:04:57 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=0626d30e41cba64b41667314c3a4f7611f0eb685

commit 0626d30e41cba64b41667314c3a4f7611f0eb685
Author:     Igor Ostapenko <pm@igoro.pro>
AuthorDate: 2023-11-29 12:35:41 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2023-11-29 16:59:28 +0000

    pf: fix mem leaks upon vnet destroy

    Add missing cleanup actions:
    - remove user defined anchor rulesets
    - remove user defined ether anchor rulesets
    - remove tables linked to user defined anchors
    - deal with wildcard anchor peculiarities to get them removed correctly

    PR:             274310
    Reviewed by:    kp
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D42747

 sys/netpfil/pf/pf_ioctl.c | 67 ++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 60 insertions(+), 7 deletions(-)
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-12-06 14:41:57 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=05c55eed44e53a3a5473451d105f81ce36ef375a

commit 05c55eed44e53a3a5473451d105f81ce36ef375a
Author:     Igor Ostapenko <pm@igoro.pro>
AuthorDate: 2023-11-29 12:35:41 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2023-12-06 13:23:33 +0000

    pf: fix mem leaks upon vnet destroy

    Add missing cleanup actions:
    - remove user defined anchor rulesets
    - remove user defined ether anchor rulesets
    - remove tables linked to user defined anchors
    - deal with wildcard anchor peculiarities to get them removed correctly

    PR:             274310
    Reviewed by:    kp
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D42747

    (cherry picked from commit 0626d30e41cba64b41667314c3a4f7611f0eb685)

 sys/netpfil/pf/pf_ioctl.c | 44 ++++++++++++++++++++++++++++++++++++++------
 1 file changed, 38 insertions(+), 6 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-12-06 14:41:59 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=285b505a4ee0ab2fdc8f970e7d23a6d3091dc686

commit 285b505a4ee0ab2fdc8f970e7d23a6d3091dc686
Author:     Igor Ostapenko <pm@igoro.pro>
AuthorDate: 2023-11-29 12:35:41 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2023-12-06 09:08:25 +0000

    pf: fix mem leaks upon vnet destroy

    Add missing cleanup actions:
    - remove user defined anchor rulesets
    - remove user defined ether anchor rulesets
    - remove tables linked to user defined anchors
    - deal with wildcard anchor peculiarities to get them removed correctly

    PR:             274310
    Reviewed by:    kp
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D42747

    (cherry picked from commit 0626d30e41cba64b41667314c3a4f7611f0eb685)

 sys/netpfil/pf/pf_ioctl.c | 67 ++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 60 insertions(+), 7 deletions(-)
Comment 4 Ed Maste freebsd_committer freebsd_triage 2024-02-05 15:14:39 UTC
Is this issue now resolved?
Comment 5 Kristof Provost freebsd_committer freebsd_triage 2024-02-05 15:48:39 UTC
Yes.