mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: <shao.mingyin@zte.com.cn>
To: <kbusch@kernel.org>, <axboe@kernel.dk>, <hch@lst.de>,
	<sagi@grimberg.me>, <linux-nvme@lists.infradead.org>
Cc: <linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Subject: [PATCH 0/2] nvmet: pci-epf: fix a configfs overflow and a failed-read hang
Date: Wed, 4 Nov 2026 03:07:07 +0800 (CST)	[thread overview]
Message-ID: <20261104030707567QiZNPqBVEESVbvpNukFkY@zte.com.cn> (raw)

This series fixes two independent bugs in the NVMe PCI endpoint function
target driver.

Patch 1 fixes a heap overflow in the subsysnqn configfs attribute.  The
store callback passed the length of the configfs write buffer to
strscpy() as the destination size; an NQN longer than NVMF_NQN_SIZE
therefore wrote past subsysnqn into the following fields of the
nvmet_pci_epf object.

Patch 2 fixes a hang on failed read commands.  queue_response() completed
a command with a non-zero status directly, without waking
exec_iod_work(), which is waiting for the transfer of a DMA_TO_DEVICE
command.  The completion queue work could then free the iod while the
work item was still waiting on iod->done.  The work item now waits based
only on the data direction and length, and completes the command after
the wait even when it failed.  This is a follow-up to the recent fix for
the use-after-free in the same function (c9e9bb757971), which moved the
wait decision earlier but left the failed-command case from
746d0ac5a07d in place.

The two patches are independent, have no inter-patch dependencies and can
be applied in any order or as a subset.  Both carry Fixes: and
Cc: stable.

Testing: both apply to next-20261030, pass checkpatch.pl --strict with
0 errors/0 warnings/0 checks, and drivers/nvme/target/pci-epf.c builds
with CONFIG_NVME_TARGET_PCI_EPF=m and W=1 without new warnings.

Patch 1 was also reproduced and re-tested in QEMU (7.3.0-next-20261030,
configfs pci_ep framework, no endpoint controller needed): writing a
230-byte value through the subsysnqn attribute stored it and clobbered
mdts_kb (512 -> 4276545) before the fix, and is rejected with -EINVAL
after it.  Patch 2 was not runtime-tested: this setup has no PCI
endpoint controller.

Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
base-commit: 7649ba73f9e7e1e04d0b46213e39c79ae09dd55c

             reply	other threads:[~2026-11-03 19:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 19:07 shao.mingyin [this message]
2026-11-03 19:07 ` [PATCH 1/2] nvmet: pci-epf: fix subsysnqn configfs buffer overflow shao.mingyin
2026-11-03 19:07 ` [PATCH 2/2] nvmet: pci-epf: complete failed read commands instead of waiting forever shao.mingyin

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=20261104030707567QiZNPqBVEESVbvpNukFkY@zte.com.cn \
    --to=shao.mingyin@zte.com.cn \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=stable@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®