From: Christoph Hellwig <hch@lst.de>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Petr Vorel <pvorel@suse.cz>,
Pavel Tatashin <pasha.tatashin@soleen.com>,
Tyler Hicks <tyhicks@linux.microsoft.com>,
Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org
Subject: Re: [PATCH] loop: reintroduce global lock for safe loop_validate_file() traversal
Date: Tue, 6 Jul 2021 07:46:22 +0200 [thread overview]
Message-ID: <20210706054622.GE17027@lst.de> (raw)
In-Reply-To: <288edd89-a33f-2561-cee9-613704c3da20@i-love.sakura.ne.jp>
> +static int loop_global_lock_killable(struct loop_device *lo, bool global)
> +{
> + int err;
> +
> + if (global) {
> + err = mutex_lock_killable(&loop_validate_mutex);
> + if (err)
> + return err;
> + }
> + err = mutex_lock_killable(&lo->lo_mutex);
> + if (err && global)
> + mutex_unlock(&loop_validate_mutex);
> + return err;
> +}
> +
> +static void loop_global_unlock(struct loop_device *lo, bool global)
> +{
> + mutex_unlock(&lo->lo_mutex);
> + if (global)
> + mutex_unlock(&loop_validate_mutex);
> +}
Comments explaining these functions would be nice.
> static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
> unsigned int arg)
> {
> - struct file *file = NULL, *old_file;
> + struct file *file = fget(arg);
> + struct file *old_file;
> int error;
> bool partscan;
> + bool is_loop;
This doesn't match the existing formatting. Either keep the existing
one or change the few other variables as well.
> + is_loop = is_loop_device(file);
> + error = loop_global_lock_killable(lo, is_loop);
> + if (error) {
> + fput(file);
> return error;
> + }
Please use a goto label to share the fput with the other error handling.
> @@ -1143,6 +1167,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
> loff_t size;
> bool partscan;
> unsigned short bsize;
> + bool is_loop;
Please follow the existing formatting.
Otherwise this looks reasonable to me.
next prev parent reply other threads:[~2021-07-06 5:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-02 15:30 [PATCH] loop: reintroduce global lock for safe loop_validate_file() traversal Tetsuo Handa
2021-07-02 17:28 ` Tetsuo Handa
2021-07-06 5:46 ` Christoph Hellwig [this message]
2021-07-06 11:19 ` [PATCH v2] " Tetsuo Handa
2021-07-06 14:40 ` [PATCH v3] " Tetsuo Handa
2021-07-19 13:34 ` Tetsuo Handa
2021-07-23 16:19 ` Jens Axboe
2021-07-24 6:57 ` Christoph Hellwig
2021-07-04 5:42 ` [PATCH] " Tetsuo Handa
2021-07-06 5:43 ` Christoph Hellwig
2021-07-06 14:35 ` Arjan van de Ven
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=20210706054622.GE17027@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=pasha.tatashin@soleen.com \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=pvorel@suse.cz \
--cc=tyhicks@linux.microsoft.com \
/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;
as well as URLs for NNTP newsgroup(s).