From: Eric Biggers <ebiggers@kernel.org>
To: Avri Altman <Avri.Altman@wdc.com>
Cc: Satya Tangirala <satyat@google.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
Alim Akhtar <alim.akhtar@samsung.com>,
Barani Muthukumaran <bmuthuku@qti.qualcomm.com>,
Kuohong Wang <kuohong.wang@mediatek.com>,
Kim Boojin <boojin.kim@samsung.com>,
Stanley Chu <stanley.chu@mediatek.com>
Subject: Re: [PATCH v4 2/3] scsi: ufs: UFS crypto API
Date: Wed, 8 Jul 2020 09:00:06 -0700 [thread overview]
Message-ID: <20200708160006.GB915@sol.localdomain> (raw)
In-Reply-To: <SN6PR04MB4640E8B9BB10FD5A5C2740D1FC670@SN6PR04MB4640.namprd04.prod.outlook.com>
On Wed, Jul 08, 2020 at 07:44:28AM +0000, Avri Altman wrote:
> > +
> > +static enum blk_crypto_mode_num
> > +ufshcd_find_blk_crypto_mode(union ufs_crypto_cap_entry cap)
> > +{
> > + int i;
> > +
> > + for (i = 0; i < ARRAY_SIZE(ufs_crypto_algs); i++) {
> > + BUILD_BUG_ON(UFS_CRYPTO_KEY_SIZE_INVALID != 0);
> > + if (ufs_crypto_algs[i].ufs_alg == cap.algorithm_id &&
> > + ufs_crypto_algs[i].ufs_key_size == cap.key_size) {
> > + return i;
> > + }
> > + }
> > + return BLK_ENCRYPTION_MODE_INVALID;
> BLK_ENCRYPTION_MODE_INVALID is 0, but 0 is a valid mode num?
ufs_crypto_algs[] does have to contain an entry for BLK_ENCRYPTION_MODE_INVALID,
but it's an empty entry with ufs_key_size == UFS_CRYPTO_KEY_SIZE_INVALID (0).
So it will never be selected and the code is correct.
We should probably start iterating at 1 to make this clearer, though note that
the code still needs to handle empty entries anyway in case any gaps are ever
introduced into the BLK_ENCRYPTION_MODE_* values.
- Eric
next prev parent reply other threads:[~2020-07-08 16:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20200706200432epcas5p1d276cdebadfecc3984de37a80c4b19f2@epcas5p1.samsung.com>
2020-07-06 20:04 ` [PATCH v4 0/3] Inline Encryption Support for UFS Satya Tangirala
2020-07-06 20:04 ` [PATCH v4 1/3] scsi: ufs: UFS driver v2.1 spec crypto additions Satya Tangirala
2020-07-06 20:04 ` [PATCH v4 2/3] scsi: ufs: UFS crypto API Satya Tangirala
2020-07-08 7:44 ` Avri Altman
2020-07-08 16:00 ` Eric Biggers [this message]
2020-07-06 20:04 ` [PATCH v4 3/3] scsi: ufs: Add inline encryption support to UFS Satya Tangirala
2020-07-07 0:13 ` [PATCH v4 0/3] Inline Encryption Support for UFS Eric Biggers
2020-07-08 7:46 ` Avri Altman
2020-07-07 17:36 ` Alim Akhtar
2020-07-07 17:59 ` Eric Biggers
2020-07-08 6:06 ` Martin K. Petersen
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=20200708160006.GB915@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=Avri.Altman@wdc.com \
--cc=alim.akhtar@samsung.com \
--cc=bmuthuku@qti.qualcomm.com \
--cc=boojin.kim@samsung.com \
--cc=kuohong.wang@mediatek.com \
--cc=linux-scsi@vger.kernel.org \
--cc=satyat@google.com \
--cc=stanley.chu@mediatek.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