Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 02 Oct 2023 16:05:56 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 273626] Memory leak in ioctl nvme passthrough commands
Message-ID:  <bug-273626-227-1dl1drTYK7@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-273626-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-273626-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D273626

--- Comment #4 from commit-hook@FreeBSD.org ---
A commit in branch main references this bug:

URL:
https://cgit.FreeBSD.org/src/commit/?id=3D7ea866eb14f8ec869a525442c03228b67=
01e1dab

commit 7ea866eb14f8ec869a525442c03228b6701e1dab
Author:     David Sloan <david.sloan@eideticom.com>
AuthorDate: 2023-09-07 16:22:21 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-10-02 15:50:14 +0000

    nvme: Fix memory leak in pt ioctl commands

    When running nvme passthrough commands through the ioctl interface
    memory is mapped with vmapbuf() but not unmapped. This results in leaked
    memory whenever a process executes an nvme passthrough command with a
    data buffer. This can be replicated with a simple c function (error
    checks skipped for brevity):

    void leak_memory(int nvme_ns_fd, uint16_t nblocks) {
            struct nvme_pt_command pt =3D {
                    .cmd =3D {
                            .opc =3D NVME_OPC_READ,
                            .cdw12 =3D nblocks - 1,
                    },
                    .len =3D nblocks * 512, // Assumes devices with 512 byt=
e lba
                    .is_read =3D 1, // Reads and writes should both trigger=
 leak
            }
            void *buf;

            posix_memalign(&buf, nblocks * 512);
            pt.buf =3D buf;
            ioctl(nvme_ns_fd, NVME_PASSTHROUGH_COMMAND, &pt);
            free(buf);
    }

    Signed-off-by: David Sloan <david.sloan@eideticom.com>

    PR:             273626
    Reviewed by:    imp, markj
    MFC after:      1 week

 sys/dev/nvme/nvme_ctrlr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-273626-227-1dl1drTYK7>