Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36c6512e authored by Neeraj Soni's avatar Neeraj Soni Committed by Veerabhadrarao Badiganti
Browse files

Enable hardware based FBE on f2fs and adapt ext4 fs



Hardware File Based Encryption (FBE) uses crypto engine to
encrypt the user data with unique key for each file.
File name and data both are encrypted with this feature.
1. security/pfk: changes to support per file
   encryption for f2fs using hardware crypto engine.
2. fs/ext4: adapted crypto APIs for generic crypto layer.
3. fs/f2fs: support hardware crypto engine based per file
   encryption.
4. fs/crypto: export APIs to support hardware crypto
   engine based per file encryption.
Other changes made to provide support framework for per
file encryption.

Change-Id: I7981fa7f8f0c4bc058b80b7b8e342cfd81697c74
Signed-off-by: default avatarNeeraj Soni <neersoni@codeaurora.org>
parent 7bcb1bb4
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -565,6 +565,15 @@ inline int bio_phys_segments(struct request_queue *q, struct bio *bio)
}
EXPORT_SYMBOL(bio_phys_segments);

static inline void bio_clone_crypt_key(struct bio *dst, const struct bio *src)
{
#ifdef CONFIG_PFK
	dst->bi_crypt_key = src->bi_crypt_key;
	dst->bi_iter.bi_dun = src->bi_iter.bi_dun;
#endif
	dst->bi_dio_inode = src->bi_dio_inode;
}

/**
 * 	__bio_clone_fast - clone a bio that shares the original bio's biovec
 * 	@bio: destination bio
@@ -590,6 +599,7 @@ void __bio_clone_fast(struct bio *bio, struct bio *bio_src)
	bio->bi_iter = bio_src->bi_iter;
	bio->bi_io_vec = bio_src->bi_io_vec;
	bio->bi_dio_inode = bio_src->bi_dio_inode;
	bio_clone_crypt_key(bio, bio_src);
	bio_clone_blkcg_association(bio, bio_src);
}
EXPORT_SYMBOL(__bio_clone_fast);
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@
#include <linux/scatterlist.h>
#include <linux/pfk.h>
#include <trace/events/block.h>

#include <linux/pfk.h>
#include "blk.h"

static struct bio *blk_bio_discard_split(struct request_queue *q,
+4 −1
Original line number Diff line number Diff line
@@ -425,7 +425,10 @@ int elv_merge(struct request_queue *q, struct request **req, struct bio *bio)
	/*
	 * First try one-hit cache.
	 */
	if (q->last_merge && elv_bio_merge_ok(q->last_merge, bio)) {
	if (q->last_merge) {
		if (!elv_bio_merge_ok(q->last_merge, bio))
			return ELEVATOR_NO_MERGE;

		ret = blk_try_merge(q->last_merge, bio);
		if (ret != ELEVATOR_NO_MERGE) {
			*req = q->last_merge;
+2 −0
Original line number Diff line number Diff line
@@ -2044,6 +2044,8 @@ static void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q)
	if (!shost->use_clustering)
		q->limits.cluster = 0;

	if (shost->inlinecrypt_support)
		queue_flag_set_unlocked(QUEUE_FLAG_INLINECRYPT, q);
	/*
	 * Set a reasonable default alignment:  The larger of 32-byte (dword),
	 * which is a common minimum for HBAs, and the minimum DMA alignment,
+14 −5
Original line number Diff line number Diff line
@@ -897,11 +897,18 @@ static int ufs_qcom_crypto_req_setup(struct ufs_hba *hba,
		req = lrbp->cmd->request;
	else
		return 0;

	/* Use request LBA as the DUN value */
	if (req->bio)
		*dun = (req->bio->bi_iter.bi_sector) >>
				UFS_QCOM_ICE_TR_DATA_UNIT_4_KB;
	/*
	 * Right now ICE do not support variable dun but can be
	 * taken as future enhancement
	 * if (bio_dun(req->bio)) {
	 *      dun @bio can be split, so we have to adjust offset
	 *      *dun = bio_dun(req->bio);
	 * } else
	 */
	if (req->bio) {
		*dun = req->bio->bi_iter.bi_sector;
		*dun >>= UFS_QCOM_ICE_TR_DATA_UNIT_4_KB;
	}

	ret = ufs_qcom_ice_req_setup(host, lrbp->cmd, cc_index, enable);

@@ -2133,6 +2140,8 @@ static int ufs_qcom_init(struct ufs_hba *hba)
		dev_err(dev, "%s: ufs_qcom_ice_get_dev failed %d\n",
			__func__, err);
		goto out_host_free;
	} else {
		hba->host->inlinecrypt_support = 1;
	}

	host->generic_phy = devm_phy_get(dev, "ufsphy");
Loading