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

Commit 4d613c93 authored by Jaegeuk Kim's avatar Jaegeuk Kim Committed by Gerrit - the friendly Code Review server
Browse files

f2fs/fscrypt-ice: disallow bio merged into request



This fixes wrong bio merge into request which breaks encrypted ICE blocks.

Bug: 71554412
Change-Id: I65b5936add01aa62449d46791a736b734022a48c
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@google.com>
Signed-off-by: default avatarNeeraj Soni <neersoni@codeaurora.org>
parent 898fc561
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -1650,6 +1650,7 @@ bool bio_attempt_front_merge(struct request_queue *q, struct request *req,
	bio->bi_next = req->bio;
	req->bio = bio;

	WARN_ON(req->__dun || bio->bi_iter.bi_dun);
	req->__sector = bio->bi_iter.bi_sector;
	req->__data_len += bio->bi_iter.bi_size;
	req->ioprio = ioprio_best(req->ioprio, bio_prio(bio));
@@ -1799,6 +1800,7 @@ void blk_init_request_from_bio(struct request *req, struct bio *bio)
	else
		req->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
	req->write_hint = bio->bi_write_hint;
	req->__dun = bio->bi_iter.bi_dun;
	blk_rq_bio_prep(req->q, req, bio);
}
EXPORT_SYMBOL_GPL(blk_init_request_from_bio);
@@ -2784,8 +2786,11 @@ bool blk_update_request(struct request *req, blk_status_t error,
	req->__data_len -= total_bytes;

	/* update sector only for requests with clear definition of sector */
	if (!blk_rq_is_passthrough(req))
	if (!blk_rq_is_passthrough(req)) {
		req->__sector += total_bytes >> 9;
		if (req->__dun)
			req->__dun += total_bytes >> 12;
	}

	/* mixed attributes always follow the first bio */
	if (req->rq_flags & RQF_MIXED_MERGE) {
@@ -3148,6 +3153,7 @@ static void __blk_rq_prep_clone(struct request *dst, struct request *src)
{
	dst->cpu = src->cpu;
	dst->__sector = blk_rq_pos(src);
	dst->__dun = blk_rq_dun(src);
	dst->__data_len = blk_rq_bytes(src);
	if (src->rq_flags & RQF_SPECIAL_PAYLOAD) {
		dst->rq_flags |= RQF_SPECIAL_PAYLOAD;
+2 −0
Original line number Diff line number Diff line
@@ -845,6 +845,8 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio)

enum elv_merge blk_try_merge(struct request *rq, struct bio *bio)
{
	if (blk_rq_dun(rq) || bio_dun(bio))
		return ELEVATOR_NO_MERGE;
	if (req_op(rq) == REQ_OP_DISCARD &&
	    queue_max_discard_segments(rq->q) > 1)
		return ELEVATOR_DISCARD_MERGE;
+6 −0
Original line number Diff line number Diff line
@@ -154,6 +154,7 @@ struct request {
	unsigned int __data_len;	/* total data len */
	int tag;
	sector_t __sector;		/* sector cursor */
	u64 __dun;			/* dun for UFS */

	struct bio *bio;
	struct bio *biotail;
@@ -1034,6 +1035,11 @@ static inline sector_t blk_rq_pos(const struct request *rq)
	return rq->__sector;
}

static inline sector_t blk_rq_dun(const struct request *rq)
{
	return rq->__dun;
}

static inline unsigned int blk_rq_bytes(const struct request *rq)
{
	return rq->__data_len;