All of lore.kernel.org
 help / color / mirror / Atom feed
* sort out the lock order in the loop driver v2
@ 2021-08-26 13:38 Christoph Hellwig
  2021-08-26 13:38 ` [PATCH 1/8] cryptoloop: fix a sparse annotation Christoph Hellwig
                   ` (9 more replies)
  0 siblings, 10 replies; 21+ messages in thread
From: Christoph Hellwig @ 2021-08-26 13:38 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Hillf Danton, Tetsuo Handa, Pavel Tatashin,
	Reviewed-by : Tyler Hicks, linux-block

Hi Jens,

this series sorts out lock order reversals involving the block layer
open_mutex by drastically reducing the scope of loop_ctl_mutex.  To do
so it first merges the cryptoloop module into the main loop driver
as the unregistrtion of transfers on live loop devices was causing
some nasty locking interactions.

Changes since v1:
 - add a new patch to fix a pre-existing spare warning in the crypto code
 - initialize various struct loop_dev fields earlier
 - hold lo_mutex over lo_state updates
 - take loop_ctl_mutex to delete from the idr in the loop_add failure
   path

Diffstat:
 b/drivers/block/Kconfig    |    6 
 b/drivers/block/Makefile   |    1 
 b/drivers/block/loop.c     |  334 ++++++++++++++++++++++++---------------------
 b/drivers/block/loop.h     |   30 ----
 drivers/block/cryptoloop.c |  204 ---------------------------
 5 files changed, 189 insertions(+), 386 deletions(-)

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 1/8] cryptoloop: fix a sparse annotation
  2021-08-26 13:38 sort out the lock order in the loop driver v2 Christoph Hellwig
@ 2021-08-26 13:38 ` Christoph Hellwig
  2021-08-26 13:38 ` [PATCH 2/8] loop: remove the unused idx argument to loop_control_get_free Christoph Hellwig
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2021-08-26 13:38 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Hillf Danton, Tetsuo Handa, Pavel Tatashin,
	Reviewed-by : Tyler Hicks, linux-block

iv is used as a little endian value, so use a __le32 type for it.  Also
move the initialization into the declaration to simplify it a bit.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/cryptoloop.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c
index 3cabc335ae74..1a65dec47b07 100644
--- a/drivers/block/cryptoloop.c
+++ b/drivers/block/cryptoloop.c
@@ -130,8 +130,7 @@ cryptoloop_transfer(struct loop_device *lo, int cmd,
 
 	while (size > 0) {
 		const int sz = min(size, LOOP_IV_SECTOR_SIZE);
-		u32 iv[4] = { 0, };
-		iv[0] = cpu_to_le32(IV & 0xffffffff);
+		__le32 iv[4] = { cpu_to_le32(IV & 0xffffffff), };
 
 		sg_set_page(&sg_in, in_page, sz, in_offs);
 		sg_set_page(&sg_out, out_page, sz, out_offs);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 2/8] loop: remove the unused idx argument to loop_control_get_free
  2021-08-26 13:38 sort out the lock order in the loop driver v2 Christoph Hellwig
  2021-08-26 13:38 ` [PATCH 1/8] cryptoloop: fix a sparse annotation Christoph Hellwig
@ 2021-08-26 13:38 ` Christoph Hellwig
  2021-08-26 13:38 ` [PATCH 3/8] loop: remove the ->ioctl method in loop_func_table Christoph Hellwig
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2021-08-26 13:38 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Hillf Danton, Tetsuo Handa, Pavel Tatashin,
	Reviewed-by : Tyler Hicks, linux-block

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/loop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index fa1c298a8cfb..35d8b30d1f25 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -2466,7 +2466,7 @@ static int loop_control_remove(int idx)
 	return ret;
 }
 
-static int loop_control_get_free(int idx)
+static int loop_control_get_free(void)
 {
 	struct loop_device *lo;
 	int id, ret;
@@ -2494,7 +2494,7 @@ static long loop_control_ioctl(struct file *file, unsigned int cmd,
 	case LOOP_CTL_REMOVE:
 		return loop_control_remove(parm);
 	case LOOP_CTL_GET_FREE:
-		return loop_control_get_free(parm);
+		return loop_control_get_free();
 	default:
 		return -ENOSYS;
 	}
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 3/8] loop: remove the ->ioctl method in loop_func_table
  2021-08-26 13:38 sort out the lock order in the loop driver v2 Christoph Hellwig
  2021-08-26 13:38 ` [PATCH 1/8] cryptoloop: fix a sparse annotation Christoph Hellwig
  2021-08-26 13:38 ` [PATCH 2/8] loop: remove the unused idx argument to loop_control_get_free Christoph Hellwig
@ 2021-08-26 13:38 ` Christoph Hellwig
  2021-08-26 13:38 ` [PATCH 4/8] loop: return void from the ->release " Christoph Hellwig
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2021-08-26 13:38 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Hillf Danton, Tetsuo Handa, Pavel Tatashin,
	Reviewed-by : Tyler Hicks, linux-block

Never set to anything useful.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/cryptoloop.c | 7 -------
 drivers/block/loop.c       | 4 +---
 drivers/block/loop.h       | 3 ---
 3 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c
index 1a65dec47b07..2c705ea7f218 100644
--- a/drivers/block/cryptoloop.c
+++ b/drivers/block/cryptoloop.c
@@ -153,12 +153,6 @@ cryptoloop_transfer(struct loop_device *lo, int cmd,
 	return err;
 }
 
-static int
-cryptoloop_ioctl(struct loop_device *lo, int cmd, unsigned long arg)
-{
-	return -EINVAL;
-}
-
 static int
 cryptoloop_release(struct loop_device *lo)
 {
@@ -175,7 +169,6 @@ cryptoloop_release(struct loop_device *lo)
 static struct loop_func_table cryptoloop_funcs = {
 	.number = LO_CRYPT_CRYPTOAPI,
 	.init = cryptoloop_init,
-	.ioctl = cryptoloop_ioctl,
 	.transfer = cryptoloop_transfer,
 	.release = cryptoloop_release,
 	.owner = THIS_MODULE
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 35d8b30d1f25..508a168fddaa 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1169,7 +1169,6 @@ loop_set_status_from_info(struct loop_device *lo,
 	if (!xfer)
 		xfer = &none_funcs;
 	lo->transfer = xfer->transfer;
-	lo->ioctl = xfer->ioctl;
 
 	lo->lo_flags = info->lo_flags;
 
@@ -1383,7 +1382,6 @@ static int __loop_clr_fd(struct loop_device *lo, bool release)
 
 	loop_release_xfer(lo);
 	lo->transfer = NULL;
-	lo->ioctl = NULL;
 	lo->lo_device = NULL;
 	lo->lo_encryption = NULL;
 	lo->lo_offset = 0;
@@ -1809,7 +1807,7 @@ static int lo_simple_ioctl(struct loop_device *lo, unsigned int cmd,
 		err = loop_set_block_size(lo, arg);
 		break;
 	default:
-		err = lo->ioctl ? lo->ioctl(lo, cmd, arg) : -EINVAL;
+		err = -EINVAL;
 	}
 	mutex_unlock(&lo->lo_mutex);
 	return err;
diff --git a/drivers/block/loop.h b/drivers/block/loop.h
index 1988899db63a..dcde46afc675 100644
--- a/drivers/block/loop.h
+++ b/drivers/block/loop.h
@@ -43,8 +43,6 @@ struct loop_device {
 	struct loop_func_table *lo_encryption;
 	__u32           lo_init[2];
 	kuid_t		lo_key_owner;	/* Who set the key */
-	int		(*ioctl)(struct loop_device *, int cmd, 
-				 unsigned long arg); 
 
 	struct file *	lo_backing_file;
 	struct block_device *lo_device;
@@ -91,7 +89,6 @@ struct loop_func_table {
 	int (*init)(struct loop_device *, const struct loop_info64 *); 
 	/* release is called from loop_unregister_transfer or clr_fd */
 	int (*release)(struct loop_device *); 
-	int (*ioctl)(struct loop_device *, int cmd, unsigned long arg);
 	struct module *owner;
 }; 
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 4/8] loop: return void from the ->release method in loop_func_table
  2021-08-26 13:38 sort out the lock order in the loop driver v2 Christoph Hellwig
                   ` (2 preceding siblings ...)
  2021-08-26 13:38 ` [PATCH 3/8] loop: remove the ->ioctl method in loop_func_table Christoph Hellwig
@ 2021-08-26 13:38 ` Christoph Hellwig
  2021-08-26 13:38 ` [PATCH 5/8] loop: merge the cryptoloop module into the main loop module Christoph Hellwig
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2021-08-26 13:38 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Hillf Danton, Tetsuo Handa, Pavel Tatashin,
	Reviewed-by : Tyler Hicks, linux-block

Returning an error here is no useful.  So remove the cargo culted check
in cryptoloop and remove the return value.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/cryptoloop.c | 12 +++---------
 drivers/block/loop.c       | 10 +++-------
 drivers/block/loop.h       |  2 +-
 3 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c
index 2c705ea7f218..c2392ce2a819 100644
--- a/drivers/block/cryptoloop.c
+++ b/drivers/block/cryptoloop.c
@@ -153,17 +153,11 @@ cryptoloop_transfer(struct loop_device *lo, int cmd,
 	return err;
 }
 
-static int
+static void
 cryptoloop_release(struct loop_device *lo)
 {
-	struct crypto_sync_skcipher *tfm = lo->key_data;
-	if (tfm != NULL) {
-		crypto_free_sync_skcipher(tfm);
-		lo->key_data = NULL;
-		return 0;
-	}
-	printk(KERN_ERR "cryptoloop_release(): tfm == NULL?\n");
-	return -EINVAL;
+	crypto_free_sync_skcipher(lo->key_data);
+	lo->key_data = NULL;
 }
 
 static struct loop_func_table cryptoloop_funcs = {
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 508a168fddaa..680974601161 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1084,20 +1084,18 @@ static void loop_update_rotational(struct loop_device *lo)
 		blk_queue_flag_clear(QUEUE_FLAG_NONROT, q);
 }
 
-static int
+static void
 loop_release_xfer(struct loop_device *lo)
 {
-	int err = 0;
 	struct loop_func_table *xfer = lo->lo_encryption;
 
 	if (xfer) {
 		if (xfer->release)
-			err = xfer->release(lo);
+			xfer->release(lo);
 		lo->transfer = NULL;
 		lo->lo_encryption = NULL;
 		module_put(xfer->owner);
 	}
-	return err;
 }
 
 static int
@@ -1140,9 +1138,7 @@ loop_set_status_from_info(struct loop_device *lo,
 	if ((unsigned int) info->lo_encrypt_key_size > LO_KEY_SIZE)
 		return -EINVAL;
 
-	err = loop_release_xfer(lo);
-	if (err)
-		return err;
+	loop_release_xfer(lo);
 
 	if (info->lo_encrypt_type) {
 		unsigned int type = info->lo_encrypt_type;
diff --git a/drivers/block/loop.h b/drivers/block/loop.h
index dcde46afc675..7b84ef724de1 100644
--- a/drivers/block/loop.h
+++ b/drivers/block/loop.h
@@ -88,7 +88,7 @@ struct loop_func_table {
 			int size, sector_t real_block);
 	int (*init)(struct loop_device *, const struct loop_info64 *); 
 	/* release is called from loop_unregister_transfer or clr_fd */
-	int (*release)(struct loop_device *); 
+	void (*release)(struct loop_device *); 
 	struct module *owner;
 }; 
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 5/8] loop: merge the cryptoloop module into the main loop module
  2021-08-26 13:38 sort out the lock order in the loop driver v2 Christoph Hellwig
                   ` (3 preceding siblings ...)
  2021-08-26 13:38 ` [PATCH 4/8] loop: return void from the ->release " Christoph Hellwig
@ 2021-08-26 13:38 ` Christoph Hellwig
  2021-08-26 16:31   ` Milan Broz
  2021-08-26 13:38 ` [PATCH 6/8] loop: devirtualize transfer transformations Christoph Hellwig
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2021-08-26 13:38 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Hillf Danton, Tetsuo Handa, Pavel Tatashin,
	Reviewed-by : Tyler Hicks, linux-block

No need to keep a separate loadable module infrastructure for a tiny
amount of cryptoapi glue, especially as unloading of the cryptoloop
module leads to nasty interactions with the loop device state machine
through loop_unregister_transfer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/Kconfig      |   6 +-
 drivers/block/Makefile     |   1 -
 drivers/block/cryptoloop.c | 190 -----------------------------------
 drivers/block/loop.c       | 200 +++++++++++++++++++++++++++----------
 drivers/block/loop.h       |   5 -
 5 files changed, 151 insertions(+), 251 deletions(-)
 delete mode 100644 drivers/block/cryptoloop.c

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 63056cfd4b62..c63386576ef6 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -156,6 +156,8 @@ config BLK_DEV_COW_COMMON
 
 config BLK_DEV_LOOP
 	tristate "Loopback device support"
+	select CRYPTO if CRYPTOLOOP
+	select CRYPTO_CBC if CRYPTOLOOP
 	help
 	  Saying Y here will allow you to use a regular file as a block
 	  device; you can then create a file system on that block device and
@@ -213,9 +215,7 @@ config BLK_DEV_LOOP_MIN_COUNT
 	  dynamically allocated with the /dev/loop-control interface.
 
 config BLK_DEV_CRYPTOLOOP
-	tristate "Cryptoloop Support"
-	select CRYPTO
-	select CRYPTO_CBC
+	bool "Cryptoloop Support"
 	depends on BLK_DEV_LOOP
 	help
 	  Say Y here if you want to be able to use the ciphers that are 
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index bc68817ef496..11a74f17c9ad 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -24,7 +24,6 @@ obj-$(CONFIG_CDROM_PKTCDVD)	+= pktcdvd.o
 obj-$(CONFIG_SUNVDC)		+= sunvdc.o
 
 obj-$(CONFIG_BLK_DEV_NBD)	+= nbd.o
-obj-$(CONFIG_BLK_DEV_CRYPTOLOOP) += cryptoloop.o
 obj-$(CONFIG_VIRTIO_BLK)	+= virtio_blk.o
 
 obj-$(CONFIG_BLK_DEV_SX8)	+= sx8.o
diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c
deleted file mode 100644
index c2392ce2a819..000000000000
--- a/drivers/block/cryptoloop.c
+++ /dev/null
@@ -1,190 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
-   Linux loop encryption enabling module
-
-   Copyright (C)  2002 Herbert Valerio Riedel <hvr@gnu.org>
-   Copyright (C)  2003 Fruhwirth Clemens <clemens@endorphin.org>
-
- */
-
-#include <linux/module.h>
-
-#include <crypto/skcipher.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/blkdev.h>
-#include <linux/scatterlist.h>
-#include <linux/uaccess.h>
-#include "loop.h"
-
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("loop blockdevice transferfunction adaptor / CryptoAPI");
-MODULE_AUTHOR("Herbert Valerio Riedel <hvr@gnu.org>");
-
-#define LOOP_IV_SECTOR_BITS 9
-#define LOOP_IV_SECTOR_SIZE (1 << LOOP_IV_SECTOR_BITS)
-
-static int
-cryptoloop_init(struct loop_device *lo, const struct loop_info64 *info)
-{
-	int err = -EINVAL;
-	int cipher_len;
-	int mode_len;
-	char cms[LO_NAME_SIZE];			/* cipher-mode string */
-	char *mode;
-	char *cmsp = cms;			/* c-m string pointer */
-	struct crypto_sync_skcipher *tfm;
-
-	/* encryption breaks for non sector aligned offsets */
-
-	if (info->lo_offset % LOOP_IV_SECTOR_SIZE)
-		goto out;
-
-	strncpy(cms, info->lo_crypt_name, LO_NAME_SIZE);
-	cms[LO_NAME_SIZE - 1] = 0;
-
-	cipher_len = strcspn(cmsp, "-");
-
-	mode = cmsp + cipher_len;
-	mode_len = 0;
-	if (*mode) {
-		mode++;
-		mode_len = strcspn(mode, "-");
-	}
-
-	if (!mode_len) {
-		mode = "cbc";
-		mode_len = 3;
-	}
-
-	if (cipher_len + mode_len + 3 > LO_NAME_SIZE)
-		return -EINVAL;
-
-	memmove(cms, mode, mode_len);
-	cmsp = cms + mode_len;
-	*cmsp++ = '(';
-	memcpy(cmsp, info->lo_crypt_name, cipher_len);
-	cmsp += cipher_len;
-	*cmsp++ = ')';
-	*cmsp = 0;
-
-	tfm = crypto_alloc_sync_skcipher(cms, 0, 0);
-	if (IS_ERR(tfm))
-		return PTR_ERR(tfm);
-
-	err = crypto_sync_skcipher_setkey(tfm, info->lo_encrypt_key,
-					  info->lo_encrypt_key_size);
-
-	if (err != 0)
-		goto out_free_tfm;
-
-	lo->key_data = tfm;
-	return 0;
-
- out_free_tfm:
-	crypto_free_sync_skcipher(tfm);
-
- out:
-	return err;
-}
-
-
-typedef int (*encdec_cbc_t)(struct skcipher_request *req);
-
-static int
-cryptoloop_transfer(struct loop_device *lo, int cmd,
-		    struct page *raw_page, unsigned raw_off,
-		    struct page *loop_page, unsigned loop_off,
-		    int size, sector_t IV)
-{
-	struct crypto_sync_skcipher *tfm = lo->key_data;
-	SYNC_SKCIPHER_REQUEST_ON_STACK(req, tfm);
-	struct scatterlist sg_out;
-	struct scatterlist sg_in;
-
-	encdec_cbc_t encdecfunc;
-	struct page *in_page, *out_page;
-	unsigned in_offs, out_offs;
-	int err;
-
-	skcipher_request_set_sync_tfm(req, tfm);
-	skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP,
-				      NULL, NULL);
-
-	sg_init_table(&sg_out, 1);
-	sg_init_table(&sg_in, 1);
-
-	if (cmd == READ) {
-		in_page = raw_page;
-		in_offs = raw_off;
-		out_page = loop_page;
-		out_offs = loop_off;
-		encdecfunc = crypto_skcipher_decrypt;
-	} else {
-		in_page = loop_page;
-		in_offs = loop_off;
-		out_page = raw_page;
-		out_offs = raw_off;
-		encdecfunc = crypto_skcipher_encrypt;
-	}
-
-	while (size > 0) {
-		const int sz = min(size, LOOP_IV_SECTOR_SIZE);
-		__le32 iv[4] = { cpu_to_le32(IV & 0xffffffff), };
-
-		sg_set_page(&sg_in, in_page, sz, in_offs);
-		sg_set_page(&sg_out, out_page, sz, out_offs);
-
-		skcipher_request_set_crypt(req, &sg_in, &sg_out, sz, iv);
-		err = encdecfunc(req);
-		if (err)
-			goto out;
-
-		IV++;
-		size -= sz;
-		in_offs += sz;
-		out_offs += sz;
-	}
-
-	err = 0;
-
-out:
-	skcipher_request_zero(req);
-	return err;
-}
-
-static void
-cryptoloop_release(struct loop_device *lo)
-{
-	crypto_free_sync_skcipher(lo->key_data);
-	lo->key_data = NULL;
-}
-
-static struct loop_func_table cryptoloop_funcs = {
-	.number = LO_CRYPT_CRYPTOAPI,
-	.init = cryptoloop_init,
-	.transfer = cryptoloop_transfer,
-	.release = cryptoloop_release,
-	.owner = THIS_MODULE
-};
-
-static int __init
-init_cryptoloop(void)
-{
-	int rc = loop_register_transfer(&cryptoloop_funcs);
-
-	if (rc)
-		printk(KERN_ERR "cryptoloop: loop_register_transfer failed\n");
-	return rc;
-}
-
-static void __exit
-cleanup_cryptoloop(void)
-{
-	if (loop_unregister_transfer(LO_CRYPT_CRYPTOAPI))
-		printk(KERN_ERR
-			"cryptoloop: loop_unregister_transfer failed\n");
-}
-
-module_init(init_cryptoloop);
-module_exit(cleanup_cryptoloop);
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 680974601161..45c7e88b0aff 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -39,6 +39,10 @@
  * Support up to 256 loop devices
  * Heinz Mauelshagen <mge@sistina.com>, Feb 2002
  *
+ * Cryptoloop support:
+ * Copyright (C)  2002 Herbert Valerio Riedel <hvr@gnu.org>
+ * Copyright (C)  2003 Fruhwirth Clemens <clemens@endorphin.org>
+ *
  * Support for falling back on the write file operation when the address space
  * operations write_begin is not available on the backing filesystem.
  * Anton Altaparmakov, 16 Feb 2005
@@ -79,13 +83,16 @@
 #include <linux/ioprio.h>
 #include <linux/blk-cgroup.h>
 #include <linux/sched/mm.h>
-
+#include <crypto/skcipher.h>
 #include "loop.h"
 
 #include <linux/uaccess.h>
 
 #define LOOP_IDLE_WORKER_TIMEOUT (60 * HZ)
 
+#define LOOP_IV_SECTOR_BITS 9
+#define LOOP_IV_SECTOR_SIZE (1 << LOOP_IV_SECTOR_BITS)
+
 static DEFINE_IDR(loop_index_idr);
 static DEFINE_MUTEX(loop_ctl_mutex);
 static DEFINE_MUTEX(loop_validate_mutex);
@@ -179,10 +186,144 @@ static struct loop_func_table xor_funcs = {
 	.init = xor_init
 }; 
 
+#ifdef CONFIG_BLK_DEV_CRYPTOLOOP
+static int cryptoloop_init(struct loop_device *lo,
+		const struct loop_info64 *info)
+{
+	int err = -EINVAL;
+	int cipher_len;
+	int mode_len;
+	char cms[LO_NAME_SIZE];			/* cipher-mode string */
+	char *mode;
+	char *cmsp = cms;			/* c-m string pointer */
+	struct crypto_sync_skcipher *tfm;
+
+	/* encryption breaks for non sector aligned offsets */
+	if (info->lo_offset % LOOP_IV_SECTOR_SIZE)
+		return -EINVAL;
+
+	strncpy(cms, info->lo_crypt_name, LO_NAME_SIZE);
+	cms[LO_NAME_SIZE - 1] = 0;
+
+	cipher_len = strcspn(cmsp, "-");
+	mode = cmsp + cipher_len;
+	mode_len = 0;
+	if (*mode) {
+		mode++;
+		mode_len = strcspn(mode, "-");
+	}
+	if (!mode_len) {
+		mode = "cbc";
+		mode_len = 3;
+	}
+	if (cipher_len + mode_len + 3 > LO_NAME_SIZE)
+		return -EINVAL;
+
+	memmove(cms, mode, mode_len);
+	cmsp = cms + mode_len;
+	*cmsp++ = '(';
+	memcpy(cmsp, info->lo_crypt_name, cipher_len);
+	cmsp += cipher_len;
+	*cmsp++ = ')';
+	*cmsp = 0;
+
+	tfm = crypto_alloc_sync_skcipher(cms, 0, 0);
+	if (IS_ERR(tfm))
+		return PTR_ERR(tfm);
+
+	err = crypto_sync_skcipher_setkey(tfm, info->lo_encrypt_key,
+					  info->lo_encrypt_key_size);
+	if (err != 0)
+		goto out_free_tfm;
+	lo->key_data = tfm;
+	return 0;
+
+ out_free_tfm:
+	crypto_free_sync_skcipher(tfm);
+	return err;
+}
+
+typedef int (*encdec_cbc_t)(struct skcipher_request *req);
+
+static int cryptoloop_transfer(struct loop_device *lo, int cmd,
+		struct page *raw_page, unsigned raw_off, struct page *loop_page,
+		unsigned loop_off, int size, sector_t IV)
+{
+	struct crypto_sync_skcipher *tfm = lo->key_data;
+	SYNC_SKCIPHER_REQUEST_ON_STACK(req, tfm);
+	struct scatterlist sg_out;
+	struct scatterlist sg_in;
+	encdec_cbc_t encdecfunc;
+	struct page *in_page, *out_page;
+	unsigned in_offs, out_offs;
+	int err;
+
+	skcipher_request_set_sync_tfm(req, tfm);
+	skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP,
+				      NULL, NULL);
+
+	sg_init_table(&sg_out, 1);
+	sg_init_table(&sg_in, 1);
+
+	if (cmd == READ) {
+		in_page = raw_page;
+		in_offs = raw_off;
+		out_page = loop_page;
+		out_offs = loop_off;
+		encdecfunc = crypto_skcipher_decrypt;
+	} else {
+		in_page = loop_page;
+		in_offs = loop_off;
+		out_page = raw_page;
+		out_offs = raw_off;
+		encdecfunc = crypto_skcipher_encrypt;
+	}
+
+	while (size > 0) {
+		const int sz = min(size, LOOP_IV_SECTOR_SIZE);
+		__le32 iv[4] = { cpu_to_le32(IV & 0xffffffff), };
+
+		sg_set_page(&sg_in, in_page, sz, in_offs);
+		sg_set_page(&sg_out, out_page, sz, out_offs);
+
+		skcipher_request_set_crypt(req, &sg_in, &sg_out, sz, iv);
+		err = encdecfunc(req);
+		if (err)
+			goto out;
+
+		IV++;
+		size -= sz;
+		in_offs += sz;
+		out_offs += sz;
+	}
+
+	err = 0;
+out:
+	skcipher_request_zero(req);
+	return err;
+}
+
+static void cryptoloop_release(struct loop_device *lo)
+{
+	crypto_free_sync_skcipher(lo->key_data);
+	lo->key_data = NULL;
+}
+
+static struct loop_func_table cryptoloop_funcs = {
+	.number		= LO_CRYPT_CRYPTOAPI,
+	.init		= cryptoloop_init,
+	.transfer	= cryptoloop_transfer,
+	.release	= cryptoloop_release,
+};
+#endif /* CONFIG_BLK_DEV_CRYPTOLOOP */
+
 /* xfer_funcs[0] is special - its release function is never called */
 static struct loop_func_table *xfer_funcs[MAX_LO_CRYPT] = {
-	&none_funcs,
-	&xor_funcs
+	[LO_CRYPT_NONE]		= &none_funcs,
+	[LO_CRYPT_XOR]		= &xor_funcs,
+#ifdef CONFIG_BLK_DEV_CRYPTOLOOP
+	[LO_CRYPT_CRYPTOAPI]	= &cryptoloop_funcs,
+#endif
 };
 
 static loff_t get_size(loff_t offset, loff_t sizelimit, struct file *file)
@@ -1094,7 +1235,6 @@ loop_release_xfer(struct loop_device *lo)
 			xfer->release(lo);
 		lo->transfer = NULL;
 		lo->lo_encryption = NULL;
-		module_put(xfer->owner);
 	}
 }
 
@@ -1104,16 +1244,9 @@ loop_init_xfer(struct loop_device *lo, struct loop_func_table *xfer,
 {
 	int err = 0;
 
-	if (xfer) {
-		struct module *owner = xfer->owner;
-
-		if (!try_module_get(owner))
-			return -EINVAL;
-		if (xfer->init)
-			err = xfer->init(lo, i);
-		if (err)
-			module_put(owner);
-		else
+	if (xfer && xfer->init) {
+		err = xfer->init(lo, i);
+		if (!err)
 			lo->lo_encryption = xfer;
 	}
 	return err;
@@ -2094,44 +2227,7 @@ module_param(max_part, int, 0444);
 MODULE_PARM_DESC(max_part, "Maximum number of partitions per loop device");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR);
-
-int loop_register_transfer(struct loop_func_table *funcs)
-{
-	unsigned int n = funcs->number;
-
-	if (n >= MAX_LO_CRYPT || xfer_funcs[n])
-		return -EINVAL;
-	xfer_funcs[n] = funcs;
-	return 0;
-}
-
-static int unregister_transfer_cb(int id, void *ptr, void *data)
-{
-	struct loop_device *lo = ptr;
-	struct loop_func_table *xfer = data;
-
-	mutex_lock(&lo->lo_mutex);
-	if (lo->lo_encryption == xfer)
-		loop_release_xfer(lo);
-	mutex_unlock(&lo->lo_mutex);
-	return 0;
-}
-
-int loop_unregister_transfer(int number)
-{
-	unsigned int n = number;
-	struct loop_func_table *xfer;
-
-	if (n == 0 || n >= MAX_LO_CRYPT || (xfer = xfer_funcs[n]) == NULL)
-		return -EINVAL;
-
-	xfer_funcs[n] = NULL;
-	idr_for_each(&loop_index_idr, &unregister_transfer_cb, xfer);
-	return 0;
-}
-
-EXPORT_SYMBOL(loop_register_transfer);
-EXPORT_SYMBOL(loop_unregister_transfer);
+MODULE_ALIAS("cryptoloop");
 
 static blk_status_t loop_queue_rq(struct blk_mq_hw_ctx *hctx,
 		const struct blk_mq_queue_data *bd)
diff --git a/drivers/block/loop.h b/drivers/block/loop.h
index 7b84ef724de1..dd12d7f1ce30 100644
--- a/drivers/block/loop.h
+++ b/drivers/block/loop.h
@@ -87,12 +87,7 @@ struct loop_func_table {
 			struct page *loop_page, unsigned loop_off,
 			int size, sector_t real_block);
 	int (*init)(struct loop_device *, const struct loop_info64 *); 
-	/* release is called from loop_unregister_transfer or clr_fd */
 	void (*release)(struct loop_device *); 
-	struct module *owner;
 }; 
 
-int loop_register_transfer(struct loop_func_table *funcs);
-int loop_unregister_transfer(int number); 
-
 #endif
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 6/8] loop: devirtualize transfer transformations
  2021-08-26 13:38 sort out the lock order in the loop driver v2 Christoph Hellwig
                   ` (4 preceding siblings ...)
  2021-08-26 13:38 ` [PATCH 5/8] loop: merge the cryptoloop module into the main loop module Christoph Hellwig
@ 2021-08-26 13:38 ` Christoph Hellwig
  2021-08-26 13:38 ` [PATCH 7/8] loop: move loop device deletion out of loop_ctl_mutex Christoph Hellwig
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2021-08-26 13:38 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Hillf Danton, Tetsuo Handa, Pavel Tatashin,
	Reviewed-by : Tyler Hicks, linux-block

Besides the already special cased non-transform fastpath there are only
two different transfers.  Hardcode them instead of the maze of indirect
calls and switch the whole cryptoloop code to use IS_ENABLED for dead
code elimination.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/loop.c | 146 +++++++++++--------------------------------
 drivers/block/loop.h |  21 ++-----
 2 files changed, 41 insertions(+), 126 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 45c7e88b0aff..6ee4b046bdcc 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -140,7 +140,7 @@ static void loop_global_unlock(struct loop_device *lo, bool global)
 static int max_part;
 static int part_shift;
 
-static int transfer_xor(struct loop_device *lo, int cmd,
+static void xor_transfer(struct loop_device *lo, int cmd,
 			struct page *raw_page, unsigned raw_off,
 			struct page *loop_page, unsigned loop_off,
 			int size, sector_t real_block)
@@ -166,27 +166,14 @@ static int transfer_xor(struct loop_device *lo, int cmd,
 	kunmap_atomic(loop_buf);
 	kunmap_atomic(raw_buf);
 	cond_resched();
-	return 0;
 }
 
-static int xor_init(struct loop_device *lo, const struct loop_info64 *info)
+static inline bool is_cryptoloop(int encrypt_type)
 {
-	if (unlikely(info->lo_encrypt_key_size <= 0))
-		return -EINVAL;
-	return 0;
+	return IS_ENABLED(CONFIG_BLK_DEV_CRYPTOLOOP) &&
+		encrypt_type == LO_CRYPT_CRYPTOAPI;
 }
 
-static struct loop_func_table none_funcs = {
-	.number = LO_CRYPT_NONE,
-}; 
-
-static struct loop_func_table xor_funcs = {
-	.number = LO_CRYPT_XOR,
-	.transfer = transfer_xor,
-	.init = xor_init
-}; 
-
-#ifdef CONFIG_BLK_DEV_CRYPTOLOOP
 static int cryptoloop_init(struct loop_device *lo,
 		const struct loop_info64 *info)
 {
@@ -235,7 +222,7 @@ static int cryptoloop_init(struct loop_device *lo,
 					  info->lo_encrypt_key_size);
 	if (err != 0)
 		goto out_free_tfm;
-	lo->key_data = tfm;
+	lo->lo_encrypt_tfm = tfm;
 	return 0;
 
  out_free_tfm:
@@ -249,7 +236,7 @@ static int cryptoloop_transfer(struct loop_device *lo, int cmd,
 		struct page *raw_page, unsigned raw_off, struct page *loop_page,
 		unsigned loop_off, int size, sector_t IV)
 {
-	struct crypto_sync_skcipher *tfm = lo->key_data;
+	struct crypto_sync_skcipher *tfm = lo->lo_encrypt_tfm;
 	SYNC_SKCIPHER_REQUEST_ON_STACK(req, tfm);
 	struct scatterlist sg_out;
 	struct scatterlist sg_in;
@@ -300,32 +287,11 @@ static int cryptoloop_transfer(struct loop_device *lo, int cmd,
 	err = 0;
 out:
 	skcipher_request_zero(req);
+	pr_err_ratelimited("loop: Transfer error at byte offset %llu, length %i.\n",
+			IV << 9, size);
 	return err;
 }
 
-static void cryptoloop_release(struct loop_device *lo)
-{
-	crypto_free_sync_skcipher(lo->key_data);
-	lo->key_data = NULL;
-}
-
-static struct loop_func_table cryptoloop_funcs = {
-	.number		= LO_CRYPT_CRYPTOAPI,
-	.init		= cryptoloop_init,
-	.transfer	= cryptoloop_transfer,
-	.release	= cryptoloop_release,
-};
-#endif /* CONFIG_BLK_DEV_CRYPTOLOOP */
-
-/* xfer_funcs[0] is special - its release function is never called */
-static struct loop_func_table *xfer_funcs[MAX_LO_CRYPT] = {
-	[LO_CRYPT_NONE]		= &none_funcs,
-	[LO_CRYPT_XOR]		= &xor_funcs,
-#ifdef CONFIG_BLK_DEV_CRYPTOLOOP
-	[LO_CRYPT_CRYPTOAPI]	= &cryptoloop_funcs,
-#endif
-};
-
 static loff_t get_size(loff_t offset, loff_t sizelimit, struct file *file)
 {
 	loff_t loopsize;
@@ -380,7 +346,7 @@ static void __loop_update_dio(struct loop_device *lo, bool dio)
 		if (queue_logical_block_size(lo->lo_queue) >= sb_bsize &&
 				!(lo->lo_offset & dio_align) &&
 				mapping->a_ops->direct_IO &&
-				!lo->transfer)
+				!lo->lo_encrypt_type)
 			use_dio = true;
 		else
 			use_dio = false;
@@ -446,16 +412,11 @@ lo_do_transfer(struct loop_device *lo, int cmd,
 	       struct page *lpage, unsigned loffs,
 	       int size, sector_t rblock)
 {
-	int ret;
-
-	ret = lo->transfer(lo, cmd, rpage, roffs, lpage, loffs, size, rblock);
-	if (likely(!ret))
-		return 0;
-
-	printk_ratelimited(KERN_ERR
-		"loop: Transfer error at byte offset %llu, length %i.\n",
-		(unsigned long long)rblock << 9, size);
-	return ret;
+	if (is_cryptoloop(lo->lo_encrypt_type))
+		return cryptoloop_transfer(lo, cmd, rpage, roffs, lpage, loffs,
+					   size, rblock);
+	xor_transfer(lo, cmd, rpage, roffs, lpage, loffs, size, rblock);
+	return 0;
 }
 
 static int lo_write_bvec(struct file *file, struct bio_vec *bvec, loff_t *ppos)
@@ -801,14 +762,14 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq)
 	case REQ_OP_DISCARD:
 		return lo_fallocate(lo, rq, pos, FALLOC_FL_PUNCH_HOLE);
 	case REQ_OP_WRITE:
-		if (lo->transfer)
+		if (lo->lo_encrypt_type)
 			return lo_write_transfer(lo, rq, pos);
 		else if (cmd->use_aio)
 			return lo_rw_aio(lo, cmd, pos, WRITE);
 		else
 			return lo_write_simple(lo, rq, pos);
 	case REQ_OP_READ:
-		if (lo->transfer)
+		if (lo->lo_encrypt_type)
 			return lo_read_transfer(lo, rq, pos);
 		else if (cmd->use_aio)
 			return lo_rw_aio(lo, cmd, pos, READ);
@@ -1225,33 +1186,6 @@ static void loop_update_rotational(struct loop_device *lo)
 		blk_queue_flag_clear(QUEUE_FLAG_NONROT, q);
 }
 
-static void
-loop_release_xfer(struct loop_device *lo)
-{
-	struct loop_func_table *xfer = lo->lo_encryption;
-
-	if (xfer) {
-		if (xfer->release)
-			xfer->release(lo);
-		lo->transfer = NULL;
-		lo->lo_encryption = NULL;
-	}
-}
-
-static int
-loop_init_xfer(struct loop_device *lo, struct loop_func_table *xfer,
-	       const struct loop_info64 *i)
-{
-	int err = 0;
-
-	if (xfer && xfer->init) {
-		err = xfer->init(lo, i);
-		if (!err)
-			lo->lo_encryption = xfer;
-	}
-	return err;
-}
-
 /**
  * loop_set_status_from_info - configure device from loop_info
  * @lo: struct loop_device to configure
@@ -1265,29 +1199,28 @@ loop_set_status_from_info(struct loop_device *lo,
 			  const struct loop_info64 *info)
 {
 	int err;
-	struct loop_func_table *xfer;
 	kuid_t uid = current_uid();
 
 	if ((unsigned int) info->lo_encrypt_key_size > LO_KEY_SIZE)
 		return -EINVAL;
 
-	loop_release_xfer(lo);
-
-	if (info->lo_encrypt_type) {
-		unsigned int type = info->lo_encrypt_type;
+	if (is_cryptoloop(lo->lo_encrypt_type))
+		crypto_free_sync_skcipher(lo->lo_encrypt_tfm);
+	lo->lo_encrypt_tfm = NULL;
 
-		if (type >= MAX_LO_CRYPT)
+	if (info->lo_encrypt_type == LO_CRYPT_XOR) {
+		if (info->lo_encrypt_key_size <= 0)
 			return -EINVAL;
-		xfer = xfer_funcs[type];
-		if (xfer == NULL)
+	} else if (is_cryptoloop(info->lo_encrypt_type)) {
+		err = cryptoloop_init(lo, info);
+		if (err)
+			return err;
+	} else {
+		if (info->lo_encrypt_type != LO_CRYPT_NONE)
 			return -EINVAL;
-	} else
-		xfer = NULL;
-
-	err = loop_init_xfer(lo, xfer, info);
-	if (err)
-		return err;
+	}
 
+	lo->lo_encrypt_type = info->lo_encrypt_type;
 	lo->lo_offset = info->lo_offset;
 	lo->lo_sizelimit = info->lo_sizelimit;
 	memcpy(lo->lo_file_name, info->lo_file_name, LO_NAME_SIZE);
@@ -1295,10 +1228,6 @@ loop_set_status_from_info(struct loop_device *lo,
 	lo->lo_file_name[LO_NAME_SIZE-1] = 0;
 	lo->lo_crypt_name[LO_NAME_SIZE-1] = 0;
 
-	if (!xfer)
-		xfer = &none_funcs;
-	lo->transfer = xfer->transfer;
-
 	lo->lo_flags = info->lo_flags;
 
 	lo->lo_encrypt_key_size = info->lo_encrypt_key_size;
@@ -1509,10 +1438,10 @@ static int __loop_clr_fd(struct loop_device *lo, bool release)
 	lo->lo_backing_file = NULL;
 	spin_unlock_irq(&lo->lo_lock);
 
-	loop_release_xfer(lo);
-	lo->transfer = NULL;
+	if (is_cryptoloop(lo->lo_encrypt_type))
+		crypto_free_sync_skcipher(lo->lo_encrypt_tfm);
+	lo->lo_encrypt_tfm = NULL;
 	lo->lo_device = NULL;
-	lo->lo_encryption = NULL;
 	lo->lo_offset = 0;
 	lo->lo_sizelimit = 0;
 	lo->lo_encrypt_key_size = 0;
@@ -1725,8 +1654,7 @@ loop_get_status(struct loop_device *lo, struct loop_info64 *info)
 	info->lo_flags = lo->lo_flags;
 	memcpy(info->lo_file_name, lo->lo_file_name, LO_NAME_SIZE);
 	memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
-	info->lo_encrypt_type =
-		lo->lo_encryption ? lo->lo_encryption->number : 0;
+	info->lo_encrypt_type = lo->lo_encrypt_type;
 	if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
 		info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
 		memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
@@ -1762,7 +1690,7 @@ loop_info64_from_old(const struct loop_info *info, struct loop_info64 *info64)
 	info64->lo_flags = info->lo_flags;
 	info64->lo_init[0] = info->lo_init[0];
 	info64->lo_init[1] = info->lo_init[1];
-	if (info->lo_encrypt_type == LO_CRYPT_CRYPTOAPI)
+	if (is_cryptoloop(info->lo_encrypt_type))
 		memcpy(info64->lo_crypt_name, info->lo_name, LO_NAME_SIZE);
 	else
 		memcpy(info64->lo_file_name, info->lo_name, LO_NAME_SIZE);
@@ -1783,7 +1711,7 @@ loop_info64_to_old(const struct loop_info64 *info64, struct loop_info *info)
 	info->lo_flags = info64->lo_flags;
 	info->lo_init[0] = info64->lo_init[0];
 	info->lo_init[1] = info64->lo_init[1];
-	if (info->lo_encrypt_type == LO_CRYPT_CRYPTOAPI)
+	if (is_cryptoloop(info->lo_encrypt_type))
 		memcpy(info->lo_name, info64->lo_crypt_name, LO_NAME_SIZE);
 	else
 		memcpy(info->lo_name, info64->lo_file_name, LO_NAME_SIZE);
@@ -2046,7 +1974,7 @@ loop_info64_from_compat(const struct compat_loop_info __user *arg,
 	info64->lo_flags = info.lo_flags;
 	info64->lo_init[0] = info.lo_init[0];
 	info64->lo_init[1] = info.lo_init[1];
-	if (info.lo_encrypt_type == LO_CRYPT_CRYPTOAPI)
+	if (is_cryptoloop(info.lo_encrypt_type))
 		memcpy(info64->lo_crypt_name, info.lo_name, LO_NAME_SIZE);
 	else
 		memcpy(info64->lo_file_name, info.lo_name, LO_NAME_SIZE);
@@ -2075,7 +2003,7 @@ loop_info64_to_compat(const struct loop_info64 *info64,
 	info.lo_flags = info64->lo_flags;
 	info.lo_init[0] = info64->lo_init[0];
 	info.lo_init[1] = info64->lo_init[1];
-	if (info.lo_encrypt_type == LO_CRYPT_CRYPTOAPI)
+	if (is_cryptoloop(info.lo_encrypt_type))
 		memcpy(info.lo_name, info64->lo_crypt_name, LO_NAME_SIZE);
 	else
 		memcpy(info.lo_name, info64->lo_file_name, LO_NAME_SIZE);
diff --git a/drivers/block/loop.h b/drivers/block/loop.h
index dd12d7f1ce30..d14ce6bdc014 100644
--- a/drivers/block/loop.h
+++ b/drivers/block/loop.h
@@ -16,6 +16,8 @@
 #include <linux/mutex.h>
 #include <uapi/linux/loop.h>
 
+struct crypto_sync_skcipher;
+
 /* Possible states of device */
 enum {
 	Lo_unbound,
@@ -32,21 +34,17 @@ struct loop_device {
 	loff_t		lo_offset;
 	loff_t		lo_sizelimit;
 	int		lo_flags;
-	int		(*transfer)(struct loop_device *, int cmd,
-				    struct page *raw_page, unsigned raw_off,
-				    struct page *loop_page, unsigned loop_off,
-				    int size, sector_t real_block);
 	char		lo_file_name[LO_NAME_SIZE];
 	char		lo_crypt_name[LO_NAME_SIZE];
 	char		lo_encrypt_key[LO_KEY_SIZE];
 	int		lo_encrypt_key_size;
-	struct loop_func_table *lo_encryption;
+	int		lo_encrypt_type;
+	struct crypto_sync_skcipher *lo_encrypt_tfm; 
 	__u32           lo_init[2];
 	kuid_t		lo_key_owner;	/* Who set the key */
 
 	struct file *	lo_backing_file;
 	struct block_device *lo_device;
-	void		*key_data; 
 
 	gfp_t		old_gfp_mask;
 
@@ -79,15 +77,4 @@ struct loop_cmd {
 	struct cgroup_subsys_state *memcg_css;
 };
 
-/* Support for loadable transfer modules */
-struct loop_func_table {
-	int number;	/* filter type */ 
-	int (*transfer)(struct loop_device *lo, int cmd,
-			struct page *raw_page, unsigned raw_off,
-			struct page *loop_page, unsigned loop_off,
-			int size, sector_t real_block);
-	int (*init)(struct loop_device *, const struct loop_info64 *); 
-	void (*release)(struct loop_device *); 
-}; 
-
 #endif
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 7/8] loop: move loop device deletion out of loop_ctl_mutex
  2021-08-26 13:38 sort out the lock order in the loop driver v2 Christoph Hellwig
                   ` (5 preceding siblings ...)
  2021-08-26 13:38 ` [PATCH 6/8] loop: devirtualize transfer transformations Christoph Hellwig
@ 2021-08-26 13:38 ` Christoph Hellwig
  2021-08-26 13:38 ` [PATCH 8/8] loop: avoid holding loop_ctl_mutex over add_disk Christoph Hellwig
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2021-08-26 13:38 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Hillf Danton, Tetsuo Handa, Pavel Tatashin,
	Reviewed-by : Tyler Hicks, linux-block

To avoid complex lock ordering issues always delete loop devices outside
of loop_ctl_mutex.  In loop_control_remove the Lo_deleting state can
be used to prevent further lookups, and given that module unload is
synchronized vs new opens of the control device and thus ioctls there
is no need for locks there at all.

Based on patches from Hillf Danton <hdanton@sina.com> and
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>.

Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/loop.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 6ee4b046bdcc..cb857d5e8313 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -2478,7 +2478,11 @@ static int loop_control_remove(int idx)
 	mutex_unlock(&lo->lo_mutex);
 
 	idr_remove(&loop_index_idr, lo->lo_number);
+	mutex_unlock(&loop_ctl_mutex);
+
 	loop_remove(lo);
+	return 0;
+
 out_unlock_ctrl:
 	mutex_unlock(&loop_ctl_mutex);
 	return ret;
@@ -2609,11 +2613,12 @@ static void __exit loop_exit(void)
 	unregister_blkdev(LOOP_MAJOR, "loop");
 	misc_deregister(&loop_misc);
 
-	mutex_lock(&loop_ctl_mutex);
+	/*
+	 * No need for loop_ctl_mutex given that no new ioctls and thus
+	 * additions and removals can happen in parallel to module unloading.
+	 */
 	idr_for_each_entry(&loop_index_idr, lo, id)
 		loop_remove(lo);
-	mutex_unlock(&loop_ctl_mutex);
-
 	idr_destroy(&loop_index_idr);
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 8/8] loop: avoid holding loop_ctl_mutex over add_disk
  2021-08-26 13:38 sort out the lock order in the loop driver v2 Christoph Hellwig
                   ` (6 preceding siblings ...)
  2021-08-26 13:38 ` [PATCH 7/8] loop: move loop device deletion out of loop_ctl_mutex Christoph Hellwig
@ 2021-08-26 13:38 ` Christoph Hellwig
  2021-08-27  0:30 ` sort out the lock order in the loop driver v2 Tetsuo Handa
       [not found] ` <20210827130259.2622-1-hdanton@sina.com>
  9 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2021-08-26 13:38 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Hillf Danton, Tetsuo Handa, Pavel Tatashin,
	Reviewed-by : Tyler Hicks, linux-block

To avoid complex lock ordering issues loop_ctl_mutex should not
be held over add_disk.  Add a new Lo_new state for a loop device
that has just been created but which is not live yet.

Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/block/loop.c | 25 +++++++++++++++----------
 drivers/block/loop.h |  1 +
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index cb857d5e8313..c8a24e06c259 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -2327,7 +2327,11 @@ static int loop_add(int i)
 	lo = kzalloc(sizeof(*lo), GFP_KERNEL);
 	if (!lo)
 		goto out;
-	lo->lo_state = Lo_unbound;
+	lo->lo_state = Lo_new;
+	atomic_set(&lo->lo_refcnt, 0);
+	mutex_init(&lo->lo_mutex);
+	spin_lock_init(&lo->lo_lock);
+	spin_lock_init(&lo->lo_work_lock);
 
 	err = mutex_lock_killable(&loop_ctl_mutex);
 	if (err)
@@ -2341,9 +2345,11 @@ static int loop_add(int i)
 	} else {
 		err = idr_alloc(&loop_index_idr, lo, 0, 0, GFP_KERNEL);
 	}
-	if (err < 0)
-		goto out_unlock;
 	i = err;
+	lo->lo_number = i;
+	mutex_unlock(&loop_ctl_mutex);
+	if (err < 0)
+		goto out_free_dev;
 
 	err = -ENOMEM;
 	lo->tag_set.ops = &loop_mq_ops;
@@ -2397,11 +2403,6 @@ static int loop_add(int i)
 	if (!part_shift)
 		disk->flags |= GENHD_FL_NO_PART_SCAN;
 	disk->flags |= GENHD_FL_EXT_DEVT;
-	atomic_set(&lo->lo_refcnt, 0);
-	mutex_init(&lo->lo_mutex);
-	lo->lo_number		= i;
-	spin_lock_init(&lo->lo_lock);
-	spin_lock_init(&lo->lo_work_lock);
 	disk->major		= LOOP_MAJOR;
 	disk->first_minor	= i << part_shift;
 	disk->minors		= 1 << part_shift;
@@ -2412,14 +2413,18 @@ static int loop_add(int i)
 	disk->event_flags	= DISK_EVENT_FLAG_UEVENT;
 	sprintf(disk->disk_name, "loop%d", i);
 	add_disk(disk);
-	mutex_unlock(&loop_ctl_mutex);
+
+	mutex_lock(&lo->lo_mutex);
+	lo->lo_state = Lo_unbound;
+	mutex_unlock(&lo->lo_mutex);
+
 	return i;
 
 out_cleanup_tags:
 	blk_mq_free_tag_set(&lo->tag_set);
 out_free_idr:
+	mutex_lock(&loop_ctl_mutex);
 	idr_remove(&loop_index_idr, i);
-out_unlock:
 	mutex_unlock(&loop_ctl_mutex);
 out_free_dev:
 	kfree(lo);
diff --git a/drivers/block/loop.h b/drivers/block/loop.h
index d14ce6bdc014..608a20c23c64 100644
--- a/drivers/block/loop.h
+++ b/drivers/block/loop.h
@@ -24,6 +24,7 @@ enum {
 	Lo_bound,
 	Lo_rundown,
 	Lo_deleting,
+	Lo_new,
 };
 
 struct loop_func_table;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 5/8] loop: merge the cryptoloop module into the main loop module
  2021-08-26 13:38 ` [PATCH 5/8] loop: merge the cryptoloop module into the main loop module Christoph Hellwig
@ 2021-08-26 16:31   ` Milan Broz
  2021-08-26 16:34     ` Christoph Hellwig
  0 siblings, 1 reply; 21+ messages in thread
From: Milan Broz @ 2021-08-26 16:31 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Hillf Danton, Tetsuo Handa, Pavel Tatashin,
	Reviewed-by : Tyler Hicks, linux-block

On 26/08/2021 15:38, Christoph Hellwig wrote:
> No need to keep a separate loadable module infrastructure for a tiny
> amount of cryptoapi glue, especially as unloading of the cryptoloop
> module leads to nasty interactions with the loop device state machine
> through loop_unregister_transfer.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Hi Christoph,

the cryptoloop is insecure, most of the encryption modes are deprecated
(and known to be problematic); util-linux no longer support cryptoloop
options in losetup.

Isn't the better way to go just to remove cryptoloop completely?

(I tried this years ago, because dm-crypt can actually implement all,
even insecure, options, see https://lkml.org/lkml/2012/11/2/162 )

I know that loopAES still use this interface, but it implements
own modes anyway, replacing kernel code.

I really think that the best option here is just to kill this mess :-)
(Or implement sector-level crypto properly in loop.)

Just my 2 eorocents... :)

Milan

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 5/8] loop: merge the cryptoloop module into the main loop module
  2021-08-26 16:31   ` Milan Broz
@ 2021-08-26 16:34     ` Christoph Hellwig
  2021-08-26 16:44       ` Milan Broz
  0 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2021-08-26 16:34 UTC (permalink / raw)
  To: Milan Broz
  Cc: Christoph Hellwig, Jens Axboe, Hillf Danton, Tetsuo Handa,
	Pavel Tatashin, Reviewed-by : Tyler Hicks, linux-block

On Thu, Aug 26, 2021 at 06:31:50PM +0200, Milan Broz wrote:
> the cryptoloop is insecure, most of the encryption modes are deprecated
> (and known to be problematic); util-linux no longer support cryptoloop
> options in losetup.
> 
> Isn't the better way to go just to remove cryptoloop completely?

I'm not sure if we're going to break existing users.  So maybe for now
get rid of the horrible registration interface, an add a patch to
deprecate it with a warning when people actually use it, and then
eventually remove it. 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 5/8] loop: merge the cryptoloop module into the main loop module
  2021-08-26 16:34     ` Christoph Hellwig
@ 2021-08-26 16:44       ` Milan Broz
  2021-08-27  6:45         ` Christoph Hellwig
  0 siblings, 1 reply; 21+ messages in thread
From: Milan Broz @ 2021-08-26 16:44 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, Hillf Danton, Tetsuo Handa, Pavel Tatashin,
	Reviewed-by : Tyler Hicks, linux-block

On 26/08/2021 18:34, Christoph Hellwig wrote:
> On Thu, Aug 26, 2021 at 06:31:50PM +0200, Milan Broz wrote:
>> the cryptoloop is insecure, most of the encryption modes are deprecated
>> (and known to be problematic); util-linux no longer support cryptoloop
>> options in losetup.
>>
>> Isn't the better way to go just to remove cryptoloop completely?
> 
> I'm not sure if we're going to break existing users.  So maybe for now
> get rid of the horrible registration interface, an add a patch to
> deprecate it with a warning when people actually use it, and then
> eventually remove it. 

Yes, I know that removal is far disturbing thing here, if it
can be planned for removal later, I think it is the best thing to do...

And I would like to know actually if there are existing users
(and how and why they are using this interface - it cannot be configured
through losetup for years IIRC).

Thanks,
Milan

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: sort out the lock order in the loop driver v2
  2021-08-26 13:38 sort out the lock order in the loop driver v2 Christoph Hellwig
                   ` (7 preceding siblings ...)
  2021-08-26 13:38 ` [PATCH 8/8] loop: avoid holding loop_ctl_mutex over add_disk Christoph Hellwig
@ 2021-08-27  0:30 ` Tetsuo Handa
  2021-08-27  6:40   ` Christoph Hellwig
       [not found] ` <20210827130259.2622-1-hdanton@sina.com>
  9 siblings, 1 reply; 21+ messages in thread
From: Tetsuo Handa @ 2021-08-27  0:30 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe
  Cc: Hillf Danton, Pavel Tatashin, Tyler Hicks, linux-block,
	Milan Broz, Greg Kroah-Hartman

On 2021/08/26 22:38, Christoph Hellwig wrote:
> Hi Jens,
> 
> this series sorts out lock order reversals involving the block layer
> open_mutex by drastically reducing the scope of loop_ctl_mutex.  To do
> so it first merges the cryptoloop module into the main loop driver
> as the unregistrtion of transfers on live loop devices was causing
> some nasty locking interactions.
> 
> Changes since v1:
>  - add a new patch to fix a pre-existing spare warning in the crypto code
>  - initialize various struct loop_dev fields earlier
>  - hold lo_mutex over lo_state updates
>  - take loop_ctl_mutex to delete from the idr in the loop_add failure
>    path
> 
> Diffstat:
>  b/drivers/block/Kconfig    |    6 
>  b/drivers/block/Makefile   |    1 
>  b/drivers/block/loop.c     |  334 ++++++++++++++++++++++++---------------------
>  b/drivers/block/loop.h     |   30 ----
>  drivers/block/cryptoloop.c |  204 ---------------------------
>  5 files changed, 189 insertions(+), 386 deletions(-)
> 

Again crashed in 3 seconds. We can't accept this series.

Jens, can we please apply "[PATCH v5] block: genhd: don't call probe function with major_names_lock held"
( https://lkml.kernel.org/r/b2af8a5b-3c1b-204e-7f56-bea0b15848d6@i-love.sakura.ne.jp ) for v5.14 (and also stable),
followed by "[PATCH] loop: replace loop_ctl_mutex with loop_idr_spinlock"
( https://lkml.kernel.org/r/2642808b-a7d0-28ff-f288-0f4eabc562f7@i-love.sakura.ne.jp ) for v5.15 (but not stable) ?

----------------------------------------
[   56.110978][ T6637] loop0: detected capacity change from 0 to 4096
[   56.116717][ T6637] EXT4-fs error (device loop0): ext4_fill_super:4956: inode #2: comm a.out: iget: root inode unallocated
[   56.125718][ T6637] EXT4-fs (loop0): get root inode failed
[   56.129558][ T6637] EXT4-fs (loop0): mount failed
[   56.252153][ T6642] loop0: detected capacity change from 0 to 4096
[   56.258165][ T6642] EXT4-fs error (device loop0): ext4_fill_super:4956: inode #2: comm a.out: iget: root inode unallocated
[   56.265403][ T6642] EXT4-fs (loop0): get root inode failed
[   56.268371][ T6642] EXT4-fs (loop0): mount failed
[   56.335800][ T6654] loop0: detected capacity change from 0 to 4096
[   56.340883][ T6654] EXT4-fs error (device loop0): ext4_fill_super:4956: inode #2: comm a.out: iget: root inode unallocated
[   56.345046][ T6654] EXT4-fs (loop0): get root inode failed
[   56.347450][ T6654] EXT4-fs (loop0): mount failed
[   56.412014][ T6659] loop0: detected capacity change from 0 to 4096
[   56.417593][ T6659] EXT4-fs error (device loop0): ext4_fill_super:4956: inode #2: comm a.out: iget: root inode unallocated
[   56.422250][ T6659] EXT4-fs (loop0): get root inode failed
[   56.425625][ T6659] EXT4-fs (loop0): mount failed
[   56.543382][ T6664] loop0: detected capacity change from 0 to 4096
[   56.548172][ T6664] EXT4-fs error (device loop0): ext4_fill_super:4956: inode #2: comm a.out: iget: root inode unallocated
[   56.552613][ T6664] EXT4-fs (loop0): get root inode failed
[   56.554906][ T6664] EXT4-fs (loop0): mount failed
[   56.633168][ T6671] loop0: detected capacity change from 0 to 4096
[   56.635267][ T4347] blk_update_request: I/O error, dev loop0, sector 0 op 0x1:(WRITE) flags 0x800 phys_seg 0 prio class 0
[   56.644605][ T6671] EXT4-fs error (device loop0): ext4_fill_super:4956: inode #2: comm a.out: iget: root inode unallocated
[   56.649600][ T6671] EXT4-fs (loop0): get root inode failed
[   56.652696][ T6671] EXT4-fs (loop0): mount failed
[   56.705027][ T6681] loop0: detected capacity change from 0 to 4096
[   56.711505][ T6681] EXT4-fs error (device loop0): ext4_fill_super:4956: inode #2: comm a.out: iget: root inode unallocated
[   56.716055][ T6681] EXT4-fs (loop0): get root inode failed
[   56.718494][ T6681] EXT4-fs (loop0): mount failed
[   56.812013][ T6686] loop0: detected capacity change from 0 to 4096
[   56.817925][ T6686] EXT4-fs error (device loop0): ext4_fill_super:4956: inode #2: comm a.out: iget: root inode unallocated
[   56.823146][ T6686] EXT4-fs (loop0): get root inode failed
[   56.826182][ T6686] EXT4-fs (loop0): mount failed
[   57.338534][ T6733] loop0: detected capacity change from 0 to 4096
[   57.344623][ T6733] EXT4-fs error (device loop0): ext4_fill_super:4956: inode #2: comm a.out: iget: root inode unallocated
[   57.352245][ T6733] EXT4-fs (loop0): get root inode failed
[   57.355118][ T6733] EXT4-fs (loop0): mount failed
[   57.369888][ T6617] sysfs: cannot create duplicate filename '/devices/virtual/block/loop1'
[   57.372738][ T6617] CPU: 2 PID: 6617 Comm: systemd-udevd Tainted: G            E     5.14.0-rc7+ #749
[   57.378013][ T6617] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 02/27/2020
[   57.382006][ T6617] Call Trace:
[   57.383106][ T6617]  dump_stack_lvl+0x57/0x7d
[   57.384722][ T6617]  sysfs_warn_dup.cold+0x17/0x24
[   57.386551][ T6617]  sysfs_create_dir_ns+0xb7/0xd0
[   57.388225][ T6617]  kobject_add_internal+0xa8/0x290
[   57.389915][ T6617]  kobject_add+0x7e/0xb0
[   57.391328][ T6617]  device_add+0x11d/0x910
[   57.392762][ T6617]  ? dev_set_name+0x4e/0x70
[   57.394396][ T6617]  __device_add_disk+0xbf/0x300
[   57.396091][ T6617]  loop_add+0x29b/0x310 [loop]
[   57.398432][ T6617]  ? blkdev_get_by_dev+0x330/0x330
[   57.400704][ T6617]  blk_request_module+0x63/0xc0
[   57.402374][ T6617]  blkdev_get_no_open+0x98/0xc0
[   57.404042][ T6617]  blkdev_get_by_dev+0x54/0x330
[   57.405717][ T6617]  ? blkdev_get_by_dev+0x330/0x330
[   57.407421][ T6617]  blkdev_open+0x59/0xa0
[   57.408834][ T6617]  do_dentry_open+0x14c/0x3a0
[   57.410547][ T6617]  path_openat+0x78e/0xa50
[   57.412073][ T6617]  do_filp_open+0xad/0x120
[   57.413534][ T6617]  ? alloc_fd+0x14c/0x1f0
[   57.415242][ T6617]  do_sys_openat2+0x241/0x310
[   57.416971][ T6617]  do_sys_open+0x3f/0x80
[   57.418455][ T6617]  do_syscall_64+0x35/0xb0
[   57.419955][ T6617]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[   57.421973][ T6617] RIP: 0033:0x7f6846523eab
[   57.423471][ T6617] Code: 25 00 00 41 00 3d 00 00 41 00 74 4b 64 8b 04 25 18 00 00 00 85 c0 75 67 44 89 e2 48 89 ee bf 9c ff ff ff b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff ff 0f 87 91 00 00 00 48 8b 4c 24 28 64 48 33 0c 25
[   57.430931][ T6617] RSP: 002b:00007fff3d4dfb70 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
[   57.434173][ T6617] RAX: ffffffffffffffda RBX: 000055c2c4b8ed20 RCX: 00007f6846523eab
[   57.436897][ T6617] RDX: 00000000000a0800 RSI: 000055c2c4b92460 RDI: 00000000ffffff9c
[   57.439749][ T6617] RBP: 000055c2c4b92460 R08: 000055c2c330b270 R09: 00007fff3d5de090
[   57.442470][ T6617] R10: 0000000000000000 R11: 0000000000000246 R12: 00000000000a0800
[   57.445475][ T6617] R13: 0000000000000000 R14: 0000000000000001 R15: 0000000000000000
[   57.449450][ T6617] kobject_add_internal failed for loop1 with -EEXIST, don't try to register things with the same name in the same directory.
[   57.453822][ T6617] kobject_add_internal failed for queue (error: -2 parent: loop1)
[   57.456684][ T6617] kobject_add_internal failed for integrity (error: -2 parent: loop1)
[   57.489728][ T6618] 
[   57.490564][ T6618] ======================================================
[   57.492856][ T6618] WARNING: possible circular locking dependency detected
[   57.495348][ T6618] 5.14.0-rc7+ #749 Tainted: G            E    
[   57.499728][ T6618] ------------------------------------------------------
[   57.502053][ T6618] systemd-udevd/6618 is trying to acquire lock:
[   57.503968][ T6618] ffff88800e512948 ((wq_completion)loop0){+.+.}-{0:0}, at: flush_workqueue+0x85/0x560
[   57.507193][ T6618] 
[   57.507193][ T6618] but task is already holding lock:
[   57.509716][ T6618] ffff88800eee0c88 (&lo->lo_mutex){+.+.}-{3:3}, at: __loop_clr_fd+0x5b/0x610 [loop]
[   57.512777][ T6618] 
[   57.512777][ T6618] which lock already depends on the new lock.
[   57.512777][ T6618] 
[   57.516841][ T6618] 
[   57.516841][ T6618] the existing dependency chain (in reverse order) is:
[   57.519840][ T6618] 
[   57.519840][ T6618] -> #5 (&lo->lo_mutex){+.+.}-{3:3}:
[   57.522270][ T6618]        lock_acquire+0xd0/0x300
[   57.523797][ T6618]        __mutex_lock+0x97/0x950
[   57.525547][ T6618]        loop_add+0x2a5/0x310 [loop]
[   57.527298][ T6618]        blk_request_module+0x63/0xc0
[   57.529327][ T6618]        blkdev_get_no_open+0x98/0xc0
[   57.532256][ T6618]        blkdev_get_by_dev+0x54/0x330
[   57.534815][ T6618]        blkdev_open+0x59/0xa0
[   57.536509][ T6618]        do_dentry_open+0x14c/0x3a0
[   57.538250][ T6618]        path_openat+0x78e/0xa50
[   57.539826][ T6618]        do_filp_open+0xad/0x120
[   57.541646][ T6618]        do_sys_openat2+0x241/0x310
[   57.543417][ T6618]        do_sys_open+0x3f/0x80
[   57.545108][ T6618]        do_syscall_64+0x35/0xb0
[   57.546641][ T6618]        entry_SYSCALL_64_after_hwframe+0x44/0xae
[   57.549221][ T6618] 
[   57.549221][ T6618] -> #4 (major_names_lock){+.+.}-{3:3}:
[   57.551694][ T6618]        lock_acquire+0xd0/0x300
[   57.553291][ T6618]        __mutex_lock+0x97/0x950
[   57.555318][ T6618]        blkdev_show+0x18/0x90
[   57.557018][ T6618]        devinfo_show+0x58/0x70
[   57.558678][ T6618]        seq_read_iter+0x27b/0x3f0
[   57.560474][ T6618]        proc_reg_read_iter+0x3c/0x60
[   57.562250][ T6618]        new_sync_read+0x110/0x190
[   57.566270][ T6618]        vfs_read+0x11d/0x1b0
[   57.567857][ T6618]        ksys_read+0x63/0xe0
[   57.569405][ T6618]        do_syscall_64+0x35/0xb0
[   57.570974][ T6618]        entry_SYSCALL_64_after_hwframe+0x44/0xae
[   57.573177][ T6618] 
[   57.573177][ T6618] -> #3 (&p->lock){+.+.}-{3:3}:
[   57.575889][ T6618]        lock_acquire+0xd0/0x300
[   57.577762][ T6618]        __mutex_lock+0x97/0x950
[   57.579591][ T6618]        seq_read_iter+0x4c/0x3f0
[   57.581586][ T6618]        generic_file_splice_read+0xf7/0x1a0
[   57.583581][ T6618]        splice_direct_to_actor+0xc0/0x230
[   57.585619][ T6618]        do_splice_direct+0x8c/0xd0
[   57.587384][ T6618]        do_sendfile+0x319/0x5a0
[   57.589057][ T6618]        __x64_sys_sendfile64+0xad/0xc0
[   57.590983][ T6618]        do_syscall_64+0x35/0xb0
[   57.592599][ T6618]        entry_SYSCALL_64_after_hwframe+0x44/0xae
[   57.595116][ T6618] 
[   57.595116][ T6618] -> #2 (sb_writers#3){.+.+}-{0:0}:
[   57.598425][ T6618]        lock_acquire+0xd0/0x300
[   57.600526][ T6618]        lo_write_bvec+0xe1/0x260 [loop]
[   57.602563][ T6618]        loop_process_work+0x3fa/0xcf0 [loop]
[   57.604709][ T6618]        process_one_work+0x2aa/0x600
[   57.606488][ T6618]        worker_thread+0x48/0x3d0
[   57.608138][ T6618]        kthread+0x13e/0x170
[   57.609676][ T6618]        ret_from_fork+0x1f/0x30
[   57.611471][ T6618] 
[   57.611471][ T6618] -> #1 ((work_completion)(&lo->rootcg_work)){+.+.}-{0:0}:
[   57.615294][ T6618]        lock_acquire+0xd0/0x300
[   57.617627][ T6618]        process_one_work+0x27e/0x600
[   57.619537][ T6618]        worker_thread+0x48/0x3d0
[   57.621259][ T6618]        kthread+0x13e/0x170
[   57.622729][ T6618]        ret_from_fork+0x1f/0x30
[   57.624460][ T6618] 
[   57.624460][ T6618] -> #0 ((wq_completion)loop0){+.+.}-{0:0}:
[   57.627186][ T6618]        check_prev_add+0x91/0xc00
[   57.629378][ T6618]        __lock_acquire+0x14a8/0x1f40
[   57.632976][ T6618]        lock_acquire+0xd0/0x300
[   57.636343][ T6618]        flush_workqueue+0xa9/0x560
[   57.638067][ T6618]        drain_workqueue+0x9b/0x100
[   57.639873][ T6618]        destroy_workqueue+0x2f/0x210
[   57.641652][ T6618]        __loop_clr_fd+0xbf/0x610 [loop]
[   57.643588][ T6618]        blkdev_put+0xaf/0x180
[   57.645246][ T6618]        blkdev_close+0x20/0x30
[   57.646831][ T6618]        __fput+0xa0/0x240
[   57.648532][ T6618]        task_work_run+0x57/0xa0
[   57.650291][ T6618]        exit_to_user_mode_prepare+0x252/0x260
[   57.652219][ T6618]        syscall_exit_to_user_mode+0x19/0x60
[   57.654332][ T6618]        do_syscall_64+0x42/0xb0
[   57.655837][ T6618]        entry_SYSCALL_64_after_hwframe+0x44/0xae
[   57.658076][ T6618] 
[   57.658076][ T6618] other info that might help us debug this:
[   57.658076][ T6618] 
[   57.661564][ T6618] Chain exists of:
[   57.661564][ T6618]   (wq_completion)loop0 --> major_names_lock --> &lo->lo_mutex
[   57.661564][ T6618] 
[   57.668254][ T6618]  Possible unsafe locking scenario:
[   57.668254][ T6618] 
[   57.670679][ T6618]        CPU0                    CPU1
[   57.672409][ T6618]        ----                    ----
[   57.674184][ T6618]   lock(&lo->lo_mutex);
[   57.675666][ T6618]                                lock(major_names_lock);
[   57.677988][ T6618]                                lock(&lo->lo_mutex);
[   57.680277][ T6618]   lock((wq_completion)loop0);
[   57.682111][ T6618] 
[   57.682111][ T6618]  *** DEADLOCK ***
[   57.682111][ T6618] 
[   57.685254][ T6618] 2 locks held by systemd-udevd/6618:
[   57.687251][ T6618]  #0: ffff8880121c3528 (&disk->open_mutex){+.+.}-{3:3}, at: blkdev_put+0x30/0x180
[   57.690362][ T6618]  #1: ffff88800eee0c88 (&lo->lo_mutex){+.+.}-{3:3}, at: __loop_clr_fd+0x5b/0x610 [loop]
[   57.693750][ T6618] 
[   57.693750][ T6618] stack backtrace:
[   57.695809][ T6618] CPU: 0 PID: 6618 Comm: systemd-udevd Tainted: G            E     5.14.0-rc7+ #749
[   57.702462][ T6618] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 02/27/2020
[   57.706363][ T6618] Call Trace:
[   57.707412][ T6618]  dump_stack_lvl+0x57/0x7d
[   57.708790][ T6618]  check_noncircular+0x114/0x130
[   57.710580][ T6618]  check_prev_add+0x91/0xc00
[   57.712288][ T6618]  ? __lock_acquire+0x5c1/0x1f40
[   57.713803][ T6618]  __lock_acquire+0x14a8/0x1f40
[   57.715952][ T6618]  lock_acquire+0xd0/0x300
[   57.717529][ T6618]  ? flush_workqueue+0x85/0x560
[   57.719026][ T6618]  ? lockdep_init_map_type+0x51/0x220
[   57.720867][ T6618]  ? lockdep_init_map_type+0x51/0x220
[   57.722546][ T6618]  flush_workqueue+0xa9/0x560
[   57.724017][ T6618]  ? flush_workqueue+0x85/0x560
[   57.726079][ T6618]  ? drain_workqueue+0x9b/0x100
[   57.727810][ T6618]  drain_workqueue+0x9b/0x100
[   57.729645][ T6618]  destroy_workqueue+0x2f/0x210
[   57.731814][ T6618]  __loop_clr_fd+0xbf/0x610 [loop]
[   57.733713][ T6618]  ? __mutex_unlock_slowpath+0x40/0x2a0
[   57.735677][ T6618]  blkdev_put+0xaf/0x180
[   57.737056][ T6618]  blkdev_close+0x20/0x30
[   57.738540][ T6618]  __fput+0xa0/0x240
[   57.739845][ T6618]  task_work_run+0x57/0xa0
[   57.741366][ T6618]  exit_to_user_mode_prepare+0x252/0x260
[   57.743238][ T6618]  syscall_exit_to_user_mode+0x19/0x60
[   57.745468][ T6618]  do_syscall_64+0x42/0xb0
[   57.747135][ T6618]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[   57.749417][ T6618] RIP: 0033:0x7f6846524987
[   57.750981][ T6618] Code: ff ff e8 9c 11 02 00 66 2e 0f 1f 84 00 00 00 00 00 66 90 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 41 c3 48 83 ec 18 89 7c 24 0c e8 c3 5d f8 ff
[   57.757556][ T6618] RSP: 002b:00007fff3d4dfbb8 EFLAGS: 00000246 ORIG_RAX: 0000000000000003
[   57.760477][ T6618] RAX: 0000000000000000 RBX: 00007f6845fac788 RCX: 00007f6846524987
[   57.763567][ T6618] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000006
[   57.767982][ T6618] RBP: 0000000000000006 R08: 000055c2c3318af0 R09: 0000000000000000
[   57.770460][ T6618] R10: 00007f6845fac788 R11: 0000000000000246 R12: 0000000000000000
[   57.773068][ T6618] R13: 0000000000000000 R14: 0000000000000000 R15: 000055c2c3300635
[   57.777617][ T6737] loop0: detected capacity change from 0 to 4096
[   57.782129][ T6737] EXT4-fs error (device loop0): ext4_fill_super:4956: inode #2: comm a.out: iget: root inode unallocated
[   57.788081][ T6737] EXT4-fs (loop0): get root inode failed
[   57.792922][ T6737] EXT4-fs (loop0): mount failed
[   57.801371][ T6743] ------------[ cut here ]------------
[   57.803882][ T6743] kernfs: can not remove 'format', no directory
[   57.807757][ T6743] WARNING: CPU: 1 PID: 6743 at fs/kernfs/dir.c:1508 kernfs_remove_by_name_ns+0x6f/0x80
[   57.811285][ T6743] Modules linked in: loop(E)
[   57.812856][ T6743] CPU: 1 PID: 6743 Comm: a.out Tainted: G            E     5.14.0-rc7+ #749
[   57.816084][ T6743] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 02/27/2020
[   57.820253][ T6743] RIP: 0010:kernfs_remove_by_name_ns+0x6f/0x80
[   57.822289][ T6743] Code: bb 38 01 31 c0 5d 41 5c 41 5d c3 48 c7 c7 e0 81 7d 83 e8 54 bb 38 01 b8 fe ff ff ff eb e7 48 c7 c7 50 3c 2a 83 e8 d1 99 29 01 <0f> 0b b8 fe ff ff ff eb d2 0f 1f 84 00 00 00 00 00 41 57 41 56 41
[   57.828947][ T6743] RSP: 0018:ffffc90001633df0 EFLAGS: 00010286
[   57.834146][ T6743] RAX: 0000000000000000 RBX: ffffffff83805028 RCX: 0000000000000027
[   57.836807][ T6743] RDX: 0000000000000027 RSI: 00000000ffffdfff RDI: ffff88807cbe78b8
[   57.839616][ T6743] RBP: 0000000000000000 R08: ffff88807cbe78b0 R09: 0000000000000000
[   57.842806][ T6743] R10: 0000000000000001 R11: 0000000000000001 R12: ffffffff833d7d30
[   57.849347][ T6743] R13: 0000000000000001 R14: ffff88801208dfc0 R15: 0000000000000000
[   57.852955][ T6743] FS:  00007f1199de5580(0000) GS:ffff88807ca00000(0000) knlGS:0000000000000000
[   57.857149][ T6743] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   57.859391][ T6743] CR2: 00007f4a41af3048 CR3: 000000001d68d000 CR4: 00000000001506e0
[   57.862417][ T6743] Call Trace:
[   57.863546][ T6743]  remove_files.isra.0+0x2b/0x60
[   57.866726][ T6743]  sysfs_remove_group+0x38/0x80
[   57.869074][ T6743]  sysfs_remove_groups+0x24/0x40
[   57.870872][ T6743]  __kobject_del+0x1b/0x80
[   57.872336][ T6743]  kobject_del+0xf/0x20
[   57.873754][ T6743]  blk_integrity_del+0x1d/0x30
[   57.875388][ T6743]  del_gendisk+0x3c/0x1d0
[   57.876993][ T6743]  loop_remove+0x10/0x40 [loop]
[   57.878733][ T6743]  loop_control_ioctl+0x1a1/0x1b0 [loop]
[   57.880711][ T6743]  __x64_sys_ioctl+0x6a/0xa0
[   57.882980][ T6743]  do_syscall_64+0x35/0xb0
[   57.885024][ T6743]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[   57.887120][ T6743] RIP: 0033:0x7f1199d0d89d
[   57.888565][ T6743] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d c3 f5 0c 00 f7 d8 64 89 01 48
[   57.895764][ T6743] RSP: 002b:00007ffd3c6a4b68 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[   57.901666][ T6743] RAX: ffffffffffffffda RBX: 431bde82d7b634db RCX: 00007f1199d0d89d
[   57.904538][ T6743] RDX: 0000000000000001 RSI: 0000000000004c81 RDI: 0000000000000005
[   57.907183][ T6743] RBP: 00007ffd3c6a4ba0 R08: 0000000000000000 R09: 0000000000000000
[   57.909933][ T6743] R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffd3c6a4ba0
[   57.912723][ T6743] R13: 000000000000dc57 R14: 00007ffd3c6a4b7c R15: 0000000000000000
[   57.916447][ T6743] irq event stamp: 0
[   57.917748][ T6743] hardirqs last  enabled at (0): [<0000000000000000>] 0x0
[   57.920198][ T6743] hardirqs last disabled at (0): [<ffffffff811262d4>] copy_process+0x984/0x2010
[   57.923208][ T6743] softirqs last  enabled at (0): [<ffffffff811262d4>] copy_process+0x984/0x2010
[   57.926387][ T6743] softirqs last disabled at (0): [<0000000000000000>] 0x0
[   57.928738][ T6743] ---[ end trace b154f08dae0bfe9a ]---
[   57.931937][ T6743] ------------[ cut here ]------------
[   57.935504][ T6743] kernfs: can not remove 'tag_size', no directory
[   57.937628][ T6743] WARNING: CPU: 1 PID: 6743 at fs/kernfs/dir.c:1508 kernfs_remove_by_name_ns+0x6f/0x80
[   57.940909][ T6743] Modules linked in: loop(E)
[   57.942448][ T6743] CPU: 1 PID: 6743 Comm: a.out Tainted: G        W   E     5.14.0-rc7+ #749
[   57.945453][ T6743] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 02/27/2020
[   57.949611][ T6743] RIP: 0010:kernfs_remove_by_name_ns+0x6f/0x80
[   57.951657][ T6743] Code: bb 38 01 31 c0 5d 41 5c 41 5d c3 48 c7 c7 e0 81 7d 83 e8 54 bb 38 01 b8 fe ff ff ff eb e7 48 c7 c7 50 3c 2a 83 e8 d1 99 29 01 <0f> 0b b8 fe ff ff ff eb d2 0f 1f 84 00 00 00 00 00 41 57 41 56 41
[   57.958697][ T6743] RSP: 0018:ffffc90001633df0 EFLAGS: 00010286
[   57.960735][ T6743] RAX: 0000000000000000 RBX: ffffffff83805030 RCX: 0000000000000027
[   57.963418][ T6743] RDX: 0000000000000027 RSI: 00000000ffffdfff RDI: ffff88807cbe78b8
[   57.967478][ T6743] RBP: 0000000000000000 R08: ffff88807cbe78b0 R09: 0000000000000000
[   57.970021][ T6743] R10: 0000000000000001 R11: 0000000000000001 R12: ffffffff832b6cfd
[   57.972597][ T6743] R13: 0000000000000001 R14: ffff88801208dfc0 R15: 0000000000000000
[   57.975229][ T6743] FS:  00007f1199de5580(0000) GS:ffff88807ca00000(0000) knlGS:0000000000000000
[   57.978516][ T6743] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   57.980798][ T6743] CR2: 00007f4a41af3048 CR3: 000000001d68d000 CR4: 00000000001506e0
[   57.983896][ T6743] Call Trace:
[   57.985248][ T6743]  remove_files.isra.0+0x2b/0x60
[   57.986968][ T6743]  sysfs_remove_group+0x38/0x80
[   57.988478][ T6743]  sysfs_remove_groups+0x24/0x40
[   57.990127][ T6743]  __kobject_del+0x1b/0x80
[   57.991609][ T6743]  kobject_del+0xf/0x20
[   57.993005][ T6743]  blk_integrity_del+0x1d/0x30
[   57.994744][ T6743]  del_gendisk+0x3c/0x1d0
[   57.996167][ T6743]  loop_remove+0x10/0x40 [loop]
[   57.999275][ T6743]  loop_control_ioctl+0x1a1/0x1b0 [loop]
[   58.001800][ T6743]  __x64_sys_ioctl+0x6a/0xa0
[   58.003278][ T6743]  do_syscall_64+0x35/0xb0
[   58.004890][ T6743]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[   58.006874][ T6743] RIP: 0033:0x7f1199d0d89d
[   58.008365][ T6743] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d c3 f5 0c 00 f7 d8 64 89 01 48
[   58.015780][ T6743] RSP: 002b:00007ffd3c6a4b68 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[   58.018692][ T6743] RAX: ffffffffffffffda RBX: 431bde82d7b634db RCX: 00007f1199d0d89d
[   58.021324][ T6743] RDX: 0000000000000001 RSI: 0000000000004c81 RDI: 0000000000000005
[   58.024202][ T6743] RBP: 00007ffd3c6a4ba0 R08: 0000000000000000 R09: 0000000000000000
[   58.027030][ T6743] R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffd3c6a4ba0
[   58.030145][ T6743] R13: 000000000000dc57 R14: 00007ffd3c6a4b7c R15: 0000000000000000
[   58.034380][ T6743] irq event stamp: 0
[   58.035696][ T6743] hardirqs last  enabled at (0): [<0000000000000000>] 0x0
[   58.038008][ T6743] hardirqs last disabled at (0): [<ffffffff811262d4>] copy_process+0x984/0x2010
[   58.040948][ T6743] softirqs last  enabled at (0): [<ffffffff811262d4>] copy_process+0x984/0x2010
[   58.044553][ T6743] softirqs last disabled at (0): [<0000000000000000>] 0x0
[   58.047127][ T6743] ---[ end trace b154f08dae0bfe9b ]---
[   58.049331][ T6743] ------------[ cut here ]------------
[   58.051183][ T6743] kernfs: can not remove 'protection_interval_bytes', no directory
[   58.053723][ T6743] WARNING: CPU: 1 PID: 6743 at fs/kernfs/dir.c:1508 kernfs_remove_by_name_ns+0x6f/0x80
[   58.056979][ T6743] Modules linked in: loop(E)
[   58.058576][ T6743] CPU: 1 PID: 6743 Comm: a.out Tainted: G        W   E     5.14.0-rc7+ #749
[   58.061800][ T6743] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 02/27/2020
[   58.068176][ T6743] RIP: 0010:kernfs_remove_by_name_ns+0x6f/0x80
[   58.070188][ T6743] Code: bb 38 01 31 c0 5d 41 5c 41 5d c3 48 c7 c7 e0 81 7d 83 e8 54 bb 38 01 b8 fe ff ff ff eb e7 48 c7 c7 50 3c 2a 83 e8 d1 99 29 01 <0f> 0b b8 fe ff ff ff eb d2 0f 1f 84 00 00 00 00 00 41 57 41 56 41
[   58.076383][ T6743] RSP: 0018:ffffc90001633df0 EFLAGS: 00010286
[   58.078511][ T6743] RAX: 0000000000000000 RBX: ffffffff83805038 RCX: 0000000000000027
[   58.081187][ T6743] RDX: 0000000000000027 RSI: 00000000ffffdfff RDI: ffff88807cbe78b8
[   58.084307][ T6743] RBP: 0000000000000000 R08: ffff88807cbe78b0 R09: 0000000000000000
[   58.087393][ T6743] R10: 0000000000000001 R11: 0000000000000001 R12: ffffffff832b6ce3
[   58.090024][ T6743] R13: 0000000000000001 R14: ffff88801208dfc0 R15: 0000000000000000
[   58.092657][ T6743] FS:  00007f1199de5580(0000) GS:ffff88807ca00000(0000) knlGS:0000000000000000
[   58.095739][ T6743] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   58.101789][ T6743] CR2: 00007f4a41af3048 CR3: 000000001d68d000 CR4: 00000000001506e0
[   58.104768][ T6743] Call Trace:
[   58.105996][ T6743]  remove_files.isra.0+0x2b/0x60
[   58.107680][ T6743]  sysfs_remove_group+0x38/0x80
[   58.109369][ T6743]  sysfs_remove_groups+0x24/0x40
[   58.111183][ T6743]  __kobject_del+0x1b/0x80
[   58.112672][ T6743]  kobject_del+0xf/0x20
[   58.114169][ T6743]  blk_integrity_del+0x1d/0x30
[   58.116165][ T6743]  del_gendisk+0x3c/0x1d0
[   58.117811][ T6743]  loop_remove+0x10/0x40 [loop]
[   58.119517][ T6743]  loop_control_ioctl+0x1a1/0x1b0 [loop]
[   58.121391][ T6743]  __x64_sys_ioctl+0x6a/0xa0
[   58.122905][ T6743]  do_syscall_64+0x35/0xb0
[   58.124538][ T6743]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[   58.126733][ T6743] RIP: 0033:0x7f1199d0d89d
[   58.128409][ T6743] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d c3 f5 0c 00 f7 d8 64 89 01 48
[   58.136499][ T6743] RSP: 002b:00007ffd3c6a4b68 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[   58.139334][ T6743] RAX: ffffffffffffffda RBX: 431bde82d7b634db RCX: 00007f1199d0d89d
[   58.142078][ T6743] RDX: 0000000000000001 RSI: 0000000000004c81 RDI: 0000000000000005
[   58.144915][ T6743] RBP: 00007ffd3c6a4ba0 R08: 0000000000000000 R09: 0000000000000000
[   58.147621][ T6743] R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffd3c6a4ba0
[   58.150715][ T6743] R13: 000000000000dc57 R14: 00007ffd3c6a4b7c R15: 0000000000000000
[   58.153291][ T6743] irq event stamp: 0
[   58.154750][ T6743] hardirqs last  enabled at (0): [<0000000000000000>] 0x0
[   58.157462][ T6743] hardirqs last disabled at (0): [<ffffffff811262d4>] copy_process+0x984/0x2010
[   58.160664][ T6743] softirqs last  enabled at (0): [<ffffffff811262d4>] copy_process+0x984/0x2010
[   58.163946][ T6743] softirqs last disabled at (0): [<0000000000000000>] 0x0
[   58.168205][ T6743] ---[ end trace b154f08dae0bfe9c ]---
[   58.170103][ T6743] ------------[ cut here ]------------
[   58.171926][ T6743] kernfs: can not remove 'read_verify', no directory
[   58.174109][ T6743] WARNING: CPU: 1 PID: 6743 at fs/kernfs/dir.c:1508 kernfs_remove_by_name_ns+0x6f/0x80
[   58.177522][ T6743] Modules linked in: loop(E)
[   58.179196][ T6743] CPU: 1 PID: 6743 Comm: a.out Tainted: G        W   E     5.14.0-rc7+ #749
[   58.182641][ T6743] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 02/27/2020
[   58.186674][ T6743] RIP: 0010:kernfs_remove_by_name_ns+0x6f/0x80
[   58.188719][ T6743] Code: bb 38 01 31 c0 5d 41 5c 41 5d c3 48 c7 c7 e0 81 7d 83 e8 54 bb 38 01 b8 fe ff ff ff eb e7 48 c7 c7 50 3c 2a 83 e8 d1 99 29 01 <0f> 0b b8 fe ff ff ff eb d2 0f 1f 84 00 00 00 00 00 41 57 41 56 41
[   58.195913][ T6743] RSP: 0018:ffffc90001633df0 EFLAGS: 00010286
[   58.198936][ T6743] RAX: 0000000000000000 RBX: ffffffff83805040 RCX: 0000000000000027
[   58.202205][ T6743] RDX: 0000000000000027 RSI: 00000000ffffdfff RDI: ffff88807cbe78b8
[   58.205001][ T6743] RBP: 0000000000000000 R08: ffff88807cbe78b0 R09: 0000000000000000
[   58.207572][ T6743] R10: 0000000000000001 R11: 0000000000000001 R12: ffffffff832b6cd7
[   58.210242][ T6743] R13: 0000000000000001 R14: ffff88801208dfc0 R15: 0000000000000000
[   58.212951][ T6743] FS:  00007f1199de5580(0000) GS:ffff88807ca00000(0000) knlGS:0000000000000000
[   58.217251][ T6743] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   58.219500][ T6743] CR2: 00007f4a41af3048 CR3: 000000001d68d000 CR4: 00000000001506e0
[   58.222253][ T6743] Call Trace:
[   58.223316][ T6743]  remove_files.isra.0+0x2b/0x60
[   58.225064][ T6743]  sysfs_remove_group+0x38/0x80
[   58.226662][ T6743]  sysfs_remove_groups+0x24/0x40
[   58.228382][ T6743]  __kobject_del+0x1b/0x80
[   58.229928][ T6743]  kobject_del+0xf/0x20
[   58.232272][ T6743]  blk_integrity_del+0x1d/0x30
[   58.236728][ T6743]  del_gendisk+0x3c/0x1d0
[   58.238122][ T6743]  loop_remove+0x10/0x40 [loop]
[   58.239822][ T6743]  loop_control_ioctl+0x1a1/0x1b0 [loop]
[   58.241611][ T6743]  __x64_sys_ioctl+0x6a/0xa0
[   58.243024][ T6743]  do_syscall_64+0x35/0xb0
[   58.244702][ T6743]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[   58.246462][ T6743] RIP: 0033:0x7f1199d0d89d
[   58.247814][ T6743] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d c3 f5 0c 00 f7 d8 64 89 01 48
[   58.255046][ T6743] RSP: 002b:00007ffd3c6a4b68 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[   58.258335][ T6743] RAX: ffffffffffffffda RBX: 431bde82d7b634db RCX: 00007f1199d0d89d
[   58.261208][ T6743] RDX: 0000000000000001 RSI: 0000000000004c81 RDI: 0000000000000005
[   58.264295][ T6743] RBP: 00007ffd3c6a4ba0 R08: 0000000000000000 R09: 0000000000000000
[   58.267761][ T6743] R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffd3c6a4ba0
[   58.270599][ T6743] R13: 000000000000dc57 R14: 00007ffd3c6a4b7c R15: 0000000000000000
[   58.273415][ T6743] irq event stamp: 0
[   58.274965][ T6743] hardirqs last  enabled at (0): [<0000000000000000>] 0x0
[   58.277685][ T6743] hardirqs last disabled at (0): [<ffffffff811262d4>] copy_process+0x984/0x2010
[   58.280915][ T6743] softirqs last  enabled at (0): [<ffffffff811262d4>] copy_process+0x984/0x2010
[   58.284267][ T6743] softirqs last disabled at (0): [<0000000000000000>] 0x0
[   58.286752][ T6743] ---[ end trace b154f08dae0bfe9d ]---
[   58.288508][ T6743] ------------[ cut here ]------------
[   58.290354][ T6743] kernfs: can not remove 'write_generate', no directory
[   58.292657][ T6743] WARNING: CPU: 1 PID: 6743 at fs/kernfs/dir.c:1508 kernfs_remove_by_name_ns+0x6f/0x80
[   58.295959][ T6743] Modules linked in: loop(E)
[   58.297762][ T6743] CPU: 1 PID: 6743 Comm: a.out Tainted: G        W   E     5.14.0-rc7+ #749
[   58.305316][ T6743] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 02/27/2020
[   58.309104][ T6743] RIP: 0010:kernfs_remove_by_name_ns+0x6f/0x80
[   58.311318][ T6743] Code: bb 38 01 31 c0 5d 41 5c 41 5d c3 48 c7 c7 e0 81 7d 83 e8 54 bb 38 01 b8 fe ff ff ff eb e7 48 c7 c7 50 3c 2a 83 e8 d1 99 29 01 <0f> 0b b8 fe ff ff ff eb d2 0f 1f 84 00 00 00 00 00 41 57 41 56 41
[   58.318333][ T6743] RSP: 0018:ffffc90001633df0 EFLAGS: 00010286
[   58.320422][ T6743] RAX: 0000000000000000 RBX: ffffffff83805048 RCX: 0000000000000027
[   58.322980][ T6743] RDX: 0000000000000027 RSI: 00000000ffffdfff RDI: ffff88807cbe78b8
[   58.326021][ T6743] RBP: 0000000000000000 R08: ffff88807cbe78b0 R09: 0000000000000000
[   58.328989][ T6743] R10: 0000000000000001 R11: 0000000000000001 R12: ffffffff832b6cc8
[   58.333216][ T6743] R13: 0000000000000001 R14: ffff88801208dfc0 R15: 0000000000000000
[   58.336144][ T6743] FS:  00007f1199de5580(0000) GS:ffff88807ca00000(0000) knlGS:0000000000000000
[   58.339067][ T6743] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   58.341185][ T6743] CR2: 00007f4a41af3048 CR3: 000000001d68d000 CR4: 00000000001506e0
[   58.344024][ T6743] Call Trace:
[   58.345458][ T6743]  remove_files.isra.0+0x2b/0x60
[   58.347259][ T6743]  sysfs_remove_group+0x38/0x80
[   58.349310][ T6743]  sysfs_remove_groups+0x24/0x40
[   58.351049][ T6743]  __kobject_del+0x1b/0x80
[   58.352405][ T6743]  kobject_del+0xf/0x20
[   58.353801][ T6743]  blk_integrity_del+0x1d/0x30
[   58.355441][ T6743]  del_gendisk+0x3c/0x1d0
[   58.356886][ T6743]  loop_remove+0x10/0x40 [loop]
[   58.358434][ T6743]  loop_control_ioctl+0x1a1/0x1b0 [loop]
[   58.360475][ T6743]  __x64_sys_ioctl+0x6a/0xa0
[   58.362207][ T6743]  do_syscall_64+0x35/0xb0
[   58.364024][ T6743]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[   58.367281][ T6743] RIP: 0033:0x7f1199d0d89d
[   58.368860][ T6743] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d c3 f5 0c 00 f7 d8 64 89 01 48
[   58.375338][ T6743] RSP: 002b:00007ffd3c6a4b68 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[   58.378157][ T6743] RAX: ffffffffffffffda RBX: 431bde82d7b634db RCX: 00007f1199d0d89d
[   58.380858][ T6743] RDX: 0000000000000001 RSI: 0000000000004c81 RDI: 0000000000000005
[   58.384278][ T6743] RBP: 00007ffd3c6a4ba0 R08: 0000000000000000 R09: 0000000000000000
[   58.387384][ T6743] R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffd3c6a4ba0
[   58.390188][ T6743] R13: 000000000000dc57 R14: 00007ffd3c6a4b7c R15: 0000000000000000
[   58.393211][ T6743] irq event stamp: 0
[   58.394873][ T6743] hardirqs last  enabled at (0): [<0000000000000000>] 0x0
[   58.397596][ T6743] hardirqs last disabled at (0): [<ffffffff811262d4>] copy_process+0x984/0x2010
[   58.402257][ T6743] softirqs last  enabled at (0): [<ffffffff811262d4>] copy_process+0x984/0x2010
[   58.405594][ T6743] softirqs last disabled at (0): [<0000000000000000>] 0x0
[   58.407966][ T6743] ---[ end trace b154f08dae0bfe9e ]---
[   58.409864][ T6743] ------------[ cut here ]------------
[   58.411743][ T6743] kernfs: can not remove 'device_is_integrity_capable', no directory
[   58.414502][ T6743] WARNING: CPU: 1 PID: 6743 at fs/kernfs/dir.c:1508 kernfs_remove_by_name_ns+0x6f/0x80
[   58.418733][ T6743] Modules linked in: loop(E)
[   58.420290][ T6743] CPU: 1 PID: 6743 Comm: a.out Tainted: G        W   E     5.14.0-rc7+ #749
[   58.423113][ T6743] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 02/27/2020
[   58.427386][ T6743] RIP: 0010:kernfs_remove_by_name_ns+0x6f/0x80
[   58.429510][ T6743] Code: bb 38 01 31 c0 5d 41 5c 41 5d c3 48 c7 c7 e0 81 7d 83 e8 54 bb 38 01 b8 fe ff ff ff eb e7 48 c7 c7 50 3c 2a 83 e8 d1 99 29 01 <0f> 0b b8 fe ff ff ff eb d2 0f 1f 84 00 00 00 00 00 41 57 41 56 41
[   58.439072][ T6743] RSP: 0018:ffffc90001633df0 EFLAGS: 00010286
[   58.441062][ T6743] RAX: 0000000000000000 RBX: ffffffff83805050 RCX: 0000000000000027
[   58.443588][ T6743] RDX: 0000000000000027 RSI: 00000000ffffdfff RDI: ffff88807cbe78b8
[   58.446972][ T6743] RBP: 0000000000000000 R08: ffff88807cbe78b0 R09: 0000000000000000
[   58.450085][ T6743] R10: 0000000000000001 R11: 0000000000000001 R12: ffffffff832b6cac
[   58.452711][ T6743] R13: 0000000000000001 R14: ffff88801208dfc0 R15: 0000000000000000
[   58.455398][ T6743] FS:  00007f1199de5580(0000) GS:ffff88807ca00000(0000) knlGS:0000000000000000
[   58.458350][ T6743] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   58.460682][ T6743] CR2: 00007f4a41af3048 CR3: 000000001d68d000 CR4: 00000000001506e0
[   58.463531][ T6743] Call Trace:
[   58.465589][ T6743]  remove_files.isra.0+0x2b/0x60
[   58.468652][ T6743]  sysfs_remove_group+0x38/0x80
[   58.470317][ T6743]  sysfs_remove_groups+0x24/0x40
[   58.471864][ T6743]  __kobject_del+0x1b/0x80
[   58.473276][ T6743]  kobject_del+0xf/0x20
[   58.474797][ T6743]  blk_integrity_del+0x1d/0x30
[   58.476335][ T6743]  del_gendisk+0x3c/0x1d0
[   58.477852][ T6743]  loop_remove+0x10/0x40 [loop]
[   58.479488][ T6743]  loop_control_ioctl+0x1a1/0x1b0 [loop]
[   58.481469][ T6743]  __x64_sys_ioctl+0x6a/0xa0
[   58.483516][ T6743]  do_syscall_64+0x35/0xb0
[   58.485186][ T6743]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[   58.486984][ T6743] RIP: 0033:0x7f1199d0d89d
[   58.488359][ T6743] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d c3 f5 0c 00 f7 d8 64 89 01 48
[   58.495307][ T6743] RSP: 002b:00007ffd3c6a4b68 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[   58.501911][ T6743] RAX: ffffffffffffffda RBX: 431bde82d7b634db RCX: 00007f1199d0d89d
[   58.504713][ T6743] RDX: 0000000000000001 RSI: 0000000000004c81 RDI: 0000000000000005
[   58.507431][ T6743] RBP: 00007ffd3c6a4ba0 R08: 0000000000000000 R09: 0000000000000000
[   58.510259][ T6743] R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffd3c6a4ba0
[   58.513018][ T6743] R13: 000000000000dc57 R14: 00007ffd3c6a4b7c R15: 0000000000000000
[   58.516976][ T6743] irq event stamp: 0
[   58.518276][ T6743] hardirqs last  enabled at (0): [<0000000000000000>] 0x0
[   58.520709][ T6743] hardirqs last disabled at (0): [<ffffffff811262d4>] copy_process+0x984/0x2010
[   58.523953][ T6743] softirqs last  enabled at (0): [<ffffffff811262d4>] copy_process+0x984/0x2010
[   58.526884][ T6743] softirqs last disabled at (0): [<0000000000000000>] 0x0
[   58.529328][ T6743] ---[ end trace b154f08dae0bfe9f ]---
[   58.531361][ T6743] ------------[ cut here ]------------
[   58.535516][ T6743] kernfs: can not remove 'bdi', no directory
[   58.537520][ T6743] WARNING: CPU: 1 PID: 6743 at fs/kernfs/dir.c:1508 kernfs_remove_by_name_ns+0x6f/0x80
[   58.540812][ T6743] Modules linked in: loop(E)
[   58.542259][ T6743] CPU: 1 PID: 6743 Comm: a.out Tainted: G        W   E     5.14.0-rc7+ #749
[   58.545443][ T6743] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 02/27/2020
[   58.549422][ T6743] RIP: 0010:kernfs_remove_by_name_ns+0x6f/0x80
[   58.551525][ T6743] Code: bb 38 01 31 c0 5d 41 5c 41 5d c3 48 c7 c7 e0 81 7d 83 e8 54 bb 38 01 b8 fe ff ff ff eb e7 48 c7 c7 50 3c 2a 83 e8 d1 99 29 01 <0f> 0b b8 fe ff ff ff eb d2 0f 1f 84 00 00 00 00 00 41 57 41 56 41
[   58.558869][ T6743] RSP: 0018:ffffc90001633e88 EFLAGS: 00010282
[   58.561018][ T6743] RAX: 0000000000000000 RBX: ffff88800e505800 RCX: 0000000000000027
[   58.563747][ T6743] RDX: 0000000000000027 RSI: 00000000ffffdfff RDI: ffff88807cbe78b8
[   58.567899][ T6743] RBP: ffff888019562c40 R08: ffff88807cbe78b0 R09: 0000000000000000
[   58.570718][ T6743] R10: 0000000000000001 R11: 0000000000000001 R12: ffffffff83290587
[   58.573295][ T6743] R13: 0000000000000001 R14: ffff88801208dfc0 R15: 0000000000000000
[   58.577017][ T6743] FS:  00007f1199de5580(0000) GS:ffff88807ca00000(0000) knlGS:0000000000000000
[   58.580048][ T6743] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   58.582390][ T6743] CR2: 00007f4a41af3048 CR3: 000000001d68d000 CR4: 00000000001506e0
[   58.585500][ T6743] Call Trace:
[   58.586566][ T6743]  del_gendisk+0x1b3/0x1d0
[   58.588063][ T6743]  loop_remove+0x10/0x40 [loop]
[   58.589669][ T6743]  loop_control_ioctl+0x1a1/0x1b0 [loop]
[   58.591579][ T6743]  __x64_sys_ioctl+0x6a/0xa0
[   58.593114][ T6743]  do_syscall_64+0x35/0xb0
[   58.595256][ T6743]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[   58.597709][ T6743] RIP: 0033:0x7f1199d0d89d
[   58.599860][ T6743] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d c3 f5 0c 00 f7 d8 64 89 01 48
[   58.606860][ T6743] RSP: 002b:00007ffd3c6a4b68 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[   58.609623][ T6743] RAX: ffffffffffffffda RBX: 431bde82d7b634db RCX: 00007f1199d0d89d
[   58.612461][ T6743] RDX: 0000000000000001 RSI: 0000000000004c81 RDI: 0000000000000005
[   58.617000][ T6743] RBP: 00007ffd3c6a4ba0 R08: 0000000000000000 R09: 0000000000000000
[   58.619703][ T6743] R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffd3c6a4ba0
[   58.622204][ T6743] R13: 000000000000dc57 R14: 00007ffd3c6a4b7c R15: 0000000000000000
[   58.625194][ T6743] irq event stamp: 0
[   58.626979][ T6743] hardirqs last  enabled at (0): [<0000000000000000>] 0x0
[   58.629419][ T6743] hardirqs last disabled at (0): [<ffffffff811262d4>] copy_process+0x984/0x2010
[   58.637066][ T6743] softirqs last  enabled at (0): [<ffffffff811262d4>] copy_process+0x984/0x2010
[   58.640146][ T6743] softirqs last disabled at (0): [<0000000000000000>] 0x0
[   58.642448][ T6743] ---[ end trace b154f08dae0bfea0 ]---
[   58.644743][ T6743] BUG: kernel NULL pointer dereference, address: 0000000000000110
[   58.647371][ T6743] #PF: supervisor read access in kernel mode
[   58.649595][ T6743] #PF: error_code(0x0000) - not-present page
[   58.651527][ T6743] PGD e6cf067 P4D e6cf067 PUD 1d69b067 PMD 0 
[   58.653403][ T6743] Oops: 0000 [#1] PREEMPT SMP
[   58.655058][ T6743] CPU: 1 PID: 6743 Comm: a.out Tainted: G        W   E     5.14.0-rc7+ #749
[   58.657741][ T6743] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 02/27/2020
[   58.661484][ T6743] RIP: 0010:device_del+0x46/0x410
[   58.663064][ T6743] Code: 48 89 ef 65 48 8b 04 25 28 00 00 00 48 89 44 24 10 31 c0 e8 4c fb 07 01 8b 05 52 96 2d 02 85 c0 0f 85 8c 03 00 00 48 8b 53 48 <0f> b6 82 10 01 00 00 a8 01 75 09 83 c8 01 88 82 10 01 00 00 48 89
[   58.672214][ T6743] RSP: 0018:ffffc90001633e80 EFLAGS: 00010246
[   58.674192][ T6743] RAX: 0000000000000000 RBX: ffff888019562c80 RCX: 0000000000000000
[   58.676821][ T6743] RDX: 0000000000000000 RSI: ffffffff817738d4 RDI: 0000000000000000
[   58.679648][ T6743] RBP: ffff888019562da0 R08: 0000000000000000 R09: 0000000000000001
[   58.682572][ T6743] R10: ffffc90001633e80 R11: ffff88800f62b838 R12: 0000000000000000
[   58.685825][ T6743] R13: 0000000000000001 R14: ffff88801208dfc0 R15: 0000000000000000
[   58.688554][ T6743] FS:  00007f1199de5580(0000) GS:ffff88807ca00000(0000) knlGS:0000000000000000
[   58.691499][ T6743] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   58.693581][ T6743] CR2: 0000000000000110 CR3: 000000001d68d000 CR4: 00000000001506e0
[   58.696457][ T6743] Call Trace:
[   58.697916][ T6743]  ? kernfs_remove_by_name_ns+0x5c/0x80
[   58.703342][ T6743]  loop_remove+0x10/0x40 [loop]
[   58.705048][ T6743]  loop_control_ioctl+0x1a1/0x1b0 [loop]
[   58.706932][ T6743]  __x64_sys_ioctl+0x6a/0xa0
[   58.708429][ T6743]  do_syscall_64+0x35/0xb0
[   58.709868][ T6743]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[   58.711987][ T6743] RIP: 0033:0x7f1199d0d89d
[   58.713428][ T6743] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d c3 f5 0c 00 f7 d8 64 89 01 48
[   58.720308][ T6743] RSP: 002b:00007ffd3c6a4b68 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
[   58.722928][ T6743] RAX: ffffffffffffffda RBX: 431bde82d7b634db RCX: 00007f1199d0d89d
[   58.726121][ T6743] RDX: 0000000000000001 RSI: 0000000000004c81 RDI: 0000000000000005
[   58.728838][ T6743] RBP: 00007ffd3c6a4ba0 R08: 0000000000000000 R09: 0000000000000000
[   58.731837][ T6743] R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffd3c6a4ba0
[   58.735598][ T6743] R13: 000000000000dc57 R14: 00007ffd3c6a4b7c R15: 0000000000000000
[   58.738251][ T6743] Modules linked in: loop(E)
[   58.739747][ T6743] CR2: 0000000000000110
[   58.741153][ T6743] ---[ end trace b154f08dae0bfea1 ]---
[   58.743734][ T6743] RIP: 0010:device_del+0x46/0x410
[   58.747855][ T6743] Code: 48 89 ef 65 48 8b 04 25 28 00 00 00 48 89 44 24 10 31 c0 e8 4c fb 07 01 8b 05 52 96 2d 02 85 c0 0f 85 8c 03 00 00 48 8b 53 48 <0f> b6 82 10 01 00 00 a8 01 75 09 83 c8 01 88 82 10 01 00 00 48 89
[   58.759456][ T6743] RSP: 0018:ffffc90001633e80 EFLAGS: 00010246
[   58.762723][ T6743] RAX: 0000000000000000 RBX: ffff888019562c80 RCX: 0000000000000000
[   58.767547][ T6743] RDX: 0000000000000000 RSI: ffffffff817738d4 RDI: 0000000000000000
[   58.771715][ T6743] RBP: ffff888019562da0 R08: 0000000000000000 R09: 0000000000000001
[   58.774548][ T6743] R10: ffffc90001633e80 R11: ffff88800f62b838 R12: 0000000000000000
[   58.777158][ T6743] R13: 0000000000000001 R14: ffff88801208dfc0 R15: 0000000000000000
[   58.779874][ T6743] FS:  00007f1199de5580(0000) GS:ffff88807ca00000(0000) knlGS:0000000000000000
[   58.783119][ T6743] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   58.785333][ T6743] CR2: 0000000000000110 CR3: 000000001d68d000 CR4: 00000000001506e0
[   58.787951][ T6743] Kernel panic - not syncing: Fatal exception
[   58.790104][ T6743] Kernel Offset: disabled
[   58.796812][ T6743] Rebooting in 10 seconds..
----------------------------------------

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: sort out the lock order in the loop driver v2
  2021-08-27  0:30 ` sort out the lock order in the loop driver v2 Tetsuo Handa
@ 2021-08-27  6:40   ` Christoph Hellwig
  2021-08-27  7:46     ` Tetsuo Handa
  0 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2021-08-27  6:40 UTC (permalink / raw)
  To: Tetsuo Handa
  Cc: Christoph Hellwig, Jens Axboe, Hillf Danton, Pavel Tatashin,
	Tyler Hicks, linux-block, Milan Broz, Greg Kroah-Hartman

On Fri, Aug 27, 2021 at 09:30:12AM +0900, Tetsuo Handa wrote:
> Again crashed in 3 seconds. We can't accept this series.

Would you gladly point to the reproducer?

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 5/8] loop: merge the cryptoloop module into the main loop module
  2021-08-26 16:44       ` Milan Broz
@ 2021-08-27  6:45         ` Christoph Hellwig
  2021-08-27 11:33           ` Tetsuo Handa
  0 siblings, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2021-08-27  6:45 UTC (permalink / raw)
  To: Milan Broz
  Cc: Christoph Hellwig, Jens Axboe, Hillf Danton, Tetsuo Handa,
	Pavel Tatashin, Reviewed-by : Tyler Hicks, linux-block

On Thu, Aug 26, 2021 at 06:44:32PM +0200, Milan Broz wrote:
> Yes, I know that removal is far disturbing thing here, if it
> can be planned for removal later, I think it is the best thing to do...
> 
> And I would like to know actually if there are existing users
> (and how and why they are using this interface - it cannot be configured
> through losetup for years IIRC).

We could just try to drop it entirely and see if anyone screams.  You
are probably right that no one will.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: sort out the lock order in the loop driver v2
  2021-08-27  6:40   ` Christoph Hellwig
@ 2021-08-27  7:46     ` Tetsuo Handa
  2021-08-27 15:34       ` Christoph Hellwig
  0 siblings, 1 reply; 21+ messages in thread
From: Tetsuo Handa @ 2021-08-27  7:46 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, Hillf Danton, Pavel Tatashin, Tyler Hicks,
	linux-block, Milan Broz, Greg Kroah-Hartman

On 2021/08/27 15:40, Christoph Hellwig wrote:
> On Fri, Aug 27, 2021 at 09:30:12AM +0900, Tetsuo Handa wrote:
>> Again crashed in 3 seconds. We can't accept this series.
> 
> Would you gladly point to the reproducer?
> 

You can reach dashboard at https://syzkaller.appspot.com/bug?extid=$hashid where
$hashid is Reporter's mail address <syzbot+$hashid@syzkaller.appspotmail.com> .
For this bug report, the dashboard is https://syzkaller.appspot.com/bug?extid=f61766d5763f9e7a118f .
Then, please find C repro column within the dashboard page. For this bug report, the C reproducer is
https://syzkaller.appspot.com/text?tag=ReproC&x=13d20adc300000 .

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 5/8] loop: merge the cryptoloop module into the main loop module
  2021-08-27  6:45         ` Christoph Hellwig
@ 2021-08-27 11:33           ` Tetsuo Handa
  2021-08-27 15:38             ` Christoph Hellwig
  0 siblings, 1 reply; 21+ messages in thread
From: Tetsuo Handa @ 2021-08-27 11:33 UTC (permalink / raw)
  To: Christoph Hellwig, Jens Axboe, Milan Broz
  Cc: Hillf Danton, Pavel Tatashin, Reviewed-by : Tyler Hicks, linux-block

On 2021/08/27 15:45, Christoph Hellwig wrote:
> On Thu, Aug 26, 2021 at 06:44:32PM +0200, Milan Broz wrote:
>> Yes, I know that removal is far disturbing thing here, if it
>> can be planned for removal later, I think it is the best thing to do...
>>
>> And I would like to know actually if there are existing users
>> (and how and why they are using this interface - it cannot be configured
>> through losetup for years IIRC).
> 
> We could just try to drop it entirely and see if anyone screams.  You
> are probably right that no one will.
> 

I recommend that we only add a patch to deprecate cryptoloop module with
a printk() when people actually try to use cryptoloop module, and then
eventually remove cryptoloop module. But that is absolutely after my patches.

You are repeatedly failing to fix this problem because you are trying to fix
a different extra thing simply because you don't like the nasty locking interactions.

I posted "[PATCH v5] block: genhd: don't call probe function with major_names_lock held"
( https://lkml.kernel.org/r/b2af8a5b-3c1b-204e-7f56-bea0b15848d6@i-love.sakura.ne.jp ) for v5.14 (and also stable),
and "[PATCH] loop: replace loop_ctl_mutex with loop_idr_spinlock"
( https://lkml.kernel.org/r/2642808b-a7d0-28ff-f288-0f4eabc562f7@i-love.sakura.ne.jp ) for v5.15 (but not stable).

Any of your further series that claims to fix this problem is invalid
until you review and fully understand my patches. You are still missing what
the loop_ctl_mutex is serializing. The loop_ctl_mutex is used for serializing
"idr_alloc() + add_disk()" sequence versus "del_gendisk() + idr_remove()"
sequence.

Your assumption in PATCH 7/8 is broken because idr_alloc() will succeed and
add_disk() will be called as soon as idr_remove() is called, and you wrongly
assumes that the Lo_deleting state can prevent further lookups. No, idr_remove()
cannot prevent further "idr_alloc() + add_disk()". In other words, idr_remove()
must not be called before del_gendisk() completes. That serialization is currently
handled by the loop_ctl_mutex, and my latter patch safely removes the loop_ctl_mutex
(at the risk of possibly changing the userspace's behavior; that's why my latter
patch is not for v5.14 but for v5.15. My former patch is for v5.14 because it has
no risk of possibly changing the userspace's behavior).

Don't try to merge the cryptoloop module into the loop module now; it makes
backporting the fix difficult. After applying my patches, applying your PATCH 1,2,3/8
will be OK as a cleanup, and your PATCH 4/8 would be OK given that several weeks
of testing are done in linux-next tree. But never your PATCH 5,6,7,8/8. You can't
fix this problem now if you try to do a different thing together.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: sort out the lock order in the loop driver v2
       [not found] ` <20210827130259.2622-1-hdanton@sina.com>
@ 2021-08-27 14:10   ` Tetsuo Handa
       [not found]   ` <20210828035114.2762-1-hdanton@sina.com>
  1 sibling, 0 replies; 21+ messages in thread
From: Tetsuo Handa @ 2021-08-27 14:10 UTC (permalink / raw)
  To: Hillf Danton
  Cc: Christoph Hellwig, Jens Axboe, Pavel Tatashin, Tyler Hicks,
	linux-block, Milan Broz, Greg Kroah-Hartman

On 2021/08/27 22:02, Hillf Danton wrote:
> This is a known issue [1] and the quick fix is destroy workqueue without
> holding lo_mutex.
> 
> Please post a link to the drivers/block/loop.c you tested, Tetsuo.
> 
> [1] https://lore.kernel.org/linux-block/0000000000005b27b805c853007b@google.com/
> 

Which link? https://lkml.kernel.org/r/2901b9c2-f798-413e-4073-451259718288@i-love.sakura.ne.jp ?
Too many failures to remember...

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: sort out the lock order in the loop driver v2
  2021-08-27  7:46     ` Tetsuo Handa
@ 2021-08-27 15:34       ` Christoph Hellwig
  0 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2021-08-27 15:34 UTC (permalink / raw)
  To: Tetsuo Handa
  Cc: Christoph Hellwig, Jens Axboe, Hillf Danton, Pavel Tatashin,
	Tyler Hicks, linux-block, Milan Broz, Greg Kroah-Hartman

On Fri, Aug 27, 2021 at 04:46:42PM +0900, Tetsuo Handa wrote:
> On 2021/08/27 15:40, Christoph Hellwig wrote:
> > On Fri, Aug 27, 2021 at 09:30:12AM +0900, Tetsuo Handa wrote:
> >> Again crashed in 3 seconds. We can't accept this series.
> > 
> > Would you gladly point to the reproducer?
> > 
> 
> You can reach dashboard at https://syzkaller.appspot.com/bug?extid=$hashid where
> $hashid is Reporter's mail address <syzbot+$hashid@syzkaller.appspotmail.com> .
> For this bug report, the dashboard is https://syzkaller.appspot.com/bug?extid=f61766d5763f9e7a118f .
> Then, please find C repro column within the dashboard page. For this bug report, the C reproducer is
> https://syzkaller.appspot.com/text?tag=ReproC&x=13d20adc300000 .

Thank you very much!

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 5/8] loop: merge the cryptoloop module into the main loop module
  2021-08-27 11:33           ` Tetsuo Handa
@ 2021-08-27 15:38             ` Christoph Hellwig
  0 siblings, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2021-08-27 15:38 UTC (permalink / raw)
  To: Tetsuo Handa
  Cc: Christoph Hellwig, Jens Axboe, Milan Broz, Hillf Danton,
	Pavel Tatashin, Reviewed-by : Tyler Hicks, linux-block

On Fri, Aug 27, 2021 at 08:33:10PM +0900, Tetsuo Handa wrote:
> I posted "[PATCH v5] block: genhd: don't call probe function with major_names_lock held"
> ( https://lkml.kernel.org/r/b2af8a5b-3c1b-204e-7f56-bea0b15848d6@i-love.sakura.ne.jp ) for v5.14 (and also stable),

And I've already told you that I think this is going in the wrong direction and
do not thing it is a good idea.

> and "[PATCH] loop: replace loop_ctl_mutex with loop_idr_spinlock"
> ( https://lkml.kernel.org/r/2642808b-a7d0-28ff-f288-0f4eabc562f7@i-love.sakura.ne.jp ) for v5.15 (but not stable).

I will review this.

> Don't try to merge the cryptoloop module into the loop module now; it makes
> backporting the fix difficult.

Which is on the one true, on the other hand simply does not matter.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: sort out the lock order in the loop driver v2
       [not found]   ` <20210828035114.2762-1-hdanton@sina.com>
@ 2021-08-28  5:17     ` Tetsuo Handa
  0 siblings, 0 replies; 21+ messages in thread
From: Tetsuo Handa @ 2021-08-28  5:17 UTC (permalink / raw)
  To: Hillf Danton
  Cc: Christoph Hellwig, Jens Axboe, Pavel Tatashin, Tyler Hicks,
	linux-block, Milan Broz, Greg Kroah-Hartman

On 2021/08/28 12:51, Hillf Danton wrote:
> On Fri, 27 Aug 2021 23:10:53 +0900 Tetsuo Handa wrote:
>> On 2021/08/27 22:02, Hillf Danton wrote:
>>> This is a known issue [1] and the quick fix is destroy workqueue without
>>> holding lo_mutex.
>>>
>>> Please post a link to the drivers/block/loop.c you tested, Tetsuo.
>>>
>>> [1] https://lore.kernel.org/linux-block/0000000000005b27b805c853007b@google.com/
>>>
>>
>> Which link? https://lkml.kernel.org/r/2901b9c2-f798-413e-4073-451259718288@i-love.sakura.ne.jp [2]?
>> Too many failures to remember...
> 
> Take another look at [2] and what is reported in this thread (see below),
> what is common in both cases is lo->workqueue is destroyed under
> disk->open_mutex.
> 
> And down the lock chain in blkdev_get_by_dev() disk->open_mutex will be
> taken again... seems it will not be solved without taking open_mutex
> into account.

We are no longer interested in this series which tries to hold lo->lo_mutex from loop_add().

We are discussing https://lkml.kernel.org/r/b9d7b6b1-236a-438b-bee7-6d65b7b58905@i-love.sakura.ne.jp
which no longer tries to hold loop_ctl_mutex or lo->lo_mutex from loop_add().


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2021-08-28  5:17 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-26 13:38 sort out the lock order in the loop driver v2 Christoph Hellwig
2021-08-26 13:38 ` [PATCH 1/8] cryptoloop: fix a sparse annotation Christoph Hellwig
2021-08-26 13:38 ` [PATCH 2/8] loop: remove the unused idx argument to loop_control_get_free Christoph Hellwig
2021-08-26 13:38 ` [PATCH 3/8] loop: remove the ->ioctl method in loop_func_table Christoph Hellwig
2021-08-26 13:38 ` [PATCH 4/8] loop: return void from the ->release " Christoph Hellwig
2021-08-26 13:38 ` [PATCH 5/8] loop: merge the cryptoloop module into the main loop module Christoph Hellwig
2021-08-26 16:31   ` Milan Broz
2021-08-26 16:34     ` Christoph Hellwig
2021-08-26 16:44       ` Milan Broz
2021-08-27  6:45         ` Christoph Hellwig
2021-08-27 11:33           ` Tetsuo Handa
2021-08-27 15:38             ` Christoph Hellwig
2021-08-26 13:38 ` [PATCH 6/8] loop: devirtualize transfer transformations Christoph Hellwig
2021-08-26 13:38 ` [PATCH 7/8] loop: move loop device deletion out of loop_ctl_mutex Christoph Hellwig
2021-08-26 13:38 ` [PATCH 8/8] loop: avoid holding loop_ctl_mutex over add_disk Christoph Hellwig
2021-08-27  0:30 ` sort out the lock order in the loop driver v2 Tetsuo Handa
2021-08-27  6:40   ` Christoph Hellwig
2021-08-27  7:46     ` Tetsuo Handa
2021-08-27 15:34       ` Christoph Hellwig
     [not found] ` <20210827130259.2622-1-hdanton@sina.com>
2021-08-27 14:10   ` Tetsuo Handa
     [not found]   ` <20210828035114.2762-1-hdanton@sina.com>
2021-08-28  5:17     ` Tetsuo Handa

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.