mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 03:35:32 -04:00
fs/buffer: Remove fs-layer decryption code
Now that fscrypt's file contents en/decryption is always implemented using blk-crypto when the filesystem is block-based, the fs-layer decryption code in fs/buffer.c is unused code. Remove it. Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Christian Brauner (Amutable) <brauner@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20260713023708.9245-12-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org>
This commit is contained in:
45
fs/buffer.c
45
fs/buffer.c
@@ -336,7 +336,7 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
|
||||
spin_unlock_irqrestore(&first->b_uptodate_lock, flags);
|
||||
}
|
||||
|
||||
struct postprocess_bh_ctx {
|
||||
struct verify_bh_ctx {
|
||||
struct work_struct work;
|
||||
struct buffer_head *bh;
|
||||
struct fsverity_info *vi;
|
||||
@@ -344,8 +344,8 @@ struct postprocess_bh_ctx {
|
||||
|
||||
static void verify_bh(struct work_struct *work)
|
||||
{
|
||||
struct postprocess_bh_ctx *ctx =
|
||||
container_of(work, struct postprocess_bh_ctx, work);
|
||||
struct verify_bh_ctx *ctx =
|
||||
container_of(work, struct verify_bh_ctx, work);
|
||||
struct buffer_head *bh = ctx->bh;
|
||||
bool valid;
|
||||
|
||||
@@ -355,29 +355,6 @@ static void verify_bh(struct work_struct *work)
|
||||
kfree(ctx);
|
||||
}
|
||||
|
||||
static void decrypt_bh(struct work_struct *work)
|
||||
{
|
||||
struct postprocess_bh_ctx *ctx =
|
||||
container_of(work, struct postprocess_bh_ctx, work);
|
||||
struct buffer_head *bh = ctx->bh;
|
||||
int err;
|
||||
|
||||
err = fscrypt_decrypt_pagecache_blocks(bh->b_folio, bh->b_size,
|
||||
bh_offset(bh));
|
||||
if (err == 0 && ctx->vi) {
|
||||
/*
|
||||
* We use different work queues for decryption and for verity
|
||||
* because verity may require reading metadata pages that need
|
||||
* decryption, and we shouldn't recurse to the same workqueue.
|
||||
*/
|
||||
INIT_WORK(&ctx->work, verify_bh);
|
||||
fsverity_enqueue_verify_work(&ctx->work);
|
||||
return;
|
||||
}
|
||||
end_buffer_async_read(bh, err == 0);
|
||||
kfree(ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
* I/O completion handler for block_read_full_folio() - folios
|
||||
* which come unlocked at the end of I/O.
|
||||
@@ -387,27 +364,21 @@ static void bh_end_async_read(struct bio *bio)
|
||||
struct buffer_head *bh;
|
||||
bool uptodate = bio_endio_bh(bio, &bh);
|
||||
struct inode *inode = bh->b_folio->mapping->host;
|
||||
bool decrypt = fscrypt_inode_uses_fs_layer_crypto(inode);
|
||||
struct fsverity_info *vi = NULL;
|
||||
|
||||
/* needed by ext4 */
|
||||
if (bh->b_folio->index < DIV_ROUND_UP(inode->i_size, PAGE_SIZE))
|
||||
vi = fsverity_get_info(inode);
|
||||
|
||||
/* Decrypt (with fscrypt) and/or verify (with fsverity) if needed. */
|
||||
if (uptodate && (decrypt || vi)) {
|
||||
struct postprocess_bh_ctx *ctx = kmalloc_obj(*ctx, GFP_ATOMIC);
|
||||
/* Verify (with fsverity) if needed. */
|
||||
if (vi && uptodate) {
|
||||
struct verify_bh_ctx *ctx = kmalloc_obj(*ctx, GFP_ATOMIC);
|
||||
|
||||
if (ctx) {
|
||||
ctx->bh = bh;
|
||||
ctx->vi = vi;
|
||||
if (decrypt) {
|
||||
INIT_WORK(&ctx->work, decrypt_bh);
|
||||
fscrypt_enqueue_decrypt_work(&ctx->work);
|
||||
} else {
|
||||
INIT_WORK(&ctx->work, verify_bh);
|
||||
fsverity_enqueue_verify_work(&ctx->work);
|
||||
}
|
||||
INIT_WORK(&ctx->work, verify_bh);
|
||||
fsverity_enqueue_verify_work(&ctx->work);
|
||||
return;
|
||||
}
|
||||
uptodate = false;
|
||||
|
||||
Reference in New Issue
Block a user