Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3753773rwb; Tue, 20 Sep 2022 04:22:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM57SGFxDqbW+sJvYbueT7MoTl4ANGGTU0Tj2j/Zi6D8XLBvTqf3B6IyBU6mhihG3NhknemW X-Received: by 2002:aa7:da97:0:b0:452:bea2:5200 with SMTP id q23-20020aa7da97000000b00452bea25200mr19860839eds.341.1663672955397; Tue, 20 Sep 2022 04:22:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663672955; cv=none; d=google.com; s=arc-20160816; b=oc2Ql3E34qqWCbHNoH0bf+M1hVO27AstPPqL/q5qV6Jf4m/d8AeDiXSmfksqWBafWY wF2wCBUvbkMX2eGMoStFlp6/bFfKceTA/CQqXQV2603bCFScBJY9p/Vs4yNK6G8SGEU+ ryx1Qs8LheAVyMbaelQtIsx93ZHEAn7UTL0CAGg8Er0mJO3+95+YYXxksu3nDHXvZ1CB eXv7M4QcoWrzzks3HOGE65cXwX1u/gL24vvHEDnsl9pIcWyVcPdCX/NyZT1Cfm6tQe2O cRXdcmTLK/xfoJrGfn+D93k6nvezjVBKmV4giIk370eTau/AhVAW00S+29gS4wlWEYRx iSFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:jabber-id:content-disposition:mime-version :message-id:subject:cc:to:from:dkim-signature:date; bh=0zLh28PQ/3q2C7DCBbA7SEgZiGOzMsl17geIksxKtPM=; b=v7IIus5iHnruPJLATUtT4rdDt50fJJ5AJkM1FWRn8p5YzjBP1EuiDliUaWMQxpi1ZJ XZK1NDIHhuAd9xXHwUtirNIfuolZOcn0bHOVCjO97GknqAF8eFpOA7YmVDJV5fqfuboX 9YLNLzL2+JM7fPjWKuTCM0Wp9zxTiQLEgraZtVMfjnzYpI4rHCHEu5Ap4e0kZgn8On9x EY7Gm2GRaGE4uGrBl5vW7zTW/0TXTh52n7v5JiJW28P4oC5ElpvEzw4WnF4MjO7JVwGg puaKy3ws75Aud4HgKS1IT5fWJK8302fjeWHEQxCFA/dmGj+PkoJF9wDCEf/3qLA45N1z arzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@t-8ch.de header.s=mail header.b=nUyYKSjI; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i1-20020a05640242c100b0044e702cd711si1759723edc.98.2022.09.20.04.22.01; Tue, 20 Sep 2022 04:22:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@t-8ch.de header.s=mail header.b=nUyYKSjI; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229963AbiITLML (ORCPT + 99 others); Tue, 20 Sep 2022 07:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230371AbiITLMJ (ORCPT ); Tue, 20 Sep 2022 07:12:09 -0400 X-Greylist: delayed 1804 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 20 Sep 2022 04:12:08 PDT Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A500561B3D for ; Tue, 20 Sep 2022 04:12:08 -0700 (PDT) Date: Tue, 20 Sep 2022 12:33:31 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=t-8ch.de; s=mail; t=1663670011; bh=wBP7/I9Gh6LWk47k8z87D5gzRBm0BSfiWpd0Ma9utdE=; h=Date:From:To:Cc:Subject:From; b=nUyYKSjI3iS9IXGjZj/OLgJTIQCdetbGNpieapZN+I5VPiv9ArpZght3a196ZH+Ly YfWrDd0968/2hvr1fx+gKfHPGgAWeGmnWhESC8nP7PA9uzeM2eO3T/0TevUQT6EMWP otF4DREf3RKRCHcbnAhvZ+DdZPxwqhY1zrGZ8QYA= From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-nfs@vger.kernel.org, thomas.weissschuh@amadeus.com Subject: O_LARGEFILE / EOVERFLOW on tmpfs / NFS Message-ID: <76bedae6-22ea-4abc-8c06-b424ceb39217@t-8ch.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="lGPmldGHO6LcANo9" Content-Disposition: inline Jabber-ID: thomas@t-8ch.de X-Accept: text/plain, text/html;q=0.2, text/*;q=0.1 X-Accept-Language: en-us, en;q=0.8, de-de;q=0.7, de;q=0.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org --lGPmldGHO6LcANo9 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Hi everybody, it seems there is some inconsistency about how large files that are opened *without* O_LARGEFILE on different filesystems. On ext4/btrfs/xfs a large file openend without O_LARGEFILE results in an EOVERFLOW error to be reported (as documented by open(2) and open(3p)). On tmpfs/NFS the file is opened successfully but the values returned for lseek() are bogus. (See the reproducer attached to this mail.) This has been reproduced on 5.19.8 but the sources look the same on current torvalds/master. Is this intentional? To me it seems this should fail with EOVERFLOW everywhere. Looking at the sources, the O_LARGEFILE flag is checked in generic_file_open() but not all filesystems call this function. If this is a bug would it make sense to hoist this check into the VFS layer so not all filesystems have to call this manually? Another question would be about backwards-compatibility becaus fixing it would prevent applications from opening files they could open before. On the other hand they could have experienced silent data corruption before. Thanks, Thomas --lGPmldGHO6LcANo9 Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="test.c" /* * Compile: * cc -m32 test.c -o test * * Prepare testfile: * fallocate -l 4294967297 large-file * * Test: * ./test large-file * * Result: * Correct: open() fails, exit code 2 * Incorrect: Prints an incorrect file size * * Observation: * Correct on ext4/btrfs * Incorrect on NFS/tmpfs */ #include #include #include #include #include static_assert(sizeof(void *) == 4, "This test only makes sense on 32bit"); static_assert(sizeof(off_t) == 4, "Large file support has to be disabled"); int main(int argc, char **argv) { if (argc != 2) return 1; int fd = open(argv[1], O_RDONLY); if (fd == -1) return 2; off_t fsize = lseek(fd, 0, SEEK_END); printf("file size=%lu\n", fsize); } --lGPmldGHO6LcANo9--