From patchwork Thu Jul 19 14:15:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10534613 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 D1DDB600D0 for ; Thu, 19 Jul 2018 14:16:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3EA329AE1 for ; Thu, 19 Jul 2018 14:16:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8B0229AE4; Thu, 19 Jul 2018 14:16:07 +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 60FEA29AE1 for ; Thu, 19 Jul 2018 14:16:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731739AbeGSO72 (ORCPT ); Thu, 19 Jul 2018 10:59:28 -0400 Received: from mout.gmx.net ([212.227.15.18]:40767 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730220AbeGSO71 (ORCPT ); Thu, 19 Jul 2018 10:59:27 -0400 Received: from localhost.localdomain ([116.30.194.72]) by mail.gmx.com (mrgmx001 [212.227.17.184]) with ESMTPSA (Nemesis) id 0MDymt-1fogZV0Hvj-00HPHA; Thu, 19 Jul 2018 16:16:00 +0200 From: Chengguang Xu To: zyan@redhat.com Cc: idryomov@gmail.com, ceph-devel@vger.kernel.org, Chengguang Xu Subject: [PATCH v2 2/4] ceph: add additional range check in ceph_fallocate() Date: Thu, 19 Jul 2018 22:15:25 +0800 Message-Id: <20180719141527.5446-3-cgxu519@gmx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180719141527.5446-1-cgxu519@gmx.com> References: <20180719141527.5446-1-cgxu519@gmx.com> X-Provags-ID: V03:K1:f/xcaE5mmSUBRl41kAXRozHSWi1Rw/WJ5EmMhWSUONSd8s184E4 lrFT7DNHIaUtNtZw1AYji9uMMJssQ7vpVYrj6/Ek38JOx7aRiJ4rESxg22mUHinNvuAYCph eHQuXMblEn+rxNbn5KyOgT0tg77J4ITPIDAJfkjTs+Oeah0hfBaiJkSLgkJfGlyJpcAg0Ql RNKbY6yYESNJ8sYIIsDuw== X-UI-Out-Filterresults: notjunk:1; V01:K0:rNmVfpxYPCA=:/ar9fOzj/Hkr5n3KrE95H8 Bt0mKefAuPRLkt7XP1XaCdJGbROaKszD21QiDDhC/MNNLJXRefVMHuH4T/79HLq2mADsoWvbq r5vaZidQ1aEJ7WGtydhNg/mK/flOcuyf+iqxlBIrC4PM9ysROYdpKlpgwrqJrielqgU2AGwyf iCJzXiYK9/6rwv3NvJPtWjIjNh7mHmOz1+aB3Hez06qApvUY6EUNaU5ScO+dw1H6hi6sJmdH9 AMN+MHNyZhZrI4TBb1wDCq8UPiF7oM9UW2yeYHvl/vYyCoc/NZCCeFLfqf8wiVDFk9vjfrz9i +5uEh7NmTSBSefYF388MJ1IMo3EP8cB2XPrETjok+YVhLtQzJOu+yOAmWQOm+5bPUZCaxYeKw i7T1bBuL8fZSTVzi/DryEejIBEbHrGUn7VkCK+l9P8cpbTr6QeTfNYMEpB2S4ho+7bgOuqP9x CQJoLGlMhMcD0D2avCOwb8BdxbyypZxwkZg3zLtyBtUWRRSBm6YWXSTzUv/GxOI2ygZ5BW9WX 4PyGJ/7jYcf7tiyk92M7q32dsItkIiOlGsGeDrKlz/d/bysjAjYdyTH7ILv6fMhx8trbtOfTP MjI0HLB5xA5m5GOJWBdY+cBoosQX3MMtiX70EcpB/VnfWPJ0oczuFLqsjt2EMUZktsSDWZH2W S6pcO+/XirKHVfUOjwHCtfrklkD2IAuz7p+C5JpnRG5725jBeFtQud4zPWpdvn5IhTSMTw8jB IxQHke2ghI/WhlFF00r+L1kDQ1swupQG3b3LuxbtfeGWLikUxcEjLY6reHo= 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;