From patchwork Wed Jul 18 11:04:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10532159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1C0866020A for ; Wed, 18 Jul 2018 11:05:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DFA72842B for ; Wed, 18 Jul 2018 11:05:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01FDA2909D; Wed, 18 Jul 2018 11:05:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95B5D2842B for ; Wed, 18 Jul 2018 11:05:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729374AbeGRLmt (ORCPT ); Wed, 18 Jul 2018 07:42:49 -0400 Received: from mout.gmx.net ([212.227.15.19]:43729 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729233AbeGRLmt (ORCPT ); Wed, 18 Jul 2018 07:42:49 -0400 Received: from localhost.localdomain ([220.112.58.66]) by mail.gmx.com (mrgmx001 [212.227.17.184]) with ESMTPSA (Nemesis) id 0LbuCq-1gMoFR2Toa-00jJTM; Wed, 18 Jul 2018 13:05:22 +0200 From: Chengguang Xu To: ceph-devel@vger.kernel.org Cc: zyan@redhat.com, idryomov@gmail.com, Chengguang Xu Subject: [PATCH 2/5] ceph: add additional range check in ceph_fallocate() Date: Wed, 18 Jul 2018 19:04:24 +0800 Message-Id: <20180718110427.7775-3-cgxu519@gmx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180718110427.7775-1-cgxu519@gmx.com> References: <20180718110427.7775-1-cgxu519@gmx.com> X-Provags-ID: V03:K1:gNTcRIfeO9qN8EExiv+2wqqQ0pkFJoF9yM2IUljvv6ol33qcwd6 X5r2CLFy99cyZQ2jScPPwd1fsWOaRwT+UOib5EKrPe5nSuv6SFPT+wJpgrZIXqtGlRSkj8a rRzsHijX442nTmpm1WWOtbN55ujUCh4quzCw9Jou3kzRTjMpMFrzXbLd+5i+RkPgEwjNzb8 IJd+/7upFA7J596GD66kQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:hosanuFqlbI=:sVk122b7vVXJ/1zy50Yypc Ev+MGCCy2iWaway9vaVgZY6kaux4z228zn7td+7MD0xR+Y6pLCy24fyR2YPhMs0RmWCpKKAiJ RLM3uaJ0fkKVWF7qmEaGA1WGZPYrK3iWG0XRKQaJ1sDbuHUyuVmCxh6YeQNRKnrrFy0o4kT7R KpHU0HEqrNgWOMJq1FrTbOCt2YyjITpVGG6NdyoHLAGCBYkvjXDApKTt7+UkaHJUqRT2gEl6z hAiMpFsbi4FMWxHO0hpx6rn/vqffj4ENSXEk/nxqAAd7g5IDVYh1jPjYJR+SGLArGA9ce82dJ KeOtSrEHywQBkeE8FvvC1ajOCwHbFZxLvDtyPQkoCOMCdLC0PthEcFAlNkBWCkzgTulb1bxQY 0TwueIAQnQDKtkkMsBsQ0mpmNQUnzqFbw7y5jin8SwWiH2w0FQm8I/8rm7wXSffCKMQ05j0Ll EGW0z5oYLopsvlcrqaFBcODIDZZibX2t6GU3XWzLuvCMfbdNc2CxMH2WEEpsXZ88yU0j2LfEi sqEsBvPvnPPkiZp0K8Lew+PD3P2bKciQh1joRMGTjhLLDJkSOU65AbptpIbMKr+ebPvCkisZU bRUwejV1nMNHM4/Z/HbHpmjNkLm1wGfy3aRxeGZIB1Fz/xHdEDRtynqQkBpNlA+kH/m7U+LF/ azH+OMW+Se32qABTXjCBiauW272KEmVoyL2ag2BsxFFtlnTlczrc+xWXr39IO+J6N6teE4Rjg Ck+rKBDpWeZaUqnkgjVvVvbRjIyNl9A4v0TakymbA57QLylx/duNvscEd3g= Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the range is larger than both real file size and limit of max file size, then return -EFBIG. Signed-off-by: Chengguang Xu --- fs/ceph/file.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index ad0bed99b1d5..e588b23681e0 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -1731,12 +1731,16 @@ static long ceph_fallocate(struct file *file, int mode, struct ceph_osd_client *osdc = &ceph_inode_to_client(inode)->client->osdc; struct ceph_cap_flush *prealloc_cf; + struct ceph_fs_client *fsc = inode->i_sb->s_fs_info; int want, got = 0; int dirty; int ret = 0; loff_t endoff = 0; loff_t size; + if ((offset + length) > max(i_size_read(inode), fsc->max_file_size)) + return -EFBIG; + if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) return -EOPNOTSUPP;