[PATCH v5 0/3] nvmet: avoid recursive configfs open

Runyu Xiao posted 3 patches 1 day, 10 hours ago
drivers/nvme/target/io-cmd-file.c |  3 +-
drivers/nvme/target/passthru.c    |  3 +-
fs/configfs/mount.c               | 67 +++++++++++++++++++++++++++++++
include/linux/configfs.h          |  5 +++
4 files changed, 76 insertions(+), 2 deletions(-)
[PATCH v5 0/3] nvmet: avoid recursive configfs open
Posted by Runyu Xiao 1 day, 10 hours ago
The nvmet configfs store callbacks hold the item's frag_sem while they
enable file-backed namespaces or passthru controllers.  Both paths open a
user-configured pathname.  If it resolves into configfs, the open path can
re-enter __configfs_open_file() and try to acquire that same non-recursive
semaphore again, which deadlocks the task.

Add configfs helpers that reject configfs-backed roots or paths and open
the resulting path with file_open_root().  This keeps the normal open-time
permission and security checks while preventing the recursive configfs
open.

Changes since v4:
- Make the filesystem-type check local to configfs_open_root() in
  fs/configfs/mount.c instead of exporting a one-line predicate, since
  there is no user outside configfs for it.
- Add kerneldoc for both helpers, documenting how they are meant to be
  used by configfs store callbacks.
- Keep the Reviewed-by tags on 2/3 and 3/3: those patches are unchanged.

Runyu Xiao (3):
  fs: configfs: add helpers for opening non-configfs paths
  nvmet: avoid recursive configfs open for file-backed namespaces
  nvmet: avoid recursive configfs open for passthru

 drivers/nvme/target/io-cmd-file.c |  3 +-
 drivers/nvme/target/passthru.c    |  3 +-
 fs/configfs/mount.c               | 67 +++++++++++++++++++++++++++++++
 include/linux/configfs.h          |  5 +++
 4 files changed, 76 insertions(+), 2 deletions(-)


base-commit: df2908090cda368b01ff43709f51890076c56157