Received: by 10.223.176.5 with SMTP id f5csp3587wra; Tue, 6 Feb 2018 15:56:07 -0800 (PST) X-Google-Smtp-Source: AH8x226Jx+L5VqkkLfze6bVARAjxk47Uo84wctBPMg8Jk96018dYrP/c9yBCwlEF04jDl+evnTnN X-Received: by 2002:a17:902:40a:: with SMTP id 10-v6mr3973426ple.88.1517961367022; Tue, 06 Feb 2018 15:56:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517961366; cv=none; d=google.com; s=arc-20160816; b=mr9eizwD/jKouCsiGQ8H2HtCx2kYhw1c76e/CsXeTO5cfYLrH+KbT73mKTDD9g8646 eHugqDmUGfLAxB3OLQmXfuvyNFP75M1OlE+KSy6fgOdndL+4DCxXuF24xQ2R27qROsIr yFyy60PaWmVbbiKIDIGW+4T2jx1jqaSLaGQ6E7wMQVwjeI79ZLEvl82NoISN+A8L6EBy trlxE9gUOg/bu3FCgP5XooD03PrXqkDbEGy4FzPfwhQNTIRzIpAl7bQaYiKz9yefARzL wbncNHlJXBgX8h9/C91VXk0wdzhPc8rwSCx0+wRT6/YpytzKf23ebadW1LaQh4soJJtl Zzrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=729lUuyFgk51mhgNKycHQylmyQGq74T667TSmIy6xUE=; b=dPuz6+SwbA+rX9c1KfdM3Jy//wyt4fWb21wdEfNxJcb62lxJnwO6oZU/puzYwcA96W ddQ1fYxy7UH5H48fRR231Hl7c72Aiq5zrTXL7eu0UHzSGXrn0ZRPSqVV9CPbFG5R21g9 0m8zf1noiiq7Ouw9Wtcx+avx1Jb5fR+mqS3+OZBADv5SNIGO3TRDU8dBHyhj0Kxuym/J GqnDPFSf8KDcoh0pwq4EcV79qcSkkwnRtVKizuLpChayGsssL78w5w1iYcNvOR6AkA54 GQXwdC3y1lcL5Ac0ykumGFKxUlG2x+LgjupU4cw9eL0Ss5rb/QFp6DUbAVzw+hpBVEO1 OHBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=d1Mv1Avy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5si98480pgo.780.2018.02.06.15.55.52; Tue, 06 Feb 2018 15:56:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=d1Mv1Avy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754239AbeBFXye (ORCPT + 99 others); Tue, 6 Feb 2018 18:54:34 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:41086 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754149AbeBFXya (ORCPT ); Tue, 6 Feb 2018 18:54:30 -0500 Received: by mail-pf0-f194.google.com with SMTP id 68so1352704pfj.8 for ; Tue, 06 Feb 2018 15:54:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=729lUuyFgk51mhgNKycHQylmyQGq74T667TSmIy6xUE=; b=d1Mv1AvyQyu1g+zGZF16qtGW5Eb27QCe1sLzcTxHewYmt+AuIL4p4EH7OgrrGJ5Hvr HIPu1Qo2l/FJq/ZnTxzBk5j28is1TfiF9MQejjQh+5yPPIQKlLQCq1PD0kEop9SKWkcd CGPkIhz9dBTKrxJNu+ob0890W/1o5kXnDwRUV6dKjwWutz3saxUB6nRHnGTV+SDY7iz0 4fxwcsrUuXIgDSEKeqZKraDV/XTBhq/EsV/Pex9Cio3ogiOoNokr5HsS22eeUZBNGptE Rp/U8H/AwHUIplnce5azwq410zO9USQlv1US2J+FzNDtUjfyu+ktCX+l8U8jC+1wn0X2 rWjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=729lUuyFgk51mhgNKycHQylmyQGq74T667TSmIy6xUE=; b=hU/DrnLG+2QwJ9ofvxZDzT3O4Un5hKv9jpXddmWqJjy56lDO6moZP1ao3Hs4SKaQI1 MPcMKaWMOeXJZEAN/f+DL3JaI9FHKyA4YbSjVseST/RdcG9nR6ZS04ueZdbEYjjuHoO3 HNiywbareT7Wh5rBmZzyVC+Z2CNLlcTQ8N9zQ0X07G9OG/ECKkFRLRVqIr4xEXyEUpZI jtUI08D/v08Ct64FRJtx6A57rlsQs5xtXnYsAoJTlX/CoEP5K9bFyNASDQZ/T2XdLiSl sC0/vqrG2kAfviCmgmrjAnPXCg2ngX0btKr4cjWFThPhBP99bu1WMe6O78F5KjXmfADC uCDg== X-Gm-Message-State: APf1xPB7afbCkBJfvzusxn1wYuizO+8eafwpk4ph9u8N5t998Te+Vim5 1TO8JmCdxa0lcyQMfWqoDcEQpA== X-Received: by 10.101.70.12 with SMTP id v12mr3262118pgq.327.1517961270320; Tue, 06 Feb 2018 15:54:30 -0800 (PST) Received: from jinqian2.mtv.corp.google.com ([2620:0:1000:1601:756c:3217:2035:e37b]) by smtp.gmail.com with ESMTPSA id g15sm163138pgu.52.2018.02.06.15.54.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Feb 2018 15:54:29 -0800 (PST) From: Jin Qian To: "Theodore Ts'o" , Andreas Dilger , Jaegeuk Kim , Changman Lee , Chao Yu , Alexander Viro , Jeff Layton , "J. Bruce Fields" , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org Cc: Jin Qian , linux-stable , Jin Qian Subject: [PATCHv2 1/1] ext4/f2fs: don't put symlink in pagecache into highmem Date: Tue, 6 Feb 2018 15:53:53 -0800 Message-Id: <20180206235354.79591-1-jinqian@android.com> X-Mailer: git-send-email 2.16.0.rc1.238.g530d649a79-goog Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jin Qian partial backport from 21fc61c73c3903c4c312d0802da01ec2b323d174 upstream to v4.4 to prevent virt_to_page on highmem. 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)); Cc: linux-stable # 4.4.y Signed-off-by: Al Viro Signed-off-by: Jin Qian Signed-off-by: Jin Qian --- fs/ext4/inode.c | 1 + fs/ext4/namei.c | 1 + fs/ext4/symlink.c | 10 +++------- fs/f2fs/inode.c | 1 + fs/f2fs/namei.c | 5 ++--- fs/inode.c | 6 ++++++ include/linux/fs.h | 1 + 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 4df1cb19a243..f0cabc8c96cb 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -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; diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 4c36dca486cc..32960b3ecd4f 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -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 diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c index e8e7af62ac95..287c3980fa0b 100644 --- a/fs/ext4/symlink.c +++ b/fs/ext4/symlink.c @@ -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); } diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index 97e20decacb4..5528801a5baf 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -202,6 +202,7 @@ make_now: inode->i_op = &f2fs_encrypted_symlink_inode_operations; else inode->i_op = &f2fs_symlink_inode_operations; + inode_nohighmem(inode); inode->i_mapping->a_ops = &f2fs_dblock_aops; } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index 2c32110f9fc0..484df6850747 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -351,6 +351,7 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry, inode->i_op = &f2fs_encrypted_symlink_inode_operations; else inode->i_op = &f2fs_symlink_inode_operations; + inode_nohighmem(inode); inode->i_mapping->a_ops = &f2fs_dblock_aops; f2fs_lock_op(sbi); @@ -942,7 +943,7 @@ static const char *f2fs_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; /* Symlink is encrypted */ @@ -982,13 +983,11 @@ static const char *f2fs_encrypted_follow_link(struct dentry *dentry, void **cook /* Null-terminate the name */ paddr[res] = '\0'; - kunmap(cpage); page_cache_release(cpage); return *cookie = paddr; errout: kfree(cstr.name); f2fs_fname_crypto_free_buffer(&pstr); - kunmap(cpage); page_cache_release(cpage); return ERR_PTR(res); } diff --git a/fs/inode.c b/fs/inode.c index b0edef500590..b95615f3fc50 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -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); diff --git a/include/linux/fs.h b/include/linux/fs.h index c8decb7075d6..f746a59fcc88 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -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 */ -- 2.16.0.rc1.238.g530d649a79-goog