With fd_async_io=1 the fileio backend calls ->read_iter() and ->write_iter() of the backing file directly. The synchronous path goes through vfs_iter_read() and vfs_iter_write() which check for them but the aio path doesn't. So a backing file without them calls a NULL pointer on its first I/O. Refuse such files when configuring the device. On the synchronous path every read or write that needed the missing method failed with EINVAL anyway. Fixes: 769031c92c8b ("scsi: target: target/file: Add support of direct and async I/O") Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig Signed-off-by: Christian Brauner (Amutable) --- drivers/target/target_core_file.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index ab9824a4852f1..a5391e57e9aa5 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c @@ -144,6 +144,14 @@ static int fd_configure_device(struct se_device *dev) goto fail; } fd_dev->fd_file = file; + + if (!file->f_op->read_iter || !file->f_op->write_iter) { + pr_err("FILEIO: %s lacks ->read_iter or ->write_iter\n", + fd_dev->fd_dev_name); + ret = -EINVAL; + goto fail; + } + /* * If using a block backend with this struct file, we extract * fd_dev->fd_[block,dev]_size from struct block_device. -- 2.53.0