From: Milan Broz <gmazyland@gmail.com>
To: linux-block@vger.kernel.org
Cc: kzak@redhat.com, axboe@kernel.dk, hare@suse.de,
Milan Broz <gmazyland@gmail.com>
Subject: [PATCH] loop: Fix freeze if configured block size is not supported
Date: Fri, 18 Aug 2017 15:07:33 +0200 [thread overview]
Message-ID: <20170818130733.11254-1-gmazyland@gmail.com> (raw)
The commit f2c6df7dbf9a60e1cd9941f9fb376d4d9ad1e8dd
loop: support 4k physical blocksize
adds support for loop block size with only specific block sizes.
If the size is not supported, the code returns -EINVAL keeping
the loop queue frozen. This causes that device could be locked
for a long time by processes trying to scan device (udev).
(And also causing subsequent LOOP_CLR_FD operations noop.)
Fix it by using goto to proper exit location with queue unfreeze.
(The same bug is for setting crypt attribute but this code is
probably no more used. Patch fixes it as well though.)
Signed-off-by: Milan Broz <gmazyland@gmail.com>
---
drivers/block/loop.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index ef8334949b42..26548e07bc31 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1125,11 +1125,15 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
if (info->lo_encrypt_type) {
unsigned int type = info->lo_encrypt_type;
- if (type >= MAX_LO_CRYPT)
- return -EINVAL;
+ if (type >= MAX_LO_CRYPT) {
+ err = -EINVAL;
+ goto exit;
+ }
xfer = xfer_funcs[type];
- if (xfer == NULL)
- return -EINVAL;
+ if (xfer == NULL) {
+ err = -EINVAL;
+ goto exit;
+ }
} else
xfer = NULL;
@@ -1144,10 +1148,14 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
if (LO_INFO_BLOCKSIZE(info) != 512 &&
LO_INFO_BLOCKSIZE(info) != 1024 &&
LO_INFO_BLOCKSIZE(info) != 2048 &&
- LO_INFO_BLOCKSIZE(info) != 4096)
- return -EINVAL;
- if (LO_INFO_BLOCKSIZE(info) > lo->lo_blocksize)
- return -EINVAL;
+ LO_INFO_BLOCKSIZE(info) != 4096) {
+ err = -EINVAL;
+ goto exit;
+ }
+ if (LO_INFO_BLOCKSIZE(info) > lo->lo_blocksize) {
+ err = -EINVAL;
+ goto exit;
+ }
}
if (lo->lo_offset != info->lo_offset ||
--
2.14.1
next reply other threads:[~2017-08-18 13:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-18 13:07 Milan Broz [this message]
2017-08-21 18:47 ` [PATCH] loop: Fix freeze if configured block size is not supported Omar Sandoval
2017-08-21 19:11 ` Milan Broz
2017-08-21 19:19 ` Omar Sandoval
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170818130733.11254-1-gmazyland@gmail.com \
--to=gmazyland@gmail.com \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=kzak@redhat.com \
--cc=linux-block@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox