FreeBSD Bugzilla – Attachment 244701 Details for
Bug 273626
Memory leak in ioctl nvme passthrough commands
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
git patch file
0001-nvme-Fix-memory-leak-in-pt-ioctl-commands.patch (text/plain), 1.47 KB, created by
David Sloan
on 2023-09-07 21:51:19 UTC
(
hide
)
Description:
git patch file
Filename:
MIME Type:
Creator:
David Sloan
Created:
2023-09-07 21:51:19 UTC
Size:
1.47 KB
patch
obsolete
>From 1dea17e787ddb6eee581b38adb270a5e1d15f6f0 Mon Sep 17 00:00:00 2001 >From: David Sloan <david.sloan@eideticom.com> >Date: Thu, 7 Sep 2023 10:22:21 -0600 >Subject: [PATCH] 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 = { > .cmd = { > .opc = NVME_OPC_READ, > .cdw12 = nblocks - 1, > }, > .len = nblocks * 512, // Assumes devices with 512 byte lba > .is_read = 1, // Reads and writes should both trigger leak > } > void *buf; > > posix_memalign(&buf, nblocks * 512); > pt.buf = buf; > ioctl(nvme_ns_fd, NVME_PASSTHROUGH_COMMAND, &pt); > free(buf); >} > >Signed-off-by: David Sloan <david.sloan@eideticom.com> >--- > sys/dev/nvme/nvme_ctrlr.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > >diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c >index c4a75090174..608b738a1ff 100644 >--- a/sys/dev/nvme/nvme_ctrlr.c >+++ b/sys/dev/nvme/nvme_ctrlr.c >@@ -1361,8 +1361,9 @@ nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctrlr, > mtx_sleep(pt, mtx, PRIBIO, "nvme_pt", 0); > mtx_unlock(mtx); > >-err: > if (buf != NULL) { >+ vunmapbuf(buf); >+err: > uma_zfree(pbuf_zone, buf); > PRELE(curproc); > } >-- >2.34.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 273626
: 244701