Skip to content

Commit 39e1605

Browse files
martinkpetersenaxboe
authored andcommitted
block: integrity: Do not call set_page_dirty_lock()
Placing multiple protection information buffers inside the same page can lead to oopses because set_page_dirty_lock() can't be called from interrupt context. Since a protection information buffer is not backed by a file there is no point in setting its page dirty, there is nothing to synchronize. Drop the call to set_page_dirty_lock() and remove the last argument to bio_integrity_unpin_bvec(). Cc: [email protected] Fixes: 492c5d4 ("block: bio-integrity: directly map user buffers") Signed-off-by: Martin K. Petersen <[email protected]> Reviewed-by: Keith Busch <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 0b7a481 commit 39e1605

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

block/bio-integrity.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,12 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
6666
}
6767
EXPORT_SYMBOL(bio_integrity_alloc);
6868

69-
static void bio_integrity_unpin_bvec(struct bio_vec *bv, int nr_vecs,
70-
bool dirty)
69+
static void bio_integrity_unpin_bvec(struct bio_vec *bv, int nr_vecs)
7170
{
7271
int i;
7372

74-
for (i = 0; i < nr_vecs; i++) {
75-
if (dirty && !PageCompound(bv[i].bv_page))
76-
set_page_dirty_lock(bv[i].bv_page);
73+
for (i = 0; i < nr_vecs; i++)
7774
unpin_user_page(bv[i].bv_page);
78-
}
7975
}
8076

8177
static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip)
@@ -91,7 +87,7 @@ static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip)
9187
ret = copy_to_iter(bvec_virt(bounce_bvec), bytes, &orig_iter);
9288
WARN_ON_ONCE(ret != bytes);
9389

94-
bio_integrity_unpin_bvec(orig_bvecs, orig_nr_vecs, true);
90+
bio_integrity_unpin_bvec(orig_bvecs, orig_nr_vecs);
9591
}
9692

9793
/**
@@ -111,8 +107,7 @@ void bio_integrity_unmap_user(struct bio *bio)
111107
return;
112108
}
113109

114-
bio_integrity_unpin_bvec(bip->bip_vec, bip->bip_max_vcnt,
115-
bio_data_dir(bio) == READ);
110+
bio_integrity_unpin_bvec(bip->bip_vec, bip->bip_max_vcnt);
116111
}
117112

118113
/**
@@ -198,7 +193,7 @@ static int bio_integrity_copy_user(struct bio *bio, struct bio_vec *bvec,
198193
}
199194

200195
if (write)
201-
bio_integrity_unpin_bvec(bvec, nr_vecs, false);
196+
bio_integrity_unpin_bvec(bvec, nr_vecs);
202197
else
203198
memcpy(&bip->bip_vec[1], bvec, nr_vecs * sizeof(*bvec));
204199

@@ -319,7 +314,7 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter)
319314
return 0;
320315

321316
release_pages:
322-
bio_integrity_unpin_bvec(bvec, nr_bvecs, false);
317+
bio_integrity_unpin_bvec(bvec, nr_bvecs);
323318
free_bvec:
324319
if (bvec != stack_vec)
325320
kfree(bvec);

0 commit comments

Comments
 (0)