Received: by 10.223.176.5 with SMTP id f5csp2905887wra; Mon, 5 Feb 2018 12:01:41 -0800 (PST) X-Google-Smtp-Source: AH8x226W83TNS6WEg7z1vJCD+p2BPDg06Z00jbLDZhlvj698F6LAHJWOGwGpxTbZjCxgiFqQZLoP X-Received: by 10.99.37.193 with SMTP id l184mr1825pgl.30.1517860901258; Mon, 05 Feb 2018 12:01:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517860901; cv=none; d=google.com; s=arc-20160816; b=a9ggM/1lTCwYi+gkIwm7G5gxlCP+67zNdykiCux7ZaoFohQjc4ul9tqKahd1QNKyEn ppYSyg/EuEy1FuM9zsIeJb+ON+yIjxuAmEMYYM4tmMk/TGFaqElbLK3iddCCEn2cGaUu 38bTwYvI3h29msqAqJ/tRZvZzmAZ8kf8ZBGo9l7u3mawPmtWI/bYO2LhbwcEnZzV95cj d4+0yS8MAjce1zu9bRCLiCm17mZ2YafCM9TOs6NzjiCDHT3WPjJ16iALSA5tmnSfKQ5q 5twDs3WLbETRKO9HRXzt7hq7q1fz1upeP/tAb2hTYc3iIkyUBIVi2PBt9PR9WaJuLmVC nEyA== 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=YRgAiT7aegv1Z/bUA5t8JIYRxmhaZm/Qg4mAmxzMsug=; b=AEO+bTbBvrtCk/hHHZbMZ6NhMeKf0bYXazRtm7H2JI/F0N6mAMUD+VL9NSqis7ZhJC i5ctKfe5tCZLqwJhMjM453/QNNm/Ee47FsAAu69CQLk3VkBTV3uMHa+fayViI9SxRLJH ADlciLUXMZLHawRI619iY6SDTRd2lYMIjRFsc5mfCb87JxRnlZ+9+ubXIwnpkZuLJwjb O/qHPEsBUQGcPrQtMxmMgB1WEUmieeqyZGEUpcHXP3mO38o2q6bDdN0t744wNhQPi3yx S514mkGvrFAeXIXe+mxbPMC4xFvnzC7fQ+MQCg8LCRg43faozkbu/kyKWVtbSc1c+mTv L+FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=lTTbYW+e; 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 m6si313427pff.273.2018.02.05.12.01.25; Mon, 05 Feb 2018 12:01:41 -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=lTTbYW+e; 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 S1752255AbeBET7F (ORCPT + 99 others); Mon, 5 Feb 2018 14:59:05 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:34166 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751770AbeBET6c (ORCPT ); Mon, 5 Feb 2018 14:58:32 -0500 Received: by mail-pg0-f65.google.com with SMTP id s73so5211822pgc.1 for ; Mon, 05 Feb 2018 11:58:31 -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=YRgAiT7aegv1Z/bUA5t8JIYRxmhaZm/Qg4mAmxzMsug=; b=lTTbYW+eXsG17EKDrXKhjjmtO+36I9SJfx0x5uG8aMZ47MidJCzI6fy3r7zYJ/hWk3 r2VEELWruEtaHbGfj8WTCQAZpvO/q5+vkO1O3oMHVh8gzqUnPECkWVDBokF+njthblYu 2jByH0Uwhw8OjOdUm/92PMHm1e36K2ulq25mj8cWuRZcji9hy1dLhTzXr3jiPTVBN7R4 BeiFRAt5y/07tAii7Jy5Cybo6DPKq7EtZSY0UfGk6rDZhuAGPOldULfwsSD1dnow2H5V 1hq2RvFyaCsTMqKmY+hrSeNG6WnurY/X5myy+YboSNdmwPsUf1dVqeXbknACXnVGu29N CUuw== 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=YRgAiT7aegv1Z/bUA5t8JIYRxmhaZm/Qg4mAmxzMsug=; b=KIxeiSq8x5xacJ3wg7mQTYBa6uqlMiqEyrhk4mvpDZxbN7oC4YGlvQvS8u4+BpEkqE CMVGkx+e/S5n2qUdMDEYOuA/xNG8eSmUfBboPSzOQw2qaHqSWG+YuFvFWXuyC+3PaAI3 z/1480BPRUoUWRiK0FB7hgyawvHBLA731I/vb0e6UCxUPHCwBrerusq+WCx7lgWGen4c c5XJFrR4pll6qt6rIuEx6sC0nNbttatf5mGjxoegeAi3IicTPsmiSkswqvsx2MHMPNAF fzcpJIABWakKwarQ07QERaCa95xm8qb2s455xZ6LHlRwQar18KReniNSi63kS1gmXaDF B9aw== X-Gm-Message-State: AKwxyte4iXlYO6NZhWBS9KED5yw/a1qtUNrt0Z8UfrscGZLnYsz4M4Vz dFR4BK7k1JCJe7QGJhx1XOhaiA== X-Received: by 10.101.98.193 with SMTP id m1mr34073134pgv.174.1517860711384; Mon, 05 Feb 2018 11:58:31 -0800 (PST) Received: from jinqian2.mtv.corp.google.com ([2620:0:1000:1601:756c:3217:2035:e37b]) by smtp.gmail.com with ESMTPSA id w9sm19265632pfl.74.2018.02.05.11.58.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:58:30 -0800 (PST) From: Jin Qian To: "Theodore Ts'o" , Andreas Dilger , Alexander Viro , Jeff Layton , "J. Bruce Fields" , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Jin Qian , stable@vger.kernel.org, Jin Qian Subject: [PATCH 1/1] ext4: don't put symlink in pagecache into highmem Date: Mon, 5 Feb 2018 11:57:39 -0800 Message-Id: <20180205195739.9654-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 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)); Cc: stable@vger.kernel.org Signed-off-by: Al Viro Signed-off-by: Jin Qian --- 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(-) 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/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