add patch fix-block_validity-documentation
[ext4-patch-queue.git] / fix-reading-new-encrypted-symlinks-on-no-journal-file-systems
blob5fc13fc2bc6971f9342c499bfa3714b2701ce1a6
1 ext4: fix reading new encrypted symlinks on no-journal file systems
3 On a filesystem with no journal, a symlink longer than about 32
4 characters (exact length depending on padding for encryption) could not
5 be followed or read immediately after being created in an encrypted
6 directory.  This happened because when the symlink data went through the
7 delayed allocation path instead of the journaling path, the symlink was
8 incorrectly detected as a "fast" symlink rather than a "slow" symlink
9 until its data was written out.
11 To fix this, disable delayed allocation for symlinks, since there is
12 no benefit for delayed allocation anyway.
14 Reported-by: Eric Biggers <ebiggers@google.com>
15 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
17 ---
18  fs/ext4/inode.c | 3 ++-
19  1 file changed, 2 insertions(+), 1 deletion(-)
21 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
22 index 59a518ad6bb2..a1eac0054203 100644
23 --- a/fs/ext4/inode.c
24 +++ b/fs/ext4/inode.c
25 @@ -2902,7 +2902,8 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
27         index = pos >> PAGE_SHIFT;
29 -       if (ext4_nonda_switch(inode->i_sb)) {
30 +       if (ext4_nonda_switch(inode->i_sb) ||
31 +           S_ISLNK(inode->i_mode)) {
32                 *fsdata = (void *)FALL_BACK_TO_NONDELALLOC;
33                 return ext4_write_begin(file, mapping, pos,
34                                         len, flags, pagep, fsdata);