ext4: don't put symlink in pagecache into highmem
Subsystems (3)
PATCH 1/1 ext4: don't put symlink in pagecache into highmem
From: Jin Qian <[email protected]>
partial backport of 21fc61c73c3903c4c312d0802da01ec2b323d174.
ext4_encrypted_follow_link uses kmap() for cpage
caddr = kmap(cpage);
_ext4_fname_disk_to_usr calls virt_to_page on the kmapped address.
_ext4_fname_disk_to_usr()
ext4_fname_decrypt()
sg_init_one()
sg_init_one(&src_sg, iname->name, iname->len);
sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));Signed-off-by Al Viro <[email protected]>
Signed-off-by Jin Qian <[email protected]>
--- fs/ext4/inode.c | 1 + fs/ext4/namei.c | 1 + fs/ext4/symlink.c | 10 +++------- fs/inode.c | 6 ++++++ include/linux/fs.h | 1 + 5 files changed, 12 insertions(+), 7 deletions(-)
fs/ext4/inode.c +1 -0
@@ -4417,6 +4417,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) inode->i_op = &ext4_symlink_inode_operations;ext4_set_aops (inode); } +inode_nohighmem (inode); }else if (S_ISCHR (inode->i_mode) ||S_ISBLK (inode->i_mode) ||S_ISFIFO (inode->i_mode) ||S_ISSOCK (inode->i_mode)) { inode->i_op = &ext4_special_inode_operations;
fs/ext4/namei.c +1 -0
@@ -3151,6 +3151,7 @@ static int ext4_symlink(struct inode *dir,if ((disk_link.len >EXT4_N_BLOCKS *4 )) {if (!encryption_required) inode->i_op = &ext4_symlink_inode_operations; +inode_nohighmem (inode);ext4_set_aops (inode);/* * We cannot call page_symlink() with transaction started
fs/ext4/symlink.c +3 -7
@@ -45,7 +45,7 @@ static const char *ext4_encrypted_follow_link(struct dentry *dentry, void **cook cpage =read_mapping_page (inode->i_mapping,0 ,NULL );if (IS_ERR (cpage))return ERR_CAST (cpage); - caddr =kmap (cpage); + caddr =page_address (cpage); caddr[size] =0 ; }
@@ -75,16 +75,12 @@ static const char *ext4_encrypted_follow_link(struct dentry *dentry, void **cook/* Null-terminate the name */ if (res <= plen) paddr[res] ='\0' ; -if (cpage) { -kunmap (cpage); +if (cpage)page_cache_release (cpage); - }return *cookie = paddr; errout: -if (cpage) { -kunmap (cpage); +if (cpage)page_cache_release (cpage); - }kfree (paddr);return ERR_PTR (res); }
fs/inode.c +6 -0
@@ -2028,3 +2028,9 @@ void inode_set_flags(struct inode *inode, unsigned int flags, new_flags) != old_flags)); }EXPORT_SYMBOL (inode_set_flags); + +void inode_nohighmem (struct inode *inode) +{ +mapping_set_gfp_mask (inode->i_mapping,GFP_USER ); +} +EXPORT_SYMBOL (inode_nohighmem);
include/linux/fs.h +1 -0
@@ -3066,5 +3066,6 @@ static inline bool dir_relax(struct inode *inode) }extern bool path_noexec (const struct path *path); +extern void inode_nohighmem (struct inode *inode);#endif /* _LINUX_FS_H */
Signature · 1 line
2.16.0.rc1.238.g530d649a79-goog
Theodore Ts'o
maintainerQuoted 3 lines · Jin Qian
From: Jin Qian <[email protected]>
partial backport of
21fc61c73c3903c4c312d0802da01ec2b323d174.
Hi Jin,
When you do a partial backport like this, it would be helpful you could indicate which kernel version(s) it is meant for, since there are many stable kernel trees.
Thanks!!
- Ted