[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200422092250.GA12290@infradead.org>
Date: Wed, 22 Apr 2020 02:22:50 -0700
From: Christoph Hellwig <hch@...radead.org>
To: Satya Tangirala <satyat@...gle.com>
Cc: linux-block@...r.kernel.org, linux-scsi@...r.kernel.org,
linux-fscrypt@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-f2fs-devel@...ts.sourceforge.net, linux-ext4@...r.kernel.org,
Barani Muthukumaran <bmuthuku@....qualcomm.com>,
Kuohong Wang <kuohong.wang@...iatek.com>,
Kim Boojin <boojin.kim@...sung.com>,
Eric Biggers <ebiggers@...gle.com>
Subject: Re: [PATCH v10 02/12] block: Keyslot Manager for Inline Encryption
> +bool blk_ksm_crypto_cfg_supported(struct blk_keyslot_manager *ksm,
> + const struct blk_crypto_config *cfg)
> +{
> + if (!ksm)
> + return false;
> + return (ksm->crypto_modes_supported[cfg->crypto_mode] &
> + cfg->data_unit_size) &&
> + (ksm->max_dun_bytes_supported >= cfg->dun_bytes);
Nit: why not expand this a bit to be more readable:
if (!(ksm->crypto_modes_supported[cfg->crypto_mode] &
cfg->data_unit_size))
return false;
if (ksm->max_dun_bytes_supported < cfg->dun_bytes)
return false;
return true;
> +int blk_ksm_evict_key(struct blk_keyslot_manager *ksm,
> + const struct blk_crypto_key *key)
> +{
> + struct blk_ksm_keyslot *slot;
> + int err = 0;
> +
> + blk_ksm_hw_enter(ksm);
> + slot = blk_ksm_find_keyslot(ksm, key);
> + if (!slot)
> + goto out_unlock;
> +
> + if (atomic_read(&slot->slot_refs) != 0) {
> + err = -EBUSY;
> + goto out_unlock;
> + }
This check looks racy.
Powered by blists - more mailing lists