Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2333430yba; Sat, 27 Apr 2019 21:31:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxdxjmpxX36zN7BURzzPi/9eBNzinOJNzEIyc4GCjRmSA6a3bnYh9QoanqCt/upkczrSJf0 X-Received: by 2002:aa7:85d9:: with SMTP id z25mr56671582pfn.31.1556425892281; Sat, 27 Apr 2019 21:31:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556425892; cv=none; d=google.com; s=arc-20160816; b=A+gpEq6fhagA8XqlBssosDU7VGJ80/d+7B8DOdDQJUzkQu07A7M9CiqZ1Qw7DngIBl 1mpgJrS8gkKQzf4wQy2ElrirTd/8FZer9ccH5N0K9hwt8CwlSErnvTr+hqaW3HhMdKBd DM1DIkFGvr6mC84aODkPMlbTRBEUnmOvHJ8ozSv5ZxAh+F8rrwRl07i3VuuK76ertak6 0ucUXihDspqkM6VW3SqkwkOxca0J0Kd3Unk/usRSgkpCIrKke9d1nmn7AxvVPt5AiCyK Q87I6dpWi/naW+A7P/TXzAlKEweTlwtcxfch4esQEelFhkg2P2YrHSc9S7H7BmYpqDan 3jdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:subject:cc:to:from; bh=nPyQCPX67P5hIxbETxxCIXVl7grYxINM0NLQePBSDTM=; b=KV/TZIXunESQrhO0oIAkTnO8AW3m7VFHy7Q3bHkjO1EfU/qm6mHB6R1318bHp6JI66 9Qv/2xL9WzDFA87Lt97qqeeX1npf4xqANjmGYkwEBHUcB3zlzAX4zfC+TOnOQEbCXBgG zqEZovm0IDt6zqKbNcVY/AA1PwvmirYCxINyAVODTskzOnmy49OH3AUeqFvEYP01QUax VQ2qXiAl/430Tffklz7A6BV5U1KaM4QYcha128LZNG2CkPsizpt6gCG5xUwPY64qYtpk BuhK0OJP7e8YFXlnXfkTGV+JfgopNkWkiCGtYIXyavbZgLL+E017/zAY7WBbod+YQU+p dtsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p27si9898766pgb.364.2019.04.27.21.31.17; Sat, 27 Apr 2019 21:31:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726359AbfD1Eaz (ORCPT + 99 others); Sun, 28 Apr 2019 00:30:55 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:37324 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726052AbfD1Eaz (ORCPT ); Sun, 28 Apr 2019 00:30:55 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3S4TAFo024392 for ; Sun, 28 Apr 2019 00:30:54 -0400 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0b-001b2d01.pphosted.com with ESMTP id 2s54kuguh2-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 28 Apr 2019 00:30:54 -0400 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 28 Apr 2019 05:30:53 +0100 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Sun, 28 Apr 2019 05:30:51 +0100 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x3S4UoZM27787416 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 28 Apr 2019 04:30:50 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F2D08112066; Sun, 28 Apr 2019 04:30:49 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 34EE8112062; Sun, 28 Apr 2019 04:30:46 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.75.21]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Sun, 28 Apr 2019 04:30:45 +0000 (GMT) From: Chandan Rajendra To: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fscrypt@vger.kernel.org Cc: Chandan Rajendra , tytso@mit.edu, adilger.kernel@dilger.ca, ebiggers@kernel.org, jaegeuk@kernel.org, yuchao0@huawei.com, hch@infradead.org Subject: [PATCH V2 04/13] fsverity: Add call back to determine readpage limit Date: Sun, 28 Apr 2019 10:01:12 +0530 X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190428043121.30925-1-chandan@linux.ibm.com> References: <20190428043121.30925-1-chandan@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19042804-0064-0000-0000-000003D33158 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011008; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000285; SDB=6.01195430; UDB=6.00626836; IPR=6.00976273; MB=3.00026628; MTD=3.00000008; XFM=3.00000015; UTC=2019-04-28 04:30:53 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19042804-0065-0000-0000-00003D3D1234 Message-Id: <20190428043121.30925-5-chandan@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-04-28_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904280030 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Ext4 and F2FS store verity metadata beyond i_size. This commit adds a call back pointer to "struct fsverity_operations" which helps in determining the the real file size limit upto which data can be read from the file. This call back will be required in order to get do_mpage_readpage() to read files having verity metadata appended beyond i_size. Signed-off-by: Chandan Rajendra --- fs/ext4/super.c | 17 +++++++++++++++++ include/linux/fsverity.h | 1 + 2 files changed, 18 insertions(+) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 63d73b360f1d..8e483afbaa2e 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1428,6 +1428,22 @@ static struct page *ext4_read_verity_metadata_page(struct inode *inode, return read_mapping_page(inode->i_mapping, index, NULL); } +static loff_t ext4_readpage_limit(struct inode *inode) +{ + if (IS_VERITY(inode)) { + if (inode->i_verity_info) + /* limit to end of metadata region */ + return fsverity_full_i_size(inode); + /* + * fsverity_info is currently being set up and no user reads are + * allowed yet. It's easiest to just not enforce a limit yet. + */ + return inode->i_sb->s_maxbytes; + } + + return i_size_read(inode); +} + static bool ext4_verity_required(struct inode *inode, pgoff_t index) { return index < (i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT; @@ -1438,6 +1454,7 @@ static const struct fsverity_operations ext4_verityops = { .get_metadata_end = ext4_get_verity_metadata_end, .read_metadata_page = ext4_read_verity_metadata_page, .verity_required = ext4_verity_required, + .readpage_limit = ext4_readpage_limit, }; #endif /* CONFIG_FS_VERITY */ diff --git a/include/linux/fsverity.h b/include/linux/fsverity.h index b83712d6c79a..fc8113acbbfe 100644 --- a/include/linux/fsverity.h +++ b/include/linux/fsverity.h @@ -19,6 +19,7 @@ struct fsverity_operations { int (*get_metadata_end)(struct inode *inode, loff_t *metadata_end_ret); struct page *(*read_metadata_page)(struct inode *inode, pgoff_t index); bool (*verity_required)(struct inode *inode, pgoff_t index); + loff_t (*readpage_limit)(struct inode *inode); }; #ifdef CONFIG_FS_VERITY -- 2.19.1