All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <kch@nvidia.com>
To: <linux-nvme@lists.infradead.org>
Cc: <hare@suse.de>, <kbusch@kernel.org>, <hch@lst.de>,
	<sagi@grimberg.me>, Chaitanya Kulkarni <kch@nvidia.com>
Subject: [PATCH V2 0/4] nvme: init ctrl memleak and debugfs fix
Date: Fri, 28 Apr 2023 00:31:11 -0700	[thread overview]
Message-ID: <20230428073115.22987-1-kch@nvidia.com> (raw)

Hi,

There is memleak in nvme_ctrl_dhchap_secret_store(), 
nvme_ctrl_dhchap_ctrl_secret_store(), and nvme_init_ctrl().

Fix dhchap memleaks by adding right kfree() :- 

unreferenced object 0xffff8886376ea800 (size 64):
  comm "check", pid 22048, jiffies 4344316705 (age 92.199s)
  hex dump (first 32 bytes):
    44 48 48 43 2d 31 3a 30 30 3a 6e 78 72 35 4b 67  DHHC-1:00:nxr5Kg
    75 58 34 75 6f 41 78 73 4a 61 34 63 2f 68 75 4c  uX4uoAxsJa4c/huL
  backtrace:
    [<0000000030ce5d4b>] __kmalloc+0x4b/0x130
    [<000000009be1cdc1>] nvme_ctrl_dhchap_secret_store+0x8f/0x160 [nvme_core]
    [<00000000ac06c96a>] kernfs_fop_write_iter+0x12b/0x1c0
    [<00000000437e7ced>] vfs_write+0x2ba/0x3c0
    [<00000000f9491baf>] ksys_write+0x5f/0xe0
    [<000000001c46513d>] do_syscall_64+0x3b/0x90
    [<00000000ecf348fe>] entry_SYSCALL_64_after_hwframe+0x72/0xdc

Fix dev_pm_qos related memleak in nvme_init_ctrl() with adding 
dev_pm_qos_hide_latency_tolerance() in the error unwind code :-

nvme/044 (Test bi-directional authentication)                [passed]
    runtime  2.111s  ...  2.124s
unreferenced object 0xffff888110c46240 (size 96):
  comm "nvme", pid 33461, jiffies 4345365353 (age 75.586s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<0000000069ac2cec>] kmalloc_trace+0x25/0x90
    [<000000006acc66d5>] dev_pm_qos_update_user_latency_tolerance+0x6f/0x100
    [<00000000cc376ea7>] nvme_init_ctrl+0x38e/0x410 [nvme_core]
    [<000000007df61b4b>] 0xffffffffc05e88b3
    [<00000000d152b985>] 0xffffffffc05744cb
    [<00000000f04a4041>] vfs_write+0xc5/0x3c0
    [<00000000f9491baf>] ksys_write+0x5f/0xe0
    [<000000001c46513d>] do_syscall_64+0x3b/0x90
    [<00000000ecf348fe>] entry_SYSCALL_64_after_hwframe+0x72/0xdc

When blktests are running multiple times we get following messages
consistently :-

[  147.853464] debugfs: Directory 'nvme1' with parent '/' already present!
[  147.853973] nvme1: failed to create debugfs attr
[  148.802490] debugfs: Directory 'nvme1' with parent '/' already present!
[  148.803244] nvme1: failed to create debugfs attr
[  148.877304] debugfs: Directory 'nvme1' with parent '/' already present!
[  148.877775] nvme1: failed to create debugfs attr
[  149.816652] debugfs: Directory 'nvme1' with parent '/' already present!
[  149.818011] nvme1: failed to create debugfs attr

Fix those by adding nvme_fault inject_fini() call in the error unwind
code path.

Still trying to find out device_add() memleak, will send patch soon.

-ck

v2:-

1. In first two patches add kfree() call after strcmp() if block.
2. Add a patch to fix the nvme_ctrl_init() dev_pm_qos memleak.
3. Add a patch to fix the debugfs directory error message.
4. Add tested by tag on patch 1.

Chaitanya Kulkarni (4):
  nvme-core: fix memory leak in dhchap_secret_store
  nvme-core: fix memory leak in dhchap_ctrl_secret
  nvme-core: add missing fault-injection cleanup
  nvme-core: fix dev_pm_qos memleak

 drivers/nvme/host/core.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

-- 
2.40.0



             reply	other threads:[~2023-04-28  7:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-28  7:31 Chaitanya Kulkarni [this message]
2023-04-28  7:31 ` [PATCH V2 1/4] nvme-core: fix memory leak in dhchap_secret_store Chaitanya Kulkarni
2023-05-01 13:14   ` Sagi Grimberg
2023-04-28  7:31 ` [PATCH V2 2/4] nvme-core: fix memory leak in dhchap_ctrl_secret Chaitanya Kulkarni
2023-05-01 13:14   ` Sagi Grimberg
2023-04-28  7:31 ` [PATCH V2 3/4] nvme-core: add missing fault-injection cleanup Chaitanya Kulkarni
2023-05-01 13:14   ` Sagi Grimberg
2023-05-06  3:20   ` Yi Zhang
2023-04-28  7:31 ` [PATCH V2 4/4] nvme-core: fix dev_pm_qos memleak Chaitanya Kulkarni
2023-05-01 13:14   ` Sagi Grimberg
2023-05-06  3:14   ` Yi Zhang
2023-04-28  8:41 ` [PATCH V2 0/4] nvme: init ctrl memleak and debugfs fix Chaitanya Kulkarni
2023-05-12 20:29 ` Christoph Hellwig
2023-05-15 17:13 ` Keith Busch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230428073115.22987-1-kch@nvidia.com \
    --to=kch@nvidia.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.