From nobody Mon Oct 2 16:05:56 2023 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Rzm5c66VMz4wDNj for ; Mon, 2 Oct 2023 16:05:56 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Rzm5c560Yz4K8X for ; Mon, 2 Oct 2023 16:05:56 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696262756; a=rsa-sha256; cv=none; b=rY8puZ2PUDumyaQOHR0raIchFaSpq72Q9ZpNCwQ5IoE8Pu0zze8i1RCUmLAESDIsjY8Xpw jqWiZb56Ax5WeYhpmOlBv/Wm40fJnLkeFCa3gxeaB3YDtB38kpuFxdSVqBkPah1uAJJ9Y5 FltplT3fjMiHrcjV08sea0ORQoEpflIwHTRernm8TILKaajd+pEf+ZVnmPL1t4koK5JsJt Q3fAf5tM4TS6o3yAeD9B/Q5zwMvTGDw8T3kcKQ2Sy/1QCsEYYz6jP12jSWlXfYLmVUgCnL eeXszZRRns4GZrqF0tjoKDPLrFvJW/V+XyuXOtocK7v/s7Foji8SW+WfhyAN2w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696262756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nvSPwQbjzVIsVlBicmNtaT95w7FvaL3lU6Mi8o7GdfQ=; b=VICzuUi+jJVoMDVontLezTgPx6RtzvD2ysPV7xQRp30fu6NBl317OAgyVXCb2pEstXvwab r8UK9CBg+K5+CPvvQMd5hMEKwpn09huKz3k1jQ/x05ngd0dQgSU1jwY/c28PsCSQRIPZin mPkCoF0oYsvTOYxYTgac8m3fIyzFP7CKYnp9uDZXrb7NFRQ4LCk7lodx1GNi41DV9uDFZG X83KCykv52sOQFcBpeKNwkS2xEDbDCD39BXl8J1YeSQvVET96M/vQa7BQ2Xr5IneeaPJdw wZdDC7NZ5kylCWmQ03RNyae5HZ0H7zMSlmPzM3XbvJlcJLsB5aZYs4CpL/cpCg== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Rzm5c44tvz45b for ; Mon, 2 Oct 2023 16:05:56 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 392G5uZr020722 for ; Mon, 2 Oct 2023 16:05:56 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from bugzilla@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 392G5uEs020721 for bugs@FreeBSD.org; Mon, 2 Oct 2023 16:05:56 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: bugzilla set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 273626] Memory leak in ioctl nvme passthrough commands Date: Mon, 02 Oct 2023 16:05:56 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 13.2-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: commit-hook@FreeBSD.org X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 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 AuthorDate: 2023-09-07 16:22:21 +0000 Commit: Mark Johnston 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 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.=