From f1ba071294f77cb13385bbe3e7a7c2f6a815e6f3 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 16 Apr 2015 13:27:55 -0400 Subject: [PATCH] update encryption patches --- add-symlink-encryption | 24 +++++++------- implement-the-ext4-decryption-read-path | 40 +++++++---------------- implement-the-ext4-encryption-write-path | 56 ++++++++++++-------------------- 3 files changed, 43 insertions(+), 77 deletions(-) diff --git a/add-symlink-encryption b/add-symlink-encryption index 7114d91c..3f9e6805 100644 --- a/add-symlink-encryption +++ b/add-symlink-encryption @@ -7,9 +7,9 @@ Signed-off-by: Theodore Ts'o fs/ext4/ext4.h | 1 + fs/ext4/ext4_crypto.h | 20 +++++++++++ fs/ext4/inode.c | 5 +-- - fs/ext4/namei.c | 85 +++++++++++++++++++++++++++++++++++----------- - fs/ext4/symlink.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++- - 5 files changed, 185 insertions(+), 23 deletions(-) + fs/ext4/namei.c | 85 ++++++++++++++++++++++++++++++++++++----------- + fs/ext4/symlink.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++- + 5 files changed, 184 insertions(+), 23 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 98a5617..c79db59 100644 @@ -53,10 +53,10 @@ index f7d46e8..c2ba35a 100644 + #endif /* _EXT4_CRYPTO_H */ diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c -index 5b6b7b6..c87bb7a 100644 +index 1a0d4ee..355c8b6 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c -@@ -143,7 +143,7 @@ static int ext4_meta_trans_blocks(struct inode *inode, int lblocks, +@@ -142,7 +142,7 @@ static int ext4_meta_trans_blocks(struct inode *inode, int lblocks, /* * Test whether an inode is a fast symlink. */ @@ -65,7 +65,7 @@ index 5b6b7b6..c87bb7a 100644 { int ea_blocks = EXT4_I(inode)->i_file_acl ? EXT4_CLUSTER_SIZE(inode->i_sb) >> 9 : 0; -@@ -4177,7 +4177,8 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) +@@ -4176,7 +4176,8 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) inode->i_op = &ext4_dir_inode_operations; inode->i_fop = &ext4_dir_operations; } else if (S_ISLNK(inode->i_mode)) { @@ -76,7 +76,7 @@ index 5b6b7b6..c87bb7a 100644 nd_terminate_link(ei->i_data, inode->i_size, sizeof(ei->i_data) - 1); diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c -index e8f82b2..0d9057a 100644 +index 7326f9f..8157dbb 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -3183,16 +3183,24 @@ static int ext4_symlink(struct inode *dir, @@ -224,14 +224,12 @@ index e8f82b2..0d9057a 100644 iput(inode); return err; diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c -index ff37119..6f71c2c 100644 +index ff37119..3f72274 100644 --- a/fs/ext4/symlink.c +++ b/fs/ext4/symlink.c -@@ -22,9 +22,99 @@ - #include +@@ -23,8 +23,97 @@ #include "ext4.h" #include "xattr.h" -+#include "ext4_crypto.h" +#ifdef CONFIG_EXT4_FS_ENCRYPTION static void *ext4_follow_link(struct dentry *dentry, struct nameidata *nd) @@ -327,7 +325,7 @@ index ff37119..6f71c2c 100644 struct ext4_inode_info *ei = EXT4_I(dentry->d_inode); nd_set_link(nd, (char *) ei->i_data); return NULL; -@@ -32,8 +122,13 @@ static void *ext4_follow_link(struct dentry *dentry, struct nameidata *nd) +@@ -32,8 +121,13 @@ static void *ext4_follow_link(struct dentry *dentry, struct nameidata *nd) const struct inode_operations ext4_symlink_inode_operations = { .readlink = generic_readlink, @@ -341,7 +339,7 @@ index ff37119..6f71c2c 100644 .setattr = ext4_setattr, .setxattr = generic_setxattr, .getxattr = generic_getxattr, -@@ -43,7 +138,7 @@ const struct inode_operations ext4_symlink_inode_operations = { +@@ -43,7 +137,7 @@ const struct inode_operations ext4_symlink_inode_operations = { const struct inode_operations ext4_fast_symlink_inode_operations = { .readlink = generic_readlink, diff --git a/implement-the-ext4-decryption-read-path b/implement-the-ext4-decryption-read-path index 8b688cca..2cbbe9a9 100644 --- a/implement-the-ext4-decryption-read-path +++ b/implement-the-ext4-decryption-read-path @@ -7,24 +7,16 @@ Signed-off-by: Michael Halcrow Signed-off-by: Ildar Muslukhov Signed-off-by: Theodore Ts'o --- - fs/ext4/file.c | 19 +++++++++++++++++-- - fs/ext4/inode.c | 8 ++++++++ - fs/ext4/readpage.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- - 3 files changed, 90 insertions(+), 3 deletions(-) + fs/ext4/file.c | 18 ++++++++++++++-- + fs/ext4/inode.c | 7 ++++++ + fs/ext4/readpage.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- + 3 files changed, 88 insertions(+), 3 deletions(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c -index 8131be8..756d10f 100644 +index fcc6c13..b132a3c 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c -@@ -28,6 +28,7 @@ - #include - #include "ext4.h" - #include "ext4_jbd2.h" -+#include "ext4_crypto.h" - #include "xattr.h" - #include "acl.h" - -@@ -200,6 +201,13 @@ static const struct vm_operations_struct ext4_file_vm_ops = { +@@ -218,6 +218,13 @@ static const struct vm_operations_struct ext4_file_vm_ops = { static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma) { @@ -36,9 +28,9 @@ index 8131be8..756d10f 100644 + return 0; + } file_accessed(file); - vma->vm_ops = &ext4_file_vm_ops; - return 0; -@@ -212,6 +220,7 @@ static int ext4_file_open(struct inode * inode, struct file * filp) + if (IS_DAX(file_inode(file))) { + vma->vm_ops = &ext4_dax_vm_ops; +@@ -235,6 +242,7 @@ static int ext4_file_open(struct inode * inode, struct file * filp) struct vfsmount *mnt = filp->f_path.mnt; struct path path; char buf[64], *cp; @@ -46,7 +38,7 @@ index 8131be8..756d10f 100644 if (unlikely(!(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED) && !(sb->s_flags & MS_RDONLY))) { -@@ -250,11 +259,17 @@ static int ext4_file_open(struct inode * inode, struct file * filp) +@@ -273,11 +281,17 @@ static int ext4_file_open(struct inode * inode, struct file * filp) * writing and the journal is present */ if (filp->f_mode & FMODE_WRITE) { @@ -67,18 +59,10 @@ index 8131be8..756d10f 100644 /* diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c -index dcc836c..5b6b7b6 100644 +index 7c4527e..8b4fe62 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c -@@ -39,6 +39,7 @@ - #include - #include - #include -+#include - - #include "ext4_jbd2.h" - #include "ext4_crypto.h" -@@ -3363,6 +3364,13 @@ static int ext4_block_zero_page_range(handle_t *handle, +@@ -3370,6 +3370,13 @@ static int __ext4_block_zero_page_range(handle_t *handle, /* Uhhuh. Read error. Complain and punt. */ if (!buffer_uptodate(bh)) goto unlock; diff --git a/implement-the-ext4-encryption-write-path b/implement-the-ext4-encryption-write-path index 1fe2655c..289a6793 100644 --- a/implement-the-ext4-encryption-write-path +++ b/implement-the-ext4-encryption-write-path @@ -11,11 +11,11 @@ Signed-off-by: Michael Halcrow Signed-off-by: Ildar Muslukhov Signed-off-by: Theodore Ts'o --- - fs/ext4/extents.c | 17 +++++++++++++++++ - fs/ext4/ialloc.c | 5 +++++ - fs/ext4/inode.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- - fs/ext4/page-io.c | 46 +++++++++++++++++++++++++++++++++++++++++----- - 4 files changed, 175 insertions(+), 6 deletions(-) + fs/ext4/extents.c | 17 +++++++++ + fs/ext4/ialloc.c | 5 +++ + fs/ext4/inode.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- + fs/ext4/page-io.c | 45 ++++++++++++++++++++--- + 4 files changed, 173 insertions(+), 6 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 74580ea..973816b 100644 @@ -69,18 +69,10 @@ index 6ab6f63..247737e 100644 if (IS_DIRSYNC(inode)) ext4_handle_sync(handle); diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c -index cd30091..77b7ff2 100644 +index cd30091..7c4527e 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c -@@ -39,6 +39,7 @@ - #include - - #include "ext4_jbd2.h" -+#include "ext4_crypto.h" - #include "xattr.h" - #include "acl.h" - #include "truncate.h" -@@ -886,6 +887,95 @@ int do_journal_get_write_access(handle_t *handle, +@@ -886,6 +886,95 @@ int do_journal_get_write_access(handle_t *handle, static int ext4_get_block_write_nolock(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create); @@ -176,7 +168,7 @@ index cd30091..77b7ff2 100644 static int ext4_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata) -@@ -948,11 +1038,19 @@ retry_journal: +@@ -948,11 +1037,19 @@ retry_journal: /* In case writeback began while the page was unlocked */ wait_for_stable_page(page); @@ -197,7 +189,7 @@ index cd30091..77b7ff2 100644 if (!ret && ext4_should_journal_data(inode)) { ret = ext4_walk_page_buffers(handle, page_buffers(page), from, to, NULL, -@@ -2574,7 +2672,12 @@ retry_journal: +@@ -2574,7 +2671,12 @@ retry_journal: /* In case writeback began while the page was unlocked */ wait_for_stable_page(page); @@ -210,7 +202,7 @@ index cd30091..77b7ff2 100644 if (ret < 0) { unlock_page(page); ext4_journal_stop(handle); -@@ -3032,6 +3135,9 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb, +@@ -3032,6 +3134,9 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb, get_block_func = ext4_get_block_write; dio_flags = DIO_LOCKING; } @@ -220,7 +212,7 @@ index cd30091..77b7ff2 100644 if (IS_DAX(inode)) ret = dax_do_io(rw, iocb, inode, iter, offset, get_block_func, ext4_end_io_dio, dio_flags); -@@ -3096,6 +3202,11 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb, +@@ -3096,6 +3201,11 @@ static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb, size_t count = iov_iter_count(iter); ssize_t ret; @@ -233,18 +225,10 @@ index cd30091..77b7ff2 100644 * If we are doing data journalling we don't support O_DIRECT */ diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c -index 5687e47..f264fc8 100644 +index 5687e47..51a5f12 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c -@@ -26,6 +26,7 @@ - #include - - #include "ext4_jbd2.h" -+#include "ext4_crypto.h" - #include "xattr.h" - #include "acl.h" - -@@ -67,6 +68,10 @@ static void ext4_finish_bio(struct bio *bio) +@@ -67,6 +67,10 @@ static void ext4_finish_bio(struct bio *bio) bio_for_each_segment_all(bvec, bio, i) { struct page *page = bvec->bv_page; @@ -255,7 +239,7 @@ index 5687e47..f264fc8 100644 struct buffer_head *bh, *head; unsigned bio_start = bvec->bv_offset; unsigned bio_end = bio_start + bvec->bv_len; -@@ -76,6 +81,15 @@ static void ext4_finish_bio(struct bio *bio) +@@ -76,6 +80,15 @@ static void ext4_finish_bio(struct bio *bio) if (!page) continue; @@ -271,7 +255,7 @@ index 5687e47..f264fc8 100644 if (error) { SetPageError(page); set_bit(AS_EIO, &page->mapping->flags); -@@ -100,8 +114,13 @@ static void ext4_finish_bio(struct bio *bio) +@@ -100,8 +113,13 @@ static void ext4_finish_bio(struct bio *bio) } while ((bh = bh->b_this_page) != head); bit_spin_unlock(BH_Uptodate_Lock, &head->b_state); local_irq_restore(flags); @@ -286,7 +270,7 @@ index 5687e47..f264fc8 100644 } } -@@ -376,6 +395,7 @@ static int io_submit_init_bio(struct ext4_io_submit *io, +@@ -376,6 +394,7 @@ static int io_submit_init_bio(struct ext4_io_submit *io, static int io_submit_add_bh(struct ext4_io_submit *io, struct inode *inode, @@ -294,7 +278,7 @@ index 5687e47..f264fc8 100644 struct buffer_head *bh) { int ret; -@@ -389,7 +409,7 @@ submit_and_retry: +@@ -389,7 +408,7 @@ submit_and_retry: if (ret) return ret; } @@ -303,7 +287,7 @@ index 5687e47..f264fc8 100644 if (ret != bh->b_size) goto submit_and_retry; io->io_next_block++; -@@ -402,6 +422,7 @@ int ext4_bio_write_page(struct ext4_io_submit *io, +@@ -402,6 +421,7 @@ int ext4_bio_write_page(struct ext4_io_submit *io, struct writeback_control *wbc, bool keep_towrite) { @@ -311,7 +295,7 @@ index 5687e47..f264fc8 100644 struct inode *inode = page->mapping->host; unsigned block_start, blocksize; struct buffer_head *bh, *head; -@@ -461,19 +482,29 @@ int ext4_bio_write_page(struct ext4_io_submit *io, +@@ -461,19 +481,29 @@ int ext4_bio_write_page(struct ext4_io_submit *io, set_buffer_async_write(bh); } while ((bh = bh->b_this_page) != head); @@ -344,7 +328,7 @@ index 5687e47..f264fc8 100644 break; } nr_submitted++; -@@ -482,6 +513,11 @@ int ext4_bio_write_page(struct ext4_io_submit *io, +@@ -482,6 +512,11 @@ int ext4_bio_write_page(struct ext4_io_submit *io, /* Error stopped previous loop? Clean up buffers... */ if (ret) { -- 2.11.4.GIT