From patchwork Fri Jul 20 01:35:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10535853 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 12C9C600F4 for ; Fri, 20 Jul 2018 01:36:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1EC6299B4 for ; Fri, 20 Jul 2018 01:36:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E63A6299B6; Fri, 20 Jul 2018 01:36:00 +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 6B8A1299B4 for ; Fri, 20 Jul 2018 01:36:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730573AbeGTCVq (ORCPT ); Thu, 19 Jul 2018 22:21:46 -0400 Received: from mout.gmx.net ([212.227.15.18]:46373 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730460AbeGTCVq (ORCPT ); Thu, 19 Jul 2018 22:21:46 -0400 Received: from localhost.localdomain ([220.112.58.66]) by mail.gmx.com (mrgmx001 [212.227.17.184]) with ESMTPSA (Nemesis) id 0MGS9o-1fkfuJ1U7E-00DGm2; Fri, 20 Jul 2018 03:35:52 +0200 From: Chengguang Xu To: ceph-devel@vger.kernel.org Cc: zyan@redhat.com, idryomov@gmail.com, Chengguang Xu Subject: [PATCH] ceph: add O_LARGEFILE flag check in ceph_open() Date: Fri, 20 Jul 2018 09:35:15 +0800 Message-Id: <20180720013515.16422-1-cgxu519@gmx.com> X-Mailer: git-send-email 2.17.1 X-Provags-ID: V03:K1:G4X9Gdl97vgQ0bylH/vR2q7eVcnZH8Msswcc6EbvPm016Y5M1rF yKGsuJ2yfZDI2MmWdyGncY1lGZz6RhANekcGFiD9tv8dJbm3EukY9HL1E7iufyVkjcmVGuT O8zGnYJozcvpGzZdthZZ/gA9B0sBv2t2kSEW3g9OULHlNaLHjwZrLG09qGw0pJOuMveTzyy WqZh4k99p7ocnYIYd9+LQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:b3wC94+y8Os=:m7GtjGkHYjPCIODualP025 ClVlXM5FOzYDFodNE3IANk/OOFs0Lvu9Jwlvfc0vFZKshqUVVCJbqKlwNcSV8kPQQg/s0Y+88 LZkPpimxL1hfHl2W74C+GCnLPM7qZssW1tS68/s9DIVXMPFGCitiur+2AcZw1s4OYwjsNNr6y fyJ/eSAnCZuSO8hrS31eaK9JPXQA6Qjfn9Ce4zBAYCcldnSK0ybsA1knbzblFKGT7fvGEeJ2g DEgI1edZTvl469On6USVmj+oNqCpA8kONtqWRHu+6X/RxUHgXHgA2PhBHuh5X4oq8L23y+rrk AFctcqXazFd89DWd8UT1vSIoAyBFV6r7o6aV1kp92ubFNfrYOrhZHjDPGcf82ugORGMOJBhfj PWc/uA3bV0td/JG8u48QhxxlgHW14CC2ikkRSRQHvbN8RklGUzPvVnN0SftgVDM6XPj2l62Gw ijrfeXN/q2FmGv8X4RBVmP5iMYWGhONk2kvbSVIyL2C/rOp/GkzHwClNOOjs1u+4RjI+S6NSr Iyy2IzR4967BjChpryL4KA0DQ1B/G2uO8Cjtn/tOiLd6oFPDjPECmeY2CYqIJHEy4wjdQcpcK 7PJQGIQ7a306iqYd8qc9f6I4cQdBk+ncbJ9uToFZ4RUGsqZ+++/VC8YYZdCJrZRgkwtTRPfjj 6NsAzgTsFcACIw8lyjksa4x4N9GCLkpPalRxch0GGquKjWt1kfyj78sz1gvR6rKA9qVW3zYhz BliNFN1VGa/HpOgjm0H0byAocZVEtW0VdRO4mOew3v8u7WwaF/umsevfSqs= 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 Add a check to disallow opening large files on 32bit systems if the caller didn't specify O_LARGEFILE. 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..0dada8d60731 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -349,6 +349,10 @@ int ceph_open(struct inode *inode, struct file *file) return 0; } + if (!(file->f_flags & O_LARGEFILE) && + i_size_read(inode) > MAX_NON_LFS) + return -EFBIG; + /* filter out O_CREAT|O_EXCL; vfs did that already. yuck. */ flags = file->f_flags & ~(O_CREAT|O_EXCL); if (S_ISDIR(inode->i_mode))