linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: luca.boccassi@gmail.com
Cc: linux-block@vger.kernel.org, jonathan.derrick@linux.dev,
	gmazyland@gmail.com, axboe@kernel.dk, brauner@kernel.org,
	stepan.horacek@gmail.com
Subject: Re: [PATCH v2] sed-opal: allow using IOC_OPAL_SAVE for locking too
Date: Sun, 4 Dec 2022 23:09:33 -0800	[thread overview]
Message-ID: <Y42ZLf8uiZEkv5xc@infradead.org> (raw)
In-Reply-To: <20221203001243.16482-1-luca.boccassi@gmail.com>

On Sat, Dec 03, 2022 at 12:12:43AM +0000, luca.boccassi@gmail.com wrote:
> +	 * Usually when closing a crypto device (eg: dm-crypt with LUKS) the volume

As said last time, please correctly format your block comments so that
they don't spill out of 80 characters for every single line and become
completely unreadable.

> +	if (lk_unlk->l_state == OPAL_LK &&
> +			lk_unlk->session.opal_key.key_len == 0) {
> +		struct opal_suspend_data *iter;
> +
> +		setup_opal_dev(dev);
> +		list_for_each_entry(iter, &dev->unlk_lst, node) {
> +			if (iter->unlk.save_for_lock &&
> +					iter->lr == lk_unlk->session.opal_key.lr &&
> +					iter->unlk.session.opal_key.key_len > 0) {
> +				lk_unlk->session.opal_key.key_len =
> +					iter->unlk.session.opal_key.key_len;
> +				memcpy(lk_unlk->session.opal_key.key,
> +					iter->unlk.session.opal_key.key,
> +					iter->unlk.session.opal_key.key_len);
> +				break;
> +			}
> +		}

And please split this logic into a helper.

>  	__u32 l_state;
> -	__u8 __align[4];
> +	__u8 save_for_lock:1; /* if in IOC_OPAL_SAVE will also use key to lock */

Please never use bitfields in ABIs, the psABI rules for them are just
a mess to start with, and not filling all of them leads to leaks of
stack contents as well.  Just turn the entire 4 bytes into a flags
field and then just bitmasks.

  reply	other threads:[~2022-12-05  7:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-02  0:36 [PATCH] sed-opal: if key is available from IOC_OPAL_SAVE use it when locking luca.boccassi
2022-12-02  8:48 ` Christian Brauner
2022-12-02  9:11   ` Christoph Hellwig
2022-12-02 10:28   ` Luca Boccassi
2022-12-02 10:37     ` Christian Brauner
2022-12-03  0:12 ` [PATCH v2] sed-opal: allow using IOC_OPAL_SAVE for locking too luca.boccassi
2022-12-05  7:09   ` Christoph Hellwig [this message]
2022-12-06  0:03 ` [PATCH v3] " luca.boccassi
2022-12-06  8:30   ` Christoph Hellwig
2022-12-06  9:23   ` Christian Brauner
2022-12-06  9:29 ` [PATCH v4] " luca.boccassi
2022-12-08 16:18   ` Jens Axboe
2022-12-08 16:19     ` Luca Boccassi
2022-12-08 16:20   ` Jens Axboe

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=Y42ZLf8uiZEkv5xc@infradead.org \
    --to=hch@infradead.org \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=gmazyland@gmail.com \
    --cc=jonathan.derrick@linux.dev \
    --cc=linux-block@vger.kernel.org \
    --cc=luca.boccassi@gmail.com \
    --cc=stepan.horacek@gmail.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).