Bug 260667 - vtnet(4): Memory leak, missing pfil_head_unregister() in vtnet_detach()
Summary: vtnet(4): Memory leak, missing pfil_head_unregister() in vtnet_detach()
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.0-RELEASE
Hardware: Any Any
: --- Affects Many People
Assignee: Gleb Smirnoff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-24 16:26 UTC by ghuckriede
Modified: 2024-01-02 19:04 UTC (History)
3 users (show)

See Also:
koobs: mfc-stable13?
koobs: mfc-stable12?


Attachments
Potential Fix (456 bytes, patch)
2022-01-04 15:43 UTC, ghuckriede
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ghuckriede 2021-12-24 16:26:32 UTC
Overview
--------

'if_vtnet' driver is missing the 'pfil_head_unregister()' during 'vtnet_detach()'.

Included a patch, which assumes the fix for bug #256714 is also applied.


Steps to Reproduce
------------------

Attach and then detach vnet device.
# vmstat -m | grep pfil
         pfil     6     1K        5  128
# devctl attach pci0:0:4:0
virtio_pci1: <VirtIO PCI (legacy) Network adapter> port 0xc020-0xc03f mem 0xfeb92000-0xfeb92fff,0xfe004000-0xfe007fff irq 11 at device 4.0 on pci0
vtnet1: <VirtIO Networking Adapter> on virtio_pci1
pfil: duplicate head "vtnet1"
810.828154 [ 450] vtnet_netmap_attach       vtnet attached txq=1, txd=256 rxq=1, rxd=128
# devctl detach pci0:0:4:0
# vmstat -m | grep pfil
         pfil     7     1K        6  128


Actual Results
--------------

Leaks 'pfil' memory at each detach.



Expected Results
----------------

All memory allocated in attach is freed in the detach.


Build Date & Hardware
---------------------

root@freebsd:~ # uname -a
FreeBSD freebsd 13.0-RELEASE FreeBSD 13.0-RELEASE #0 releng/13.0-n244733-ea31abc261f: Fri Apr  9 04:24:09 UTC 2021     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64


Additional Information
----------------------
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2021-12-24 22:40:18 UTC
Thank you for your report. Was a patch/attachment accidentally not included here?
Comment 2 ghuckriede 2022-01-04 15:43:27 UTC
Created attachment 230696 [details]
Potential Fix
Comment 3 ghuckriede 2022-01-04 15:44:33 UTC
Yes, I neglected to attach the diff.
Comment 4 commit-hook freebsd_committer freebsd_triage 2022-01-05 02:42:44 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=3f6ab5493f4b89e7625dd31f807065cfae6c503d

commit 3f6ab5493f4b89e7625dd31f807065cfae6c503d
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2022-01-05 02:41:05 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2022-01-05 02:41:05 +0000

    vtnet: don't leak pfil(9) data on detach

    PR:             260667
    Submitted by:   <ghuckriede blackberry.com>

 sys/dev/virtio/network/if_vtnet.c | 5 +++++
 1 file changed, 5 insertions(+)
Comment 5 commit-hook freebsd_committer freebsd_triage 2023-12-21 18:42:57 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=0084d02356494eb7a1b276ded9d37f3164a7248e

commit 0084d02356494eb7a1b276ded9d37f3164a7248e
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2022-01-05 02:41:05 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2023-12-21 18:41:48 +0000

    vtnet: don't leak pfil(9) data on detach

    PR:             260667
    Submitted by:   <ghuckriede blackberry.com>

    (cherry picked from commit 3f6ab5493f4b89e7625dd31f807065cfae6c503d)

 sys/dev/virtio/network/if_vtnet.c | 5 +++++
 1 file changed, 5 insertions(+)