From patchwork Mon Feb 18 10:04:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Rajendra X-Patchwork-Id: 1043871 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 442zxJ53npz9s3x for ; Mon, 18 Feb 2019 21:04:36 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729203AbfBRKEg (ORCPT ); Mon, 18 Feb 2019 05:04:36 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57944 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729161AbfBRKEg (ORCPT ); Mon, 18 Feb 2019 05:04:36 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x1IA3r5X022877 for ; Mon, 18 Feb 2019 05:04:35 -0500 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2qqrf5dmq3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 18 Feb 2019 05:04:35 -0500 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Feb 2019 10:04:34 -0000 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 18 Feb 2019 10:04:31 -0000 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x1IA4UA227721756 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Feb 2019 10:04:30 GMT Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2CF57136055; Mon, 18 Feb 2019 10:04:30 +0000 (GMT) Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A5044136051; Mon, 18 Feb 2019 10:04:27 +0000 (GMT) Received: from localhost.in.ibm.com (unknown [9.124.35.115]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP; Mon, 18 Feb 2019 10:04:27 +0000 (GMT) From: Chandan Rajendra To: 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 Subject: [RFC PATCH 07/10] fsverity: Add call back to determine readpage limit Date: Mon, 18 Feb 2019 15:34:30 +0530 X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190218100433.20048-1-chandan@linux.ibm.com> References: <20190218100433.20048-1-chandan@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19021810-0012-0000-0000-0000170C8EC9 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010619; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000280; SDB=6.01162773; UDB=6.00607075; IPR=6.00943349; MB=3.00025633; MTD=3.00000008; XFM=3.00000015; UTC=2019-02-18 10:04:33 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19021810-0013-0000-0000-0000563EC07D Message-Id: <20190218100433.20048-8-chandan@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-02-18_07:, , 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-1902180077 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 | 18 ++++++++++++++++++ include/linux/fsverity.h | 1 + 2 files changed, 19 insertions(+) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 2d7781ab6824..4493ddc357c6 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1428,6 +1428,23 @@ 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) +{ +#ifdef CONFIG_FS_VERITY + 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; + } +#endif + return i_size_read(inode); +} + static bool ext4_verity_required(struct inode *inode, pgoff_t index) { if (index < ((i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT)) @@ -1441,6 +1458,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